diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/cyberscript.log b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/cyberscript.log deleted file mode 100644 index e69de29..0000000 diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/desc.json b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/desc.json index 6823f34..61c2f1f 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/desc.json +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/desc.json @@ -1,5 +1,5 @@ -{ - "version": "5.1.4", - "channel": "stable", - "changelog": "" +{ + "version": "5.1.9", + "channel": "stable", + "changelog": "B-26: Option to disable fixer NPCs on streets. See CHANGELOG.md for full details." } diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/actiontemplate.json b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/actiontemplate.json index d8234ce..965fefe 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/actiontemplate.json +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/actiontemplate.json @@ -629,9 +629,15 @@ }, "vehicle_add_to_traffic": { "helperTitle": "Vehicle : Add to Traffic", - "helper": "This action will change vehicle as traffic", + "helper": "This action will change vehicle as traffic. Optional: min_speed, max_speed, cleartraffic, x/y/z (or position). Defaults: min_speed=1, max_speed=5, cleartraffic=true, position=0,0,0.", "tag": "myvehiculetag", - "name": "vehicle_add_to_traffic" + "name": "vehicle_add_to_traffic", + "minspeed": 1, + "maxspeed": 5, + "cleartraffic": true, + "x": 0, + "y": 0, + "z": 0 }, "getSalaryFromCurrentRent": { "helperTitle": "House : Get Salary from current place", diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy/README.md b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy/README.md new file mode 100644 index 0000000..e0056e4 --- /dev/null +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy/README.md @@ -0,0 +1,42 @@ +# Legacy files — DO NOT install these into the game + +These two files were shipped in `mod/data/` in Cyberscript 5.1.4 and earlier. +They are **not loaded by any Cyberscript Lua code** — they exist only as +reference templates. Unfortunately, the old wiki instructed users (and some +downstream mod authors) to manually copy them into the game's +`r6/config/` directory, which caused the widespread **"F-key stops working +in quickhack / dialog / exit-vehicle"** bug: + +- `inputUserMappings.xml` re-asserts `IK_F` as the binding for + `selectChoice`, `selectChoiceUI`, and `exitVehicle` in **17 places**, + overriding any user rebinding. +- `settings.lua` ships a complete CP2077 settings template that likewise + hard-codes `IK_F` defaults for those same actions. + +## Why they were moved (B-06 / B-20 fix) + +Moving them out of the active mod path (`mod/data/`) into +`mod/data/legacy/` prevents accidental installation and the resulting +key-binding conflict. The Cyberscript mod itself never reads either file — +verified by grepping every `*.lua` in `mod/modules/` and `mod/init.lua` for +references to `inputUserMappings.xml` / `data/settings.lua` (zero matches). + +## What to do if you previously installed these files + +1. Delete `bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/inputUserMappings.xml` + if present (it is no longer shipped here). +2. Check your game's `r6/config/inputUserMappings.xml` — if you (or a mod + manager) copied the Cyberscript version there, restore the backup or + verify your quickhack/dialog/exit-vehicle keys in the game's Options → + Key Bindings screen. +3. Re-bind `selectChoice` / `selectChoiceUI` / `exitVehicle` in-game if + needed. + +## Downstream mod authors + +If your mod previously relied on reading `mod/data/settings.lua` directly +(none currently do, per the research report), please read your own copy of +the template from your mod's directory instead. The Cyberscript Lua runtime +does not and never did apply these settings to the game. + +— Cyberscript CP2077 fork, bug-fix pass (B-06 / B-20) diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/inputUserMappings.xml b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy/inputUserMappings.xml similarity index 100% rename from bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/inputUserMappings.xml rename to bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy/inputUserMappings.xml diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/settings.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy/settings.lua similarity index 100% rename from bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/settings.lua rename to bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy/settings.lua diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy_interaction_aliases.json b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy_interaction_aliases.json new file mode 100644 index 0000000..8988403 --- /dev/null +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/data/legacy_interaction_aliases.json @@ -0,0 +1,10 @@ +{ + "_comment": "B-14 fix: Backward-compatibility alias map for Cyberscript interactions and menu options. v5.1.4 renamed default interactions and menu options, which silently broke downstream mods that referenced the old names. This file maps old names -> new names so legacy JSON actions continue to fire. Cyberscript loads this file at cache-build time and registers each old tag as an alias pointing at the new tag's cached data. To add your own aliases, add entries below (old name as key, new name as value). Both names will then resolve to the same cached interaction.", + "_format": "key = old interaction tag (string), value = new interaction tag (string)", + "_example": { + "old_interaction_name": "new_interaction_name", + "open_phone": "open_phone_menu" + }, + "aliases": { + } +} diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/api.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/api.lua index b94cd83..3e77ee4 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/api.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/api.lua @@ -2,66 +2,128 @@ logme(10,"CyberMod: api module loaded") cyberscript.module = cyberscript.module +1 local api = {} +-- B-13 fix: every public api.* entry point wraps the internal call in pcall +-- and logs the failure with enough context for downstream-mod authors to +-- debug spawn failures (GH #17 — dependent mods reported "no NPC spawns" with +-- no diagnostic). The api surface (argument count, return value) is unchanged +-- so existing downstream mods are not broken. Failures return nil; callers +-- that already check for nil continue to work; callers that ignored errors +-- now at least leave a trace in cyberscript.log. + function api.spawn(chara,appearance, tag, x, y ,z, spawnlevel, isprevention, isMPplayer, scriptlevel, isitem, rotation) - - spawnNPC(chara,appearance, tag, x, y ,z, spawnlevel, isprevention, isMPplayer, scriptlevel, isitem, rotation) - + local ok, err = pcall(function() + spawnNPC(chara,appearance, tag, x, y ,z, spawnlevel, isprevention, isMPplayer, scriptlevel, isitem, rotation) + end) + if not ok then + logme(1, "[Cyberscript API] api.spawn failed for chara=" .. tostring(chara) .. " tag=" .. tostring(tag) .. " err=" .. tostring(err)) + end end function api.spawnVehicle(chara, appearance, tag, x, y ,z, spawnlevel, spawn_system ,isAV,from_behind,isMP,wait_for_vehicule, scriptlevel, wait_for_vehicle_second) - - - - spawnVehicleV2(chara, appearance, tag, x, y ,z, spawnlevel, spawn_system ,isAV,from_behind,isMP,wait_for_vehicule, scriptlevel, wait_for_vehicle_second) + + + + local ok, err = pcall(function() + spawnVehicleV2(chara, appearance, tag, x, y ,z, spawnlevel, spawn_system ,isAV,from_behind,isMP,wait_for_vehicule, scriptlevel, wait_for_vehicle_second) + end) + if not ok then + logme(1, "[Cyberscript API] api.spawnVehicle failed for chara=" .. tostring(chara) .. " tag=" .. tostring(tag) .. " err=" .. tostring(err)) + end end function api.despawn(tag) - - despawnEntity(tag) - + + local ok, err = pcall(function() + despawnEntity(tag) + end) + if not ok then + logme(1, "[Cyberscript API] api.despawn failed for tag=" .. tostring(tag) .. " err=" .. tostring(err)) + end + end function api.move(targetPuppet, targetPosition, targetDistance, movementType, v2) - - MoveTo(targetPuppet, targetPosition, targetDistance, movementType, v2) - + + local ok, err = pcall(function() + MoveTo(targetPuppet, targetPosition, targetDistance, movementType, v2) + end) + if not ok then + logme(1, "[Cyberscript API] api.move failed err=" .. tostring(err)) + end + end function api.teleport(objlook, position, rotation, isplayer) - - teleportTo(objlook, position, rotation, isplayer) - + + local ok, err = pcall(function() + teleportTo(objlook, position, rotation, isplayer) + end) + if not ok then + logme(1, "[Cyberscript API] api.teleport failed err=" .. tostring(err)) + end + end function api.getEntitybyTag(tag) - - getEntityFromManager(tag) - + + local ok, result = pcall(function() + return getEntityFromManager(tag) + end) + if not ok then + logme(1, "[Cyberscript API] api.getEntitybyTag failed for tag=" .. tostring(tag) .. " err=" .. tostring(err)) + return nil + end + return result + end function api.runActionList(actionlist, tag, source,isquest,executortag,bypassMenu) - - runActionList(actionlist, tag, source,isquest,executortag,bypassMenu) - + + local ok, err = pcall(function() + runActionList(actionlist, tag, source,isquest,executortag,bypassMenu) + end) + if not ok then + logme(1, "[Cyberscript API] api.runActionList failed for tag=" .. tostring(tag) .. " err=" .. tostring(err)) + end + end function api.checkTriggerRequirement(requirement,triggerlist) - - checkTriggerRequirement(requirement,triggerlist) - + + local ok, result = pcall(function() + return checkTriggerRequirement(requirement,triggerlist) + end) + if not ok then + logme(1, "[Cyberscript API] api.checkTriggerRequirement failed err=" .. tostring(err)) + return false + end + return result + end function api.setVariable(tag,key,score) - - setVariable(tag,key,score) - + + local ok, err = pcall(function() + setVariable(tag,key,score) + end) + if not ok then + logme(1, "[Cyberscript API] api.setVariable failed for tag=" .. tostring(tag) .. " key=" .. tostring(key) .. " err=" .. tostring(err)) + end + end function api.getVariableKey(tag,key) - - getVariableKey(tag,key) - + + local ok, result = pcall(function() + return getVariableKey(tag,key) + end) + if not ok then + logme(1, "[Cyberscript API] api.getVariableKey failed for tag=" .. tostring(tag) .. " key=" .. tostring(key) .. " err=" .. tostring(err)) + return nil + end + return result + end return api \ No newline at end of file diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/core.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/core.lua index 9b5ebbd..60e6917 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/core.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/core.lua @@ -7,39 +7,39 @@ local modLoaded = false function loadexternal() - - - inputManager = dofile('mod/modules/inputManager.lua') - GameUI = dofile('mod/external/GameUI.lua') - TargetingHelper = dofile('mod/external/TargetingHelper.lua') - AIControl = dofile('mod/external/AIControl.lua') - GameHUD = dofile('mod/external/GameHUD.lua') - GameSettings = dofile('mod/external/GameSettings.lua') - IGE = dofile('mod/external/ImGuiExtension.lua') - Cron = dofile('mod/external/Cron.lua') - Ref = dofile('mod/external/Ref.lua') - EventProxy = dofile('mod/external/EventProxy.lua') - UIPopupsManager = dofile('mod/external/UIPopupsManager.lua') - UIScroller = dofile('mod/external/UIScroller.lua') - UIButton = dofile('mod/external/UIButton.lua') - GameSession = dofile('mod/external/GameSession.lua') - CPStyling = dofile('mod/external/cpstyling.lua') - CPS = CPStyling:New() - RES_slot = dofile('mod/external/attachment-slots.lua') - RES_attributes = dofile('mod/external/attributes.lua') - RES_crafting = dofile('mod/external/crafting-components.lua') - RES_area = dofile('mod/external/equipment-areas.lua') - RES_perks = dofile('mod/external/perks.lua') - RES_perksalias = dofile('mod/external/perks-by-alias.lua') - RES_skills = dofile('mod/external/skills.lua') - RES_TweakDB = dofile('mod/external/tweakdb-ids.lua') - RES_TweakDBmeta = dofile('mod/external/tweakdb-meta.lua') - - LVector = dofile("mod/external/Vector2") - if GetMod('corruptNCPD') then - - CorruptNCPDLang = dofile('mod/external/CorruptNCPDLang.lua') - end + + + inputManager = dofile('mod/modules/inputManager.lua') + GameUI = dofile('mod/external/GameUI.lua') + TargetingHelper = dofile('mod/external/TargetingHelper.lua') + AIControl = dofile('mod/external/AIControl.lua') + GameHUD = dofile('mod/external/GameHUD.lua') + GameSettings = dofile('mod/external/GameSettings.lua') + IGE = dofile('mod/external/ImGuiExtension.lua') + Cron = dofile('mod/external/Cron.lua') + Ref = dofile('mod/external/Ref.lua') + EventProxy = dofile('mod/external/EventProxy.lua') + UIPopupsManager = dofile('mod/external/UIPopupsManager.lua') + UIScroller = dofile('mod/external/UIScroller.lua') + UIButton = dofile('mod/external/UIButton.lua') + GameSession = dofile('mod/external/GameSession.lua') + CPStyling = dofile('mod/external/cpstyling.lua') + CPS = CPStyling:New() + RES_slot = dofile('mod/external/attachment-slots.lua') + RES_attributes = dofile('mod/external/attributes.lua') + RES_crafting = dofile('mod/external/crafting-components.lua') + RES_area = dofile('mod/external/equipment-areas.lua') + RES_perks = dofile('mod/external/perks.lua') + RES_perksalias = dofile('mod/external/perks-by-alias.lua') + RES_skills = dofile('mod/external/skills.lua') + RES_TweakDB = dofile('mod/external/tweakdb-ids.lua') + RES_TweakDBmeta = dofile('mod/external/tweakdb-meta.lua') + + LVector = dofile("mod/external/Vector2") + if GetMod('corruptNCPD') then + + CorruptNCPDLang = dofile('mod/external/CorruptNCPDLang.lua') + end end -- logme(2,"Start Mod") @@ -52,293 +52,331 @@ end function ModInitialisation() - - - --version of compiled cache - cacheVersion = 3 - - - --print("test") - - currentSave = {} - currentSave.Score = {} - currentSave.Variable = {} - currentSave.Variable["Affinity"] = {} - - currentSave.arrayPlayerData = {} - currentSave.arrayAffinity = {} - currentSave.arrayQuestStatut = {} - currentSave.arrayFactionScore = {} - arrayUserSetting = {} - arrayUserInput = {} - arrayUserInput = { - ["cyberscriptOpenGroup"] = - { - ["repeatable"]=false, - ["keyboard"]= - { - ["key_1"] = "IK_Pad_DigitLeft", -- Key 1' keycode of the "mkbBinding" - ["key_2"] = "IK_Pad_DigitLeft", - ["key_3"] = "IK_Pad_DigitLeft", - ["hold_1"] = true, -- Is Key 1 of the "mkbBinding" a hold down key? - ["hold_2"] = false, - ["hold_3"] = false, - ["keys"] = 1 -- How many of the keys are currently being used for the binding "mkbBinding"? - }, - ["gamepad"]= - { - ["key_1"] = "IK_Pad_DigitLeft", -- Key 1' keycode of the "mkbBinding" - ["key_2"] = "IK_Pad_DigitLeft", - ["key_3"] = "IK_Pad_DigitLeft", - ["hold_1"] = true, -- Is Key 1 of the "mkbBinding" a hold down key? - ["hold_2"] = false, - ["hold_3"] = false, - ["keys"] = 1 -- How many of the keys are currently being used for the binding "mkbBinding"? - } - } - } - currentSave.arrayHouseStatut = {} - currentSave.arrayHousing = {} - currentSave.arrayPlayerItems = {} - currentSave.savedStates = {} - currentSave.arrayFactionDistrict = nil - currentSave.arrayFactionRelation = nil - currentSave.garage = {} - currentSave.arrayHUD = {} - - --not require a verification because it's not mine ^^ - loadModule() - SetObserver() - - interactionUI_init() - - if file_exists("editor/editor.lua") then - - - cyberscript.editor2_variable = dofile('editor/editor_variable.lua') - end - - CompiledDatapack = {} - - - -- File Checking for Init - if file_exists("desc.json") then - local f = io.open("desc.json") - lines = f:read("*a") - if lines ~= "" then - local json = json.decode(lines) - cyberscript.version = json.version - cyberscript.channel = json.channel - cyberscript.changelog = json.changelog - end - f:close() - end - - - - - --lang import - havelang = ImportLanguage() - - + + + --version of compiled cache + cacheVersion = 3 + + + --print("test") + + currentSave = {} + currentSave.Score = {} + currentSave.Variable = {} + currentSave.Variable["Affinity"] = {} + + currentSave.arrayPlayerData = {} + currentSave.arrayAffinity = {} + currentSave.arrayQuestStatut = {} + currentSave.arrayFactionScore = {} + arrayUserSetting = {} + arrayUserInput = {} + arrayUserInput = { + ["cyberscriptOpenGroup"] = + { + ["repeatable"]=false, + ["keyboard"]= + { + ["key_1"] = "IK_Pad_DigitLeft", -- Key 1' keycode of the "mkbBinding" + ["key_2"] = "IK_Pad_DigitLeft", + ["key_3"] = "IK_Pad_DigitLeft", + ["hold_1"] = true, -- Is Key 1 of the "mkbBinding" a hold down key? + ["hold_2"] = false, + ["hold_3"] = false, + ["keys"] = 1 -- How many of the keys are currently being used for the binding "mkbBinding"? + }, + ["gamepad"]= + { + ["key_1"] = "IK_Pad_DigitLeft", -- Key 1' keycode of the "mkbBinding" + ["key_2"] = "IK_Pad_DigitLeft", + ["key_3"] = "IK_Pad_DigitLeft", + ["hold_1"] = true, -- Is Key 1 of the "mkbBinding" a hold down key? + ["hold_2"] = false, + ["hold_3"] = false, + ["keys"] = 1 -- How many of the keys are currently being used for the binding "mkbBinding"? + } + } + } + currentSave.arrayHouseStatut = {} + currentSave.arrayHousing = {} + currentSave.arrayPlayerItems = {} + currentSave.savedStates = {} + currentSave.arrayFactionDistrict = nil + currentSave.arrayFactionRelation = nil + currentSave.garage = {} + currentSave.arrayHUD = {} + + --not require a verification because it's not mine ^^ + loadModule() + SetObserver() + + interactionUI_init() + + if file_exists("editor/editor.lua") then + + + cyberscript.editor2_variable = dofile('editor/editor_variable.lua') + end + + CompiledDatapack = {} + + + -- File Checking for Init + if file_exists("desc.json") then + local f = io.open("desc.json") + lines = f:read("*a") + if lines ~= "" then + local json = json.decode(lines) + cyberscript.version = json.version + cyberscript.channel = json.channel + cyberscript.changelog = json.changelog + end + f:close() + end + + + + + --lang import + havelang = ImportLanguage() + + end function SaveLoading() - arrayVehicles2 = {} - arrayVehicles = initVehicles() - - unlockVehicles(initVehicles()) - arrayDistricts = initDistrict() - arrayFastTravel = initFastTravel() - arrayGameSounds = initGameSounds() - arrayAttitudeGroup = initAttitudeGroup() - - - if #currentSave.arrayAffinity == 0 then - reloadCET = false - if file_exists("user/sessions/latest.txt") then - nodata = false - GameSession.readLatest() - logme(1,"CyberScript Session : data found, recover latest data") - else - nodata = true - - end - end - - - - - if GameIsLoaded == true and #currentSave.arrayAffinity > 0 then - loadUIsetting() - end - - - - if #currentSave.garage > 0 then - for i=1, #currentSave.garage do - Game.GetVehicleSystem():EnablePlayerVehicle(currentSave.garage[i].path, true, false) - end - end - - arrayUserSetting = {} - - if file_exists("user/settings/cyberscript.json") then - local f = io.open("user/settings/cyberscript.json") - lines = f:read("*a") - if lines ~= "" then - local json = json.decode(lines) - arrayUserSetting = json - end - f:close() - - end - - - arrayUserInput = { - ["cyberscriptOpenGroup"] = - { - ["repeatable"]=false, - ["keyboard"]= - { - ["key_1"] = "IK_Pad_DigitLeft", -- Key 1' keycode of the "mkbBinding" - ["key_2"] = "IK_Pad_DigitLeft", - ["key_3"] = "IK_Pad_DigitLeft", - ["hold_1"] = true, -- Is Key 1 of the "mkbBinding" a hold down key? - ["hold_2"] = false, - ["hold_3"] = false, - ["keys"] = 1 -- How many of the keys are currently being used for the binding "mkbBinding"? - }, - ["gamepad"]= - { - ["key_1"] = "IK_Pad_DigitLeft", -- Key 1' keycode of the "mkbBinding" - ["key_2"] = "IK_Pad_DigitLeft", - ["key_3"] = "IK_Pad_DigitLeft", - ["hold_1"] = true, -- Is Key 1 of the "mkbBinding" a hold down key? - ["hold_2"] = false, - ["hold_3"] = false, - ["keys"] = 1 -- How many of the keys are currently being used for the binding "mkbBinding"? - } - } - } - - - - - if file_exists("user/settings/userinput.json") then - local f = io.open("user/settings/userinput.json") - lines = f:read("*a") - if lines ~= "" then - local json = json.decode(lines) - arrayUserInput = json - end - f:close() - - end - - - moddisabled = getUserSettingWithDefault("moddisabled",moddisabled) - - currentController = getUserSettingWithDefault("currentController",currentController) - currentControllerName = "Keyboard" - currentControllerid = "keyboard" - - if(currentController == true)then - currentControllerName = "Gamepad" - currentControllerid = "gamepad" - end - - - - AmbushMin = getUserSettingWithDefault("AmbushMin",AmbushMin) - CurrentPOIDetectionRange = getUserSettingWithDefault("CurrentPOIDetectionRange",CurrentPOIDetectionRange) - - - enableCustomQuest = getUserSettingWithDefault("enableCustomQuest",enableCustomQuest) - AutoRefreshDatapack = getUserSettingWithDefault("AutoRefreshDatapack",AutoRefreshDatapack) - - Player_Sprint_Multiplier = getUserSettingWithDefault("Player_Sprint_Multiplier",Player_Sprint_Multiplier) - Player_Run_Multiplier = getUserSettingWithDefault("Player_Run_Multiplier",Player_Run_Multiplier) - Jump_Height = getUserSettingWithDefault("Jump_Height",Jump_Height) - Double_Jump_Height = getUserSettingWithDefault("Double_Jump_Height",Double_Jump_Height) - Immortal = getUserSettingWithDefault("Immortal",Immortal) - InfiniteStaminas = getUserSettingWithDefault("InfiniteStaminas",InfiniteStaminas) - - RamUpgrade = getUserSettingWithDefault("RamUpgrade",RamUpgrade) - - OpticalCamo = getUserSettingWithDefault("OpticalCamo",false) - - - debugLog = getUserSettingWithDefault("debugLog",debugLog) - showcyberscriptfixeronmap = getUserSettingWithDefault("showcyberscriptfixeronmap",showcyberscriptfixeronmap) - - logrecordlevel = getUserSettingWithDefault("logrecordlevel",logrecordlevel) - - holdTime = getUserSettingWithDefault("holdTime",holdTime) - - favoriteInteractGroup = getUserSettingWithDefault("favoriteInteractGroup","cyberscript") - - SetFlatFromSetting() - - GetScriptableSystemsContainer = Game.GetScriptableSystemsContainer() - FastTravelSystem = GetScriptableSystemsContainer:Get('FastTravelSystem') - FastTravelPoints = FastTravelSystem:GetFastTravelPoints() - local mappinData = Game.GetMappinSystem():GetMappins(gamemappinsMappinTargetType.Map) - - mappedFastTravelPoint = {} - for i=1, #FastTravelPoints do - local point = FastTravelPoints[i] - local position = "" - local obj = {} - for i=1, #mappinData do - local pointmp = mappinData[i] - if(pointmp.id.value == point.mappinID.value) then - --position = .."X : "..tostring(pointmp.worldPosition.x) .." Y : ".. tostring(pointmp.worldPosition.x) .." Z : ".. tostring(pointmp.worldPosition.x) - obj.position = pointmp.worldPosition - end - end - obj.name = Game.GetLocalizedText(point:GetPointDisplayName()) - obj.markerref = GameDump(point:GetMarkerRef()) - obj.markerrefdata = point:GetMarkerRef() - table.insert(mappedFastTravelPoint,obj) - end - - - - - - - if (currentSave.Variable["player"] == nil) then - - currentSave.Variable["player"]= {} - - end - - if (currentSave.Variable["player"]["current_gang"] == nil) then - - currentSave.Variable["player"]["current_gang"] = "faction_mox" - - end - - if (currentSave.Variable["game"] == nil) then - currentSave.Variable["game"] ={} - - - end - if (currentSave.Variable["game"]["loaded_gang_affinity"] == nil) then - - currentSave.Variable["game"]["loaded_gang_affinity"] = true - GangAffinityCalculator() - initGangRelation() - initGangDistrictScore() - - end - - - loadModule() - - makeNativeSettings() - makefavoritesetting() - print("save me") + arrayVehicles2 = {} + arrayVehicles = initVehicles() + + unlockVehicles(initVehicles()) + arrayDistricts = initDistrict() + arrayFastTravel = initFastTravel() + arrayGameSounds = initGameSounds() + arrayAttitudeGroup = initAttitudeGroup() + + + if #currentSave.arrayAffinity == 0 then + reloadCET = false + if file_exists("user/sessions/latest.txt") then + nodata = false + GameSession.readLatest() + logme(1,"CyberScript Session : data found, recover latest data") + else + nodata = true + + end + end + + + + + if GameIsLoaded == true and #currentSave.arrayAffinity > 0 then + loadUIsetting() + end + + + + if #currentSave.garage > 0 then + -- B-07 fix: validate each garage entry before calling EnablePlayerVehicle. + -- The original code blindly called EnablePlayerVehicle(currentSave.garage[i].path, ...) + -- for every entry on every load. If currentSave.garage got corrupted + -- (e.g., a Cyberscript-spawned temp vehicle tagged as persistent, or a + -- stale path from a removed mod), the bad entry could silently disable + -- or un-register the player's actual garage vehicles, leading to the + -- "Call Car List is Empty" bug (GH #2, recurring). We now: + -- 1. Skip entries with nil/empty path + -- 2. pcall the EnablePlayerVehicle call so one bad entry can't break the loop + -- 3. Track and prune invalid entries to keep currentSave.garage clean + local validGarage = {} + for i=1, #currentSave.garage do + local entry = currentSave.garage[i] + local path = entry and entry.path + if type(path) == "string" and path ~= "" then + local ok, err = pcall(function() + Game.GetVehicleSystem():EnablePlayerVehicle(path, true, false) + end) + if ok then + table.insert(validGarage, entry) + else + logme(1, "[Cyberscript] B-07: skipped invalid garage entry path=" .. tostring(path) .. " err=" .. tostring(err)) + end + else + logme(1, "[Cyberscript] B-07: skipped garage entry with missing path at index " .. tostring(i)) + end + end + -- Replace currentSave.garage with the validated list so bad entries + -- don't keep firing on every subsequent load. + if #validGarage ~= #currentSave.garage then + logme(2, "[Cyberscript] B-07: pruned garage from " .. tostring(#currentSave.garage) .. " to " .. tostring(#validGarage) .. " valid entries") + currentSave.garage = validGarage + end + end + + arrayUserSetting = {} + + if file_exists("user/settings/cyberscript.json") then + local f = io.open("user/settings/cyberscript.json") + lines = f:read("*a") + if lines ~= "" then + local json = json.decode(lines) + arrayUserSetting = json + end + f:close() + + end + + + arrayUserInput = { + ["cyberscriptOpenGroup"] = + { + ["repeatable"]=false, + ["keyboard"]= + { + ["key_1"] = "IK_Pad_DigitLeft", -- Key 1' keycode of the "mkbBinding" + ["key_2"] = "IK_Pad_DigitLeft", + ["key_3"] = "IK_Pad_DigitLeft", + ["hold_1"] = true, -- Is Key 1 of the "mkbBinding" a hold down key? + ["hold_2"] = false, + ["hold_3"] = false, + ["keys"] = 1 -- How many of the keys are currently being used for the binding "mkbBinding"? + }, + ["gamepad"]= + { + ["key_1"] = "IK_Pad_DigitLeft", -- Key 1' keycode of the "mkbBinding" + ["key_2"] = "IK_Pad_DigitLeft", + ["key_3"] = "IK_Pad_DigitLeft", + ["hold_1"] = true, -- Is Key 1 of the "mkbBinding" a hold down key? + ["hold_2"] = false, + ["hold_3"] = false, + ["keys"] = 1 -- How many of the keys are currently being used for the binding "mkbBinding"? + } + } + } + + + + + if file_exists("user/settings/userinput.json") then + local f = io.open("user/settings/userinput.json") + lines = f:read("*a") + if lines ~= "" then + local json = json.decode(lines) + arrayUserInput = json + end + f:close() + + end + + + moddisabled = getUserSettingWithDefault("moddisabled",moddisabled) + + currentController = getUserSettingWithDefault("currentController",currentController) + currentControllerName = "Keyboard" + currentControllerid = "keyboard" + + if(currentController == true)then + currentControllerName = "Gamepad" + currentControllerid = "gamepad" + end + + + + AmbushMin = getUserSettingWithDefault("AmbushMin",AmbushMin) + CurrentPOIDetectionRange = getUserSettingWithDefault("CurrentPOIDetectionRange",CurrentPOIDetectionRange) + + + enableCustomQuest = getUserSettingWithDefault("enableCustomQuest",enableCustomQuest) + AutoRefreshDatapack = getUserSettingWithDefault("AutoRefreshDatapack",AutoRefreshDatapack) + + Player_Sprint_Multiplier = getUserSettingWithDefault("Player_Sprint_Multiplier",Player_Sprint_Multiplier) + Player_Run_Multiplier = getUserSettingWithDefault("Player_Run_Multiplier",Player_Run_Multiplier) + Jump_Height = getUserSettingWithDefault("Jump_Height",Jump_Height) + Double_Jump_Height = getUserSettingWithDefault("Double_Jump_Height",Double_Jump_Height) + Immortal = getUserSettingWithDefault("Immortal",Immortal) + InfiniteStaminas = getUserSettingWithDefault("InfiniteStaminas",InfiniteStaminas) + + RamUpgrade = getUserSettingWithDefault("RamUpgrade",RamUpgrade) + + OpticalCamo = getUserSettingWithDefault("OpticalCamo",false) + + + debugLog = getUserSettingWithDefault("debugLog",debugLog) + -- B-23 fix: separate debug flag for entity/group lookup diagnostics. + -- Off by default (silent). Mod authors can enable it in the native + -- settings UI under "Script Settings" → "Debug Entity Lookups" to + -- see every nil/skipped entity reference in cyberscript.log. + debugEntityLookups = getUserSettingWithDefault("debugEntityLookups",false) + showcyberscriptfixeronmap = getUserSettingWithDefault("showcyberscriptfixeronmap",showcyberscriptfixeronmap) + showcyberscriptfixeronstreet = getUserSettingWithDefault("showcyberscriptfixeronstreet",showcyberscriptfixeronstreet) + + logrecordlevel = getUserSettingWithDefault("logrecordlevel",logrecordlevel) + + holdTime = getUserSettingWithDefault("holdTime",holdTime) + + favoriteInteractGroup = getUserSettingWithDefault("favoriteInteractGroup","cyberscript") + + SetFlatFromSetting() + + GetScriptableSystemsContainer = Game.GetScriptableSystemsContainer() + FastTravelSystem = GetScriptableSystemsContainer:Get('FastTravelSystem') + FastTravelPoints = FastTravelSystem:GetFastTravelPoints() + local mappinData = Game.GetMappinSystem():GetMappins(gamemappinsMappinTargetType.Map) + + mappedFastTravelPoint = {} + for i=1, #FastTravelPoints do + local point = FastTravelPoints[i] + local position = "" + local obj = {} + for i=1, #mappinData do + local pointmp = mappinData[i] + if(pointmp.id.value == point.mappinID.value) then + --position = .."X : "..tostring(pointmp.worldPosition.x) .." Y : ".. tostring(pointmp.worldPosition.x) .." Z : ".. tostring(pointmp.worldPosition.x) + obj.position = pointmp.worldPosition + end + end + obj.name = Game.GetLocalizedText(point:GetPointDisplayName()) + obj.markerref = GameDump(point:GetMarkerRef()) + obj.markerrefdata = point:GetMarkerRef() + table.insert(mappedFastTravelPoint,obj) + end + + + + + + + if (currentSave.Variable["player"] == nil) then + + currentSave.Variable["player"]= {} + + end + + if (currentSave.Variable["player"]["current_gang"] == nil) then + + currentSave.Variable["player"]["current_gang"] = "faction_mox" + + end + + if (currentSave.Variable["game"] == nil) then + currentSave.Variable["game"] ={} + + + end + if (currentSave.Variable["game"]["loaded_gang_affinity"] == nil) then + + currentSave.Variable["game"]["loaded_gang_affinity"] = true + GangAffinityCalculator() + initGangRelation() + initGangDistrictScore() + + end + + + loadModule() + + logme(1, "[Cyberscript Init] SaveLoading() — about to call makeNativeSettings()", true) + makeNativeSettings() + makefavoritesetting() + logme(1, "[Cyberscript Init] SaveLoading() — makeNativeSettings() completed", true) + print("save me") end -- ---------------------------------------------------------------------- -------------------------------Var Loading------------------------------- @@ -351,316 +389,416 @@ end -- --------------------------------------------------------------------------- function setupCore() --Setup environnement (DatapackLoading, observer, overrider) - - inputManager.onInit() - GameUI.Listen(function(state) - - if(state.submenu == "Stats") then - end - if(state.isMenu) then - inMenu = true - ActiveMenu = state.menu - ActiveSubMenu = state.submenu - if(ActiveSubMenu ~= "Shards") then - firstexecutionshard = nil - end - else - if(GameController["NewHudPhoneGameController"] ~= nil and GameController["NewHudPhoneGameController"]:IsA('NewHudPhoneGameController') and GameController["NewHudPhoneGameController"]:IsPhoneActive() == true) then - inMenu = true - ActiveMenu = "Phone" - ActiveSubMenu = "Phone" - if(ActiveSubMenu ~= "Shards") then - firstexecutionshard = nil - end - else - inMenu = false - ActiveMenu = nil - ActiveSubMenu = nil - firstexecutionshard = nil - AffinityPopupisShow = false - end - end - - end) - MasterVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "MasterVolume") - UIPopupsManager.Inititalize() - playerDeltaPos = Vector4.new(0, 0, 0, 1) - cyberscript.language = Game.GetSettingsSystem():GetVar("/language", "OnScreen"):GetValue().value - targetS = Game.GetTargetingSystem() - tp = Game.GetTeleportationFacility() - SfxVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "SfxVolume") - playerDeltaPos = Vector4.new(0, 0, 0, 1) - screenWidth, screenHight = GetDisplayResolution() - windowPos = ((screenWidth / 4) *3) - 43 - - tp = Game.GetTeleportationFacility() - SfxVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "SfxVolume") - DialogueVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "DialogueVolume") - MusicVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "MusicVolume") - CarRadioVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "CarRadioVolume") - SetOverrider() - SetObserver() - - interactionUI_init() - - eventCatcher = sampleStyleManagerGameController.new() - - - - if(ModIsLoaded) then - reloadDB() - GameSession.StoreInDir('user/sessions') - GameSession.Persist(currentSave, true) - GameSession.OnLoad(function() - reloadDB() - inputManager.onShutdown() - for k,v in pairs(mappinManager) do - deleteMappinByTag(k) - end - isdead = false - if(#currentSave.arrayAffinity > 0) then - GameIsLoaded = true - reloadCET = false - end - inputManager.onInit() - initCore() - - end) - initCore() - - CName.add("Available Quests") - end + logme(1, "[Cyberscript Init] setupCore() started", true) + + inputManager.onInit() + GameUI.Listen(function(state) + + if(state.submenu == "Stats") then + end + if(state.isMenu) then + inMenu = true + ActiveMenu = state.menu + ActiveSubMenu = state.submenu + if(ActiveSubMenu ~= "Shards") then + firstexecutionshard = nil + end + else + -- B-22 fix: the GameUI callback fires on every menu state change. + -- The original code called :IsA('NewHudPhoneGameController') without + -- checking the controller is still a valid scriptable, which throws + -- "Function 'IsA' context must be 'IScriptable'" when the controller + -- is mid-teardown. Wrap the whole check in pcall so a stale + -- controller reference can never crash the GameUI listener. + local phoneActive = false + pcall(function() + local ctrl = GameController["NewHudPhoneGameController"] + if ctrl ~= nil and ctrl:IsA('NewHudPhoneGameController') and ctrl:IsPhoneActive() == true then + phoneActive = true + end + end) + if phoneActive then + inMenu = true + ActiveMenu = "Phone" + ActiveSubMenu = "Phone" + if(ActiveSubMenu ~= "Shards") then + firstexecutionshard = nil + end + else + inMenu = false + ActiveMenu = nil + ActiveSubMenu = nil + firstexecutionshard = nil + AffinityPopupisShow = false + end + end + + end) + MasterVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "MasterVolume") + UIPopupsManager.Inititalize() + playerDeltaPos = Vector4.new(0, 0, 0, 1) + cyberscript.language = Game.GetSettingsSystem():GetVar("/language", "OnScreen"):GetValue().value + targetS = Game.GetTargetingSystem() + tp = Game.GetTeleportationFacility() + SfxVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "SfxVolume") + playerDeltaPos = Vector4.new(0, 0, 0, 1) + screenWidth, screenHight = GetDisplayResolution() + windowPos = ((screenWidth / 4) *3) - 43 + + tp = Game.GetTeleportationFacility() + SfxVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "SfxVolume") + DialogueVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "DialogueVolume") + MusicVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "MusicVolume") + CarRadioVolume = Game.GetSettingsSystem():GetVar("/audio/volume", "CarRadioVolume") + SetOverrider() + SetObserver() + + interactionUI_init() + + eventCatcher = sampleStyleManagerGameController.new() + + + + if(ModIsLoaded) then + logme(1, "[Cyberscript Init] setupCore: ModIsLoaded=true, setting up GameSession", true) + reloadDB() + GameSession.StoreInDir('user/sessions') + GameSession.Persist(currentSave, true) + GameSession.OnLoad(function() + logme(1, "[Cyberscript Init] GameSession.OnLoad fired", true) + reloadDB() + inputManager.onShutdown() + for k,v in pairs(mappinManager) do + deleteMappinByTag(k) + end + isdead = false + if(#currentSave.arrayAffinity > 0) then + GameIsLoaded = true + reloadCET = false + end + inputManager.onInit() + initCore() + -- B-05 fix: clear any stuck GameplayRestriction.NoCombat status and + -- reset the interaction UI state on every session load. Second Heart + -- revive + open Cyberscript hub leaves NoCombat stuck, blocking + -- inventory/map/phone (NexusMods "Inventory/map not working after + -- using 'Second Heart'"). Also defends against hubShown getting + -- stuck true across a load boundary (B-02 partial). + cyberscriptClearNoCombatAndResetUI() + -- B-09 fix: re-sync the player invisibility state to the current + -- Cyberscript setting on every load. Without this, the engine's + -- saved invisibility flag can persist even after the user disables + -- the "infinite invisibility" option (GH #15). + cyberscriptSyncInvisibilityOnLoad() + end) + -- B-05 fix: also clear NoCombat + reset hubShown on Death events. + -- Wrapped in pcall so it can NEVER abort the init chain. If this + -- fails (e.g. GameSession.Observe doesn't support 'Death' in this + -- CET version), we log and continue — initCore() must still run. + local deathObserveOk, deathObserveErr = pcall(function() + GameSession.Observe('Death', function() + pcall(function() + if interactionUI then + interactionUI.hubShown = false + interactionUI.input = false + end + end) + cyberscriptClearNoCombatAndResetUI() + end) + end) + if not deathObserveOk then + logme(1, "[Cyberscript Init] WARNING: GameSession.Observe('Death') failed (non-fatal): " .. tostring(deathObserveErr), true) + end + logme(1, "[Cyberscript Init] setupCore: about to call initCore()", true) + initCore() + logme(1, "[Cyberscript Init] setupCore: initCore() completed", true) + + CName.add("Available Quests") + else + logme(1, "[Cyberscript Init] setupCore: ModIsLoaded is FALSE — initCore will not run", true) + end +end + +-- B-05 helper: clear GameplayRestriction.NoCombat + reset interaction UI state. +-- Wrapped in pcall so a failure inside the cleanup never blocks the session +-- load path. Safe to call even before interactionUI is initialized. +function cyberscriptClearNoCombatAndResetUI() + pcall(function() + if interactionUI then + interactionUI.hubShown = false + interactionUI.input = false + interactionUI.callbacks = {} + end + local player = Game.GetPlayer() + if player then + StatusEffectHelper.RemoveStatusEffect(player, "GameplayRestriction.NoCombat") + end + end) +end + +-- B-09 helper: re-sync player invisibility to the current Cyberscript setting. +-- Called on every GameSession.Load. Reads the saved user setting and applies +-- SetInvisible(false) if the user has disabled the "infinite invisibility" +-- option, so the engine's persisted invisibility flag cannot outlive the +-- setting that enabled it. +function cyberscriptSyncInvisibilityOnLoad() + pcall(function() + local player = Game.GetPlayer() + if not player then return end + -- The "infinite invisibility" setting is read via getUserSetting. + -- Default to false (visible) if the setting is missing — visible + -- is the safe default for an unintended permanent state. + local invisSetting = getUserSettingWithDefault and getUserSettingWithDefault("InvisiblePlayer", false) + -- Only force-clear; never force-enable invisibility on load (the + -- user may have toggled it off mid-session and reloaded). + if invisSetting == false or invisSetting == nil then + player:SetInvisible(false) + pcall(function() player:UpdateVisibility() end) + end + end) end function DatapackLoading() --handle the loading and creation of cache for datapack in datapack - - - - - - local haveerror = false - - - loadAssetsObject() - ImportDataPack() - - - - + + + + + + local haveerror = false + + + loadAssetsObject() + ImportDataPack() + + + + end function initCore() --Setup session, mod/external observer and trigger mod core loading - isGameLoaded = Game.GetPlayer() and Game.GetPlayer():IsAttached() and not GetSingleton('inkMenuScenario'):GetSystemRequestsHandler():IsPreGame() - if GetMod('AppearanceMenuMod') then - AMM = GetMod("AppearanceMenuMod") - if(AMM.API ~= nil) then - AMMversion = AMM.API.version - print("Cyberscript : AMM Version founded : "..AMMversion) - else - AMM = nil - print("Cyberscript : AMM outdated !") - end - else - print("Cyberscript : AMM not found !") - - end - - - resetVar() - - - - if GetMod('nativeSettings') then nativeSettings = GetMod("nativeSettings") else logme(1,getLang("nonattivesetting")) error(getLang("nonattivesetting")) end - - - - - - - - - - - - - - - tweakdbtable = {} - - - - - logme(2,"CyberScript version "..cyberscript.version..cyberscript.channel) - logme(1,"CyberScript Initialisation...") - - - - - - - - - - - - cyberscript.EnemyManager = {} - cyberscript.FriendManager = {} - cyberscript.NPCManager = {} - cyberscript.EntityManager = {} - cyberscript.GroupManager = {} - cyberscript.PositionManager = {} - - testVehicule = {} - currentdialogQuestList = {} - currentdialogOptionList = {} - arrayInteractEnable = {} - -- --INIT VAR - bgcolor = "5df6ff" - draw = false - next_ambush = 0 - nexttimer_ambush = 300 - setkillAggro = false - setPassive = false - enemy_count = 0 - currentMissionId = 0 - haveMission = false - canTakeContract = false - npcSpawned = false - npcStarSpawn = false - enemySpawned = false - setStarFriend = false - currentHostileFaction = "" - getArrow = false - isInHouse = false - candrwMapPinFixer= true - fixerCanSpawn = true - nash_have_speak = false - - - - - - LoadDataPackCache() - SaveLoading() - - - - if file_exists("modules/editor.lua") then - initEditor() - end - - - logme(1,getLang("CyberScriptinit")) - tick = 0 + logme(1, "[Cyberscript Init] initCore() started — version 5.1.9", true) + isGameLoaded = Game.GetPlayer() and Game.GetPlayer():IsAttached() and not GetSingleton('inkMenuScenario'):GetSystemRequestsHandler():IsPreGame() + if GetMod('AppearanceMenuMod') then + AMM = GetMod("AppearanceMenuMod") + if(AMM.API ~= nil) then + AMMversion = AMM.API.version + print("Cyberscript : AMM Version founded : "..AMMversion) + else + AMM = nil + print("Cyberscript : AMM outdated !") + end + else + print("Cyberscript : AMM not found !") + + end + + + resetVar() + + + + if GetMod('nativeSettings') then nativeSettings = GetMod("nativeSettings") else logme(1,getLang("nonattivesetting")) error(getLang("nonattivesetting")) end + + + + + + + + + + + + + + + tweakdbtable = {} + + + + + logme(2,"CyberScript version "..cyberscript.version..cyberscript.channel) + logme(1,"CyberScript Initialisation...") + + + + + + + + + + + + cyberscript.EnemyManager = {} + cyberscript.FriendManager = {} + cyberscript.NPCManager = {} + cyberscript.EntityManager = {} + cyberscript.GroupManager = {} + cyberscript.PositionManager = {} + + testVehicule = {} + currentdialogQuestList = {} + currentdialogOptionList = {} + arrayInteractEnable = {} + -- --INIT VAR + bgcolor = "5df6ff" + draw = false + next_ambush = 0 + nexttimer_ambush = 300 + setkillAggro = false + setPassive = false + enemy_count = 0 + currentMissionId = 0 + haveMission = false + canTakeContract = false + npcSpawned = false + npcStarSpawn = false + enemySpawned = false + setStarFriend = false + currentHostileFaction = "" + getArrow = false + isInHouse = false + candrwMapPinFixer= true + fixerCanSpawn = true + nash_have_speak = false + + + + + + LoadDataPackCache() + SaveLoading() + + + + if file_exists("modules/editor.lua") then + initEditor() + end + + + logme(1,getLang("CyberScriptinit")) + tick = 0 end function shutdownManager() -- setup some function at shutdown - - UIPopupsManager.ClosePopup() - for k,v in pairs(mappinManager) do - deleteMappinByTag(k) - end - logme(10,"mappin deleted") - inputManager.onShutdown() - despawnAll() - resetVar() - - - - - - logme(2,"End Mod") - - collectgarbage() + + UIPopupsManager.ClosePopup() + for k,v in pairs(mappinManager) do + deleteMappinByTag(k) + end + logme(10,"mappin deleted") + inputManager.onShutdown() + despawnAll() + resetVar() + + + + + + logme(2,"End Mod") + + collectgarbage() end function TweakManager() -- Load vehicles and change some TweakDB - - TweakDB:CloneRecord("Cyberscript.Player_Male", "Character.TPP_Player_Cutscene_Male") - TweakDB:CloneRecord("Cyberscript.Player_Female", "Character.TPP_Player_Cutscene_Female") - - - TweakDB:SetFlat("Cyberscript.Player_Male.entityTemplatePath", "base\\cyberscript\\ent\\player_ma_tpp.ent") - TweakDB:SetFlat("Cyberscript.Player_Female.entityTemplatePath", "base\\cyberscript\\ent\\player_wa_tpp.ent") - - - + + -- B-21 fix: only clone Player_Male/Player_Female if they don't already exist. + -- TweakManager runs on every onTweak event; without this guard, CET logs + -- "Record already exists" on every reload. + pcall(function() + if TweakDB:GetRecord("Cyberscript.Player_Male") == nil then + TweakDB:CloneRecord("Cyberscript.Player_Male", "Character.TPP_Player_Cutscene_Male") + end + end) + pcall(function() + if TweakDB:GetRecord("Cyberscript.Player_Female") == nil then + TweakDB:CloneRecord("Cyberscript.Player_Female", "Character.TPP_Player_Cutscene_Female") + end + end) + + + TweakDB:SetFlat("Cyberscript.Player_Male.entityTemplatePath", "base\\cyberscript\\ent\\player_ma_tpp.ent") + TweakDB:SetFlat("Cyberscript.Player_Female.entityTemplatePath", "base\\cyberscript\\ent\\player_wa_tpp.ent") + + + - local f = assert(io.open("mod/data/vehicles.json")) - local lines = f:read("*a") - local encdo = lines - local tableDis = {} - tableDis =json.decode(lines) - vehiclelist = tableDis - f:close() - - local unlockableVehicles = TweakDB:GetFlat(TweakDBID.new('Vehicle.vehicle_list.list')) - - for _, vehiclePath in ipairs(tableDis) do - - local targetVehicleTweakDbId = TweakDBID.new(vehiclePath) - local isVehicleUnlockable = false - - for _, unlockableVehicleTweakDbId in ipairs(unlockableVehicles) do - if tostring(unlockableVehicleTweakDbId) == tostring(targetVehicleTweakDbId) then - isVehicleUnlockable = true - break - end - end - - if not isVehicleUnlockable then - table.insert(unlockableVehicles, targetVehicleTweakDbId) - end - end - - TweakDB:SetFlat('Vehicle.vehicle_list.list', unlockableVehicles) - - - - SetFlatFromSetting() - + local f = assert(io.open("mod/data/vehicles.json")) + local lines = f:read("*a") + local encdo = lines + local tableDis = {} + tableDis =json.decode(lines) + vehiclelist = tableDis + f:close() + + local unlockableVehicles = TweakDB:GetFlat(TweakDBID.new('Vehicle.vehicle_list.list')) + + for _, vehiclePath in ipairs(tableDis) do + + local targetVehicleTweakDbId = TweakDBID.new(vehiclePath) + local isVehicleUnlockable = false + + for _, unlockableVehicleTweakDbId in ipairs(unlockableVehicles) do + if tostring(unlockableVehicleTweakDbId) == tostring(targetVehicleTweakDbId) then + isVehicleUnlockable = true + break + end + end + + if not isVehicleUnlockable then + table.insert(unlockableVehicles, targetVehicleTweakDbId) + end + end + + TweakDB:SetFlat('Vehicle.vehicle_list.list', unlockableVehicles) + + + + SetFlatFromSetting() + end function SetFlatFromSetting() - - if(Player_Sprint_Multiplier ~= nil) then - TweakDB:SetFlat("PlayerLocomotion.player_locomotion_data_Sprint_inline1.value", 6.5 * Player_Sprint_Multiplier) - TweakDB:SetFlat("PlayerLocomotion.player_locomotion_data_Stand_inline1.value", 3.5 * Player_Run_Multiplier) - TweakDB:SetFlat("PlayerLocomotion.JumpJumpHeightModifier.value", 1 * Jump_Height) - TweakDB:SetFlat("PlayerLocomotion.DoubleJumpJumpHeightModifier.value", 2.6 * Double_Jump_Height) - - end - - - - TweakDB:SetFlat("PreventionSystem.setup.totalEntitiesLimit", 999999) - - - - if(RamUpgrade ~= nil and RamUpgrade == true) then - - TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline1.value", 1000) - TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline4.value", 50) - - TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline2.floatValues", {1000}) - TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline5.floatValues", {50}) - end - - - if(OpticalCamo ~= nil and OpticalCamo == true) then - - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffLegendary_inline1.value", 30) - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffEpic_inline1.value", 30) - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffRare_inline1.value", 30) - - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoLegendaryCooldown_inline1.value", 1) - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoCooldown_inline1.value",1) - - TweakDB:SetFlat("Items.OpticalCamoLegendary_inline2.intValues", 1) - TweakDB:SetFlat("Items.OpticalCamoEpic_inline2.intValues", 30) - TweakDB:SetFlat("Items.OpticalCamoRare_inline2.intValues", 30) - end - + + if(Player_Sprint_Multiplier ~= nil) then + TweakDB:SetFlat("PlayerLocomotion.player_locomotion_data_Sprint_inline1.value", 6.5 * Player_Sprint_Multiplier) + TweakDB:SetFlat("PlayerLocomotion.player_locomotion_data_Stand_inline1.value", 3.5 * Player_Run_Multiplier) + TweakDB:SetFlat("PlayerLocomotion.JumpJumpHeightModifier.value", 1 * Jump_Height) + TweakDB:SetFlat("PlayerLocomotion.DoubleJumpJumpHeightModifier.value", 2.6 * Double_Jump_Height) + + end + + + + TweakDB:SetFlat("PreventionSystem.setup.totalEntitiesLimit", 999999) + + + + if(RamUpgrade ~= nil and RamUpgrade == true) then + + TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline1.value", 1000) + TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline4.value", 50) + + TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline2.floatValues", {1000}) + TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline5.floatValues", {50}) + end + + + if(OpticalCamo ~= nil and OpticalCamo == true) then + + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffLegendary_inline1.value", 30) + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffEpic_inline1.value", 30) + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffRare_inline1.value", 30) + + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoLegendaryCooldown_inline1.value", 1) + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoCooldown_inline1.value",1) + + TweakDB:SetFlat("Items.OpticalCamoLegendary_inline2.intValues", 1) + TweakDB:SetFlat("Items.OpticalCamoEpic_inline2.intValues", 30) + TweakDB:SetFlat("Items.OpticalCamoRare_inline2.intValues", 30) + end + end @@ -669,102 +807,102 @@ end -- ------------------------------------------------------------------ registerForEvent("onInit", function() - arrayDatapack = {} - currentControllerid = "keyboard" - currentControllerName = "Keyboard" - --TweakDB:SetFlat("PreventionSystem.setup.totalEntitiesLimit", 999999) - JSON = dofile("mod/external/json.lua") - - Observe('PlayerPuppet', 'OnAction',function(_,action) - - listenPlayerInput(action) - - end) - holdTime = 1 - loadexternal() - - cyberscript.var = dofile('mod/modules/var.lua') - interactionUI = dofile("mod/modules/interactionUI") - cyberscript.observercontroller = dofile('mod/modules/observer_call.lua') - - if GetMod('AppearanceMenuMod') then - AMM = GetMod("AppearanceMenuMod") - if(AMM.API ~= nil) then - AMMversion = AMM.API.version - print("Cyberscript : AMM Version founded : "..AMMversion) - else - AMM = nil - print("Cyberscript : AMM outdated !") - end - else - print("Cyberscript : AMM Not found !") - - end - resetVar() - ModInitialisation() - setupCore() - + arrayDatapack = {} + currentControllerid = "keyboard" + currentControllerName = "Keyboard" + --TweakDB:SetFlat("PreventionSystem.setup.totalEntitiesLimit", 999999) + JSON = dofile("mod/external/json.lua") + + Observe('PlayerPuppet', 'OnAction',function(_,action) + + listenPlayerInput(action) + + end) + holdTime = 1 + loadexternal() + + cyberscript.var = dofile('mod/modules/var.lua') + interactionUI = dofile("mod/modules/interactionUI") + cyberscript.observercontroller = dofile('mod/modules/observer_call.lua') + + if GetMod('AppearanceMenuMod') then + AMM = GetMod("AppearanceMenuMod") + if(AMM.API ~= nil) then + AMMversion = AMM.API.version + print("Cyberscript : AMM Version founded : "..AMMversion) + else + AMM = nil + print("Cyberscript : AMM outdated !") + end + else + print("Cyberscript : AMM Not found !") + + end + resetVar() + ModInitialisation() + setupCore() + end) registerForEvent('onDraw', function() - - - if(moddisabled == false) then - windowsManager() - - end - + + + if(moddisabled == false) then + windowsManager() + + end + end) registerForEvent("onUpdate", function(delta) - - if(moddisabled == false) then - - - inputManager.onUpdate(delta) - refresh(delta) - interactionUI.update() - - end - - - - - - - - - - - - + + if(moddisabled == false) then + + + inputManager.onUpdate(delta) + refresh(delta) + interactionUI.update() + + end + + + + + + + + + + + + end) registerForEvent("onShutdown", function() - - shutdownManager() - + + shutdownManager() + end) registerForEvent("onOverlayOpen", function() - overlayOpen = true + overlayOpen = true end) registerForEvent("onOverlayClose", function() - overlayOpen = false + overlayOpen = false end) registerForEvent("onTweak", function() - - - - - TweakManager() - - - - - + + + + + TweakManager() + + + + + end) registerHotkey('OpenInteractMenu', 'Open Interact Menu (CET mode)', function() - cycleInteract2() + cycleInteract2() end) diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/db.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/db.lua index b1b7383..7ddfde2 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/db.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/db.lua @@ -1,68 +1,93 @@ logme(1,"CyberScript: db module loaded") cyberscript.module = cyberscript.module +1 +-- Defensive: ensure the db global exists and has the expected tables before +-- any query runs. If the db is missing or the schema is wrong, log a clear +-- error and return empty tables instead of crashing the entire init chain. +-- This prevents the "no such table: Characters" fatal error that aborts +-- setupCore() → initCore() → makeNativeSettings(). +function ensureDBReady() + if db == nil then + logme(1, "[Cyberscript DB] ERROR: db global is nil — sqlite3 connection not established. Database features disabled.", true) + return false + end + -- Check that the Characters table exists + local hasChars = false + local checkOk = pcall(function() + for row in db:nrows("SELECT name FROM sqlite_master WHERE type='table' AND name='Characters'") do + hasChars = true + end + end) + if not checkOk or not hasChars then + logme(1, "[Cyberscript DB] ERROR: Characters table missing from db.sqlite3. Database features disabled. Please restore db.sqlite3 from the Cyberscript distribution.", true) + return false + end + return true +end function loadCharacters(arrayPnjDb) - local stat = string.format("SELECT * FROM Characters") - - for row in db:nrows(stat) do - local quest = {} - quest.ID= row.ID - quest.TweakIDs= row.TweakIDs - quest.Names= row.Names - table.insert(arrayPnjDb, quest) - - -- ----logme(2,arrayQuest[row.Id].Id) - - end - + if not ensureDBReady() then return end + local stat = string.format("SELECT * FROM Characters") + + for row in db:nrows(stat) do + local quest = {} + quest.ID= row.ID + quest.TweakIDs= row.TweakIDs + quest.Names= row.Names + table.insert(arrayPnjDb, quest) + + -- ----logme(2,arrayQuest[row.Id].Id) + + end + end function loadItems(arrayItems) - local stat = string.format("SELECT * FROM Items") - - for row in db:nrows(stat) do - local item = {} - item.Id= row.Id - item.TweakId= row.TweakId - item.Name= row.Name - table.insert(arrayItems, item) - - -- ----logme(2,arrayQuest[row.Id].Id) - - end - + if not ensureDBReady() then return end + local stat = string.format("SELECT * FROM Items") + + for row in db:nrows(stat) do + local item = {} + item.Id= row.Id + item.TweakId= row.TweakId + item.Name= row.Name + table.insert(arrayItems, item) + + -- ----logme(2,arrayQuest[row.Id].Id) + + end + end function readDBOutput(res) - - if(res == 0) then - - logme(2,"DB saved") - - else - logme(2,"Error in DB : "..res) - error("db error code " .. res) - error (db:errmsg()) - db:interrupt() - end - - + + if(res == 0) then + + logme(2,"DB saved") + + else + logme(2,"Error in DB : "..res) + error("db error code " .. res) + error (db:errmsg()) + db:interrupt() + end + + end function reloadDB() - - --arrayQuest = initQuest() - - + + --arrayQuest = initQuest() + + - loadCharacters(arrayPnjDb) - loadItems(arrayItems) - - - + loadCharacters(arrayPnjDb) + loadItems(arrayItems) + + + end \ No newline at end of file diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/interactionUI.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/interactionUI.lua index 4c509aa..dfd2ce8 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/interactionUI.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/interactionUI.lua @@ -108,38 +108,71 @@ function ui.update() -- Run ever frame to avoid unwanted changes end function ui.OnAction(action) - + -- B-02 fix: wrap the whole action handler in pcall so an exception in a + -- hub callback (or in Game.GetPlayer() / StatusEffectHelper when the + -- player is mid-death/revive) can NEVER leave `hubShown` stuck true. + -- A stuck `hubShown` swallows every subsequent menu navigation input + -- and is the root cause of the widespread "cannot navigate menus" bug + -- (GH #20 / #16). On exception we forcibly reset the interaction UI + -- state so the next frame is clean. Also moves the NoCombat cleanup + -- out of the callback-success branch so it always fires on ChoiceApply + -- (B-05 partial fix). if interactionUI.input or not interactionUI.hubShown then return end - local actionName = Game.NameToString(action:GetName(action)) - local actionType = action:GetType(action).value - if actionName == 'ChoiceScrollUp' then - if actionType == 'BUTTON_PRESSED'then - interactionUI.selectedIndex = interactionUI.selectedIndex - 1 - if interactionUI.selectedIndex < 0 then - interactionUI.selectedIndex = #interactionUI.hub.choices - 1 - end - interactionUI.input = true - end - elseif actionName == 'ChoiceScrollDown' then - if actionType == 'BUTTON_PRESSED'then - interactionUI.selectedIndex = interactionUI.selectedIndex + 1 - if interactionUI.selectedIndex > #interactionUI.hub.choices - 1 then - interactionUI.selectedIndex = 0 - end - interactionUI.input = true - end - elseif actionName == 'ChoiceApply' then - if actionType == 'BUTTON_PRESSED'then - if interactionUI.callbacks[interactionUI.selectedIndex + 1] then - interactionUI.callbacks[interactionUI.selectedIndex + 1]() - - StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - end - interactionUI.input = true - end - end + local ok, err = pcall(function() + local actionName = Game.NameToString(action:GetName(action)) + local actionType = action:GetType(action).value + + if actionName == 'ChoiceScrollUp' then + if actionType == 'BUTTON_PRESSED'then + interactionUI.selectedIndex = interactionUI.selectedIndex - 1 + if interactionUI.selectedIndex < 0 then + interactionUI.selectedIndex = #interactionUI.hub.choices - 1 + end + interactionUI.input = true + end + elseif actionName == 'ChoiceScrollDown' then + if actionType == 'BUTTON_PRESSED'then + interactionUI.selectedIndex = interactionUI.selectedIndex + 1 + if interactionUI.selectedIndex > #interactionUI.hub.choices - 1 then + interactionUI.selectedIndex = 0 + end + interactionUI.input = true + end + elseif actionName == 'ChoiceApply' then + if actionType == 'BUTTON_PRESSED'then + -- B-05 partial fix: clear NoCombat on EVERY ChoiceApply, not + -- only when a callback exists. Second Heart revive + open hub + -- would otherwise leave NoCombat stuck (GH #20 / NexusMods + -- "Inventory/map not working after using 'Second Heart'"). + pcall(function() + if Game.GetPlayer() then + StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + end + end) + if interactionUI.callbacks[interactionUI.selectedIndex + 1] then + interactionUI.callbacks[interactionUI.selectedIndex + 1]() + end + interactionUI.input = true + end + end + end) + if not ok then + logme(1, "[Cyberscript] interactionUI.OnAction caught error: " .. tostring(err)) + -- Force-reset so a thrown callback can never freeze the hub. + interactionUI.input = false + interactionUI.hubShown = false + -- Best-effort hide; ignore if the controller is gone. + pcall(function() + if interactionUI.hub and interactionUI.baseControler then + local data = DialogChoiceHubs.new() + interactionUI.baseControler:UpdateDialogsData(data) + interactionUI.baseControler:OnInteractionsChanged() + interactionUI.baseControler:UpdateListBlackboard() + end + end) + end end function ui.OnDialogsSelectIndex( idx, wrapped) diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/modpack.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/modpack.lua index 6f2ae23..4b2c94f 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/modpack.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/modpack.lua @@ -3,136 +3,136 @@ cyberscript.module = cyberscript.module +1 function exportDatapackArray(t, max, depth, result) - if type(t) ~= 'table' then - return '{}' - end - max = max or 63 - depth = depth or 0 - local indent = string.rep('\t', depth) - local output = result or {} - table.insert(output, '{\n') - for k, v in pairs(t) do - local ktype = type(k) - local vtype = type(v) - local kstr = '' - if ktype == 'string' then - kstr = string.format('[%q] = ', k) - end - local vstr = '' - if vtype == 'string' then - vstr = string.format('%q', v) - elseif vtype == 'table' then - if depth < max then - table.insert(output, string.format('\t%s%s', indent, kstr)) - exportDatapackArray(v, max, depth + 1, output) - table.insert(output, ',\n') - end - elseif vtype == 'userdata' then - vstr = tostring(v) - if vstr:find('^userdata:') or vstr:find('^sol%.') then - if not sessionDataRelaxed then - --vtype = vstr:match('^sol%.(.+):') - if ktype == 'string' then - logme(10,('Cannot store userdata in the %q field.'):format(k)) - --raiseError(('Cannot store userdata of type %q in the %q field.'):format(vtype, k)) - else - logme(10,('Cannot store userdata in the list.')) - --raiseError(('Cannot store userdata of type %q.'):format(vtype)) - end - else - vstr = '' - end - end - elseif vtype == 'function' or vtype == 'thread' then - if not sessionDataRelaxed then - if ktype == 'string' then - logme(10,('Cannot store %s in the %q field.'):format(vtype, k)) - else - logme(10,('Cannot store %s.'):format(vtype)) - end - end - else - vstr = tostring(v) - end - if vstr ~= '' then - table.insert(output, string.format('\t%s%s%s,\n', indent, kstr, vstr)) - end - end - if not result and #output == 1 then - return '{}' - end - table.insert(output, indent .. '}') - if not result then - return table.concat(output) - end + if type(t) ~= 'table' then + return '{}' + end + max = max or 63 + depth = depth or 0 + local indent = string.rep('\t', depth) + local output = result or {} + table.insert(output, '{\n') + for k, v in pairs(t) do + local ktype = type(k) + local vtype = type(v) + local kstr = '' + if ktype == 'string' then + kstr = string.format('[%q] = ', k) + end + local vstr = '' + if vtype == 'string' then + vstr = string.format('%q', v) + elseif vtype == 'table' then + if depth < max then + table.insert(output, string.format('\t%s%s', indent, kstr)) + exportDatapackArray(v, max, depth + 1, output) + table.insert(output, ',\n') + end + elseif vtype == 'userdata' then + vstr = tostring(v) + if vstr:find('^userdata:') or vstr:find('^sol%.') then + if not sessionDataRelaxed then + --vtype = vstr:match('^sol%.(.+):') + if ktype == 'string' then + logme(10,('Cannot store userdata in the %q field.'):format(k)) + --raiseError(('Cannot store userdata of type %q in the %q field.'):format(vtype, k)) + else + logme(10,('Cannot store userdata in the list.')) + --raiseError(('Cannot store userdata of type %q.'):format(vtype)) + end + else + vstr = '' + end + end + elseif vtype == 'function' or vtype == 'thread' then + if not sessionDataRelaxed then + if ktype == 'string' then + logme(10,('Cannot store %s in the %q field.'):format(vtype, k)) + else + logme(10,('Cannot store %s.'):format(vtype)) + end + end + else + vstr = tostring(v) + end + if vstr ~= '' then + table.insert(output, string.format('\t%s%s%s,\n', indent, kstr, vstr)) + end + end + if not result and #output == 1 then + return '{}' + end + table.insert(output, indent .. '}') + if not result then + return table.concat(output) + end end -- function exportCompiledDatapackFolder(directories,msg) - --- local k = directories --- local file = io.open("user/cache/"..k..".lua", "w") --- --file:write('logme(10,'..k..' Cache Loaded) return ') --- if(file ~= nil) then --- file:write('return ') --- file:write(exportDatapackArray(arrayDatapack[k])) --- file:close() - - --- logme(1,k.." : "..msg,true) --- end - + +-- local k = directories +-- local file = io.open("user/cache/"..k..".lua", "w") +-- --file:write('logme(10,'..k..' Cache Loaded) return ') +-- if(file ~= nil) then +-- file:write('return ') +-- file:write(exportDatapackArray(arrayDatapack[k])) +-- file:close() + + +-- logme(1,k.." : "..msg,true) +-- end + -- end function ImportDataPack() - + - local directories = {} - - - --we load the directories from datapack registry - - for k,v in ipairs(cyberscript.datapackRegistry) do - - table.insert(directories,v) - - end + local directories = {} + + + --we load the directories from datapack registry + + for k,v in ipairs(cyberscript.datapackRegistry) do + + table.insert(directories,v) + + end - --for each directories - for i,u in ipairs(directories) do - - -- we check if there is an existing cache - - local success, message = pcall(function() - local mod = GetMod(u) - local datapack = {} + --for each directories + for i,u in ipairs(directories) do + + -- we check if there is an existing cache + + local success, message = pcall(function() + local mod = GetMod(u) + local datapack = {} - if mod ~= nil then - - datapack = mod.compile() - if(datapack == nil)then error("Cyberscript : FAILED TO COMPILE "..u,2) end - arrayDatapack[u] = datapack - arrayDatapack[u].enabled= true - print("Cyberscript : "..u.." compiled !") - - else - print("ERROR : "..u.." mod not found !") - - end - end) - if success == false then - print(message) - end - - - - - - end + if mod ~= nil then + + datapack = mod.compile() + if(datapack == nil)then error("Cyberscript : FAILED TO COMPILE "..u,2) end + arrayDatapack[u] = datapack + arrayDatapack[u].enabled= true + print("Cyberscript : "..u.." compiled !") + + else + print("ERROR : "..u.." mod not found !") + + end + end) + if success == false then + print(message) + end + + + + + + end @@ -150,21 +150,21 @@ end function ImportDataPackSingle(tag) - local mod = GetMod(tag) - local datapack = {} - - if mod ~= nil then - - datapack = mod.compile() - arrayDatapack[tag] = datapack - arrayDatapack[tag].enabled= true - print("Cyberscript : "..tag.." compiled !") - - else - - print("Cyberscript : FAILED TO COMPILE "..u,2) - end - + local mod = GetMod(tag) + local datapack = {} + + if mod ~= nil then + + datapack = mod.compile() + arrayDatapack[tag] = datapack + arrayDatapack[tag].enabled= true + print("Cyberscript : "..tag.." compiled !") + + else + + print("Cyberscript : FAILED TO COMPILE "..u,2) + end + end @@ -178,1445 +178,1520 @@ end --cache manipulation function loadAssetsObject() - - - local namespace = "cyberscript" - arrayDatapack[namespace] = {} - - arrayDatapack[namespace].metadata = {} - arrayDatapack[namespace].metadata.name = "Default Assets" - arrayDatapack[namespace].metadata.desc = "Default Assets" - arrayDatapack[namespace].metadata.author = "CyberScript" - arrayDatapack[namespace].metadata.file = "cyberscript" - arrayDatapack[namespace].metadata.tag = "cyberscript" - arrayDatapack[namespace].metadata.version = cyberscript.version - arrayDatapack[namespace].metadata.flags = {"compile","essential"} - - - for i=1,#datapackObjectType do - local objtype = datapackObjectType[i] - - local reader = dir("assets/"..objtype) - if(reader ~= nil) then - arrayDatapack[namespace][objtype] = {} - for i=1, #reader do - if(objtype == "sound") then - - if(tostring(reader[i].type) == "file" and (string.match(tostring(reader[i].name), ".mp3") or string.match(tostring(reader[i].name), ".wav"))) then - - local soundobj = {} - soundobj.name = reader[i].name - soundobj.path=namespace.."\\sound\\" - soundobj.namespace = namespace - - arrayDatapack[namespace][objtype][tostring(reader[i].name)] = {} - arrayDatapack[namespace][objtype][tostring(reader[i].name)] = soundobj - - - end - - - - - - elseif(objtype == "texture") then - - if(tostring(reader[i].type) == "file" and - ( - string.match(tostring(reader[i].name), ".jpg") or - string.match(tostring(reader[i].name), ".jpeg") or - string.match(tostring(reader[i].name), ".png")or - string.match(tostring(reader[i].name), ".bmp") - ) - ) then - - local imageobj = {} - - - imageobj.name = reader[i].name - imageobj.path=namespace.."\\texture\\"..reader[i].name - imageobj.namespace = namespace - - - - arrayDatapack[namespace][objtype][tostring(reader[i].name)] = {} - arrayDatapack[namespace][objtype][tostring(reader[i].name)] = imageobj - - end - - - else - - if(tostring(reader[i].type) == "file" and string.match(tostring(reader[i].name), ".json")) then - - local foo = io.open("assets/"..objtype.."/"..reader[i].name) - local lines = foo:read("*a") - if(lines ~= "") then - local jsonf = trydecodeJSOn(lines,foo,"assets/"..objtype.."/"..reader[i].name) - arrayDatapack[namespace][objtype][tostring(reader[i].name)] = {} - arrayDatapack[namespace][objtype][tostring(reader[i].name)] = jsonf - - else - res = false - - end - foo:close() - end - - - - end - end - end - end - - - - - - logme(1,"CyberScript Assets Loaded",true) + + + local namespace = "cyberscript" + arrayDatapack[namespace] = {} + + arrayDatapack[namespace].metadata = {} + arrayDatapack[namespace].metadata.name = "Default Assets" + arrayDatapack[namespace].metadata.desc = "Default Assets" + arrayDatapack[namespace].metadata.author = "CyberScript" + arrayDatapack[namespace].metadata.file = "cyberscript" + arrayDatapack[namespace].metadata.tag = "cyberscript" + arrayDatapack[namespace].metadata.version = cyberscript.version + arrayDatapack[namespace].metadata.flags = {"compile","essential"} + + + for i=1,#datapackObjectType do + local objtype = datapackObjectType[i] + + local reader = dir("assets/"..objtype) + if(reader ~= nil) then + arrayDatapack[namespace][objtype] = {} + for i=1, #reader do + if(objtype == "sound") then + + if(tostring(reader[i].type) == "file" and (string.match(tostring(reader[i].name), ".mp3") or string.match(tostring(reader[i].name), ".wav"))) then + + local soundobj = {} + soundobj.name = reader[i].name + soundobj.path=namespace.."\\sound\\" + soundobj.namespace = namespace + + arrayDatapack[namespace][objtype][tostring(reader[i].name)] = {} + arrayDatapack[namespace][objtype][tostring(reader[i].name)] = soundobj + + + end + + + + + + elseif(objtype == "texture") then + + if(tostring(reader[i].type) == "file" and + ( + string.match(tostring(reader[i].name), ".jpg") or + string.match(tostring(reader[i].name), ".jpeg") or + string.match(tostring(reader[i].name), ".png")or + string.match(tostring(reader[i].name), ".bmp") + ) + ) then + + local imageobj = {} + + + imageobj.name = reader[i].name + imageobj.path=namespace.."\\texture\\"..reader[i].name + imageobj.namespace = namespace + + + + arrayDatapack[namespace][objtype][tostring(reader[i].name)] = {} + arrayDatapack[namespace][objtype][tostring(reader[i].name)] = imageobj + + end + + + else + + if(tostring(reader[i].type) == "file" and string.match(tostring(reader[i].name), ".json")) then + + local foo = io.open("assets/"..objtype.."/"..reader[i].name) + local lines = foo:read("*a") + if(lines ~= "") then + local jsonf = trydecodeJSOn(lines,foo,"assets/"..objtype.."/"..reader[i].name) + arrayDatapack[namespace][objtype][tostring(reader[i].name)] = {} + arrayDatapack[namespace][objtype][tostring(reader[i].name)] = jsonf + + else + res = false + + end + foo:close() + end + + + + end + end + end + end + + + + + + logme(1,"CyberScript Assets Loaded",true) end function DatapackChecker(desc) - local result = true - - if(desc ~= nil) then - if(desc.flags ~= nil and #desc.flags > 0) then - - for i=1,#desc.flags do - - result = flagChecker(desc.flags[i]) - local myflag = string.lower(desc.flags[i]) - - - - if((string.match(tostring(flag), "cm_version:") or string.match(tostring(flag), "cm_version_strict:")) and table_contains(desc.flags,"beta",false) == true and string.match(tostring(cyberscript.version), "9999."))then - - result = true - - end - - end - - - - - else - - - - if( - - ( - (desc.explicits == nil or (desc.explicits ~= nil and((GameSettings.Get("/gameplay/misc/CensorNudity") == true and desc.explicits == false) or GameSettings.Get("/gameplay/misc/CensorNudity") == false)))) - and - - ( - desc.requirement == nil - or - ( - desc.requirement ~= nil - - and - ( - checkVersionNumber(cyberscript.version,desc.requirement) == false - - or - - (string.match(tostring(cyberscript.version), "9999.")) - ) - ) - ) - - - ) - - - then - - result = true - else - result = false - end - - end - - else - - result = false - end - - - return result + local result = true + + if(desc ~= nil) then + if(desc.flags ~= nil and #desc.flags > 0) then + + for i=1,#desc.flags do + + result = flagChecker(desc.flags[i]) + local myflag = string.lower(desc.flags[i]) + + + + if((string.match(tostring(flag), "cm_version:") or string.match(tostring(flag), "cm_version_strict:")) and table_contains(desc.flags,"beta",false) == true and string.match(tostring(cyberscript.version), "9999."))then + + result = true + + end + + end + + + + + else + + + + if( + + ( + (desc.explicits == nil or (desc.explicits ~= nil and((GameSettings.Get("/gameplay/misc/CensorNudity") == true and desc.explicits == false) or GameSettings.Get("/gameplay/misc/CensorNudity") == false)))) + and + + ( + desc.requirement == nil + or + ( + desc.requirement ~= nil + + and + ( + checkVersionNumber(cyberscript.version,desc.requirement) == false + + or + + (string.match(tostring(cyberscript.version), "9999.")) + ) + ) + ) + + + ) + + + then + + result = true + else + result = false + end + + end + + else + + result = false + end + + + return result end function flagChecker(myflag) - - local result = true - - local flag = string.lower(myflag) - - if(flag == "amm") then - - if(AMM ~= nil) then - - result = true - - else - - result = false - - end - - end - - if(string.match(tostring(flag), "amm_version:")) then - - if(AMM ~= nil and AMMversion ~= nil) then - local splitted = split(flag, ":") - - if #splitted > 1 then - - if (checkVersionNumber(tostring(AMMversion),tostring(splitted[2])) == false) then - result = true - else - - result = false - end - else - - result = false - end - - else - - result = false - end - - end - - if(string.match(tostring(flag), "amm_version_strict:")) then - - if(AMM ~= nil and AMMversion ~= nil) then - local splitted = split(flag, ":") - - if #splitted > 1 then - - if (AMMversion == tostring(splitted[2])) then - result = true - else - - result = false - end - else - - result = false - end - - else - - result = false - end - - end - - if(string.match(tostring(flag), "cm_version:")) then - - - local splitted = split(flag, ":") - - if #splitted > 1 then - - result = (checkVersionNumber(tostring(cyberscript.version),tostring(splitted[2])) == false) - - else - - result = false - end - - - - - end - - if(string.match(tostring(flag), "cm_version_strict:")) then - - - local splitted = split(flag, ":") - - if #splitted > 1 then - - result = cyberscript.version == tostring(splitted[2]) - - else - - result = false - end - - - - - end - - if(string.match(tostring(flag), "mod:")) then - - - local splitted = split(flag, ":") - - if #splitted > 1 then - - result = (GetMod(splitted[2]) ~= nil) - - else - - result = false - end - - - - - end - - if(flag == "nsfw") then - - result = (GameSettings.Get("/gameplay/misc/CensorNudity") == false) - - end - - if(string.match(tostring(flag), "datapack:")) then - local splitted = split(flag, ":") - result = (arrayDatapack[splitted[2]] ~= nil) - - end - - if(string.match(tostring(flag), "datapack_version:")) then - local splitted = split(flag, ":") - result = (arrayDatapack[splitted[2]] ~= nil and (checkVersionNumber(tostringarrayDatapack[splitted[2]].metadata.version,tostring(splitted[3]))) == false) - - end - - if(string.match(tostring(flag), "datapack_version_strict:")) then - local splitted = split(flag, ":") - result = (arrayDatapack[splitted[2]] ~= nil and arrayDatapack[splitted[2]].metadata.version == splitted[3]) - - end - - if(flag == "compile") then - - result = true - - end - - - - return result + + local result = true + + local flag = string.lower(myflag) + + if(flag == "amm") then + + if(AMM ~= nil) then + + result = true + + else + + result = false + + end + + end + + if(string.match(tostring(flag), "amm_version:")) then + + if(AMM ~= nil and AMMversion ~= nil) then + local splitted = split(flag, ":") + + if #splitted > 1 then + + if (checkVersionNumber(tostring(AMMversion),tostring(splitted[2])) == false) then + result = true + else + + result = false + end + else + + result = false + end + + else + + result = false + end + + end + + if(string.match(tostring(flag), "amm_version_strict:")) then + + if(AMM ~= nil and AMMversion ~= nil) then + local splitted = split(flag, ":") + + if #splitted > 1 then + + if (AMMversion == tostring(splitted[2])) then + result = true + else + + result = false + end + else + + result = false + end + + else + + result = false + end + + end + + if(string.match(tostring(flag), "cm_version:")) then + + + local splitted = split(flag, ":") + + if #splitted > 1 then + + result = (checkVersionNumber(tostring(cyberscript.version),tostring(splitted[2])) == false) + + else + + result = false + end + + + + + end + + if(string.match(tostring(flag), "cm_version_strict:")) then + + + local splitted = split(flag, ":") + + if #splitted > 1 then + + result = cyberscript.version == tostring(splitted[2]) + + else + + result = false + end + + + + + end + + if(string.match(tostring(flag), "mod:")) then + + + local splitted = split(flag, ":") + + if #splitted > 1 then + + result = (GetMod(splitted[2]) ~= nil) + + else + + result = false + end + + + + + end + + if(flag == "nsfw") then + + result = (GameSettings.Get("/gameplay/misc/CensorNudity") == false) + + end + + if(string.match(tostring(flag), "datapack:")) then + local splitted = split(flag, ":") + result = (arrayDatapack[splitted[2]] ~= nil) + + end + + if(string.match(tostring(flag), "datapack_version:")) then + local splitted = split(flag, ":") + result = (arrayDatapack[splitted[2]] ~= nil and (checkVersionNumber(tostringarrayDatapack[splitted[2]].metadata.version,tostring(splitted[3]))) == false) + + end + + if(string.match(tostring(flag), "datapack_version_strict:")) then + local splitted = split(flag, ":") + result = (arrayDatapack[splitted[2]] ~= nil and arrayDatapack[splitted[2]].metadata.version == splitted[3]) + + end + + if(flag == "compile") then + + result = true + + end + + + + return result end function UnloadDataPackCacheSingle(k) - for i,objtype in ipairs(datapackObjectType) do - spdlog.error(objtype) - for tag,v in pairs(cyberscript.cache[objtype]) do - - if(v.datapack == k)then - - logme(1,"delete "..tag) - - cyberscript.cache[objtype][tag] = nil - - - end - end - - end - loadQuestsToUI() - getInteractGroup() - FillCharacterArchive() - FillTweakFlatArchive() - - calculatePOIList() + for i,objtype in ipairs(datapackObjectType) do + spdlog.error(objtype) + for tag,v in pairs(cyberscript.cache[objtype]) do + + if(v.datapack == k)then + + logme(1,"delete "..tag) + + cyberscript.cache[objtype][tag] = nil + + + end + end + + end + loadQuestsToUI() + getInteractGroup() + FillCharacterArchive() + FillTweakFlatArchive() + + calculatePOIList() end function LoadDataPackCacheSingle(k) - - - - - - local v = arrayDatapack[k] - if('table' == type(v)) then - - if(DatapackChecker(v.metadata)) then - - for y=1,#datapackObjectType do - - local objtype = datapackObjectType[y] - - - - if(arrayDatapack[k][objtype] ~= nil) then - - try { - function() - FillList(objtype,arrayDatapack[k][objtype],k) - end, - - catch { - function(error) - logme(1,'Error during loading cache for datatpack: '..error,true) - - end - } - } - else - -- logme(10,"can't find "..objtype.." for "..k) - - end - - end - else - logme(1,"Output : "..tostring(DatapackChecker(v.metadata)),true) - logme(1,"can't load : "..k.." data :"..tostring(dump(v.metadata)),true) - - end - end - - - - - - - - loadQuestsToUI() - getInteractGroup() - FillCharacterArchive() - FillTweakFlatArchive() - - calculatePOIList() - + + + + + + local v = arrayDatapack[k] + if('table' == type(v)) then + + if(DatapackChecker(v.metadata)) then + + for y=1,#datapackObjectType do + + local objtype = datapackObjectType[y] + + + + if(arrayDatapack[k][objtype] ~= nil) then + + try { + function() + FillList(objtype,arrayDatapack[k][objtype],k) + end, + + catch { + function(error) + logme(1,'Error during loading cache for datatpack: '..error,true) + + end + } + } + else + -- logme(10,"can't find "..objtype.." for "..k) + + end + + end + else + logme(1,"Output : "..tostring(DatapackChecker(v.metadata)),true) + logme(1,"can't load : "..k.." data :"..tostring(dump(v.metadata)),true) + + end + end + + + + + + + + loadQuestsToUI() + getInteractGroup() + FillCharacterArchive() + FillTweakFlatArchive() + + calculatePOIList() + end - + function LoadDataPackCache() - - - cyberscript.cache = {} - for y=1,#datapackObjectType do - - local objtype = datapackObjectType[y] - - cyberscript.cache[objtype] = {} - - end - - if(arrayDatapack ~= nil) then - - - - for k,v in pairs(arrayDatapack) do - if('table' == type(v)) then - - if(DatapackChecker(v.metadata)) then - - for y=1,#datapackObjectType do - - local objtype = datapackObjectType[y] - - - - if(arrayDatapack[k][objtype] ~= nil) then - logme(5,"Loading "..objtype.." for "..k,true) - try { - function() - FillList(objtype,arrayDatapack[k][objtype],k) - end, - - catch { - function(error) - logme(1,'Error during loading cache for datatpack: '..error,true) - - end - } - } - else - -- logme(10,"can't find "..objtype.." for "..k) - - end - - end - else - logme(1,"Output : "..tostring(DatapackChecker(v.metadata)),true) - logme(1,"can't load : "..k.." data :"..tostring(dump(v.metadata)),true) - - end - end - end - else - - end - - - - - loadQuestsToUI() - getInteractGroup() - FillCharacterArchive() - FillTweakFlatArchive() - buildnativesetting() - - calculatePOIList() + + + cyberscript.cache = {} + for y=1,#datapackObjectType do + + local objtype = datapackObjectType[y] + + cyberscript.cache[objtype] = {} + + end + + if(arrayDatapack ~= nil) then + + + + for k,v in pairs(arrayDatapack) do + if('table' == type(v)) then + + if(DatapackChecker(v.metadata)) then + + for y=1,#datapackObjectType do + + local objtype = datapackObjectType[y] + + + + if(arrayDatapack[k][objtype] ~= nil) then + logme(5,"Loading "..objtype.." for "..k,true) + try { + function() + FillList(objtype,arrayDatapack[k][objtype],k) + end, + + catch { + function(error) + logme(1,'Error during loading cache for datatpack: '..error,true) + + end + } + } + else + -- logme(10,"can't find "..objtype.." for "..k) + + end + + end + else + logme(1,"Output : "..tostring(DatapackChecker(v.metadata)),true) + logme(1,"can't load : "..k.." data :"..tostring(dump(v.metadata)),true) + + end + end + end + else + + end + + + + + loadQuestsToUI() + getInteractGroup() + FillCharacterArchive() + FillTweakFlatArchive() + buildnativesetting() + + calculatePOIList() + + -- B-14 fix: apply backward-compatibility aliases for renamed + -- interactions / menu options. v5.1.4 renamed default interactions + -- and menu options ("for better clarity" per the changelog) which + -- silently broke downstream mods that referenced the old names. + -- This loader reads mod/data/legacy_interaction_aliases.json and + -- registers each old-name -> new-name mapping as an additional + -- cache entry pointing at the same data, so legacy JSON actions + -- continue to fire. Purely additive; no behavior change for mods + -- using current names. + applyLegacyInteractionAliases() + + -- B-25 fix: rebuild the favorite-interactions dropdown now that + -- arrayDatapack is fully populated. Previously makefavoritesetting() + -- only ran from SaveLoading() which fires BEFORE ImportDataPack/ + -- LoadDataPackCache populate arrayDatapack — so on first load the + -- dropdown was empty and selecting an item set favoriteInteractGroup + -- to nil. Calling it here (after arrayDatapack is populated) ensures + -- the dropdown is always correct, on first load AND on reloads. + if makefavoritesetting and nativeSettings then + local ok, err = pcall(function() makefavoritesetting() end) + if not ok then + logme(1, "[Cyberscript] B-25: makefavoritesetting failed during LoadDataPackCache: " .. tostring(err)) + end + end end +-- B-14 fix: load legacy_interaction_aliases.json and register each old->new +-- tag mapping as an alias in cyberscript.cache["interact"]. If the file is +-- missing or malformed, logs a warning and continues (non-fatal). +function applyLegacyInteractionAliases() + pcall(function() + if not file_exists("mod/data/legacy_interaction_aliases.json") then + return + end + local f = io.open("mod/data/legacy_interaction_aliases.json") + if not f then return end + local contents = f:read("*a") + f:close() + if not contents or contents == "" then return end + local parsed = json.decode(contents) + if not parsed or not parsed.aliases then return end + local count = 0 + for oldTag, newTag in pairs(parsed.aliases) do + if type(oldTag) == "string" and type(newTag) == "string" then + if cyberscript.cache["interact"] and cyberscript.cache["interact"][newTag] then + cyberscript.cache["interact"][oldTag] = cyberscript.cache["interact"][newTag] + count = count + 1 + else + logme(2, "[Cyberscript] B-14: alias target '" .. tostring(newTag) .. "' not found for old name '" .. tostring(oldTag) .. "'") + end + end + end + if count > 0 then + logme(2, "[Cyberscript] B-14: registered " .. tostring(count) .. " legacy interaction alias(es)") + end + end) +end + function calculatePOIList() - - poi_district = {} - poi_subdistrict = {} - poi_type = {} - poi_tag = {} - - for k,v in pairs(cyberscript.cache["poi"]) do - - - for i,location in ipairs(v.data.locations) do - - - local obj = {} - obj.tag = location.Tag - obj.type = v.data.isFor - obj.district =location.district - obj.subdistrict = location.subdistrict - obj.inVehicule = location.inVehicule - obj.x = location.x - obj.y = location.y - obj.z = location.z - - - if(poi_district[obj.district] == nil) then poi_district[obj.district] = {} end - if(poi_district[obj.district]["inVehicule"] == nil) then poi_district[obj.district]["inVehicule"] = {} end - if(poi_district[obj.district]["outVehicule"] == nil) then poi_district[obj.district]["outVehicule"] = {} end - - if(obj.inVehicule) then - - poi_district[obj.district]["inVehicule"][obj.tag] = obj - - else - - poi_district[obj.district]["outVehicule"][obj.tag] = obj - - end - - - - if(poi_subdistrict[obj.subdistrict] == nil) then poi_subdistrict[obj.subdistrict] = {} end - if(poi_subdistrict[obj.subdistrict]["inVehicule"] == nil) then poi_subdistrict[obj.subdistrict]["inVehicule"] = {} end - if(poi_subdistrict[obj.subdistrict]["outVehicule"] == nil) then poi_subdistrict[obj.subdistrict]["outVehicule"] = {} end - - if(obj.inVehicule) then - - poi_subdistrict[obj.subdistrict]["inVehicule"][obj.tag] = obj - - else - - poi_subdistrict[obj.subdistrict]["outVehicule"][obj.tag] = obj - - end - - - if(poi_type[tostring(obj.type)] == nil) then poi_type[tostring(obj.type)] = {} end - if(poi_type[tostring(obj.type)]["inVehicule"] == nil) then poi_type[tostring(obj.type)]["inVehicule"] = {} end - if(poi_type[tostring(obj.type)]["outVehicule"] == nil) then poi_type[tostring(obj.type)]["outVehicule"] = {} end - - if(obj.inVehicule) then - - poi_type[tostring(obj.type)]["inVehicule"][obj.tag] = obj - - else - - poi_type[tostring(obj.type)]["outVehicule"][obj.tag] = obj - - end - - - poi_tag[obj.tag] = obj - - - end - - - end - - - + + poi_district = {} + poi_subdistrict = {} + poi_type = {} + poi_tag = {} + + for k,v in pairs(cyberscript.cache["poi"]) do + + + for i,location in ipairs(v.data.locations) do + + + local obj = {} + obj.tag = location.Tag + obj.type = v.data.isFor + obj.district =location.district + obj.subdistrict = location.subdistrict + obj.inVehicule = location.inVehicule + obj.x = location.x + obj.y = location.y + obj.z = location.z + + + if(poi_district[obj.district] == nil) then poi_district[obj.district] = {} end + if(poi_district[obj.district]["inVehicule"] == nil) then poi_district[obj.district]["inVehicule"] = {} end + if(poi_district[obj.district]["outVehicule"] == nil) then poi_district[obj.district]["outVehicule"] = {} end + + if(obj.inVehicule) then + + poi_district[obj.district]["inVehicule"][obj.tag] = obj + + else + + poi_district[obj.district]["outVehicule"][obj.tag] = obj + + end + + + + if(poi_subdistrict[obj.subdistrict] == nil) then poi_subdistrict[obj.subdistrict] = {} end + if(poi_subdistrict[obj.subdistrict]["inVehicule"] == nil) then poi_subdistrict[obj.subdistrict]["inVehicule"] = {} end + if(poi_subdistrict[obj.subdistrict]["outVehicule"] == nil) then poi_subdistrict[obj.subdistrict]["outVehicule"] = {} end + + if(obj.inVehicule) then + + poi_subdistrict[obj.subdistrict]["inVehicule"][obj.tag] = obj + + else + + poi_subdistrict[obj.subdistrict]["outVehicule"][obj.tag] = obj + + end + + + if(poi_type[tostring(obj.type)] == nil) then poi_type[tostring(obj.type)] = {} end + if(poi_type[tostring(obj.type)]["inVehicule"] == nil) then poi_type[tostring(obj.type)]["inVehicule"] = {} end + if(poi_type[tostring(obj.type)]["outVehicule"] == nil) then poi_type[tostring(obj.type)]["outVehicule"] = {} end + + if(obj.inVehicule) then + + poi_type[tostring(obj.type)]["inVehicule"][obj.tag] = obj + + else + + poi_type[tostring(obj.type)]["outVehicule"][obj.tag] = obj + + end + + + poi_tag[obj.tag] = obj + + + end + + + end + + + end - - + + function FillList(objtype,tabl, datapackname) - local rootpath = "" - try { - function() - if(tabl ~= nil ) then - - if(objtype == "circuit") then - for key, value in pairs(tabl) do - - if(#value > 0) then - for i=1,#value do - local path = "scripts/"..objtype.."/"..value[i].tag..".json" - rootpath = path - makeTypeCachedObject(objtype,value[i],nil,path,datapackname) - - end - else - if(value.tag ~= nil) then - local path = "scripts/"..objtype.."/"..key - rootpath = path - cyberscript.cache["circuit"][value.tag] = {} - cyberscript.cache["circuit"][value.tag].data = value - cyberscript.cache["circuit"][value.tag].file = path - cyberscript.cache["circuit"][value.tag].datapack = datapackname - cyberscript.cache["circuit"][value.tag].scripttype = objtype - end - end - end - elseif(objtype == "choice") then - for key, value in pairs(tabl) do - - if(#value > 0) then - for i=1,#value do - local path = "scripts/"..objtype.."/"..value[i].tag..".json" - rootpath = path - makeTypeCachedObject(objtype,value[i],nil,path,datapackname) - - if(cyberscript.cache[objtype][tostring(value[i].tag)]["data"] == nil) then - cyberscript.cache[objtype][tostring(value[i].tag)]["data"]["havequitoption"] = true - end - end - else - if(value.tag ~= nil) then - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - if(cyberscript.cache[objtype][tostring(value.tag)]["data"] == nil) then - cyberscript.cache[objtype][tostring(value.tag)]["data"]["havequitoption"] = true - end - - end - end - end - elseif(objtype == "event") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - end - elseif(objtype == "faction") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "fixer") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "functions") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "help") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "housing") then - for key, value in pairs(tabl) do - - - - local path = "scripts/"..objtype.."/"..key - rootpath = path - - - - if(value.customIncluded ~= nil) then --amm template - logme(1,"Cyberscript : AMM housing founded : "..path..". Converting to CS Housing..") - local statutfile = true - - local newobj = {} - newobj.target = value.props[1].tag - newobj.trigger = {} - newobj.tag = value.props[1].tag - newobj.trigger.auto = {} - newobj.trigger.auto.name = "auto" - newobj.requirement = {} - local requirement = { "auto" } - - table.insert(newobj.requirement,requirement) - - newobj.items = {} - newobj.gameid = "fb721b23723385bfd5cb959ad14961d6" - - - for i,prop in ipairs(value.props) do - - - - local csprop = {} - csprop.HouseTag = prop.tag - - - local testtt = amm_entities[prop.entity_id] - if(testttt ~= nil) then - - csprop.Tag = amm_entities[prop.entity_id].entity_path - csprop.Id = prop.tag.."_"..amm_entities[prop.entity_id].entity_path.."_"..prop.uid - - else - - csprop.Tag = prop.tag - csprop.Id = prop.tag.."_".."unknown".."_"..prop.uid - - end - csprop.Title = prop.name - csprop.ItemPath = prop.template_path - csprop.appearance = prop.app - - local pos = loadstring("return "..prop.pos, '')() - - csprop.X = pos.x - csprop.Y = pos.y - csprop.Z = pos.z - - csprop.Yaw = pos.yaw - csprop.Pitch = pos.pitch - csprop.Roll = pos.roll - csprop.gameid = "fb721b23723385bfd5cb959ad14961d6" - csprop.scale =loadstring("return "..prop.scale, '')() - - - for y,light in ipairs(value.lights) do - - if(light.uid == prop.uid) then - - csprop.color = loadstring("return "..light.color, '')() - csprop.angles = loadstring("return "..light.angles, '')() - - - - csprop.radius = light.radius - csprop.intensity = light.intensity - - - end - - end - - - - table.insert(newobj.items,csprop) - - end - - - makeTypeCachedObject(objtype,newobj,nil,path,datapackname) - - - if(statutfile == true) then logme(1,"Cyberscript : AMM housing : "..path..". Convertion successfull !") else logme(1,"Cyberscript : AMM housing : "..path..". Convertion failed !") end - - else - - if(value.tag ~= nil) then - - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - - else - - logme(1,"Cyberscript : old housing format founded : "..path..". Not Loaded, apply modification to allow the loading.") - - end - - - - end - - - - - - end - elseif(objtype == "interact") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - cyberscript.cache["interact"][value.tag].data.group = datapackname - - end - elseif(objtype == "interfaces") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "lang") then - - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - cyberscript.cache["lang"][value.tag] = {} - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - - - end - elseif(objtype == "mission") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - - end - elseif(objtype == "node") then - for key, value in pairs(tabl) do - - if(#value > 0) then - for i=1,#value do - local path = "scripts/"..objtype.."/"..value[i].tag..".json" - rootpath = path - makeTypeCachedObject(objtype,value[i],nil,path,datapackname) - - end - - else - if(value.tag ~= nil) then - local path = "scripts/"..objtype.."/"..key - rootpath = path - cyberscript.cache["node"][tostring(value.tag)] = {} - cyberscript.cache["node"][tostring(value.tag)].data = value - cyberscript.cache["node"][tostring(value.tag)].file = path - cyberscript.cache["node"][tostring(value.tag)].datapack = datapackname - cyberscript.cache["node"][tostring(value.tag)].scripttype = objtype - end - end - - end - elseif(objtype == "npc") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - - cyberscript.cache["npc"][value.tag].data.isspawn=false - cyberscript.cache["npc"][value.tag].data.init=false - cyberscript.cache["npc"][value.tag].data.spawnforced=false - cyberscript.cache["npc"][value.tag].data.dospawnaction=true - cyberscript.cache["npc"][value.tag].data.doroutineaction=true - cyberscript.cache["npc"][value.tag].data.dodeathaction=true - cyberscript.cache["npc"][value.tag].data.dodespawnaction=true - cyberscript.cache["npc"][value.tag].data.workinglocation=value.location - - end - elseif(objtype == "path") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "phone_dialog") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - setScore(value.tag,"unlocked",1) - - - - for i,conversation in ipairs(cyberscript.cache["phone_dialog"][tostring(value.tag)].data.conversation) do - if(getScoreKey(conversation.tag,"readed") == nil) then - - setScore(conversation.tag,"readed",0) - end - if(conversation.unlock == false ) then - if(getScoreKey(conversation.tag,"unlocked") == 0 or getScoreKey(conversation.tag,"unlocked") == nil ) then - setScore(conversation.tag,"unlocked",0) - end - else - if(getScoreKey(conversation.tag,"unlocked") == 0 or getScoreKey(conversation.tag,"unlocked") == nil) then - setScore(conversation.tag,"unlocked",1) - end - end - for j,message in ipairs(conversation.message) do - if(getScoreKey(message.tag,"readed") == nil) then - - setScore(message.tag,"readed",0) - end - - if(message.unlock == false ) then - if(getScoreKey(message.tag,"unlocked") == 0 or getScoreKey(message.tag,"unlocked") == nil ) then - setScore(message.tag,"unlocked",0) - end - else - if(getScoreKey(message.tag,"unlocked") == 0 or getScoreKey(message.tag,"unlocked") == nil) then - setScore(message.tag,"unlocked",1) - end - end - end - -- if(message.choices ~= nil) then - -- for k,choice in ipairs(message.choices) do - -- if(choice.unlock == false ) then - -- if(getScoreKey(choice.tag,"unlocked") == 0 or getScoreKey(choice.tag,"unlocked") == nil ) then - -- setScore(choice.tag,"unlocked",0) - -- end - -- else - -- if(getScoreKey(choice.tag,"unlocked") == 0 or getScoreKey(choice.tag,"unlocked") == nil) then - -- setScore(choice.tag,"unlocked",1) - -- end - - - -- end - -- end - -- end - end - end - elseif(objtype == "place") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "poi") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - if(value.tag == nil) then - value.tag = key..tostring(math.random(1,99999)) - end - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "radio") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - cyberscript.cache["radio"][value.tag].enabled = false - - end - elseif(objtype == "shard") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "sound") then - for key, value in pairs(tabl) do - - - if(#value > 0) then - for i=1,#value do - local path = "scripts/"..objtype.."/"..value[i].tag..".json" - rootpath = path - makeTypeCachedObject(objtype,value[i],nil,path,datapackname) - - - end - - - else - if(value.tag ~= nil) then - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - end - end - elseif(objtype == "texture") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - - cyberscript.cache[objtype][key] = {} - - cyberscript.cache[objtype][key].datapack = datapackname - cyberscript.cache[objtype][key].scripttype = objtype - cyberscript.cache[objtype][key].data = path - cyberscript.cache[objtype][key].file = path - end - elseif(objtype == "scene") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "housing_template") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "hud") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "setting") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "codex") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - - elseif(objtype == "webpage") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "email") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "character") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,"name",path,datapackname) - - end - elseif(objtype == "tweakflat") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "quickhack") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - makeTypeCachedObject(objtype,value,nil,path,datapackname) - - end - elseif(objtype == "garage") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - - makeTypeCachedObject(objtype,value,nil,path,datapackname) - end - elseif(objtype == "animpack") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - - makeTypeCachedObject(objtype,value,nil,path,datapackname) - end - elseif(objtype == "ai") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - - makeTypeCachedObject(objtype,value,nil,path,datapackname) - end - elseif(objtype == "aitemplate") then - for key, value in pairs(tabl) do - local path = "scripts/"..objtype.."/"..key - rootpath = path - - makeTypeCachedObject(objtype,value,nil,path,datapackname) - end - end - - end - - - end, - catch { - function(error) - logme(1,'Error during creating cache for datatpack: '..error.." "..objtype.." "..datapackname.." path : "..rootpath,true) - - end - } - - } - + local rootpath = "" + try { + function() + if(tabl ~= nil ) then + + if(objtype == "circuit") then + for key, value in pairs(tabl) do + + if(#value > 0) then + for i=1,#value do + local path = "scripts/"..objtype.."/"..value[i].tag..".json" + rootpath = path + makeTypeCachedObject(objtype,value[i],nil,path,datapackname) + + end + else + if(value.tag ~= nil) then + local path = "scripts/"..objtype.."/"..key + rootpath = path + cyberscript.cache["circuit"][value.tag] = {} + cyberscript.cache["circuit"][value.tag].data = value + cyberscript.cache["circuit"][value.tag].file = path + cyberscript.cache["circuit"][value.tag].datapack = datapackname + cyberscript.cache["circuit"][value.tag].scripttype = objtype + end + end + end + elseif(objtype == "choice") then + for key, value in pairs(tabl) do + + if(#value > 0) then + for i=1,#value do + local path = "scripts/"..objtype.."/"..value[i].tag..".json" + rootpath = path + makeTypeCachedObject(objtype,value[i],nil,path,datapackname) + + if(cyberscript.cache[objtype][tostring(value[i].tag)]["data"] == nil) then + cyberscript.cache[objtype][tostring(value[i].tag)]["data"]["havequitoption"] = true + end + end + else + if(value.tag ~= nil) then + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + if(cyberscript.cache[objtype][tostring(value.tag)]["data"] == nil) then + cyberscript.cache[objtype][tostring(value.tag)]["data"]["havequitoption"] = true + end + + end + end + end + elseif(objtype == "event") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + end + elseif(objtype == "faction") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "fixer") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "functions") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "help") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "housing") then + for key, value in pairs(tabl) do + + + + local path = "scripts/"..objtype.."/"..key + rootpath = path + + + + if(value.customIncluded ~= nil) then --amm template + logme(1,"Cyberscript : AMM housing founded : "..path..". Converting to CS Housing..") + local statutfile = true + + local newobj = {} + newobj.target = value.props[1].tag + newobj.trigger = {} + newobj.tag = value.props[1].tag + newobj.trigger.auto = {} + newobj.trigger.auto.name = "auto" + newobj.requirement = {} + local requirement = { "auto" } + + table.insert(newobj.requirement,requirement) + + newobj.items = {} + newobj.gameid = "fb721b23723385bfd5cb959ad14961d6" + + + for i,prop in ipairs(value.props) do + + + + local csprop = {} + csprop.HouseTag = prop.tag + + + local testtt = amm_entities[prop.entity_id] + if(testttt ~= nil) then + + csprop.Tag = amm_entities[prop.entity_id].entity_path + csprop.Id = prop.tag.."_"..amm_entities[prop.entity_id].entity_path.."_"..prop.uid + + else + + csprop.Tag = prop.tag + csprop.Id = prop.tag.."_".."unknown".."_"..prop.uid + + end + csprop.Title = prop.name + csprop.ItemPath = prop.template_path + csprop.appearance = prop.app + + local pos = loadstring("return "..prop.pos, '')() + + csprop.X = pos.x + csprop.Y = pos.y + csprop.Z = pos.z + + csprop.Yaw = pos.yaw + csprop.Pitch = pos.pitch + csprop.Roll = pos.roll + csprop.gameid = "fb721b23723385bfd5cb959ad14961d6" + csprop.scale =loadstring("return "..prop.scale, '')() + + + for y,light in ipairs(value.lights) do + + if(light.uid == prop.uid) then + + csprop.color = loadstring("return "..light.color, '')() + csprop.angles = loadstring("return "..light.angles, '')() + + + + csprop.radius = light.radius + csprop.intensity = light.intensity + + + end + + end + + + + table.insert(newobj.items,csprop) + + end + + + makeTypeCachedObject(objtype,newobj,nil,path,datapackname) + + + if(statutfile == true) then logme(1,"Cyberscript : AMM housing : "..path..". Convertion successfull !") else logme(1,"Cyberscript : AMM housing : "..path..". Convertion failed !") end + + else + + if(value.tag ~= nil) then + + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + + else + + logme(1,"Cyberscript : old housing format founded : "..path..". Not Loaded, apply modification to allow the loading.") + + end + + + + end + + + + + + end + elseif(objtype == "interact") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + cyberscript.cache["interact"][value.tag].data.group = datapackname + + end + elseif(objtype == "interfaces") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "lang") then + + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + cyberscript.cache["lang"][value.tag] = {} + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + + + end + elseif(objtype == "mission") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + + end + elseif(objtype == "node") then + for key, value in pairs(tabl) do + + if(#value > 0) then + for i=1,#value do + local path = "scripts/"..objtype.."/"..value[i].tag..".json" + rootpath = path + makeTypeCachedObject(objtype,value[i],nil,path,datapackname) + + end + + else + if(value.tag ~= nil) then + local path = "scripts/"..objtype.."/"..key + rootpath = path + cyberscript.cache["node"][tostring(value.tag)] = {} + cyberscript.cache["node"][tostring(value.tag)].data = value + cyberscript.cache["node"][tostring(value.tag)].file = path + cyberscript.cache["node"][tostring(value.tag)].datapack = datapackname + cyberscript.cache["node"][tostring(value.tag)].scripttype = objtype + end + end + + end + elseif(objtype == "npc") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + + cyberscript.cache["npc"][value.tag].data.isspawn=false + cyberscript.cache["npc"][value.tag].data.init=false + cyberscript.cache["npc"][value.tag].data.spawnforced=false + cyberscript.cache["npc"][value.tag].data.dospawnaction=true + cyberscript.cache["npc"][value.tag].data.doroutineaction=true + cyberscript.cache["npc"][value.tag].data.dodeathaction=true + cyberscript.cache["npc"][value.tag].data.dodespawnaction=true + cyberscript.cache["npc"][value.tag].data.workinglocation=value.location + + end + elseif(objtype == "path") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "phone_dialog") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + setScore(value.tag,"unlocked",1) + + + + for i,conversation in ipairs(cyberscript.cache["phone_dialog"][tostring(value.tag)].data.conversation) do + if(getScoreKey(conversation.tag,"readed") == nil) then + + setScore(conversation.tag,"readed",0) + end + if(conversation.unlock == false ) then + if(getScoreKey(conversation.tag,"unlocked") == 0 or getScoreKey(conversation.tag,"unlocked") == nil ) then + setScore(conversation.tag,"unlocked",0) + end + else + if(getScoreKey(conversation.tag,"unlocked") == 0 or getScoreKey(conversation.tag,"unlocked") == nil) then + setScore(conversation.tag,"unlocked",1) + end + end + for j,message in ipairs(conversation.message) do + if(getScoreKey(message.tag,"readed") == nil) then + + setScore(message.tag,"readed",0) + end + + if(message.unlock == false ) then + if(getScoreKey(message.tag,"unlocked") == 0 or getScoreKey(message.tag,"unlocked") == nil ) then + setScore(message.tag,"unlocked",0) + end + else + if(getScoreKey(message.tag,"unlocked") == 0 or getScoreKey(message.tag,"unlocked") == nil) then + setScore(message.tag,"unlocked",1) + end + end + end + -- if(message.choices ~= nil) then + -- for k,choice in ipairs(message.choices) do + -- if(choice.unlock == false ) then + -- if(getScoreKey(choice.tag,"unlocked") == 0 or getScoreKey(choice.tag,"unlocked") == nil ) then + -- setScore(choice.tag,"unlocked",0) + -- end + -- else + -- if(getScoreKey(choice.tag,"unlocked") == 0 or getScoreKey(choice.tag,"unlocked") == nil) then + -- setScore(choice.tag,"unlocked",1) + -- end + + + -- end + -- end + -- end + end + end + elseif(objtype == "place") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "poi") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + if(value.tag == nil) then + value.tag = key..tostring(math.random(1,99999)) + end + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "radio") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + cyberscript.cache["radio"][value.tag].enabled = false + + end + elseif(objtype == "shard") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "sound") then + for key, value in pairs(tabl) do + + + if(#value > 0) then + for i=1,#value do + local path = "scripts/"..objtype.."/"..value[i].tag..".json" + rootpath = path + makeTypeCachedObject(objtype,value[i],nil,path,datapackname) + + + end + + + else + if(value.tag ~= nil) then + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + end + end + elseif(objtype == "texture") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + + cyberscript.cache[objtype][key] = {} + + cyberscript.cache[objtype][key].datapack = datapackname + cyberscript.cache[objtype][key].scripttype = objtype + cyberscript.cache[objtype][key].data = path + cyberscript.cache[objtype][key].file = path + end + elseif(objtype == "scene") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "housing_template") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "hud") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "setting") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "codex") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + + elseif(objtype == "webpage") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "email") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "character") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,"name",path,datapackname) + + end + elseif(objtype == "tweakflat") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "quickhack") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + makeTypeCachedObject(objtype,value,nil,path,datapackname) + + end + elseif(objtype == "garage") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + + makeTypeCachedObject(objtype,value,nil,path,datapackname) + end + elseif(objtype == "animpack") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + + makeTypeCachedObject(objtype,value,nil,path,datapackname) + end + elseif(objtype == "ai") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + + makeTypeCachedObject(objtype,value,nil,path,datapackname) + end + elseif(objtype == "aitemplate") then + for key, value in pairs(tabl) do + local path = "scripts/"..objtype.."/"..key + rootpath = path + + makeTypeCachedObject(objtype,value,nil,path,datapackname) + end + end + + end + + + end, + catch { + function(error) + logme(1,'Error during creating cache for datatpack: '..error.." "..objtype.." "..datapackname.." path : "..rootpath,true) + + end + } + + } + end function makeTypeCachedObject(objtype,value,field,path,datapackname) - local tag = value.tag - - if(field ~= nil) then - - tag = value[field] + local tag = value.tag + + if(field ~= nil) then + + tag = value[field] - end - if(cyberscript.cache[objtype] == nil) then cyberscript.cache[objtype] = {} end - cyberscript.cache[objtype][tag] = {} - cyberscript.cache[objtype][tag].data = value - cyberscript.cache[objtype][tag].file = path - cyberscript.cache[objtype][tag].datapack = datapackname - cyberscript.cache[objtype][tag].scripttype = objtype + end + if(cyberscript.cache[objtype] == nil) then cyberscript.cache[objtype] = {} end + cyberscript.cache[objtype][tag] = {} + cyberscript.cache[objtype][tag].data = value + cyberscript.cache[objtype][tag].file = path + cyberscript.cache[objtype][tag].datapack = datapackname + cyberscript.cache[objtype][tag].scripttype = objtype - + end function FillTweakFlatArchive() - for k, tweak in pairs(cyberscript.cache["tweakflat"]) do - - - for source, object in pairs(tweak.data.tweak) do - - if(object.type == "set") then - - TweakDB:SetFlat(source, object.value) - end - - if(object.type == "setnoupdate") then - - TweakDB:SetFlatNoUpdate(source, object.value) - end - - if(object.type == "update") then - - TweakDB:Update(source) - end - - if(object.type == "setbyget") then - - TweakDB:SetFlat(source, TweakDB:GetFlat(object.value)) - end - - if(object.type == "setbygetnoupdate") then - - TweakDB:SetFlatNoUpdate(source, object.value) - end - - if(object.type == "clone") then - - TweakDB:CloneRecord(source, object.value) - end - - if(object.type == "create") then - - TweakDB:CreateRecord(source, object.value) - end - - if(object.type == "delete") then - - TweakDB:DeleteRecord(source) - end - - logme(1,"Cyberscript - Mod "..k.." : Applied tweak for "..source) - - end - - - end + for k, tweak in pairs(cyberscript.cache["tweakflat"]) do + + + for source, object in pairs(tweak.data.tweak) do + + if(object.type == "set") then + + TweakDB:SetFlat(source, object.value) + end + + if(object.type == "setnoupdate") then + + TweakDB:SetFlatNoUpdate(source, object.value) + end + + if(object.type == "update") then + + TweakDB:Update(source) + end + + if(object.type == "setbyget") then + + TweakDB:SetFlat(source, TweakDB:GetFlat(object.value)) + end + + if(object.type == "setbygetnoupdate") then + + TweakDB:SetFlatNoUpdate(source, object.value) + end + + if(object.type == "clone") then + -- B-21 fix: skip clone if record already exists (avoids log spam) + pcall(function() + if TweakDB:GetRecord(source) == nil then + TweakDB:CloneRecord(source, object.value) + end + end) + end + + if(object.type == "create") then + -- B-21 fix: skip create if record already exists (avoids log spam) + pcall(function() + if TweakDB:GetRecord(source) == nil then + TweakDB:CreateRecord(source, object.value) + end + end) + end + + if(object.type == "delete") then + + TweakDB:DeleteRecord(source) + end + + logme(1,"Cyberscript - Mod "..k.." : Applied tweak for "..source) + + end + + + end end - - + + function FillCharacterArchive() - for k, ent in pairs(cyberscript.cache["character"]) do - - TweakDB:CloneRecord(ent.data.name, ent.data.source) - - - if(ent.data.model ~= nil) then - TweakDB:SetFlats(ent.data.name,{ - voiceTag = TweakDB:GetFlat(ent.data.model..".voiceTag"), - displayName = TweakDB:GetFlat(ent.data.model..".displayName"), - alternativeDisplayName = TweakDB:GetFlat(ent.data.model..".alternativeDisplayName"), - alternativeFullDisplayName = TweakDB:GetFlat(ent.data.model..".alternativeFullDisplayName"), - fullDisplayName = TweakDB:GetFlat(ent.data.model..".fullDisplayName"), - affiliation = TweakDB:GetFlat(ent.data.model..".affiliation"), - statPools = TweakDB:GetFlat(ent.data.model..".statPools") - }) - end - - if(ent.data.path ~= nil) then - - TweakDB:SetFlat(ent.data.name..".entityTemplatePath", ent.data.path) - - end - - if(ent.data.rarity ~= nil) then - - TweakDB:SetFlat(ent.data.name..".rarity", "NPCRarity."..ent.data.rarity) - - end - - - -- print("Making Character "..ent.data.name) - -- print("Falt Character "..GameDump(TweakDB:GetFlat(ent.data.name..".entityTemplatePath"))) - local parent = {} - for i,v in ipairs(cyberscript.entities) do - - if(v.entity_tweak == ent.data.source) then parent = deepcopy(v, nil) break end - - end - - - parent.entity_id = TweakDBID.new(ent.data.name).hash - parent.entity_entname = ent.data.path - parent.entity_name = ent.data.name - if(ent.data.path ~= nil)then - parent.entity_entpath = ent.data.path - end - parent.entity_tweak = ent.data.name - - local caninsert = true - - for i,v in ipairs(cyberscript.entities) do - - if(v.entity_id == parent.entity_id) then caninsert = false end - - end - - if caninsert == true then table.insert(cyberscript.entities,parent)end - - - - - end - + for k, ent in pairs(cyberscript.cache["character"]) do + + -- B-21 fix: TweakDB:CloneRecord logs "Record already exists" every time + -- FillCharacterArchive runs (on every LoadDataPackCache / hot-reload). + -- Check existence first to suppress the noise. The record is created + -- successfully on the first run; subsequent runs just re-apply the + -- flats below, which is the intended behavior. + local recordName = ent.data.name + pcall(function() + if TweakDB:GetRecord(recordName) == nil then + TweakDB:CloneRecord(recordName, ent.data.source) + end + end) + + + if(ent.data.model ~= nil) then + TweakDB:SetFlats(ent.data.name,{ + voiceTag = TweakDB:GetFlat(ent.data.model..".voiceTag"), + displayName = TweakDB:GetFlat(ent.data.model..".displayName"), + alternativeDisplayName = TweakDB:GetFlat(ent.data.model..".alternativeDisplayName"), + alternativeFullDisplayName = TweakDB:GetFlat(ent.data.model..".alternativeFullDisplayName"), + fullDisplayName = TweakDB:GetFlat(ent.data.model..".fullDisplayName"), + affiliation = TweakDB:GetFlat(ent.data.model..".affiliation"), + statPools = TweakDB:GetFlat(ent.data.model..".statPools") + }) + end + + if(ent.data.path ~= nil) then + + TweakDB:SetFlat(ent.data.name..".entityTemplatePath", ent.data.path) + + end + + if(ent.data.rarity ~= nil) then + + TweakDB:SetFlat(ent.data.name..".rarity", "NPCRarity."..ent.data.rarity) + + end + + + -- print("Making Character "..ent.data.name) + -- print("Falt Character "..GameDump(TweakDB:GetFlat(ent.data.name..".entityTemplatePath"))) + local parent = {} + for i,v in ipairs(cyberscript.entities) do + + if(v.entity_tweak == ent.data.source) then parent = deepcopy(v, nil) break end + + end + + + parent.entity_id = TweakDBID.new(ent.data.name).hash + parent.entity_entname = ent.data.path + parent.entity_name = ent.data.name + if(ent.data.path ~= nil)then + parent.entity_entpath = ent.data.path + end + parent.entity_tweak = ent.data.name + + local caninsert = true + + for i,v in ipairs(cyberscript.entities) do + + if(v.entity_id == parent.entity_id) then caninsert = false end + + end + + if caninsert == true then table.insert(cyberscript.entities,parent)end + + + + + end + end - + function loadQuestsToUI() - for k,v in pairs(cyberscript.cache["mission"]) do - local questos = cyberscript.cache["mission"][k].data - local data = {} - checkContext(questos) - - - - data.id = questos.tag - data.title = getLang(questos.title) - data.description = getLang(questos.content) - data.extra = questos.extra - data.metadata = {} - data.metadata.level = questos.recommandedlevel - data.metadata.questType = questos.questtype - data.metadata.district = questos.district - data.objectives = {} - for i=1,#questos.objectives do - local irpobj = questos.objectives[i] - checkContext(irpobj) - - - local obj = irpobj - obj.id = irpobj.tag - obj.title = getLang(irpobj.title) - obj.isOptional = irpobj.isoptionnal - obj.state = irpobj.state - table.insert(data.objectives,obj) - end - QuestManager.AddQuest(data) - QuestManager.MarkQuestAsInactive(questos.tag) - for i=1,#questos.objectives do - local irpobj = questos.objectives[i] - QuestManager.MarkObjectiveAs(irpobj.tag, irpobj.state) - end - end + for k,v in pairs(cyberscript.cache["mission"]) do + local questos = cyberscript.cache["mission"][k].data + local data = {} + checkContext(questos) + + + + data.id = questos.tag + data.title = getLang(questos.title) + data.description = getLang(questos.content) + data.extra = questos.extra + data.metadata = {} + data.metadata.level = questos.recommandedlevel + data.metadata.questType = questos.questtype + data.metadata.district = questos.district + data.objectives = {} + for i=1,#questos.objectives do + local irpobj = questos.objectives[i] + checkContext(irpobj) + + + local obj = irpobj + obj.id = irpobj.tag + obj.title = getLang(irpobj.title) + obj.isOptional = irpobj.isoptionnal + obj.state = irpobj.state + table.insert(data.objectives,obj) + end + QuestManager.AddQuest(data) + QuestManager.MarkQuestAsInactive(questos.tag) + for i=1,#questos.objectives do + local irpobj = questos.objectives[i] + QuestManager.MarkObjectiveAs(irpobj.tag, irpobj.state) + end + end end function loadQuestToUI(quest) - local questos = quest - local data = {} - checkContext(questos) - data.id = questos.tag - data.title = getLang(questos.title) - data.description = getLang(questos.content) - data.extra = questos.extra - data.metadata = {} - data.metadata.level = questos.recommandedlevel - data.metadata.questType = questos.questtype - data.metadata.district = questos.district - data.objectives = {} - for i=1,#questos.objectives do - local irpobj = questos.objectives[i] - checkContext(irpobj) - local obj = {} - obj.id = irpobj.tag - obj.title = getLang(irpobj.title) - obj.isOptional = irpobj.isoptionnal - obj.state = irpobj.state - table.insert(data.objectives,obj) - end - QuestManager.AddQuest(data) - QuestManager.MarkQuestAsInactive(questos.tag) - for i=1,#questos.objectives do - local irpobj = questos.objectives[i] - QuestManager.MarkObjectiveAs(irpobj.tag, irpobj.state) - end + local questos = quest + local data = {} + checkContext(questos) + data.id = questos.tag + data.title = getLang(questos.title) + data.description = getLang(questos.content) + data.extra = questos.extra + data.metadata = {} + data.metadata.level = questos.recommandedlevel + data.metadata.questType = questos.questtype + data.metadata.district = questos.district + data.objectives = {} + for i=1,#questos.objectives do + local irpobj = questos.objectives[i] + checkContext(irpobj) + local obj = {} + obj.id = irpobj.tag + obj.title = getLang(irpobj.title) + obj.isOptional = irpobj.isoptionnal + obj.state = irpobj.state + table.insert(data.objectives,obj) + end + QuestManager.AddQuest(data) + QuestManager.MarkQuestAsInactive(questos.tag) + for i=1,#questos.objectives do + local irpobj = questos.objectives[i] + QuestManager.MarkObjectiveAs(irpobj.tag, irpobj.state) + end end - + function initDistrict() - --logme(1,"Importing District...") - local f = assert(io.open("mod/data/districts.json")) - lines = f:read("*a") - encdo = lines - tableDis = {} - tableDis = trydecodeJSOn(lines,f,"mod/data/districts.json") - --logme(1,"District Imported") - f:close() - return tableDis + --logme(1,"Importing District...") + local f = assert(io.open("mod/data/districts.json")) + lines = f:read("*a") + encdo = lines + tableDis = {} + tableDis = trydecodeJSOn(lines,f,"mod/data/districts.json") + --logme(1,"District Imported") + f:close() + return tableDis end function initVehicles() - --logme(1,"Importing District...") - local f = assert(io.open("mod/data/vehicles.json")) - local lines = f:read("*a") - local encdo = lines - local tableDis = {} - tableDis = trydecodeJSOn(lines,f,"mod/data/vehicles.json") - --logme(1,"District Imported") - f:close() - - for i,v in ipairs(tableDis) do - - arrayVehicles2[tostring(TweakDBID.new(v))] = v - - end - - return tableDis + --logme(1,"Importing District...") + local f = assert(io.open("mod/data/vehicles.json")) + local lines = f:read("*a") + local encdo = lines + local tableDis = {} + tableDis = trydecodeJSOn(lines,f,"mod/data/vehicles.json") + --logme(1,"District Imported") + f:close() + + for i,v in ipairs(tableDis) do + + arrayVehicles2[tostring(TweakDBID.new(v))] = v + + end + + return tableDis end function initGameSounds() - --logme(1,"Importing District...") - local f = assert(io.open("mod/data/gamesounds.json")) - local lines = f:read("*a") - local encdo = lines - local tableDis = {} - tableDis = trydecodeJSOn(lines,f,"mod/data/gamesounds.json") - --logme(1,"District Imported") - f:close() - return tableDis + --logme(1,"Importing District...") + local f = assert(io.open("mod/data/gamesounds.json")) + local lines = f:read("*a") + local encdo = lines + local tableDis = {} + tableDis = trydecodeJSOn(lines,f,"mod/data/gamesounds.json") + --logme(1,"District Imported") + f:close() + return tableDis end function initAttitudeGroup() - local tableDis = {} - local reader = dir("mod/data/attitudegroup/") - if(reader ~= nil) then - for i=1, #reader do - if(tostring(reader[i].type) == "file" and string.match(tostring(reader[i].name), ".json")) then - local f = io.open("mod/data/attitudegroup/"..reader[i].name) - local lines = f:read("*a") - if(lines ~= "") then - local jsonf = trydecodeJSOn(lines,f,"mod/data/attitudegroup/"..reader[i].name) - table.insert(tableDis, jsonf) - end - f:close() - end - end - end - --logme(1,"Importing District...") - return tableDis + local tableDis = {} + local reader = dir("mod/data/attitudegroup/") + if(reader ~= nil) then + for i=1, #reader do + if(tostring(reader[i].type) == "file" and string.match(tostring(reader[i].name), ".json")) then + local f = io.open("mod/data/attitudegroup/"..reader[i].name) + local lines = f:read("*a") + if(lines ~= "") then + local jsonf = trydecodeJSOn(lines,f,"mod/data/attitudegroup/"..reader[i].name) + table.insert(tableDis, jsonf) + end + f:close() + end + end + end + --logme(1,"Importing District...") + return tableDis end function initFastTravel() - - --logme("Importing District...") - - local f = assert(io.open("mod/data/fasttravelmarkref.json")) - - lines = f:read("*a") - - encdo = lines - - tableDis = {} - - tableDis = trydecodeJSOn(lines,f,"mod/data/fasttravelmarkref.json") - - - - - - - - --logme("District Imported") - f:close() - return tableDis - - + + --logme("Importing District...") + + local f = assert(io.open("mod/data/fasttravelmarkref.json")) + + lines = f:read("*a") + + encdo = lines + + tableDis = {} + + tableDis = trydecodeJSOn(lines,f,"mod/data/fasttravelmarkref.json") + + + + + + + + --logme("District Imported") + f:close() + return tableDis + + end function initPath() - for k,v in pairs(arrayDatapack) do - if('table' == type(v)) then - local reader = dir("datapack/"..k.."/path") - if(reader ~= nil) then - for i=1, #reader do - local f = io.open("datapack/"..k.."/".."path".."/"..reader[i].name) - local lines = f:read("*a") - if(lines ~= "") then - - local path = "datapack/"..k.."/".."path".."/"..reader[i].name - - local jsonf = trydecodeJSOn(lines,f,path) - - cyberscript.cache["path"][jsonf.tag] = {} - cyberscript.cache["path"][jsonf.tag].data = jsonf - cyberscript.cache["path"][jsonf.tag].file = path - cyberscript.cache["path"][jsonf.tag].datapack = k - f:close() - else - res = false - f:close() - end - - - - end - - end - - end - end - - + for k,v in pairs(arrayDatapack) do + if('table' == type(v)) then + local reader = dir("datapack/"..k.."/path") + if(reader ~= nil) then + for i=1, #reader do + local f = io.open("datapack/"..k.."/".."path".."/"..reader[i].name) + local lines = f:read("*a") + if(lines ~= "") then + + local path = "datapack/"..k.."/".."path".."/"..reader[i].name + + local jsonf = trydecodeJSOn(lines,f,path) + + cyberscript.cache["path"][jsonf.tag] = {} + cyberscript.cache["path"][jsonf.tag].data = jsonf + cyberscript.cache["path"][jsonf.tag].file = path + cyberscript.cache["path"][jsonf.tag].datapack = k + f:close() + else + res = false + f:close() + end + + + + end + + end + + end + end + + end @@ -1625,5 +1700,5 @@ end - - + + diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/npc.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/npc.lua index 9f3863f..67fd2b1 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/npc.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/npc.lua @@ -9,666 +9,668 @@ local vehiculeRegion = true if spawnRegion then - - function spawnAnimationWorkspot(entitytag,anim_cname,workspot,isinstant,unlockcamera,angle) - - local obj = getEntityFromManager(entitytag) - local enti = Game.FindEntityByID(obj.id) - - - if(enti ~= nil) then - - if obj.workspot ~= nil and cyberscript.EntityManager[obj.workspot] ~= nil then - - if(cyberscript.EntityManager[obj.workspot].workspottag ~= workspot) then - changeWorkSpot(entitytag,obj.workspot,workspot,unlockcamera) - end - - changeWorkSpotAnims(entitytag,anim_cname,isinstant) - else - - local spawnTransform = enti:GetWorldTransform() - spawnTransform:SetPosition(enti:GetWorldPosition()) - local angles = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) - if(entitytag == "player")then - spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw-180)) - else - spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw-180)) - - end - - if(angle ~= nil) then - spawnTransform:SetOrientationEuler(EulerAngles.new(angle.roll, angle.pitch, angle.yaw)) - end - - - local NPC = exEntitySpawner.Spawn([[base\cyberscript\entity\workspot_anim.ent]], spawnTransform, '') - - Cron.Every(0.1, {tick = 1}, function(timer) - local ent = Game.FindEntityByID(NPC) - if ent then - -- stand_wall_lean180__rh_phone__ow__01 - Game.GetWorkspotSystem():PlayInDeviceSimple(ent, enti, unlockcamera, workspot, nil, nil, 0, 1, nil) - - Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, anim_cname, isinstant) - - if(NPC ~= nil) then - local entity = {} - entity.id = NPC - entity.iscodeware = false - local tag = entitytag.."_workspot" - entity.tag =tag - entity.tweak = anim_cname - entity.isprevention = false - entity.scriptlevel = 0 - entity.name = tag - entity.isMP = false - entity.isWorkspot = true - entity.workspottag = workspot - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+300 - cyberscript.EntityManager[tag]=entity - - cyberscript.EntityManager[entitytag].animation = anim_cname - - cyberscript.EntityManager[entitytag].workspot_name = workspot - - end - - - - Cron.Halt(timer) - end - - timer.tick = timer.tick + 1 - if timer.tick > 300 then - Cron.Halt(timer) - error("Couldn't spawn correctly the entity"..entitytag) - end - end) - end - end - end - - function enterInWorkspot(entitytag,workspottag,workspot,unlockcamera) - local obj = getEntityFromManager(entitytag) - local enti = Game.FindEntityByID(obj.id) - local objwk = getEntityFromManager(workspottag) - local entiwk = Game.FindEntityByID(objwk.id) - - if(enti ~= nil and entiwk ~= nil) then - - Game.GetWorkspotSystem():PlayInDeviceSimple(entiwk, enti, unlockcamera, workspot, nil, nil, 0, 1, nil) - Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, "idle_stand", true) - - - cyberscript.EntityManager[entitytag].animation = "idle_stand" - - cyberscript.EntityManager[entitytag].workspot_name = workspot - end - - end - - function playAnimInWorkspot(entitytag,anim_cname,isinstant) - local obj = getEntityFromManager(entitytag) - local enti = Game.FindEntityByID(obj.id) - - - if(enti ~= nil) then - print(tostring(isinstant)) - Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, anim_cname, isinstant) - cyberscript.EntityManager[entitytag].animation = anim_cname - - end - - end - - function stopWorkSpotAnims(entitytag) - local obj = getEntityFromManager(entitytag) - local enti = Game.FindEntityByID(obj.id) - local objwk = getEntityFromManager(workspottag) - local entiwk = Game.FindEntityByID(objwk.id) - - if(enti ~= nil and entiwk ~= nil) then - Game.GetWorkspotSystem():StopInDevice(enti) - - end - - end - - function spawnCustomAnimationWorkspot(entitytag,entname,anim_cname,workspot,isinstant,unlockcamera,angle) - print(anim_cname) - print(workspot) - local obj = getEntityFromManager(entitytag) - local enti = Game.FindEntityByID(obj.id) - - - if(enti ~= nil) then - local spawnTransform = enti:GetWorldTransform() - spawnTransform:SetPosition(enti:GetWorldPosition()) - local angles = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) - if(entitytag == "player")then - spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw-180)) - else - spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw-180)) - - end - - if(angle ~= nil) then - spawnTransform:SetOrientationEuler(EulerAngles.new(angle.roll, angle.pitch, angle.yaw)) - end - - cyberscript.EntityManager[entitytag].animation = anim_cname - cyberscript.EntityManager[entitytag].workspot_ent = entname - cyberscript.EntityManager[entitytag].workspot_name = workspot - if obj.workspot ~= nil and cyberscript.EntityManager[obj.workspot] ~= nil then - - local objwk = getEntityFromManager(obj.workspot) - local entiwk = Game.FindEntityByID(objwk.id) - - if(angle ~= nil) then - Game.GetTeleportationFacility():Teleport(entiwk, enti:GetWorldPosition(), EulerAngles.new(angle.roll, angle.pitch, angle.yaw)) - end - if(cyberscript.EntityManager[obj.workspot].workspottag ~= workspot) then - changeWorkSpot(entitytag,obj.workspot,workspot,unlockcamera) - end - - changeWorkSpotAnims(entitytag,anim_cname,isinstant) - else - - - - - local NPC = exEntitySpawner.Spawn(entname, spawnTransform, '') - - Cron.Every(0.1, {tick = 1}, function(timer) - - local ent = Game.FindEntityByID(NPC) - if ent then - - Game.GetWorkspotSystem():PlayInDeviceSimple(ent, enti, unlockcamera, workspot, nil, nil, 0, 1, nil) - Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, anim_cname, isinstant) - - - if(NPC ~= nil and cyberscript.EntityManager[entitytag] ~= nil) then + + function spawnAnimationWorkspot(entitytag,anim_cname,workspot,isinstant,unlockcamera,angle) + + local obj = getEntityFromManager(entitytag) + local enti = safeFindEntityByID(obj.id) + + + if(enti ~= nil) then + + if obj.workspot ~= nil and cyberscript.EntityManager[obj.workspot] ~= nil then + + if(cyberscript.EntityManager[obj.workspot].workspottag ~= workspot) then + changeWorkSpot(entitytag,obj.workspot,workspot,unlockcamera) + end + + changeWorkSpotAnims(entitytag,anim_cname,isinstant) + else + + local spawnTransform = enti:GetWorldTransform() + spawnTransform:SetPosition(enti:GetWorldPosition()) + local angles = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) + if(entitytag == "player")then + spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw-180)) + else + spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw-180)) + + end + + if(angle ~= nil) then + spawnTransform:SetOrientationEuler(EulerAngles.new(angle.roll, angle.pitch, angle.yaw)) + end + + + local NPC = exEntitySpawner.Spawn([[base\cyberscript\entity\workspot_anim.ent]], spawnTransform, '') + + Cron.Every(0.1, {tick = 1}, function(timer) + local ent = safeFindEntityByID(NPC) + if ent then + -- stand_wall_lean180__rh_phone__ow__01 + Game.GetWorkspotSystem():PlayInDeviceSimple(ent, enti, unlockcamera, workspot, nil, nil, 0, 1, nil) + + Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, anim_cname, isinstant) + + if(NPC ~= nil) then + local entity = {} + entity.id = NPC + entity.iscodeware = false + local tag = entitytag.."_workspot" + entity.tag =tag + entity.tweak = anim_cname + entity.isprevention = false + entity.scriptlevel = 0 + entity.name = tag + entity.isMP = false + entity.isWorkspot = true + entity.workspottag = workspot + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+300 + cyberscript.EntityManager[tag]=entity + + cyberscript.EntityManager[entitytag].animation = anim_cname + + cyberscript.EntityManager[entitytag].workspot_name = workspot + + end + + + + Cron.Halt(timer) + end + + timer.tick = timer.tick + 1 + if timer.tick > 300 then + Cron.Halt(timer) + error("Couldn't spawn correctly the entity"..entitytag) + end + end) + end + end + end + + function enterInWorkspot(entitytag,workspottag,workspot,unlockcamera) + local obj = getEntityFromManager(entitytag) + local enti = safeFindEntityByID(obj.id) + local objwk = getEntityFromManager(workspottag) + local entiwk = safeFindEntityByID(objwk.id) + + if(enti ~= nil and entiwk ~= nil) then + + Game.GetWorkspotSystem():PlayInDeviceSimple(entiwk, enti, unlockcamera, workspot, nil, nil, 0, 1, nil) + Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, "idle_stand", true) + + + cyberscript.EntityManager[entitytag].animation = "idle_stand" + + cyberscript.EntityManager[entitytag].workspot_name = workspot + end + + end + + function playAnimInWorkspot(entitytag,anim_cname,isinstant) + local obj = getEntityFromManager(entitytag) + local enti = safeFindEntityByID(obj.id) + + + if(enti ~= nil) then + print(tostring(isinstant)) + Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, anim_cname, isinstant) + cyberscript.EntityManager[entitytag].animation = anim_cname + + end + + end + + function stopWorkSpotAnims(entitytag) + local obj = getEntityFromManager(entitytag) + local enti = safeFindEntityByID(obj.id) + local objwk = getEntityFromManager(workspottag) + local entiwk = safeFindEntityByID(objwk.id) + + if(enti ~= nil and entiwk ~= nil) then + Game.GetWorkspotSystem():StopInDevice(enti) + + end + + end + + function spawnCustomAnimationWorkspot(entitytag,entname,anim_cname,workspot,isinstant,unlockcamera,angle) + print(anim_cname) + print(workspot) + local obj = getEntityFromManager(entitytag) + local enti = safeFindEntityByID(obj.id) + + + if(enti ~= nil) then + local spawnTransform = enti:GetWorldTransform() + spawnTransform:SetPosition(enti:GetWorldPosition()) + local angles = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) + if(entitytag == "player")then + spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw-180)) + else + spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw-180)) + + end + + if(angle ~= nil) then + spawnTransform:SetOrientationEuler(EulerAngles.new(angle.roll, angle.pitch, angle.yaw)) + end + + cyberscript.EntityManager[entitytag].animation = anim_cname + cyberscript.EntityManager[entitytag].workspot_ent = entname + cyberscript.EntityManager[entitytag].workspot_name = workspot + if obj.workspot ~= nil and cyberscript.EntityManager[obj.workspot] ~= nil then + + local objwk = getEntityFromManager(obj.workspot) + local entiwk = safeFindEntityByID(objwk.id) + + if(angle ~= nil) then + Game.GetTeleportationFacility():Teleport(entiwk, enti:GetWorldPosition(), EulerAngles.new(angle.roll, angle.pitch, angle.yaw)) + end + if(cyberscript.EntityManager[obj.workspot].workspottag ~= workspot) then + changeWorkSpot(entitytag,obj.workspot,workspot,unlockcamera) + end + + changeWorkSpotAnims(entitytag,anim_cname,isinstant) + else + + + + + local NPC = exEntitySpawner.Spawn(entname, spawnTransform, '') + + Cron.Every(0.1, {tick = 1}, function(timer) + + local ent = safeFindEntityByID(NPC) + if ent then + + Game.GetWorkspotSystem():PlayInDeviceSimple(ent, enti, unlockcamera, workspot, nil, nil, 0, 1, nil) + Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, anim_cname, isinstant) + + + if(NPC ~= nil and cyberscript.EntityManager[entitytag] ~= nil) then - local success, response = pcall(function() - local entity = {} - entity.id = NPC - entity.iscodeware = false - local tag = entitytag.."_workspot" - cyberscript.EntityManager[entitytag].workspot = tag - cyberscript.EntityManager[entitytag].animation = anim_cname - cyberscript.EntityManager[entitytag].workspot_name = workspot - entity.tag =tag - entity.tweak = anim_cname - entity.isprevention = false - entity.scriptlevel = 0 - entity.name = tag - entity.isMP = false - entity.isWorkspot = true - entity.workspottag = workspot - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+600 - cyberscript.EntityManager[tag]=entity - end) - if(success == false) then - Cron.Halt(timer) - end - end - - - - Cron.Halt(timer) - end - - if timer.tick > 300 then - Cron.Halt(timer) - error("Couldn't spawn correctly the entity"..entitytag.."_workspot") - end - - end) - - end - - end - - end - - function changeWorkSpotAnims(entitytag,anim_cname,isinstant) - - local obj = getEntityFromManager(entitytag) - local enti = Game.FindEntityByID(obj.id) - - cyberscript.EntityManager[entitytag].animation = anim_cname - - - if(enti ~= nil ) then - - - Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, anim_cname, isinstant) + local success, response = pcall(function() + local entity = {} + entity.id = NPC + entity.iscodeware = false + local tag = entitytag.."_workspot" + cyberscript.EntityManager[entitytag].workspot = tag + cyberscript.EntityManager[entitytag].animation = anim_cname + cyberscript.EntityManager[entitytag].workspot_name = workspot + entity.tag =tag + entity.tweak = anim_cname + entity.isprevention = false + entity.scriptlevel = 0 + entity.name = tag + entity.isMP = false + entity.isWorkspot = true + entity.workspottag = workspot + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+600 + cyberscript.EntityManager[tag]=entity + end) + if(success == false) then + Cron.Halt(timer) + end + end + + + + Cron.Halt(timer) + end + + if timer.tick > 300 then + Cron.Halt(timer) + error("Couldn't spawn correctly the entity"..entitytag.."_workspot") + end + + end) + + end + + end + + end + + function changeWorkSpotAnims(entitytag,anim_cname,isinstant) + + local obj = getEntityFromManager(entitytag) + local enti = safeFindEntityByID(obj.id) + + cyberscript.EntityManager[entitytag].animation = anim_cname + + + if(enti ~= nil ) then + + + Game.GetWorkspotSystem():SendJumpToAnimEnt(enti, anim_cname, isinstant) - cyberscript.EntityManager[entitytag].animation = anim_cname - end - - end - - function changeWorkSpot(entitytag,workspotEnttag,workspot,unlockcamera) - - local obj = getEntityFromManager(entitytag) - local enti = Game.FindEntityByID(obj.id) - cyberscript.EntityManager[entitytag].animation = nil - - cyberscript.EntityManager[entitytag].workspot_name = workspot - local objwk = getEntityFromManager(workspotEnttag) - local entiwk = Game.FindEntityByID(objwk.id) - - if(enti ~= nil and entiwk ~= nil ) then - cyberscript.EntityManager[workspotEnttag].workspottag = workspot - - Game.GetWorkspotSystem():PlayInDeviceSimple(entiwk, enti, unlockcamera, workspot, nil, nil, 0, 1, nil) - end - - end - - - function stopWorkSpotAnims(entitytag) - - local obj = getEntityFromManager(entitytag) - local enti = Game.FindEntityByID(obj.id) - - cyberscript.EntityManager[entitytag].animation = nil - cyberscript.EntityManager[entitytag].workspot_ent = nil - cyberscript.EntityManager[entitytag].workspot_name = nil - if(enti ~= nil) then - - - Game.GetWorkspotSystem():StopInDevice(enti) - despawnEntity(cyberscript.EntityManager[entitytag].workspot) - cyberscript.EntityManager[entitytag].workspot = nil - end - - end - - function spawnNPC(chara,appearance, tag, x, y ,z, spawnlevel, isprevention, isMPplayer, scriptlevel, isitem, rotation,despawntimer,codeware,persistState,persistSpawn,AlwaysSpawned,SpawnInView,dontregister,name,isboss) - - - - - if (('string' == type(chara)) and (string.match(tostring(chara), "AMM_Character.") == nil or (string.match(tostring(chara), "AMM_Character.") ~= nil and AMM ~= nil) ) )then - --logme(2,appearance) - - if ('string' == type(chara)) and string.match(chara, "Vehicle.") then - - error(getLang("npc_spawnnpc_error_vehicle")) - - - else - - local player = Game.GetPlayer() - local worldpos = player:GetWorldTransform() - local firstspawn = false - range = 5 - - if despawntimer == nil then despawntimer = 0 end - - --local vec4 = getBehindPosition(player,range) - - -- worldpos:SetPosition(worldpos, vec4) - - - if appearance == "none" then appearance = "" end - local NPC = nil - codeware = true - - if(isboss)then - TweakDB:CloneRecord(tag, chara) - TweakDB:SetFlat(tag..".rarity", "NPCRarity.Boss") + cyberscript.EntityManager[entitytag].animation = anim_cname + end + + end + + function changeWorkSpot(entitytag,workspotEnttag,workspot,unlockcamera) + + local obj = getEntityFromManager(entitytag) + local enti = safeFindEntityByID(obj.id) + cyberscript.EntityManager[entitytag].animation = nil + + cyberscript.EntityManager[entitytag].workspot_name = workspot + local objwk = getEntityFromManager(workspotEnttag) + local entiwk = safeFindEntityByID(objwk.id) + + if(enti ~= nil and entiwk ~= nil ) then + cyberscript.EntityManager[workspotEnttag].workspottag = workspot + + Game.GetWorkspotSystem():PlayInDeviceSimple(entiwk, enti, unlockcamera, workspot, nil, nil, 0, 1, nil) + end + + end + + + function stopWorkSpotAnims(entitytag) + + local obj = getEntityFromManager(entitytag) + local enti = safeFindEntityByID(obj) + + if cyberscript.EntityManager[entitytag] then + cyberscript.EntityManager[entitytag].animation = nil + cyberscript.EntityManager[entitytag].workspot_ent = nil + cyberscript.EntityManager[entitytag].workspot_name = nil + end + if(enti ~= nil) then + + + Game.GetWorkspotSystem():StopInDevice(enti) + despawnEntity(cyberscript.EntityManager[entitytag].workspot) + cyberscript.EntityManager[entitytag].workspot = nil + end + + end + + function spawnNPC(chara,appearance, tag, x, y ,z, spawnlevel, isprevention, isMPplayer, scriptlevel, isitem, rotation,despawntimer,codeware,persistState,persistSpawn,AlwaysSpawned,SpawnInView,dontregister,name,isboss) + + + + + if (('string' == type(chara)) and (string.match(tostring(chara), "AMM_Character.") == nil or (string.match(tostring(chara), "AMM_Character.") ~= nil and AMM ~= nil) ) )then + --logme(2,appearance) + + if ('string' == type(chara)) and string.match(chara, "Vehicle.") then + + error(getLang("npc_spawnnpc_error_vehicle")) + + + else + + local player = Game.GetPlayer() + local worldpos = player:GetWorldTransform() + local firstspawn = false + range = 5 + + if despawntimer == nil then despawntimer = 0 end + + --local vec4 = getBehindPosition(player,range) + + -- worldpos:SetPosition(worldpos, vec4) + + + if appearance == "none" then appearance = "" end + local NPC = nil + codeware = true + + if(isboss)then + TweakDB:CloneRecord(tag, chara) + TweakDB:SetFlat(tag..".rarity", "NPCRarity.Boss") - - - local parent = {} - for i,v in ipairs(cyberscript.entities) do - - if(v.entity_tweak == chara) then parent = deepcopy(v, nil) break end - - end - - - parent.entity_id = TweakDBID.new(tag).hash - - parent.entity_name = tag - - parent.entity_tweak = tag - - local caninsert = true - - for i,v in ipairs(cyberscript.entities) do - - if(v.entity_id == parent.entity_id) then caninsert = false end - - end - - if caninsert == true then table.insert(cyberscript.entities,parent)end - - chara = tag + + + local parent = {} + for i,v in ipairs(cyberscript.entities) do + + if(v.entity_tweak == chara) then parent = deepcopy(v, nil) break end + + end + + + parent.entity_id = TweakDBID.new(tag).hash + + parent.entity_name = tag + + parent.entity_tweak = tag + + local caninsert = true + + for i,v in ipairs(cyberscript.entities) do + + if(v.entity_id == parent.entity_id) then caninsert = false end + + end + + if caninsert == true then table.insert(cyberscript.entities,parent)end + + chara = tag - end - local twk = TweakDBID.new(chara) - - local postp = Vector4.new( x, y, z,1) - - worldpos:SetPosition(worldpos, postp) - if(rotation == nil) then - - rotation = EulerAngles.new(0,0,0) - - end - - local npcSpec = DynamicEntitySpec.new() - if(chara:sub(-4) == ".ent")then - npcSpec.templatePath = chara - else - npcSpec.recordID = twk + end + local twk = TweakDBID.new(chara) + + local postp = Vector4.new( x, y, z,1) + + worldpos:SetPosition(worldpos, postp) + if(rotation == nil) then + + rotation = EulerAngles.new(0,0,0) + + end + + local npcSpec = DynamicEntitySpec.new() + if(chara:sub(-4) == ".ent")then + npcSpec.templatePath = chara + else + npcSpec.recordID = twk - end - npcSpec.appearanceName = appearance or "" - npcSpec.position = postp - npcSpec.orientation = GetSingleton('EulerAngles'):ToQuat(rotation) - npcSpec.persistState = persistState or false - npcSpec.persistSpawn = persistSpawn or false - npcSpec.alwaysSpawned = AlwaysSpawned or false - npcSpec.spawnInView = true + end + npcSpec.appearanceName = appearance or "" + npcSpec.position = postp + npcSpec.orientation = GetSingleton('EulerAngles'):ToQuat(rotation) + npcSpec.persistState = persistState or false + npcSpec.persistSpawn = persistSpawn or false + npcSpec.alwaysSpawned = AlwaysSpawned or false + npcSpec.spawnInView = true - local textdump = {} - if(chara:sub(-4) == ".ent")then - textdump.templatePath = chara - else - textdump.recordID = chara - end - textdump.appearanceName = appearance or "" - textdump.position = postp - textdump.orientation = GetSingleton('EulerAngles'):ToQuat(rotation) - textdump.persistState = persistState or false - textdump.persistSpawn = persistSpawn or false - textdump.alwaysSpawned = AlwaysSpawned or false - textdump.spawnInView = true + local textdump = {} + if(chara:sub(-4) == ".ent")then + textdump.templatePath = chara + else + textdump.recordID = chara + end + textdump.appearanceName = appearance or "" + textdump.position = postp + textdump.orientation = GetSingleton('EulerAngles'):ToQuat(rotation) + textdump.persistState = persistState or false + textdump.persistSpawn = persistSpawn or false + textdump.alwaysSpawned = AlwaysSpawned or false + textdump.spawnInView = true - logme(10,dump(textdump),false) - CName.add("CyberScript") - CName.add("CyberScript.NPC") - CName.add("CyberScript.NPC."..tag) - - npcSpec.tags = {"CyberScript","CyberScript.NPC","CyberScript.NPC."..tag} - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.NPC."..tag) end - - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..tag) == false) then - - NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) - - if dontregister == nil then dontregister = false end - - if(NPC ~= nil and dontregister == false) then - print(chara) - print(NPC) - print(dontregister) - local entity = {} - entity.id = NPC - if(name ~= nil and name ~= "") then - entity.name = name - end - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+despawntimer - entity.spawnlocation = postp - entity.tag = tag - entity.isitem = isitem - entity.tweak = chara - entity.isprevention = isprevention - entity.iscodeware = true - entity.persistState = persistState or false - entity.persistSpawn = persistSpawn or false - entity.alwaysSpawned = AlwaysSpawned or false - entity.spawnInView = true - if(scriptlevel == nil) then - entity.scriptlevel = 0 - else - entity.scriptlevel = scriptlevel - end - entity.isMP = false - - if(isitem == nil or isitem == false) then - - local npgc = getNPCByTweakId(chara) - if(npgc ~= nil) then - entity.name = npgc.Names - else - entity.name = tag - end - else - - entity.name = tag - - end - - - entity.name = tag - - cyberscript.EntityManager[tag]=entity - cyberscript.EntityManager["last_spawned"].tag=tag - - - - end - - - - - end - - - - - - - end - - else - - logme(10,getLang("npc_spawnnpc_error_amm")) - - end - end - - - - - function spawnWidgetEnt(tag, x, y ,z) - - - - local spawnTransform = Game.GetPlayer():GetWorldTransform() - local pos = Game.GetPlayer():GetWorldPosition() - local heading = Game.GetPlayer():GetWorldForward() - local angles = GetSingleton('Quaternion'):ToEulerAngles(Game.GetPlayer():GetWorldOrientation()) - local offset = 1 - local postp = Vector4.new( x, y, z,1) - - spawnTransform:SetPosition(postp) - spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw - 180)) - - - local NPC = exEntitySpawner.Spawn([[base\cyberscript\entity\inkwidget.ent]], spawnTransform, '') - ----print("Spawned "..entname) - Cron.Every(0.1, {tick = 1}, function(timer) - local ent = Game.FindEntityByID(NPC) - if ent then - -- stand_wall_lean180__rh_phone__ow__01 - - - if(NPC ~= nil) then - local entity = {} - entity.id = NPC - local tag = tag - entity.iscodeware = false - entity.tag =tag - entity.tweak = [[base\cyberscript\entity\inkwidget.ent]] - entity.isprevention = false - entity.scriptlevel = 0 - entity.name = tag - entity.isMP = false - entity.isitem = true - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+300 - cyberscript.EntityManager[tag]=entity - - end - - - - Cron.Halt(timer) - end - timer.tick = timer.tick + 1 - if timer.tick > 300 then - Cron.Halt(timer) - error("Couldn't spawn correctly the entity"..tag) - end - end) - - - - end - - - - function spawnCamera(tag,pos,surveillance,angle) - - - - - if(surveillance == true)then - spawnNPC("base\\gameplay\\devices\\security_systems\\surveillance_cameras\\appearances\\ceiling_camera_1_militech.ent","", tag, pos.x, pos.y ,pos.z, -90, false, false, 0,true) - else - spawnNPC("base\\entities\\cameras\\simple_free_camera.ent","", tag, pos.x, pos.y ,pos.z, -90, false, false, 0,true) - - end - - - Cron.After(0.3, function() - local obj = getEntityFromManager(tag) - obj.surveillance = surveillance - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - RotateEntityTo(enti, angle.pitch, angle.yaw, angle.roll) - else - --error(getLang("npc_error_nocamera")) - end - end) - - - - - - - - - - end - - - function moveCamera(tag, pos,angle) - - - - - - - - local obj = getEntityFromManager(tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - -- teleportTo(enti, pos,angle, false) - - local rot = {} - - if(angle ~= 1) then - - rot = EulerAngles.new(0,0,0) - - rot.roll = angle.roll - rot.pitch = angle.pitch - rot.yaw = angle.yaw - - else - - rot = EulerAngles.new(0,0,0) - - end - - Game.GetTeleportationFacility():Teleport(enti, Vector4.new(pos.x, pos.y, pos.z,1) , rot) - else - --error(getLang("npc_error_nocamera")) - end - - - - - end - - - function enableCamera(tag) - - - - - local obj = getEntityFromManager(tag) - local enti = Game.FindEntityByID(obj.id) - - - if(enti ~= nil) then - - if(obj.surveillance == true) then - enti:OnToggleTakeOverControl(ToggleTakeOverControl.new()) - else - local camera = enti:FindComponentByName("camera") - camera:Activate(1,false) - end - - end - - - end - - function stopCamera(tag) - - local obj = getEntityFromManager(tag) - local enti = Game.FindEntityByID(obj.id) - - - if(enti ~= nil) then - - if(obj.surveillance == true) then - enti:OnToggleTakeOverControl(ToggleTakeOverControl.new()) - else - local camera = enti:FindComponentByName("camera") - camera:Deactivate(1,false) - end - end - - - - end - - - - - - - - - - + logme(10,dump(textdump),false) + CName.add("CyberScript") + CName.add("CyberScript.NPC") + CName.add("CyberScript.NPC."..tag) + + npcSpec.tags = {"CyberScript","CyberScript.NPC","CyberScript.NPC."..tag} + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.NPC."..tag) end + + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..tag) == false) then + + NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) + + if dontregister == nil then dontregister = false end + + if(NPC ~= nil and dontregister == false) then + print(chara) + print(NPC) + print(dontregister) + local entity = {} + entity.id = NPC + if(name ~= nil and name ~= "") then + entity.name = name + end + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+despawntimer + entity.spawnlocation = postp + entity.tag = tag + entity.isitem = isitem + entity.tweak = chara + entity.isprevention = isprevention + entity.iscodeware = true + entity.persistState = persistState or false + entity.persistSpawn = persistSpawn or false + entity.alwaysSpawned = AlwaysSpawned or false + entity.spawnInView = true + if(scriptlevel == nil) then + entity.scriptlevel = 0 + else + entity.scriptlevel = scriptlevel + end + entity.isMP = false + + if(isitem == nil or isitem == false) then + + local npgc = getNPCByTweakId(chara) + if(npgc ~= nil) then + entity.name = npgc.Names + else + entity.name = tag + end + else + + entity.name = tag + + end + + + entity.name = tag + + cyberscript.EntityManager[tag]=entity + cyberscript.EntityManager["last_spawned"].tag=tag + + + + end + + + + + end + + + + + + + end + + else + + logme(10,getLang("npc_spawnnpc_error_amm")) + + end + end + + + + + function spawnWidgetEnt(tag, x, y ,z) + + + + local spawnTransform = Game.GetPlayer():GetWorldTransform() + local pos = Game.GetPlayer():GetWorldPosition() + local heading = Game.GetPlayer():GetWorldForward() + local angles = GetSingleton('Quaternion'):ToEulerAngles(Game.GetPlayer():GetWorldOrientation()) + local offset = 1 + local postp = Vector4.new( x, y, z,1) + + spawnTransform:SetPosition(postp) + spawnTransform:SetOrientationEuler(EulerAngles.new(0, 0, angles.yaw - 180)) + + + local NPC = exEntitySpawner.Spawn([[base\cyberscript\entity\inkwidget.ent]], spawnTransform, '') + ----print("Spawned "..entname) + Cron.Every(0.1, {tick = 1}, function(timer) + local ent = safeFindEntityByID(NPC) + if ent then + -- stand_wall_lean180__rh_phone__ow__01 + + + if(NPC ~= nil) then + local entity = {} + entity.id = NPC + local tag = tag + entity.iscodeware = false + entity.tag =tag + entity.tweak = [[base\cyberscript\entity\inkwidget.ent]] + entity.isprevention = false + entity.scriptlevel = 0 + entity.name = tag + entity.isMP = false + entity.isitem = true + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+300 + cyberscript.EntityManager[tag]=entity + + end + + + + Cron.Halt(timer) + end + timer.tick = timer.tick + 1 + if timer.tick > 300 then + Cron.Halt(timer) + error("Couldn't spawn correctly the entity"..tag) + end + end) + + + + end + + + + function spawnCamera(tag,pos,surveillance,angle) + + + + + if(surveillance == true)then + spawnNPC("base\\gameplay\\devices\\security_systems\\surveillance_cameras\\appearances\\ceiling_camera_1_militech.ent","", tag, pos.x, pos.y ,pos.z, -90, false, false, 0,true) + else + spawnNPC("base\\entities\\cameras\\simple_free_camera.ent","", tag, pos.x, pos.y ,pos.z, -90, false, false, 0,true) + + end + + + Cron.After(0.3, function() + local obj = getEntityFromManager(tag) + obj.surveillance = surveillance + local enti = safeFindEntityByID(obj.id) + + if(enti ~= nil) then + RotateEntityTo(enti, angle.pitch, angle.yaw, angle.roll) + else + --error(getLang("npc_error_nocamera")) + end + end) + + + + + + + + + + end + + + function moveCamera(tag, pos,angle) + + + + + + + + local obj = getEntityFromManager(tag) + local enti = safeFindEntityByID(obj.id) + + if(enti ~= nil) then + -- teleportTo(enti, pos,angle, false) + + local rot = {} + + if(angle ~= 1) then + + rot = EulerAngles.new(0,0,0) + + rot.roll = angle.roll + rot.pitch = angle.pitch + rot.yaw = angle.yaw + + else + + rot = EulerAngles.new(0,0,0) + + end + + Game.GetTeleportationFacility():Teleport(enti, Vector4.new(pos.x, pos.y, pos.z,1) , rot) + else + --error(getLang("npc_error_nocamera")) + end + + + + + end + + + function enableCamera(tag) + + + + + local obj = getEntityFromManager(tag) + local enti = safeFindEntityByID(obj.id) + + + if(enti ~= nil) then + + if(obj.surveillance == true) then + enti:OnToggleTakeOverControl(ToggleTakeOverControl.new()) + else + local camera = enti:FindComponentByName("camera") + camera:Activate(1,false) + end + + end + + + end + + function stopCamera(tag) + + local obj = getEntityFromManager(tag) + local enti = safeFindEntityByID(obj.id) + + + if(enti ~= nil) then + + if(obj.surveillance == true) then + enti:OnToggleTakeOverControl(ToggleTakeOverControl.new()) + else + local camera = enti:FindComponentByName("camera") + camera:Deactivate(1,false) + end + end + + + + end + + + + + + + + + + @@ -679,65 +681,65 @@ if spawnRegion then function despawnEntity(tag) - - - local obj = getEntityFromManager(tag) - - local enti = Game.FindEntityByID(obj.id) - - if enti ~= nil then - - -- else - -- if(enti:IsVehicle() == false) then - -- if(obj.isprevention ~= nil and obj.isprevention == false) then - - -- exEntitySpawner.Despawn(enti) - -- else - - -- Game.GetPreventionSpawnSystem():RequestDespawn(enti:GetEntityID()) - - -- end - - -- else - -- if(obj.isprevention == false) then - -- if(obj.fromgarage == true) then - -- despawnVehicle(obj.tweak) - -- else - -- exEntitySpawner.Despawn(enti) - -- end - -- else - -- Game.GetPreventionSpawnSystem():RequestDespawn(enti:GetEntityID()) - -- end - -- end - if(obj.iscodeware == nil or obj.iscodeware == false) then - enti:Dispose() - - else - - Game.GetDynamicEntitySystem():DeleteEntity(enti:GetEntityID()) - - end - - - end - - if(obj.lock == true) then - obj.id = nil - obj.tag = tag - obj.tweak = "None" - obj.lock = true - else - if(cyberscript.EntityManager[tag]~=nil) then cyberscript.EntityManager[tag]=nil end - end - - --enti:Dispose() - - - --Game.GetPreventionSpawnSystem():RequestDespawn(enti:GetEntityID()) - --Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(spawnlevel * -1) - --Game.GetPreventionSpawnSystem():RequestDespawn(enti:GetEntityID()) - --enti:Dispose() - + + + local obj = getEntityFromManager(tag) + + local enti = safeFindEntityByID(obj.id) + + if enti ~= nil then + + -- else + -- if(enti:IsVehicle() == false) then + -- if(obj.isprevention ~= nil and obj.isprevention == false) then + + -- exEntitySpawner.Despawn(enti) + -- else + + -- Game.GetPreventionSpawnSystem():RequestDespawn(enti:GetEntityID()) + + -- end + + -- else + -- if(obj.isprevention == false) then + -- if(obj.fromgarage == true) then + -- despawnVehicle(obj.tweak) + -- else + -- exEntitySpawner.Despawn(enti) + -- end + -- else + -- Game.GetPreventionSpawnSystem():RequestDespawn(enti:GetEntityID()) + -- end + -- end + if(obj.iscodeware == nil or obj.iscodeware == false) then + enti:Dispose() + + else + + Game.GetDynamicEntitySystem():DeleteEntity(enti:GetEntityID()) + + end + + + end + + if(obj.lock == true) then + obj.id = nil + obj.tag = tag + obj.tweak = "None" + obj.lock = true + else + if(cyberscript.EntityManager[tag]~=nil) then cyberscript.EntityManager[tag]=nil end + end + + --enti:Dispose() + + + --Game.GetPreventionSpawnSystem():RequestDespawn(enti:GetEntityID()) + --Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(spawnlevel * -1) + --Game.GetPreventionSpawnSystem():RequestDespawn(enti:GetEntityID()) + --enti:Dispose() + end @@ -745,156 +747,156 @@ end function despawnAll() - - - for k,v in pairs(cyberscript.EntityManager)do - - local enti = v - if(enti.isprevention ~= nil and enti.isprevention == false) then - local np = Game.FindEntityByID(enti.id) - exEntitySpawner.Despawn(np) - end - - - end - - cyberscript.NPCManager = {} - cyberscript.FriendManager = {} - cyberscript.EnemyManager = {} - cyberscript.EntityManager = {} - cyberscript.GroupManager = {} - - - - - -- if(Game.GetPlayer()) then - -- local inVehiculse = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - -- if(inVehiculse == false) then - - - -- -- for i = -100, -1 do - - -- -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(i) - - -- -- end - - -- for i=1,#arrayVehicles do - -- despawnVehicle(arrayVehicles[i]) - -- end - - - -- else - - -- Game.GetPlayer():SetWarningMessage("Go out of vehicule to despawn entities") - - - -- end - - -- end - -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-2) - -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-95) - -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-2) - -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-17) - -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-18) - - - -- if(objLook ~= nil) then - -- Game.GetPreventionSpawnSystem():RequestDespawn(objLook:GetEntityID()) - -- end - - if(Game.GetPlayer()) then - local entity = {} - entity.id = Game.GetPlayer():GetEntityID() - entity.tag = "player" - entity.tweak = "player" - entity.lock = true - cyberscript.EntityManager[entity.tag] = entity - - local entity = {} - entity.id = nil - entity.tag = "lookatnpc" - entity.tweak = "None" - entity.lock = true - cyberscript.EntityManager[entity.tag] = entity - - local entity = {} - entity.id = nil - entity.tag = "last_scanned" - entity.tweak = "None" - entity.lock = true - cyberscript.EntityManager[entity.tag] = entity - - local entity = {} - entity.id = nil - entity.tag = "lookatentity" - entity.tweak = "None" - entity.lock = true - - cyberscript.EntityManager[entity.tag] = entity - - local entity = {} - entity.id = nil - entity.tag = "current_car" - entity.tweak = "None" - entity.lock = true - cyberscript.EntityManager[entity.tag] = entity - - - - local entity = {} - entity.id = nil - entity.tag = "last_killed" - entity.tweak = "None" - - cyberscript.EntityManager[entity.tag] = entity - - local entity = {} - entity.id = nil - entity.tag = "last_spawned" - entity.tweak = "None" - - cyberscript.EntityManager[entity.tag] = entity - - local group = {} - - group.tag = "AMMCompanion" - group.entities = {} - - cyberscript.GroupManager[group.tag] = group - - - local group = {} - - group.tag = "Multi" - group.entities = {} - - - cyberscript.GroupManager[group.tag] = group - local group = {} - - group.tag = "AV" - group.entities = {} - - - cyberscript.GroupManager[group.tag] = group - local group2 = {} - - group2.tag = "Crew" - group2.entities = {} - - - cyberscript.GroupManager[group.tag] = group - - local group2 = {} - - group2.tag = "companion" - group2.entities = {} - - - cyberscript.GroupManager[group.tag] = group - end - logme(2,"Despawn finished") - + + + for k,v in pairs(cyberscript.EntityManager)do + + local enti = v + if(enti.isprevention ~= nil and enti.isprevention == false) then + local np = safeFindEntityByID(enti.id) + exEntitySpawner.Despawn(np) + end + + + end + + cyberscript.NPCManager = {} + cyberscript.FriendManager = {} + cyberscript.EnemyManager = {} + cyberscript.EntityManager = {} + cyberscript.GroupManager = {} + + + + + -- if(Game.GetPlayer()) then + -- local inVehiculse = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + -- if(inVehiculse == false) then + + + -- -- for i = -100, -1 do + + -- -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(i) + + -- -- end + + -- for i=1,#arrayVehicles do + -- despawnVehicle(arrayVehicles[i]) + -- end + + + -- else + + -- Game.GetPlayer():SetWarningMessage("Go out of vehicule to despawn entities") + + + -- end + + -- end + -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-2) + -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-95) + -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-2) + -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-17) + -- Game.GetPreventionSpawnSystem():RequestDespawnPreventionLevel(-18) + + + -- if(objLook ~= nil) then + -- Game.GetPreventionSpawnSystem():RequestDespawn(objLook:GetEntityID()) + -- end + + if(Game.GetPlayer()) then + local entity = {} + entity.id = Game.GetPlayer():GetEntityID() + entity.tag = "player" + entity.tweak = "player" + entity.lock = true + cyberscript.EntityManager[entity.tag] = entity + + local entity = {} + entity.id = nil + entity.tag = "lookatnpc" + entity.tweak = "None" + entity.lock = true + cyberscript.EntityManager[entity.tag] = entity + + local entity = {} + entity.id = nil + entity.tag = "last_scanned" + entity.tweak = "None" + entity.lock = true + cyberscript.EntityManager[entity.tag] = entity + + local entity = {} + entity.id = nil + entity.tag = "lookatentity" + entity.tweak = "None" + entity.lock = true + + cyberscript.EntityManager[entity.tag] = entity + + local entity = {} + entity.id = nil + entity.tag = "current_car" + entity.tweak = "None" + entity.lock = true + cyberscript.EntityManager[entity.tag] = entity + + + + local entity = {} + entity.id = nil + entity.tag = "last_killed" + entity.tweak = "None" + + cyberscript.EntityManager[entity.tag] = entity + + local entity = {} + entity.id = nil + entity.tag = "last_spawned" + entity.tweak = "None" + + cyberscript.EntityManager[entity.tag] = entity + + local group = {} + + group.tag = "AMMCompanion" + group.entities = {} + + cyberscript.GroupManager[group.tag] = group + + + local group = {} + + group.tag = "Multi" + group.entities = {} + + + cyberscript.GroupManager[group.tag] = group + local group = {} + + group.tag = "AV" + group.entities = {} + + + cyberscript.GroupManager[group.tag] = group + local group2 = {} + + group2.tag = "Crew" + group2.entities = {} + + + cyberscript.GroupManager[group.tag] = group + + local group2 = {} + + group2.tag = "companion" + group2.entities = {} + + + cyberscript.GroupManager[group.tag] = group + end + logme(2,"Despawn finished") + end @@ -904,2948 +906,2975 @@ end end if actionRegion then - - function toggleVBodyComponent(toggle) - for _, component in ipairs(VBodyComponents) do - local comp = Game.GetPlayer():FindComponentByName(component) - if comp then comp:Toggle(toggle) end - end - end - - function getBehindPosition(entity,distance) - local pos = entity:GetWorldPosition() - local heading = entity:GetWorldForward() - local vec4 = Vector4.new(pos.x - (heading.x * distance), pos.y - (heading.y * distance), pos.z, pos.w) - return vec4 - end - - function getForwardPosition(entity,distance) - local pos = entity:GetWorldPosition() - local heading = entity:GetWorldForward() - local vec4 = Vector4.new(pos.x + (heading.x * distance), pos.y + (heading.y * distance), pos.z, pos.w) - return vec4 - end - - function getForwardPosition2(entity,distance,offset,isworld) - - local vec4 = Vector4.new() - if(isworld) then - vec4 = Vector4.new( - entity:GetForward().x * offset.y + entity:GetRight().x * offset.x + entity:GetWorldPosition():ToVector4().x, - entity:GetForward().y * offset.y + entity:GetRight().y * offset.x + entity:GetWorldPosition():ToVector4().y, - entity:GetWorldPosition():ToVector4().z, 0) - else - vec4 = Vector4.new( - entity:GetWorldForward().x * offset.y + entity:GetWorldRight().x * offset.x + entity:GetWorldPosition().x, - entity:GetWorldForward().y * offset.y + entity:GetWorldRight().y * offset.x + entity:GetWorldPosition().y, - entity:GetWorldPosition().z, 0) - end - + + function toggleVBodyComponent(toggle) + for _, component in ipairs(VBodyComponents) do + local comp = Game.GetPlayer():FindComponentByName(component) + if comp then comp:Toggle(toggle) end + end + end + + function getBehindPosition(entity,distance) + local pos = entity:GetWorldPosition() + local heading = entity:GetWorldForward() + local vec4 = Vector4.new(pos.x - (heading.x * distance), pos.y - (heading.y * distance), pos.z, pos.w) + return vec4 + end + + function getForwardPosition(entity,distance) + local pos = entity:GetWorldPosition() + local heading = entity:GetWorldForward() + local vec4 = Vector4.new(pos.x + (heading.x * distance), pos.y + (heading.y * distance), pos.z, pos.w) + return vec4 + end + + function getForwardPosition2(entity,distance,offset,isworld) + + local vec4 = Vector4.new() + if(isworld) then + vec4 = Vector4.new( + entity:GetForward().x * offset.y + entity:GetRight().x * offset.x + entity:GetWorldPosition():ToVector4().x, + entity:GetForward().y * offset.y + entity:GetRight().y * offset.x + entity:GetWorldPosition():ToVector4().y, + entity:GetWorldPosition():ToVector4().z, 0) + else + vec4 = Vector4.new( + entity:GetWorldForward().x * offset.y + entity:GetWorldRight().x * offset.x + entity:GetWorldPosition().x, + entity:GetWorldForward().y * offset.y + entity:GetWorldRight().y * offset.x + entity:GetWorldPosition().y, + entity:GetWorldPosition().z, 0) + end + return vec4 end - - - local function ToPositionSpec(targetPosition) - local worldPosition = NewObject('WorldPosition') - GetSingleton('WorldPosition'):SetVector4(worldPosition, targetPosition) - - local positionSpec = NewObject('AIPositionSpec') - GetSingleton('AIPositionSpec'):SetWorldPosition(positionSpec, worldPosition) - - return positionSpec - end - - function PlayerToggleInvisible(toggle) - GetPlayer():SetInvisible(toggle) - end - - function ToggleImmortal(enti, isImmortal) - local id = enti:GetEntityID() - - local godsystem = Game.GetGodModeSystem() - -- Immortal = 1, - -- Invulnerable = 0, - -- Mortal = 2 - if isImmortal then - - godsystem:AddGodMode(id,gameGodModeType.Immortal, "FastTravel") - godsystem:AddGodMode(id,gameGodModeType.Invulnerable, "FastTravel") - godsystem:RemoveGodMode(id, gameGodModeType.Mortal, "") - - else - godsystem:ClearGodMode(id,"") - - godsystem:RemoveGodMode(id,gameGodModeType.Immortal, "FastTravel") - godsystem:RemoveGodMode(id,gameGodModeType.Invulnerable, "FastTravel") - godsystem:AddGodMode(id, gameGodModeType.Mortal, "") - - end - - end - - - - - function setAppearance(entity,appearance) - - if(AMM ~= nil) then - - AMM.API.ChangeAppearance(entity,appearance) - - else - entity:PrefetchAppearanceChange(appearance) - entity:ScheduleAppearanceChange(appearance) - - end - - - end - - function randomAppearance(entity) - if(AMM ~= nil) then - - AMM.API.ChangeAppearance(entity,"") - - else - entity:ScheduleAppearanceChange("") - end - end - - function getAppearance(entity) - if(AMM ~= nil) then - - local possibleApp = AMM.API.GetAppearancesForEntity(entity) - - for _, app in ipairs(possibleApp) do - logme(10,(tostring(app))) - end - - - else - for _, app in ipairs(entity:GetRecord():CrowdAppearanceNames()) do - logme(2,tostring(app)) - end - end - end - - function swapEntity(npc,newnpc) - - local temp = TweakDB:GetFlat(TweakDBID.new(newnpc..".entityTemplatePath")) - - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc..".entityTemplatePath"), temp) - - TweakDB:Update(TweakDBID.new(npc)) - - end - - - function changePreset(npc,newnpc) - - - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.itemGroups'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.itemGroups'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.attachmentSlots'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.attachmentSlots'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.abilities'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.abilities'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.actionMap'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.actionMap'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.alertedSensesPreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.alertedSensesPreset'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.combatSensesPreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.combatSensesPreset'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.defaultEquipment'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.defaultEquipment'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.equipmentAreas'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.equipmentAreas'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.items'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.items'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.primaryEquipment'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.primaryEquipment'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.reactionPreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.reactionPreset'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.secondaryEquipment'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.secondaryEquipment'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.sensePreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.sensePreset'))) - TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.threatTrackingPreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.threatTrackingPreset'))) - TweakDB:Update(TweakDBID.new(npc)) - - - end - - - - - - - function EquipPrimaryWeaponCommand(objlook, equip) - local cmd = NewObject("handle:AISwitchToPrimaryWeaponCommand") - cmd.unEquip = equip - cmd = cmd:Copy() - - executeCmd(objlook, cmd) - end - - function EquipSecondaryWeaponCommand(objlook, equip) - local cmd = NewObject("handle:AISwitchToSecondaryWeaponCommand") - cmd.unEquip = equip - cmd = cmd:Copy() - - executeCmd(objlook, cmd) - end - - function EquipGivenWeapon(objlook, weapon, override, slot) - local cmd = NewObject("AIEquipCommand") - if slot == nil then - cmd.slotId = TweakDBID.new("AttachmentSlots.WeaponRight") - - else - cmd.slotId = TweakDBID.new(slot) - end - - cmd.itemId = weapon - cmd.failIfItemNotFound = false - if override then - cmd.durationOverride = 99999 - end - cmd = cmd:Copy() - - executeCmd(objlook, cmd) - end - - function UnEquipSlot(objlook, override, slot) - local cmd = NewObject("AIUnequipCommand") - if slot == nil then - cmd.slotId = TweakDBID.new("AttachmentSlots.WeaponRight") - - else - cmd.slotId = TweakDBID.new(slot) - end - - - - if override then - cmd.durationOverride = 99999 - end - cmd = cmd:Copy() - - executeCmd(objlook, cmd) - end - - - - - function FollowEntity(enti, target, movementType, stealth) - if not target then - local currentRole = enti:GetAIControllerComponent():GetAIRole() - - if currentRole and currentRole:IsA('AIFollowerRole') then - target = currentRole.followTarget - else - target = Game.GetPlayer() - end - end - - if not movementType then - movementType = 'Sprint' - end - - local followCmd = NewObject('handle:AIFollowTargetCommand') - followCmd.target = target - followCmd.lookAtTarget = target - followCmd.desiredDistance = 1.0 - followCmd.tolerance = 0.5 - followCmd.movementType = movementType - followCmd.matchSpeed = true - followCmd.teleport = false - followCmd.stopWhenDestinationReached = false - followCmd.ignoreInCombat = false - followCmd.removeAfterCombat = false - followCmd.alwaysUseStealth = stealth - - enti:GetAIControllerComponent():SendCommand(followCmd) - - end - - function lookAtPlayer(entity, duration) - - - local stimReact = entity:GetStimReactionComponent() - stimReact:ActivateReactionLookAt(Game.GetPlayer(), false, true, duration, true) - - - end - - function playerLookAtEntity(tag) - - - local obj = getEntityFromManager(tag) - local enti = Game.FindEntityByID(obj.id) - - local player = Game.GetPlayer() - local dirVector = diffVector(player:GetWorldPosition(), enti:GetWorldPosition()) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - - pitch = angle.pitch - yaw = angle.yaw - freezeCamera = true - - end - - - function playerLookAtDirection(x, y, z) - - local player = Game.GetPlayer() - - local direction = {} - direction.x = x - direction.y = y - direction.z = z - direction.w = 1 - - local dirVector = diffVector(player:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - - pitch = angle.pitch - - yaw = angle.yaw - - Game.GetPlayer():GetFPPCameraComponent().pitchMin = pitch - 0.01 -- Use pitchMin/Max to set pitch, needs to have a small difference between Min and Max - Game.GetPlayer():GetFPPCameraComponent().pitchMax = pitch - Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Game.GetPlayer():GetWorldPosition() , EulerAngles.new(0,0,-yaw)) - - - end - - - function setPlayerAttributes(attname,attrLevel) - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) - - local playerId = player:GetEntityID() - local statsSystem = Game.GetStatsSystem() - local playerDevData = playerDevSystem:GetDevelopmentData(player) - - for i,attribute in ipairs(RES_attributes) do - - if(attribute.alias == attname) then - playerDevData:SetAttribute(attribute, attrLevel) - end - end - - - end - - function setPlayerSkill(skillname,skillLevel) - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) - - local playerId = player:GetEntityID() - local statsSystem = Game.GetStatsSystem() - local playerDevData = playerDevSystem:GetDevelopmentData(player) - - local skill = RES_skills[skillname] - - if(skill ~= nil) then - - - playerDevData:SetLevel(skill.type, skillLevel, 'Gameplay') - - - end - - - end - - - function setPlayerSkillProgression(skill,skillExp) - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) - - local playerId = player:GetEntityID() - local statsSystem = Game.GetStatsSystem() - local playerDevData = playerDevSystem:GetDevelopmentData(player) - - - - local skill = RES_skills[skillname] - - if(skill ~= nil) then - - - local playerSkillExp = math.floor(playerDevData:GetCurrentLevelProficiencyExp(skill.alias)) - playerDevData:AddExperience((skillExp - playerSkillExp), skill.type, 'Gameplay') - - end - - - - end - - - - - function setPlayerPerk(perkname,perkLevel) - local perk = RES_perksalias[perkname] - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) - - local playerId = player:GetEntityID() - local statsSystem = Game.GetStatsSystem() - local playerDevData = playerDevSystem:GetDevelopmentData(player) - - if perk ~= nil then - - if perk.trait then - playerDevData:RemoveTrait(perk.type) - else - playerDevData:RemovePerk(perk.type) - end - - - - local adjustPerks = {} - local adjustTraits = {} - local needPerkPoints = 0 - - - playerDevData:AddDevelopmentPoints(10, 'Primary') - - self.playerDevData:BuyPerk(perkType) - - - - - - - end - - end - - - function getAtttribute(typeatt, nameatt) - - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) - - local playerId = player:GetEntityID() - local statsSystem = Game.GetStatsSystem() - local playerDevData = playerDevSystem:GetDevelopmentData(player) - - - - if(typeatt == "attribute") then - - return math.floor(statsSystem:GetStatValue(playerId, nameatt)) - - end - - if(typeatt == "skill") then - - return math.floor(statsSystem:GetStatValue(playerId, nameatt)) - - end - - - if(typeatt == "perk") then - - for i,perk in ipairs(RES_perks) do - - if(perk.alias == nameatt) then - - local perkLevel - - if perk.trait then - perkLevel = playerDevData:GetTraitLevel(perk.type) - else - perkLevel = playerDevData:GetPerkLevel(perk.type) - end - - if perkLevel < 0 then - return 0 - end - - return math.floor(perkLevel) - end - end - end - end - - - function isEquipped(itemweak) - local tid = TweakDBID.new(itemweak) - local itemId = ItemID.new(tid) - - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') - local transactionSystem = Game.GetTransactionSystem() - local inventoryManager = Game.GetInventoryManager() - local playerEquipmentData = equipmentSystem:GetPlayerData(player) - local playerInventoryData = playerEquipmentData:GetInventoryManager() - local craftingSystem = scriptableSystemsContainer:Get(CName.new('CraftingSystem')) - local gameRPGManager = GetSingleton('gameRPGManager') - local forceItemQuality = Game['gameRPGManager::ForceItemQuality;GameObjectgameItemDataCName'] - local itemModSystem = scriptableSystemsContainer:Get(CName.new('ItemModificationSystem')) - playerEquipmentData['EquipItemInSlot'] = playerEquipmentData['EquipItem;ItemIDInt32BoolBool'] - playerEquipmentData['GetItemInEquipSlotArea'] = playerEquipmentData['GetItemInEquipSlot;gamedataEquipmentAreaInt32'] - playerEquipmentData['GetSlotIndexInArea'] = playerEquipmentData['GetSlotIndex;ItemIDgamedataEquipmentArea'] - - local clothingSlotBlocker = TweakDBID.new('Items.DummyFabricEnhancer') - local weaponSlotBlocker = TweakDBID.new('Items.DummyWeaponMod') - - return playerEquipmentData:IsEquipped(itemId) - end - - - function haveOneEquippedMatch(stringname) - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') - local transactionSystem = Game.GetTransactionSystem() - local inventoryManager = Game.GetInventoryManager() - local playerEquipmentData = equipmentSystem:GetPlayerData(player) - local playerInventoryData = playerEquipmentData:GetInventoryManager() - local craftingSystem = scriptableSystemsContainer:Get(CName.new('CraftingSystem')) - local gameRPGManager = GetSingleton('gameRPGManager') - local forceItemQuality = Game['gameRPGManager::ForceItemQuality;GameObjectgameItemDataCName'] - local itemModSystem = scriptableSystemsContainer:Get(CName.new('ItemModificationSystem')) - - local myitemlist = {} - logme(1,GameDump(playerEquipmentData)) - for i,area in ipairs(playerEquipmentData.equipment.equipAreas) do - - for y,item in ipairs(area.equipSlots) do - - if(RES_TweakDBmeta[TweakDbtoKey(item.itemID.id)] ~= nil) then table.insert(myitemlist,RES_TweakDBmeta[TweakDbtoKey(item.itemID.id)]) end - - end - - - - end - - - - result = false - for i,item in ipairs(myitemlist) do - - if( string.match(item.id, stringname)) then - logme(5,"Item Found : "..item.id) - result = true - - end - end - - return result - - end - - function equipItem(itemweak) - local tid = TweakDBID.new(itemweak) - local itemId = ItemID.new(tid) - - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') - - local playerEquipmentData = equipmentSystem:GetPlayerData(player) - - if not playerEquipmentData:IsEquipped(itemId) then - playerEquipmentData:EquipItem(itemId, true, true) - - end - end - - function equipVisualItem(itemweak) - local tid = TweakDBID.new(itemweak) - local itemId = ItemID.new(tid) - - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') - - local playerEquipmentData = equipmentSystem:GetPlayerData(player) - playerEquipmentData:InitializeClothingOverrideInfo() - playerEquipmentData:HideItem(gamedataEquipmentArea.Outfit, false) - playerEquipmentData:HideItem(gamedataEquipmentArea.OuterChest, false) - playerEquipmentData:HideItem(gamedataEquipmentArea.InnerChest, false) - playerEquipmentData:HideItem(gamedataEquipmentArea.Legs, false) - playerEquipmentData:HideItem(gamedataEquipmentArea.Feet, false) - playerEquipmentData:HideItem(gamedataEquipmentArea.Head, false) - playerEquipmentData:HideItem(gamedataEquipmentArea.Face, false) - playerEquipmentData:HideItem(gamedataEquipmentArea.UnderwearTop, false) - playerEquipmentData:HideItem(gamedataEquipmentArea.UnderwearBottom, false) - - - playerEquipmentData:EquipVisuals(itemId) - end - - function clearVisualarea(area) - - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') - - local playerEquipmentData = equipmentSystem:GetPlayerData(player) - playerEquipmentData:ClearVisuals(area) - end - - function unequipItem(itemweak) - local tid = TweakDBID.new(itemweak) - local itemId = ItemID.new(tid) - - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') - - local playerEquipmentData = equipmentSystem:GetPlayerData(player) - if playerEquipmentData:IsEquipped(itemId) then - playerEquipmentData:UnequipItem(itemId) - end - end - - - - - - function lookAtEntity(entity,tag, duration) - - - local obj = getEntityFromManager(tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - local stimReact = entity:GetStimReactionComponent() - - stimReact:ActivateReactionLookAt(enti, false, true, duration, true) - end - - end - - - - function InterruptBehavior(objlook) - - teleportTo(objlook, objlook:GetWorldPosition(), 1,false,nil) - end - - function IsMoving(tag) - - local obj = getEntityFromManager(tag) - local enti = Game.FindEntityByID(obj.id) - - return GetSingleton('AIbehaviorUniqueActiveCommandList'):IsActionCommandById( - targetPuppet:GetAIControllerComponent().activeCommands, - commandInstance.id - ) - end - - function executeCmd(objlook, cmd) - if objlook ~= nil or objlook ~= '' then - AIComponent = objlook:GetAIControllerComponent() - - if (AIComponent ~= nil) then - AIComponent:SendCommand(cmd) - end - - end - end - - function entityLookAtDirection(tag,x, y, z) - - local obj = getEntityFromManager(tag) - local enti = Game.FindEntityByID(obj.id) - - local direction = Vector4.new(x,y,z,1) - - - local dirVector = diffVector(direction,enti:GetWorldPosition()) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - - local pitch0 = angle.pitch - local yaw0 = angle.yaw - - Game.GetTeleportationFacility():Teleport(enti, enti:GetWorldPosition() , angle) -- Set yaw when teleporting - - - - end - - function RotateTo(objlook, target) - local positionSpec = ToPositionSpec(target:GetWorldPosition()) - - local rotateCmd = NewObject('handle:AIRotateToCommand') - rotateCmd.target = positionSpec - rotateCmd.angleTolerance = 10.0 -- If zero then command will never finish - rotateCmd.angleOffset = 0.0 - rotateCmd.speed = 1.0 - - objlook:GetAIControllerComponent():SendCommand(rotateCmd) - - - - - - end - - function RotateToXYZ(objlook, x,y,z) - local positionSpec = ToPositionSpec(Vector4.new(x, y, z,1)) - - local rotateCmd = NewObject('handle:AIRotateToCommand') - rotateCmd.target = positionSpec - rotateCmd.angleTolerance = 10.0 -- If zero then command will never finish - rotateCmd.angleOffset = 0.0 - rotateCmd.speed = 1.0 - - objlook:GetAIControllerComponent():SendCommand(rotateCmd) - - - - - - end - - function RotateEntityTo(objlook, pitch, yaw, roll) - local objpos = objlook:GetWorldPosition() - - - - - - local rot = EulerAngles.new(0,0,0) - - rot.roll = roll - rot.pitch = pitch - rot.yaw = yaw - - if(objlook ~= nil) then - local item = nil - - - pcall(function() - if objlook:IsVehicle() == true then - -- logme(2,position.x) - -- logme(2,position.y) - -- logme(2,position.z) - - - if(obj.isAV == false) then - rot.roll = 0 - rot.pitch = 0 - end - Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(objpos.x, objpos.y, objpos.z,1), rot) - -- logme(2,"ok") - else - inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(objlook) - if (inVehicule) then - vehicule = Game['GetMountedVehicle;GameObject'](objlook) - - GetSingleton('gameTeleportationFacility'):Teleport(vehicule, Vector4.new(objpos.x, objpos.y, objpos.z,1), rot) - else - - if(isplayer) then - logme(10,tostring(rot.pitch)) - - --print("TP Player") - Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Vector4.new(objpos.x, objpos.y, objpos.z,1) , rot) - Game.GetPlayer():GetFPPCameraComponent().pitchMin = rot.pitch - 0.01 - Game.GetPlayer():GetFPPCameraComponent().pitchMax = rot.pitch - Game.GetPlayer():GetFPPCameraComponent():SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(rot.roll, 0, 0))) - else - local test = nil - pcall(function() - local cmd = NewObject('handle:AITeleportCommand') - - cmd.doNavTest = false - cmd.rotation = rot.yaw - cmd.position = Vector4.new(objpos.x, objpos.y, objpos.z,1) - - executeCmd(objlook, cmd) - test = "ok" - --print("testOK") - end) - - if(test == nil) then - --print("test") - Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(objpos.x, objpos.y, objpos.z,1) , rot) - end - - end - - - - end - - - end - item = "ok" - end) - - if(item == nil) then - rot.roll = 0 - rot.pitch = 0 - - Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(objpos.x, objpos.y, objpos.z,1) , rot) - end - - end - - - - - - - - - - end - - function HoldPosition(enti, timer,stealth) - InterruptBehavior(enti) - - local cmd = NewObject('handle:AIHoldPositionCommand') - cmd.alwaysUseStealth = stealth - cmd.removeAfterCombat = false - cmd.ignoreInCombat = false - - - cmd.duration = timer - - executeCmd(enti, cmd) - end - - function talk(enti,voiceText,target) - local StimReaction = enti:GetStimReactionComponent() - --local StimReaction = objlook:GetStimReactionComponent():ActivateReactionLookAt() - --resetFacial(enti) - local AnimationController = enti:GetAnimationControllerComponent() - - - - if StimReaction ~= nil and AnimationController ~= nil then - - - - - - - - Game["gameObject::PlayVoiceOver;GameObjectCNameCNameFloatEntityIDBool"](enti, CName.new(voiceText), CName.new(""), 0) - - - - end - - Cron.After(0.5, function() - - - end) - - - end - - - function makeFacial(tag,reactiontodo) - logme(10,tag) - local obj = getEntityFromManager(tag) - logme(10,dump(obj)) - logme(10,dump(reactiontodo)) - local enti = Game.FindEntityByID(obj.id) - - local StimReaction = enti:GetStimReactionComponent() - - - local stimComp = enti:FindComponentByName("ReactionManager") - local animComp = enti:FindComponentByName("AnimationControllerComponent") - - if stimComp and animComp then - logme(10,"test") - stimComp:ResetFacial(0) - - Cron.After(0.5, function() - - local animFeat = NewObject("handle:AnimFeature_FacialReaction") - animFeat.category = reactiontodo.category - animFeat.idle = reactiontodo.idle - animComp:ApplyFeature(CName.new("FacialReaction"), animFeat) - logme(10,"test2") - end) - end - - - - end - - - function resetFacial(enti) - local StimReaction = enti:GetStimReactionComponent() - if StimReaction ~= nil then - StimReaction:ResetFacial(0) - end - - end - - function resetLookAt(enti) - - local StimReactionComponent = enti:GetStimReactionComponent() - if StimReactionComponent then - StimReactionComponent:DeactiveLookAt() - end - - end - - - function setInvisible(tag,isHidden) - - if(tag == "player") then - - - Game.GetPlayer():SetInvisible(isHidden) - Game.GetPlayer():UpdateVisibility() - - - -- else - - -- local obj = getEntityFromManager(tag) - -- local enti = Game.FindEntityByID(obj.id) - - -- CreateTarget(enti, false, isHidden) - - end - - - end - - function InterruptCombat(tag) - - local enti = nil - local obj = nil - if(tag =="lookat") then - - enti = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - - else - - - obj = getEntityFromManager(tag) - enti = Game.FindEntityByID(obj.id) - - - end - - - - enti:SetDetectionPercentage(0) - - Game['NPCPuppet::ChangeLocomotionMode;GameObjectgamedataLocomotionMode'](enti, 'Static') - Game['NPCPuppet::ChangeHighLevelState;GameObjectgamedataNPCHighLevelState'](enti, 'Relaxed') - Game['NPCPuppet::ChangeDefenseModeState;GameObjectgamedataDefenseMode'](enti, 'NoDefend') - Game['NPCPuppet::ChangeUpperBodyState;GameObjectgamedataNPCUpperBodyState'](enti, 'Normal') - end - - - -- enum gamedataNPCStanceState - -- { - -- Any = 0, - -- Cover = 1, - -- Crouch = 2, - -- Stand = 3, - -- Swim = 4, - -- Vehicle = 5, - -- VehicleWindow = 6, - -- Count = 7, - -- Invalid = 8 - -- } - function changeStance(tag,stance) - - - NPCPuppet.ChangeStanceState(objLook, stance) - - end - - - - - function MoveTo(targetPuppet, targetPosition, targetDistance, movementType, v2) - - --logme(2,"moving....") - if not targetPosition or not targetPosition.x then - targetPosition = Game.GetPlayer():GetWorldPosition() - - end - - if not targetDistance then - targetDistance = 1.0 - end - - if not movementType then - movementType = 'Sprint' - end - - if(v2 == nil) then - - local worldPosition = NewObject('WorldPosition') - - worldPosition:SetVector4(worldPosition,Vector4.new(targetPosition.x, targetPosition.y, targetPosition.z, 1)) - - local AIPositionSpec = NewObject('AIPositionSpec') - AIPositionSpec:SetWorldPosition(AIPositionSpec, worldPosition) - - local moveCmd = NewObject('handle:AIMoveToCommand') - moveCmd.movementTarget = AIPositionSpec - moveCmd.movementType = movementType - moveCmd.desiredDistanceFromTarget = targetDistance - moveCmd.finishWhenDestinationReached = true - moveCmd.rotateEntityTowardsFacingTarget = false - - - moveCmd.ignoreNavigation = true - moveCmd.useStart = true - moveCmd.useStop = false - executeCmd(targetPuppet, moveCmd) - - else - if not v2.ignoreNav then v2.ignoreNav = false end - if not v2.stoponobstacle then v2.stoponobstacle = false end - if not v2.outofway then v2.outofway = false end - - local policy = MovePolicies.new() - - policy:SetDestinationPosition(Vector4.new(targetPosition.x, targetPosition.y, targetPosition.z, 1)) - policy:SetDestinationOrientation(v2.quat) - policy:SetMovementType(movementType) - policy:SetIgnoreNavigation(v2.ignoreNav) - policy:SetStopOnObstacle(v2.stoponobstacle) - policy:SetDistancePolicy(v2.distance,v2.distancetolerance) - policy:SetIgnoreNavigation(v2.outofway) - - targetPuppet:GetMovePolicesComponent():AddPolicies(policy) - - end - - end - - - - function teleportTo(objlook, position, rotation, isplayer,obj) - --logme(2,rotation) - if rotation.yaw == nil then - - rotation = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) - - end - - local rot = rotation - - if(rotation ~= 1) then - - rot = EulerAngles.new(0,0,0) - - rot.roll = rotation.roll - rot.pitch = rotation.pitch - rot.yaw = rotation.yaw - - else - local rot = GetSingleton('Quaternion'):ToEulerAngles(objlook:GetWorldOrientation()) - - - - end - - if(objlook ~= nil) then - local item = nil - - pcall(function() - if objlook:IsVehicle() == true or (obj ~= nil and obj.isWorkspot == true) then - -- logme(2,position.x) - -- logme(2,position.y) - -- logme(2,position.z) - -- logme(2,rot) - - if(obj.isAV == false) then - rot.roll = 0 - rot.pitch = 0 - end - Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(position.x, position.y, position.z,1), rot) - -- logme(2,"ok") - else - inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(objlook) - if (inVehicule) then - vehicule = Game['GetMountedVehicle;GameObject'](objlook) - - GetSingleton('gameTeleportationFacility'):Teleport(vehicule, Vector4.new(position.x, position.y, position.z,1), rot) - else - - if(isplayer) then - - --print("TP Player") - Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Vector4.new(position.x, position.y, position.z,1) , rot) - Game.GetPlayer():GetFPPCameraComponent().pitchMin = rot.pitch - 0.01 - Game.GetPlayer():GetFPPCameraComponent().pitchMax = rot.pitch - Game.GetPlayer():GetFPPCameraComponent():SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(rot.roll, 0, 0))) - else - local test = nil - pcall(function() - local cmd = NewObject('handle:AITeleportCommand') - - cmd.doNavTest = false - cmd.rotation = rot.yaw - cmd.position = Vector4.new(position.x, position.y, position.z,1) - - executeCmd(objlook, cmd) - test = "ok" - - end) - - if(test == nil) then - --print("test") - Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(position.x, position.y, position.z,1) , rot) - end - - end - - - - end - - - end - item = "ok" - end) - - if(item == nil) then - - if rotation == 1 then - rot = GetSingleton('Quaternion'):ToEulerAngles(objlook:GetWorldOrientation()) - end - - -- print(dump(position)) - -- print(dump(rot)) - -- print(GameDump(objlook)) - Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(position.x, position.y, position.z,1) , rot) - end - else - - print("nope") - end - - - - - - - - end - - + + + local function ToPositionSpec(targetPosition) + local worldPosition = NewObject('WorldPosition') + GetSingleton('WorldPosition'):SetVector4(worldPosition, targetPosition) + + local positionSpec = NewObject('AIPositionSpec') + GetSingleton('AIPositionSpec'):SetWorldPosition(positionSpec, worldPosition) + + return positionSpec + end + + function PlayerToggleInvisible(toggle) + -- B-09 fix: also call UpdateVisibility (matches setInvisible() at npc.lua:1792) + -- so the engine re-broadcasts the visibility state immediately instead of + -- relying on the next render tick. Without this, the "infinite invisibility" + -- option can leave the player permanently invisible after a save/reload + -- because the saved invisibility flag is never re-synced when the user + -- disables the option (GH #15). + local player = GetPlayer() + if player == nil then return end + player:SetInvisible(toggle) + pcall(function() player:UpdateVisibility() end) + end + + function ToggleImmortal(enti, isImmortal) + local id = enti:GetEntityID() + + local godsystem = Game.GetGodModeSystem() + -- Immortal = 1, + -- Invulnerable = 0, + -- Mortal = 2 + if isImmortal then + + godsystem:AddGodMode(id,gameGodModeType.Immortal, "FastTravel") + godsystem:AddGodMode(id,gameGodModeType.Invulnerable, "FastTravel") + godsystem:RemoveGodMode(id, gameGodModeType.Mortal, "") + + else + godsystem:ClearGodMode(id,"") + + godsystem:RemoveGodMode(id,gameGodModeType.Immortal, "FastTravel") + godsystem:RemoveGodMode(id,gameGodModeType.Invulnerable, "FastTravel") + godsystem:AddGodMode(id, gameGodModeType.Mortal, "") + + end + + end + + + + + function setAppearance(entity,appearance) + + if(AMM ~= nil) then + + AMM.API.ChangeAppearance(entity,appearance) + + else + entity:PrefetchAppearanceChange(appearance) + entity:ScheduleAppearanceChange(appearance) + + end + + + end + + function randomAppearance(entity) + if(AMM ~= nil) then + + AMM.API.ChangeAppearance(entity,"") + + else + entity:ScheduleAppearanceChange("") + end + end + + function getAppearance(entity) + if(AMM ~= nil) then + + local possibleApp = AMM.API.GetAppearancesForEntity(entity) + + for _, app in ipairs(possibleApp) do + logme(10,(tostring(app))) + end + + + else + for _, app in ipairs(entity:GetRecord():CrowdAppearanceNames()) do + logme(2,tostring(app)) + end + end + end + + function swapEntity(npc,newnpc) + + local temp = TweakDB:GetFlat(TweakDBID.new(newnpc..".entityTemplatePath")) + + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc..".entityTemplatePath"), temp) + + TweakDB:Update(TweakDBID.new(npc)) + + end + + + function changePreset(npc,newnpc) + + + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.itemGroups'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.itemGroups'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.attachmentSlots'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.attachmentSlots'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.abilities'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.abilities'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.actionMap'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.actionMap'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.alertedSensesPreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.alertedSensesPreset'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.combatSensesPreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.combatSensesPreset'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.defaultEquipment'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.defaultEquipment'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.equipmentAreas'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.equipmentAreas'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.items'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.items'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.primaryEquipment'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.primaryEquipment'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.reactionPreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.reactionPreset'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.secondaryEquipment'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.secondaryEquipment'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.sensePreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.sensePreset'))) + TweakDB:SetFlatNoUpdate(TweakDBID.new(npc ..'.threatTrackingPreset'), TweakDB:GetFlat(TweakDBID.new(newnpc..'.threatTrackingPreset'))) + TweakDB:Update(TweakDBID.new(npc)) + + + end + + + + + + + function EquipPrimaryWeaponCommand(objlook, equip) + local cmd = NewObject("handle:AISwitchToPrimaryWeaponCommand") + cmd.unEquip = equip + cmd = cmd:Copy() + + executeCmd(objlook, cmd) + end + + function EquipSecondaryWeaponCommand(objlook, equip) + local cmd = NewObject("handle:AISwitchToSecondaryWeaponCommand") + cmd.unEquip = equip + cmd = cmd:Copy() + + executeCmd(objlook, cmd) + end + + function EquipGivenWeapon(objlook, weapon, override, slot) + local cmd = NewObject("AIEquipCommand") + if slot == nil then + cmd.slotId = TweakDBID.new("AttachmentSlots.WeaponRight") + + else + cmd.slotId = TweakDBID.new(slot) + end + + cmd.itemId = weapon + cmd.failIfItemNotFound = false + if override then + cmd.durationOverride = 99999 + end + cmd = cmd:Copy() + + executeCmd(objlook, cmd) + end + + function UnEquipSlot(objlook, override, slot) + local cmd = NewObject("AIUnequipCommand") + if slot == nil then + cmd.slotId = TweakDBID.new("AttachmentSlots.WeaponRight") + + else + cmd.slotId = TweakDBID.new(slot) + end + + + + if override then + cmd.durationOverride = 99999 + end + cmd = cmd:Copy() + + executeCmd(objlook, cmd) + end + + + + + function FollowEntity(enti, target, movementType, stealth) + if not target then + local currentRole = enti:GetAIControllerComponent():GetAIRole() + + if currentRole and currentRole:IsA('AIFollowerRole') then + target = currentRole.followTarget + else + target = Game.GetPlayer() + end + end + + if not movementType then + movementType = 'Sprint' + end + + local followCmd = NewObject('handle:AIFollowTargetCommand') + followCmd.target = target + followCmd.lookAtTarget = target + followCmd.desiredDistance = 1.0 + followCmd.tolerance = 0.5 + followCmd.movementType = movementType + followCmd.matchSpeed = true + followCmd.teleport = false + followCmd.stopWhenDestinationReached = false + followCmd.ignoreInCombat = false + followCmd.removeAfterCombat = false + followCmd.alwaysUseStealth = stealth + + enti:GetAIControllerComponent():SendCommand(followCmd) + + end + + function lookAtPlayer(entity, duration) + + + local stimReact = entity:GetStimReactionComponent() + stimReact:ActivateReactionLookAt(Game.GetPlayer(), false, true, duration, true) + + + end + + function playerLookAtEntity(tag) + + + local obj = getEntityFromManager(tag) + local enti = safeFindEntityByID(obj.id) + + local player = Game.GetPlayer() + local dirVector = diffVector(player:GetWorldPosition(), enti:GetWorldPosition()) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + + pitch = angle.pitch + yaw = angle.yaw + freezeCamera = true + + end + + + function playerLookAtDirection(x, y, z) + + local player = Game.GetPlayer() + + local direction = {} + direction.x = x + direction.y = y + direction.z = z + direction.w = 1 + + local dirVector = diffVector(player:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + + pitch = angle.pitch + + yaw = angle.yaw + + Game.GetPlayer():GetFPPCameraComponent().pitchMin = pitch - 0.01 -- Use pitchMin/Max to set pitch, needs to have a small difference between Min and Max + Game.GetPlayer():GetFPPCameraComponent().pitchMax = pitch + Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Game.GetPlayer():GetWorldPosition() , EulerAngles.new(0,0,-yaw)) + + + end + + + function setPlayerAttributes(attname,attrLevel) + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) + + local playerId = player:GetEntityID() + local statsSystem = Game.GetStatsSystem() + local playerDevData = playerDevSystem:GetDevelopmentData(player) + + for i,attribute in ipairs(RES_attributes) do + + if(attribute.alias == attname) then + playerDevData:SetAttribute(attribute, attrLevel) + end + end + + + end + + function setPlayerSkill(skillname,skillLevel) + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) + + local playerId = player:GetEntityID() + local statsSystem = Game.GetStatsSystem() + local playerDevData = playerDevSystem:GetDevelopmentData(player) + + local skill = RES_skills[skillname] + + if(skill ~= nil) then + + + playerDevData:SetLevel(skill.type, skillLevel, 'Gameplay') + + + end + + + end + + + function setPlayerSkillProgression(skill,skillExp) + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) + + local playerId = player:GetEntityID() + local statsSystem = Game.GetStatsSystem() + local playerDevData = playerDevSystem:GetDevelopmentData(player) + + + + local skill = RES_skills[skillname] + + if(skill ~= nil) then + + + local playerSkillExp = math.floor(playerDevData:GetCurrentLevelProficiencyExp(skill.alias)) + playerDevData:AddExperience((skillExp - playerSkillExp), skill.type, 'Gameplay') + + end + + + + end + + + + + function setPlayerPerk(perkname,perkLevel) + local perk = RES_perksalias[perkname] + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) + + local playerId = player:GetEntityID() + local statsSystem = Game.GetStatsSystem() + local playerDevData = playerDevSystem:GetDevelopmentData(player) + + if perk ~= nil then + + if perk.trait then + playerDevData:RemoveTrait(perk.type) + else + playerDevData:RemovePerk(perk.type) + end + + + + local adjustPerks = {} + local adjustTraits = {} + local needPerkPoints = 0 + + + playerDevData:AddDevelopmentPoints(10, 'Primary') + + self.playerDevData:BuyPerk(perkType) + + + + + + + end + + end + + + function getAtttribute(typeatt, nameatt) + + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) + + local playerId = player:GetEntityID() + local statsSystem = Game.GetStatsSystem() + local playerDevData = playerDevSystem:GetDevelopmentData(player) + + + + if(typeatt == "attribute") then + + return math.floor(statsSystem:GetStatValue(playerId, nameatt)) + + end + + if(typeatt == "skill") then + + return math.floor(statsSystem:GetStatValue(playerId, nameatt)) + + end + + + if(typeatt == "perk") then + + for i,perk in ipairs(RES_perks) do + + if(perk.alias == nameatt) then + + local perkLevel + + if perk.trait then + perkLevel = playerDevData:GetTraitLevel(perk.type) + else + perkLevel = playerDevData:GetPerkLevel(perk.type) + end + + if perkLevel < 0 then + return 0 + end + + return math.floor(perkLevel) + end + end + end + end + + + function isEquipped(itemweak) + local tid = TweakDBID.new(itemweak) + local itemId = ItemID.new(tid) + + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') + local transactionSystem = Game.GetTransactionSystem() + local inventoryManager = Game.GetInventoryManager() + local playerEquipmentData = equipmentSystem:GetPlayerData(player) + local playerInventoryData = playerEquipmentData:GetInventoryManager() + local craftingSystem = scriptableSystemsContainer:Get(CName.new('CraftingSystem')) + local gameRPGManager = GetSingleton('gameRPGManager') + local forceItemQuality = Game['gameRPGManager::ForceItemQuality;GameObjectgameItemDataCName'] + local itemModSystem = scriptableSystemsContainer:Get(CName.new('ItemModificationSystem')) + playerEquipmentData['EquipItemInSlot'] = playerEquipmentData['EquipItem;ItemIDInt32BoolBool'] + playerEquipmentData['GetItemInEquipSlotArea'] = playerEquipmentData['GetItemInEquipSlot;gamedataEquipmentAreaInt32'] + playerEquipmentData['GetSlotIndexInArea'] = playerEquipmentData['GetSlotIndex;ItemIDgamedataEquipmentArea'] + + local clothingSlotBlocker = TweakDBID.new('Items.DummyFabricEnhancer') + local weaponSlotBlocker = TweakDBID.new('Items.DummyWeaponMod') + + return playerEquipmentData:IsEquipped(itemId) + end + + + function haveOneEquippedMatch(stringname) + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') + local transactionSystem = Game.GetTransactionSystem() + local inventoryManager = Game.GetInventoryManager() + local playerEquipmentData = equipmentSystem:GetPlayerData(player) + local playerInventoryData = playerEquipmentData:GetInventoryManager() + local craftingSystem = scriptableSystemsContainer:Get(CName.new('CraftingSystem')) + local gameRPGManager = GetSingleton('gameRPGManager') + local forceItemQuality = Game['gameRPGManager::ForceItemQuality;GameObjectgameItemDataCName'] + local itemModSystem = scriptableSystemsContainer:Get(CName.new('ItemModificationSystem')) + + local myitemlist = {} + logme(1,GameDump(playerEquipmentData)) + for i,area in ipairs(playerEquipmentData.equipment.equipAreas) do + + for y,item in ipairs(area.equipSlots) do + + if(RES_TweakDBmeta[TweakDbtoKey(item.itemID.id)] ~= nil) then table.insert(myitemlist,RES_TweakDBmeta[TweakDbtoKey(item.itemID.id)]) end + + end + + + + end + + + + result = false + for i,item in ipairs(myitemlist) do + + if( string.match(item.id, stringname)) then + logme(5,"Item Found : "..item.id) + result = true + + end + end + + return result + + end + + function equipItem(itemweak) + local tid = TweakDBID.new(itemweak) + local itemId = ItemID.new(tid) + + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') + + local playerEquipmentData = equipmentSystem:GetPlayerData(player) + + if not playerEquipmentData:IsEquipped(itemId) then + playerEquipmentData:EquipItem(itemId, true, true) + + end + end + + function equipVisualItem(itemweak) + local tid = TweakDBID.new(itemweak) + local itemId = ItemID.new(tid) + + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') + + local playerEquipmentData = equipmentSystem:GetPlayerData(player) + playerEquipmentData:InitializeClothingOverrideInfo() + playerEquipmentData:HideItem(gamedataEquipmentArea.Outfit, false) + playerEquipmentData:HideItem(gamedataEquipmentArea.OuterChest, false) + playerEquipmentData:HideItem(gamedataEquipmentArea.InnerChest, false) + playerEquipmentData:HideItem(gamedataEquipmentArea.Legs, false) + playerEquipmentData:HideItem(gamedataEquipmentArea.Feet, false) + playerEquipmentData:HideItem(gamedataEquipmentArea.Head, false) + playerEquipmentData:HideItem(gamedataEquipmentArea.Face, false) + playerEquipmentData:HideItem(gamedataEquipmentArea.UnderwearTop, false) + playerEquipmentData:HideItem(gamedataEquipmentArea.UnderwearBottom, false) + + + playerEquipmentData:EquipVisuals(itemId) + end + + function clearVisualarea(area) + + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') + + local playerEquipmentData = equipmentSystem:GetPlayerData(player) + playerEquipmentData:ClearVisuals(area) + end + + function unequipItem(itemweak) + local tid = TweakDBID.new(itemweak) + local itemId = ItemID.new(tid) + + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local equipmentSystem = scriptableSystemsContainer:Get('EquipmentSystem') + + local playerEquipmentData = equipmentSystem:GetPlayerData(player) + if playerEquipmentData:IsEquipped(itemId) then + playerEquipmentData:UnequipItem(itemId) + end + end + + + + + + function lookAtEntity(entity,tag, duration) + + + local obj = getEntityFromManager(tag) + local enti = safeFindEntityByID(obj.id) + + if(enti ~= nil) then + local stimReact = entity:GetStimReactionComponent() + + stimReact:ActivateReactionLookAt(enti, false, true, duration, true) + end + + end + + + + function InterruptBehavior(objlook) + + teleportTo(objlook, objlook:GetWorldPosition(), 1,false,nil) + end + + function IsMoving(tag) + + local obj = getEntityFromManager(tag) + local enti = safeFindEntityByID(obj.id) + + return GetSingleton('AIbehaviorUniqueActiveCommandList'):IsActionCommandById( + targetPuppet:GetAIControllerComponent().activeCommands, + commandInstance.id + ) + end + + function executeCmd(objlook, cmd) + if objlook ~= nil or objlook ~= '' then + AIComponent = objlook:GetAIControllerComponent() + + if (AIComponent ~= nil) then + AIComponent:SendCommand(cmd) + end + + end + end + + function entityLookAtDirection(tag,x, y, z) + + local obj = getEntityFromManager(tag) + local enti = safeFindEntityByID(obj.id) + + local direction = Vector4.new(x,y,z,1) + + + local dirVector = diffVector(direction,enti:GetWorldPosition()) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + + local pitch0 = angle.pitch + local yaw0 = angle.yaw + + Game.GetTeleportationFacility():Teleport(enti, enti:GetWorldPosition() , angle) -- Set yaw when teleporting + + + + end + + function RotateTo(objlook, target) + local positionSpec = ToPositionSpec(target:GetWorldPosition()) + + local rotateCmd = NewObject('handle:AIRotateToCommand') + rotateCmd.target = positionSpec + rotateCmd.angleTolerance = 10.0 -- If zero then command will never finish + rotateCmd.angleOffset = 0.0 + rotateCmd.speed = 1.0 + + objlook:GetAIControllerComponent():SendCommand(rotateCmd) + + + + + + end + + function RotateToXYZ(objlook, x,y,z) + local positionSpec = ToPositionSpec(Vector4.new(x, y, z,1)) + + local rotateCmd = NewObject('handle:AIRotateToCommand') + rotateCmd.target = positionSpec + rotateCmd.angleTolerance = 10.0 -- If zero then command will never finish + rotateCmd.angleOffset = 0.0 + rotateCmd.speed = 1.0 + + objlook:GetAIControllerComponent():SendCommand(rotateCmd) + + + + + + end + + function RotateEntityTo(objlook, pitch, yaw, roll) + local objpos = objlook:GetWorldPosition() + + + + + + local rot = EulerAngles.new(0,0,0) + + rot.roll = roll + rot.pitch = pitch + rot.yaw = yaw + + if(objlook ~= nil) then + local item = nil + + + pcall(function() + if objlook:IsVehicle() == true then + -- logme(2,position.x) + -- logme(2,position.y) + -- logme(2,position.z) + + + if(obj.isAV == false) then + rot.roll = 0 + rot.pitch = 0 + end + Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(objpos.x, objpos.y, objpos.z,1), rot) + -- logme(2,"ok") + else + inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(objlook) + if (inVehicule) then + vehicule = Game['GetMountedVehicle;GameObject'](objlook) + + GetSingleton('gameTeleportationFacility'):Teleport(vehicule, Vector4.new(objpos.x, objpos.y, objpos.z,1), rot) + else + + if(isplayer) then + logme(10,tostring(rot.pitch)) + + --print("TP Player") + Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Vector4.new(objpos.x, objpos.y, objpos.z,1) , rot) + Game.GetPlayer():GetFPPCameraComponent().pitchMin = rot.pitch - 0.01 + Game.GetPlayer():GetFPPCameraComponent().pitchMax = rot.pitch + Game.GetPlayer():GetFPPCameraComponent():SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(rot.roll, 0, 0))) + else + local test = nil + pcall(function() + local cmd = NewObject('handle:AITeleportCommand') + + cmd.doNavTest = false + cmd.rotation = rot.yaw + cmd.position = Vector4.new(objpos.x, objpos.y, objpos.z,1) + + executeCmd(objlook, cmd) + test = "ok" + --print("testOK") + end) + + if(test == nil) then + --print("test") + Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(objpos.x, objpos.y, objpos.z,1) , rot) + end + + end + + + + end + + + end + item = "ok" + end) + + if(item == nil) then + rot.roll = 0 + rot.pitch = 0 + + Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(objpos.x, objpos.y, objpos.z,1) , rot) + end + + end + + + + + + + + + + end + + function HoldPosition(enti, timer,stealth) + InterruptBehavior(enti) + + local cmd = NewObject('handle:AIHoldPositionCommand') + cmd.alwaysUseStealth = stealth + cmd.removeAfterCombat = false + cmd.ignoreInCombat = false + + + cmd.duration = timer + + executeCmd(enti, cmd) + end + + function talk(enti,voiceText,target) + -- B-23 fix: wrap GetStimReactionComponent in pcall — some entities + -- don't have this component and calling the method throws. + local StimReaction = nil + pcall(function() StimReaction = enti:GetStimReactionComponent() end) + --local StimReaction = objlook:GetStimReactionComponent():ActivateReactionLookAt() + --resetFacial(enti) + local AnimationController = nil + pcall(function() AnimationController = enti:GetAnimationControllerComponent() end) + + + + if StimReaction ~= nil and AnimationController ~= nil then + + + + + + + + Game["gameObject::PlayVoiceOver;GameObjectCNameCNameFloatEntityIDBool"](enti, CName.new(voiceText), CName.new(""), 0) + + + + end + + Cron.After(0.5, function() + + + end) + + + end + + + function makeFacial(tag,reactiontodo) + logme(10,tag) + local obj = getEntityFromManager(tag) + logme(10,dump(obj)) + logme(10,dump(reactiontodo)) + local enti = safeFindEntityByID(obj.id) + + local StimReaction = enti:GetStimReactionComponent() + + + local stimComp = enti:FindComponentByName("ReactionManager") + local animComp = enti:FindComponentByName("AnimationControllerComponent") + + if stimComp and animComp then + logme(10,"test") + stimComp:ResetFacial(0) + + Cron.After(0.5, function() + + local animFeat = NewObject("handle:AnimFeature_FacialReaction") + animFeat.category = reactiontodo.category + animFeat.idle = reactiontodo.idle + animComp:ApplyFeature(CName.new("FacialReaction"), animFeat) + logme(10,"test2") + end) + end + + + + end + + + function resetFacial(enti) + local StimReaction = enti:GetStimReactionComponent() + if StimReaction ~= nil then + StimReaction:ResetFacial(0) + end + + end + + function resetLookAt(enti) + + local StimReactionComponent = enti:GetStimReactionComponent() + if StimReactionComponent then + StimReactionComponent:DeactiveLookAt() + end + + end + + + function setInvisible(tag,isHidden) + + if(tag == "player") then + + + Game.GetPlayer():SetInvisible(isHidden) + Game.GetPlayer():UpdateVisibility() + + + -- else + + -- local obj = getEntityFromManager(tag) + -- local enti = safeFindEntityByID(obj.id) + + -- CreateTarget(enti, false, isHidden) + + end + + + end + + function InterruptCombat(tag) + + local enti = nil + local obj = nil + if(tag =="lookat") then + + enti = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + + else + + + obj = getEntityFromManager(tag) + enti = safeFindEntityByID(obj.id) + + + end + + + + enti:SetDetectionPercentage(0) + + Game['NPCPuppet::ChangeLocomotionMode;GameObjectgamedataLocomotionMode'](enti, 'Static') + Game['NPCPuppet::ChangeHighLevelState;GameObjectgamedataNPCHighLevelState'](enti, 'Relaxed') + Game['NPCPuppet::ChangeDefenseModeState;GameObjectgamedataDefenseMode'](enti, 'NoDefend') + Game['NPCPuppet::ChangeUpperBodyState;GameObjectgamedataNPCUpperBodyState'](enti, 'Normal') + end + + + -- enum gamedataNPCStanceState + -- { + -- Any = 0, + -- Cover = 1, + -- Crouch = 2, + -- Stand = 3, + -- Swim = 4, + -- Vehicle = 5, + -- VehicleWindow = 6, + -- Count = 7, + -- Invalid = 8 + -- } + function changeStance(tag,stance) + + + NPCPuppet.ChangeStanceState(objLook, stance) + + end + + + + + function MoveTo(targetPuppet, targetPosition, targetDistance, movementType, v2) + + --logme(2,"moving....") + if not targetPosition or not targetPosition.x then + targetPosition = Game.GetPlayer():GetWorldPosition() + + end + + if not targetDistance then + targetDistance = 1.0 + end + + if not movementType then + movementType = 'Sprint' + end + + if(v2 == nil) then + + local worldPosition = NewObject('WorldPosition') + + worldPosition:SetVector4(worldPosition,Vector4.new(targetPosition.x, targetPosition.y, targetPosition.z, 1)) + + local AIPositionSpec = NewObject('AIPositionSpec') + AIPositionSpec:SetWorldPosition(AIPositionSpec, worldPosition) + + local moveCmd = NewObject('handle:AIMoveToCommand') + moveCmd.movementTarget = AIPositionSpec + moveCmd.movementType = movementType + moveCmd.desiredDistanceFromTarget = targetDistance + moveCmd.finishWhenDestinationReached = true + moveCmd.rotateEntityTowardsFacingTarget = false + + + moveCmd.ignoreNavigation = true + moveCmd.useStart = true + moveCmd.useStop = false + executeCmd(targetPuppet, moveCmd) + + else + if not v2.ignoreNav then v2.ignoreNav = false end + if not v2.stoponobstacle then v2.stoponobstacle = false end + if not v2.outofway then v2.outofway = false end + + local policy = MovePolicies.new() + + policy:SetDestinationPosition(Vector4.new(targetPosition.x, targetPosition.y, targetPosition.z, 1)) + policy:SetDestinationOrientation(v2.quat) + policy:SetMovementType(movementType) + policy:SetIgnoreNavigation(v2.ignoreNav) + policy:SetStopOnObstacle(v2.stoponobstacle) + policy:SetDistancePolicy(v2.distance,v2.distancetolerance) + policy:SetIgnoreNavigation(v2.outofway) + + targetPuppet:GetMovePolicesComponent():AddPolicies(policy) + + end + + end + + + + function teleportTo(objlook, position, rotation, isplayer,obj) + --logme(2,rotation) + if rotation.yaw == nil then + + rotation = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) + + end + + local rot = rotation + + if(rotation ~= 1) then + + rot = EulerAngles.new(0,0,0) + + rot.roll = rotation.roll + rot.pitch = rotation.pitch + rot.yaw = rotation.yaw + + else + local rot = GetSingleton('Quaternion'):ToEulerAngles(objlook:GetWorldOrientation()) + + + + end + + if(objlook ~= nil) then + local item = nil + + pcall(function() + if objlook:IsVehicle() == true or (obj ~= nil and obj.isWorkspot == true) then + -- logme(2,position.x) + -- logme(2,position.y) + -- logme(2,position.z) + -- logme(2,rot) + + if(obj.isAV == false) then + rot.roll = 0 + rot.pitch = 0 + end + Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(position.x, position.y, position.z,1), rot) + -- logme(2,"ok") + else + inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(objlook) + if (inVehicule) then + vehicule = Game['GetMountedVehicle;GameObject'](objlook) + + GetSingleton('gameTeleportationFacility'):Teleport(vehicule, Vector4.new(position.x, position.y, position.z,1), rot) + else + + if(isplayer) then + + --print("TP Player") + Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Vector4.new(position.x, position.y, position.z,1) , rot) + Game.GetPlayer():GetFPPCameraComponent().pitchMin = rot.pitch - 0.01 + Game.GetPlayer():GetFPPCameraComponent().pitchMax = rot.pitch + Game.GetPlayer():GetFPPCameraComponent():SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(rot.roll, 0, 0))) + else + local test = nil + pcall(function() + local cmd = NewObject('handle:AITeleportCommand') + + cmd.doNavTest = false + cmd.rotation = rot.yaw + cmd.position = Vector4.new(position.x, position.y, position.z,1) + + executeCmd(objlook, cmd) + test = "ok" + + end) + + if(test == nil) then + --print("test") + Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(position.x, position.y, position.z,1) , rot) + end + + end + + + + end + + + end + item = "ok" + end) + + if(item == nil) then + + if rotation == 1 then + rot = GetSingleton('Quaternion'):ToEulerAngles(objlook:GetWorldOrientation()) + end + + -- print(dump(position)) + -- print(dump(rot)) + -- print(GameDump(objlook)) + Game.GetTeleportationFacility():Teleport(objlook, Vector4.new(position.x, position.y, position.z,1) , rot) + end + else + + print("nope") + end + + + + + + + + end + + end if attitudeRegion then - function checkAttitudeCounter(obj) - - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - if(enti:IsCrowd() and obj.attitudechanged == true) then - local postp = enti:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - - worldpos:SetOrientation(worldpos, enti:GetWorldOrientation()) - - - local npcSpec = DynamicEntitySpec.new() - npcSpec.recordID = enti:GetRecordID() - npcSpec.appearanceName = Game.NameToString(enti:GetCurrentAppearanceName()) - npcSpec.position = postp - npcSpec.orientation = enti:GetWorldOrientation() - npcSpec.persistState = obj.persiststate - npcSpec.persistSpawn = obj.persistspawn - npcSpec.alwaysSpawned = obj.alwaysspawned - npcSpec.spawnInView = true - - CName.add("CyberScript") - CName.add("CyberScript.NPC") - CName.add("CyberScript.NPC."..obj.tag) - - npcSpec.tags = {"CyberScript","CyberScript.NPC","CyberScript.NPC."..obj.tag} - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..obj.tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.NPC."..obj.tag) end - - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..obj.tag) == false) then - - NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) - - obj.id = NPC - enti:Dispose() - + function checkAttitudeCounter(obj) + + local enti = safeFindEntityByID(obj.id) + if(enti ~= nil) then + + if(enti:IsCrowd() and obj.attitudechanged == true) then + local postp = enti:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + + worldpos:SetOrientation(worldpos, enti:GetWorldOrientation()) + + + local npcSpec = DynamicEntitySpec.new() + npcSpec.recordID = enti:GetRecordID() + npcSpec.appearanceName = Game.NameToString(enti:GetCurrentAppearanceName()) + npcSpec.position = postp + npcSpec.orientation = enti:GetWorldOrientation() + npcSpec.persistState = obj.persiststate + npcSpec.persistSpawn = obj.persistspawn + npcSpec.alwaysSpawned = obj.alwaysspawned + npcSpec.spawnInView = true + + CName.add("CyberScript") + CName.add("CyberScript.NPC") + CName.add("CyberScript.NPC."..obj.tag) + + npcSpec.tags = {"CyberScript","CyberScript.NPC","CyberScript.NPC."..obj.tag} + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..obj.tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.NPC."..obj.tag) end + + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..obj.tag) == false) then + + NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) + + obj.id = NPC + enti:Dispose() + - end - + end + - - - - + + + + - - end - + + end + - end - end + end + end - function setAttitudeAgainstAttitude(atttitude,targetattitude,relation) - - Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(atttitude), CName.new(targetattitude), relation) - - - end - - function setAggressiveAgainst(tag, target) - - local enti = nil - local obj = nil - if(tag =="lookat" and objLook ~= nil) then - - enti = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - - else - - - obj = getEntityFromManager(tag) - - enti = Game.FindEntityByID(obj.id) - - - end - - local targets = nil - - if(target =="target") then - - - targets = Game.FindEntityByID(selectTarget) - - else - - local obj2 = getEntityFromManager(target) - targets = Game.FindEntityByID(obj2.id) - - - end - - - - - if(enti== nil) then - - - - end - - if(targets~= nil) then - - - - - - if enti ~= nil and enti:IsVehicle() == false then - local AIC = enti:GetAIControllerComponent() - local targetAttAgent = enti:GetAttitudeAgent() - local reactionComp = enti.reactionComponent - - local aiRole = NewObject('handle:AIRole') - aiRole:OnRoleSet(enti) - - senseComponent.RequestMainPresetChange(enti, "Combat") - - NPCPuppet.ChangeStanceState(enti, "Combat") - - AIC:SetAIRole(aiRole) - enti.movePolicies:Toggle(true) - - targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Hostile")) - - - - reactionComp:SetReactionPreset(GetSingleton("gamedataTweakDBInterface"):GetReactionPresetRecord(TweakDBID.new("ReactionPresets.Ganger_Aggressive"))) - targetAttAgent:SetAttitudeTowardsAgentGroup(targetAttAgent, targetAttAgent, Enum.new("EAIAttitude", "AIA_Friendly")) - targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Hostile")) - -- reactionComp:TriggerCombat(targets) - cyberscript.EntityManager[tag].attitudechanged = true - ToggleImmortal(enti, false) - - end - end - end - - function setFollower(tag) - TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.distance'), 1) - - TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.avoidObstacleWithinTolerance'), true) - TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.ignoreCollisionAvoidance'), false) - TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.ignoreSpotReservation'), false) - - TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.tolerance'), 0.0) - TweakDB:Update(TweakDBID.new('FollowerActions.FollowCloseMovePolicy')) - TweakDB:Update(TweakDBID.new('FollowerActions.FollowStayPolicy')) - TweakDB:Update(TweakDBID.new('FollowerActions.FollowGetOutOfWayMovePolicy')) - TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowStayPolicy.distance'), 1) - TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowGetOutOfWayMovePolicy.distance'), 0.0) - - - local entity = nil - local obj = nil - if(tag =="lookat" and objLook ~= nil) then - - entity = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - - else - - - obj = getEntityFromManager(tag) - - entity = Game.FindEntityByID(obj.id) - - - end - - if(entity ~= nil) then - local AIC = entity:GetAIControllerComponent() - local targetAttAgent = entity:GetAttitudeAgent() - local currTime = entity.isPlayerCompanionCachedTimeStamp + 11 - - local roleComp = NewObject('handle:AIFollowerRole') - - roleComp:SetFollowTarget(Game.GetPlayerSystem():GetLocalPlayerControlledGameObject()) - roleComp:OnRoleSet(entity) - roleComp.attitudeGroupName = CName.new("player") - roleComp.followerRef = Game.CreateEntityReference("#player", {}) - targetAttAgent:SetAttitudeGroup(CName.new("player")) - senseComponent.RequestMainPresetChange(entity, "Follower") - senseComponent.ShouldIgnoreIfPlayerCompanion(entity, Game.GetPlayer()) - NPCPuppet.ChangeStanceState(entity, "Relaxed") - cyberscript.EntityManager[tag].attitudechanged = true - - entity.isPlayerCompanionCached = true - entity.isPlayerCompanionCachedTimeStamp = currTime - local targName = tostring(entity:GetTweakDBFullDisplayName(true)) - local npcType = entity:IsCrowd() - if not string.match(targName, "Johnny") and not string.match(targName, "Nibbles") then - AIC:SetAIRole(roleComp) - entity.movePolicies:Toggle(true) - - end - -- if objLook.isPlayerCompanionCached == false then - - end - - end + function setAttitudeAgainstAttitude(atttitude,targetattitude,relation) + + Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(atttitude), CName.new(targetattitude), relation) + + + end + + function setAggressiveAgainst(tag, target) + + local enti = nil + local obj = nil + if(tag =="lookat" and objLook ~= nil) then + + enti = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + + else + + + obj = getEntityFromManager(tag) + + enti = safeFindEntityByID(obj.id) + + + end + + local targets = nil + + if(target =="target") then + + + targets = safeFindEntityByID(selectTarget) + + else + + local obj2 = getEntityFromManager(target) + targets = safeFindEntityByID(obj2.id) + + + end + + + + + if(enti== nil) then + + + + end + + if(targets~= nil) then + + + + + + if enti ~= nil and enti:IsVehicle() == false then + local AIC = enti:GetAIControllerComponent() + local targetAttAgent = enti:GetAttitudeAgent() + local reactionComp = enti.reactionComponent + + local aiRole = NewObject('handle:AIRole') + aiRole:OnRoleSet(enti) + + senseComponent.RequestMainPresetChange(enti, "Combat") + + NPCPuppet.ChangeStanceState(enti, "Combat") + + AIC:SetAIRole(aiRole) + enti.movePolicies:Toggle(true) + + targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Hostile")) + + + + reactionComp:SetReactionPreset(GetSingleton("gamedataTweakDBInterface"):GetReactionPresetRecord(TweakDBID.new("ReactionPresets.Ganger_Aggressive"))) + targetAttAgent:SetAttitudeTowardsAgentGroup(targetAttAgent, targetAttAgent, Enum.new("EAIAttitude", "AIA_Friendly")) + targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Hostile")) + -- reactionComp:TriggerCombat(targets) + cyberscript.EntityManager[tag].attitudechanged = true + ToggleImmortal(enti, false) + + end + end + end + + function setFollower(tag) + TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.distance'), 1) + + TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.avoidObstacleWithinTolerance'), true) + TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.ignoreCollisionAvoidance'), false) + TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.ignoreSpotReservation'), false) + + TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowCloseMovePolicy.tolerance'), 0.0) + TweakDB:Update(TweakDBID.new('FollowerActions.FollowCloseMovePolicy')) + TweakDB:Update(TweakDBID.new('FollowerActions.FollowStayPolicy')) + TweakDB:Update(TweakDBID.new('FollowerActions.FollowGetOutOfWayMovePolicy')) + TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowStayPolicy.distance'), 1) + TweakDB:SetFlatNoUpdate(TweakDBID.new('FollowerActions.FollowGetOutOfWayMovePolicy.distance'), 0.0) + + + local entity = nil + local obj = nil + if(tag =="lookat" and objLook ~= nil) then + + entity = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + + else + + + obj = getEntityFromManager(tag) + + entity = safeFindEntityByID(obj.id) + + + end + + if(entity ~= nil) then + local AIC = entity:GetAIControllerComponent() + local targetAttAgent = entity:GetAttitudeAgent() + local currTime = entity.isPlayerCompanionCachedTimeStamp + 11 + + local roleComp = NewObject('handle:AIFollowerRole') + + roleComp:SetFollowTarget(Game.GetPlayerSystem():GetLocalPlayerControlledGameObject()) + roleComp:OnRoleSet(entity) + roleComp.attitudeGroupName = CName.new("player") + roleComp.followerRef = Game.CreateEntityReference("#player", {}) + targetAttAgent:SetAttitudeGroup(CName.new("player")) + senseComponent.RequestMainPresetChange(entity, "Follower") + senseComponent.ShouldIgnoreIfPlayerCompanion(entity, Game.GetPlayer()) + NPCPuppet.ChangeStanceState(entity, "Relaxed") + cyberscript.EntityManager[tag].attitudechanged = true + + entity.isPlayerCompanionCached = true + entity.isPlayerCompanionCachedTimeStamp = currTime + local targName = tostring(entity:GetTweakDBFullDisplayName(true)) + local npcType = entity:IsCrowd() + if not string.match(targName, "Johnny") and not string.match(targName, "Nibbles") then + AIC:SetAIRole(roleComp) + entity.movePolicies:Toggle(true) + + end + -- if objLook.isPlayerCompanionCached == false then + + end + + end - function resetFollower(tag) - - local entity = nil - local obj = nil - if(tag =="lookat" and objLook ~= nil) then - - entity = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - - else - - - obj = getEntityFromManager(tag) - - entity = Game.FindEntityByID(obj.id) - - - end - - if(entity ~= nil) then - local handle = entity - local currentRole = handle:GetAIControllerComponent():GetAIRole() - - if handle.isPlayerCompanionCached and currentRole:IsA('AIFollowerRole') and not handle:IsCrowd() then - - currentRole:OnRoleCleared(handle) - - local noRole = AINoRole.new() - AIHumanComponent.SetCurrentRole(handle, noRole) - - local sensePreset = handle:GetRecord():SensePreset():GetID() - SenseComponent.RequestPresetChange(handle, sensePreset, true) - - handle.isPlayerCompanionCached = false - handle.isPlayerCompanionCachedTimeStamp = 0 - - end - - end - - end - - function setPassiveAgainst(tag, target) - - - local enti = nil - local obj = nil - if(tag =="lookat" and objLook ~= nil) then - - enti = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - - else - - - obj = getEntityFromManager(tag) - - enti = Game.FindEntityByID(obj.id) - - - - end - local targets = nil - - if(target =="target") then - - - targets = Game.FindEntityByID(selectTarget) - - else - - local obj2 = getEntityFromManager(target) - targets = Game.FindEntityByID(obj2.id) - - - end - - - if enti ~= nil and enti:IsVehicle() == false and targets ~= nil then - - local AIC = enti:GetAIControllerComponent() - local targetAttAgent = enti:GetAttitudeAgent() - local reactionComp = enti.reactionComponent - - local aiRole = NewObject('handle:AIRole') - aiRole:OnRoleSet(enti) - - enti:GetAIControllerComponent():OnAttach() - Game['NPCPuppet::ChangeStanceState;GameObjectgamedataNPCStanceState'](enti, "Relaxed") - AIC:SetAIRole(aiRole) - enti.movePolicies:Toggle(true) - - targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Neutral")) - - cyberscript.EntityManager[tag].attitudechanged = true - - ToggleImmortal(enti, false) - end - end - - function setFriendAgainst(tag, target) - - - local enti = nil - local obj = nil - if(tag =="lookat" and objLook ~= nil) then - - enti = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - - else - - - obj = getEntityFromManager(tag) - - enti = Game.FindEntityByID(obj.id) - - - - end - local targets = nil - - if(target =="target") then - - - targets = Game.FindEntityByID(selectTarget) - - else - - local obj2 = getEntityFromManager(target) - targets = Game.FindEntityByID(obj2.id) - - - end - - - - if enti ~= nil and enti:IsVehicle() == false and targets ~= nil then - local AIC = enti:GetAIControllerComponent() - local targetAttAgent = enti:GetAttitudeAgent() - -- local reactionComp = enti.reactionComponent - - -- local aiRole = NewObject('handle:AIRole') - -- aiRole:OnRoleSet(enti) - - -- enti:GetAIControllerComponent():OnAttach() - -- Game['NPCPuppet::ChangeStanceState;GameObjectgamedataNPCStanceState'](enti, "Relaxed") - -- AIC:SetAIRole(aiRole) - -- enti.movePolicies:Toggle(true) - - targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Neutral")) + function resetFollower(tag) + + local entity = nil + local obj = nil + if(tag =="lookat" and objLook ~= nil) then + + entity = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + + else + + + obj = getEntityFromManager(tag) + + entity = safeFindEntityByID(obj.id) + + + end + + if(entity ~= nil) then + local handle = entity + local currentRole = handle:GetAIControllerComponent():GetAIRole() + + if handle.isPlayerCompanionCached and currentRole:IsA('AIFollowerRole') and not handle:IsCrowd() then + + currentRole:OnRoleCleared(handle) + + local noRole = AINoRole.new() + AIHumanComponent.SetCurrentRole(handle, noRole) + + local sensePreset = handle:GetRecord():SensePreset():GetID() + SenseComponent.RequestPresetChange(handle, sensePreset, true) + + handle.isPlayerCompanionCached = false + handle.isPlayerCompanionCachedTimeStamp = 0 + + end + + end + + end + + function setPassiveAgainst(tag, target) + + + local enti = nil + local obj = nil + if(tag =="lookat" and objLook ~= nil) then + + enti = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + + else + + + obj = getEntityFromManager(tag) + + enti = safeFindEntityByID(obj.id) + + + + end + local targets = nil + + if(target =="target") then + + + targets = safeFindEntityByID(selectTarget) + + else + + local obj2 = getEntityFromManager(target) + targets = safeFindEntityByID(obj2.id) + + + end + + + if enti ~= nil and enti:IsVehicle() == false and targets ~= nil then + + local AIC = enti:GetAIControllerComponent() + local targetAttAgent = enti:GetAttitudeAgent() + local reactionComp = enti.reactionComponent + + local aiRole = NewObject('handle:AIRole') + aiRole:OnRoleSet(enti) + + enti:GetAIControllerComponent():OnAttach() + Game['NPCPuppet::ChangeStanceState;GameObjectgamedataNPCStanceState'](enti, "Relaxed") + AIC:SetAIRole(aiRole) + enti.movePolicies:Toggle(true) + + targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Neutral")) + + cyberscript.EntityManager[tag].attitudechanged = true + + ToggleImmortal(enti, false) + end + end + + function setFriendAgainst(tag, target) + + + local enti = nil + local obj = nil + if(tag =="lookat" and objLook ~= nil) then + + enti = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + + else + + + obj = getEntityFromManager(tag) + + enti = safeFindEntityByID(obj.id) + + + + end + local targets = nil + + if(target =="target") then + + + targets = safeFindEntityByID(selectTarget) + + else + + local obj2 = getEntityFromManager(target) + targets = safeFindEntityByID(obj2.id) + + + end + + + + if enti ~= nil and enti:IsVehicle() == false and targets ~= nil then + local AIC = enti:GetAIControllerComponent() + local targetAttAgent = enti:GetAttitudeAgent() + -- local reactionComp = enti.reactionComponent + + -- local aiRole = NewObject('handle:AIRole') + -- aiRole:OnRoleSet(enti) + + -- enti:GetAIControllerComponent():OnAttach() + -- Game['NPCPuppet::ChangeStanceState;GameObjectgamedataNPCStanceState'](enti, "Relaxed") + -- AIC:SetAIRole(aiRole) + -- enti.movePolicies:Toggle(true) + + targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Neutral")) - targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Friendly")) - - print("fruend") - cyberscript.EntityManager[tag].attitudechanged = true - - ToggleImmortal(enti, false) - end - end + targetAttAgent:SetAttitudeTowards(targets:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Friendly")) + + print("fruend") + cyberscript.EntityManager[tag].attitudechanged = true + + ToggleImmortal(enti, false) + end + end - function setPsycho(tag, friendtag) - - local enti = nil - local obj = nil - local targets = nil - - if(tag =="lookat"and objLook ~= nil) then - - enti = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - - else - - - obj = getEntityFromManager(tag) - - enti = Game.FindEntityByID(obj.id) - - - end - - - if not friendPuppet then - targets = Game.GetPlayer() - else - if(target =="target") then - - - targets = Game.FindEntityByID(selectTarget) - - else - - local obj2 = getEntityFromManager(friendtag) - targets = Game.FindEntityByID(obj2.id) - - - end - end - - if enti ~= nil and enti:IsVehicle() == false and targets ~= nil then - enti:GetAttitudeAgent():SetAttitudeGroup('HostileToEveryone') - enti:GetAttitudeAgent():SetAttitudeTowards(targets:GetAttitudeAgent(), EAIAttitude.AIA_Neutral) - cyberscript.EntityManager[tag].attitudechanged = true - end - end - - function setPassiveAgainstAttitudeGroup(tag,targetgroup, attitudegroup, attitudegrouptarget) - - - - local group =getGroupfromManager(tag) - - for i=1, #group.entities do - local entityTag = group.entities[i] - - - local obj = getEntityFromManager(entityTag) - - - local enti = Game.FindEntityByID(obj.id) - - - - - - - ToggleImmortal(enti, false) - local AIC = enti:GetAIControllerComponent() - local targetAttAgent = enti:GetAttitudeAgent() - local reactionComp = enti.reactionComponent - - local aiRole = NewObject('handle:AIRole') - aiRole:OnRoleSet(enti) - - enti:GetAIControllerComponent():OnAttach() - Game['NPCPuppet::ChangeStanceState;GameObjectgamedataNPCStanceState'](enti, "Relaxed") - AIC:SetAIRole(aiRole) - enti.movePolicies:Toggle(true) - cyberscript.EntityManager[entityTag].attitudechanged = true - - local entityGroup = {} - local targetAttGroup = {} - - for i=1, #arrayAttitudeGroup do - - if(arrayAttitudeGroup[i].properties['.name'] == attitudegroup) then - entityGroup= arrayAttitudeGroup[i] - end - - if(arrayAttitudeGroup[i].properties['.name'] == attitudegrouptarget) then - targetAttGroup= arrayAttitudeGroup[i] - end - - end - - targetAttAgent:SetAttitudeGroup(CName.new(entityGroup.properties['.name'])) - - Game.GetAttitudeSystem():SetAttitudeRelationFromTweak(TweakDBID.new(entityGroup.path), TweakDBID.new(targetAttGroup.path), Enum.new("EAIAttitude", "AIA_Friendly")) - - - - - - targetAttAgent:SetAttitudeTowardsAgentGroup(targetAttAgent, targetAttAgent, Enum.new("EAIAttitude", "AIA_Friendly")) - - - - local targetgroup =getGroupfromManager(targetgroup) - - for y=1, #group.entities do - local entityTag2 = group.entities[y] - - - local obj2 = getEntityFromManager(entityTag2) - - - local target = Game.FindEntityByID(obj2.id) - if(target ~= nil) then - targetAttAgent:SetAttitudeTowards(target:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Friendly")) - -- reactionComp:TriggerCombat(target) - end - - - end - - - end - - - end - - function setAggressiveAgainstAttitudeGroup(tag,targetgroup, attitudegroup, attitudegrouptarget) - - - local group =getGroupfromManager(tag) - - for i=1, #group.entities do - local entityTag = group.entities[i] - - - local obj = getEntityFromManager(entityTag) - - checkAttitudeCounter(obj) + function setPsycho(tag, friendtag) + + local enti = nil + local obj = nil + local targets = nil + + if(tag =="lookat"and objLook ~= nil) then + + enti = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + + else + + + obj = getEntityFromManager(tag) + + enti = safeFindEntityByID(obj.id) + + + end + + + if not friendPuppet then + targets = Game.GetPlayer() + else + if(target =="target") then + + + targets = safeFindEntityByID(selectTarget) + + else + + local obj2 = getEntityFromManager(friendtag) + targets = safeFindEntityByID(obj2.id) + + + end + end + + if enti ~= nil and enti:IsVehicle() == false and targets ~= nil then + enti:GetAttitudeAgent():SetAttitudeGroup('HostileToEveryone') + enti:GetAttitudeAgent():SetAttitudeTowards(targets:GetAttitudeAgent(), EAIAttitude.AIA_Neutral) + cyberscript.EntityManager[tag].attitudechanged = true + end + end + + function setPassiveAgainstAttitudeGroup(tag,targetgroup, attitudegroup, attitudegrouptarget) + + + + local group =getGroupfromManager(tag) + + for i=1, #group.entities do + local entityTag = group.entities[i] + + + local obj = getEntityFromManager(entityTag) + + + local enti = safeFindEntityByID(obj.id) + + + + + + + ToggleImmortal(enti, false) + local AIC = enti:GetAIControllerComponent() + local targetAttAgent = enti:GetAttitudeAgent() + local reactionComp = enti.reactionComponent + + local aiRole = NewObject('handle:AIRole') + aiRole:OnRoleSet(enti) + + enti:GetAIControllerComponent():OnAttach() + Game['NPCPuppet::ChangeStanceState;GameObjectgamedataNPCStanceState'](enti, "Relaxed") + AIC:SetAIRole(aiRole) + enti.movePolicies:Toggle(true) + cyberscript.EntityManager[entityTag].attitudechanged = true + + local entityGroup = {} + local targetAttGroup = {} + + for i=1, #arrayAttitudeGroup do + + if(arrayAttitudeGroup[i].properties['.name'] == attitudegroup) then + entityGroup= arrayAttitudeGroup[i] + end + + if(arrayAttitudeGroup[i].properties['.name'] == attitudegrouptarget) then + targetAttGroup= arrayAttitudeGroup[i] + end + + end + + targetAttAgent:SetAttitudeGroup(CName.new(entityGroup.properties['.name'])) + + Game.GetAttitudeSystem():SetAttitudeRelationFromTweak(TweakDBID.new(entityGroup.path), TweakDBID.new(targetAttGroup.path), Enum.new("EAIAttitude", "AIA_Friendly")) + + + + + + targetAttAgent:SetAttitudeTowardsAgentGroup(targetAttAgent, targetAttAgent, Enum.new("EAIAttitude", "AIA_Friendly")) + + + + local targetgroup =getGroupfromManager(targetgroup) + + for y=1, #group.entities do + local entityTag2 = group.entities[y] + + + local obj2 = getEntityFromManager(entityTag2) + + + local target = safeFindEntityByID(obj2.id) + if(target ~= nil) then + targetAttAgent:SetAttitudeTowards(target:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Friendly")) + -- reactionComp:TriggerCombat(target) + end + + + end + + + end + + + end + + function setAggressiveAgainstAttitudeGroup(tag,targetgroup, attitudegroup, attitudegrouptarget) + + + local group =getGroupfromManager(tag) + + for i=1, #group.entities do + local entityTag = group.entities[i] + + + local obj = getEntityFromManager(entityTag) + + checkAttitudeCounter(obj) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - ToggleImmortal(enti, false) - local AIC = enti:GetAIControllerComponent() - local targetAttAgent = enti:GetAttitudeAgent() - local reactionComp = enti.reactionComponent - - local aiRole = NewObject('handle:AIRole') - aiRole:OnRoleSet(enti) - - enti:GetAIControllerComponent():OnAttach() - senseComponent.RequestMainPresetChange(enti, "Combat") - - NPCPuppet.ChangeStanceState(enti, "Combat") - - AIC:SetAIRole(aiRole) - enti.movePolicies:Toggle(true) - cyberscript.EntityManager[entityTag].attitudechanged = true - - local entityGroup = {} - local targetAttGroup = {} - - for i=1, #arrayAttitudeGroup do --from json Attitude, may remork ? - - - if(arrayAttitudeGroup[i].properties['.name'] == attitudegroup) then - entityGroup= arrayAttitudeGroup[i] - end - - if(arrayAttitudeGroup[i].properties['.name'] == attitudegrouptarget) then - targetAttGroup= arrayAttitudeGroup[i] - end - - end - - targetAttAgent:SetAttitudeGroup(CName.new(entityGroup.properties['.name'])) - - Game.GetAttitudeSystem():SetAttitudeRelationFromTweak(TweakDBID.new(entityGroup.path), TweakDBID.new(targetAttGroup.path), Enum.new("EAIAttitude", "AIA_Hostile")) - - reactionComp:SetReactionPreset(GetSingleton("gamedataTweakDBInterface"):GetReactionPresetRecord(TweakDBID.new("ReactionPresets.Ganger_Aggressive"))) - - - - targetAttAgent:SetAttitudeTowardsAgentGroup(targetAttAgent, targetAttAgent, Enum.new("EAIAttitude", "AIA_Friendly")) - - - - - local targetgroup =getGroupfromManager(targetgroup) - logme(2,targetgroup.tag) - for y=1, #targetgroup.entities do - local entityTag2 = targetgroup.entities[i] - - - local obj2 = getEntityFromManager(entityTag2) - - - local target = Game.FindEntityByID(obj2.id) - - if(target ~= nil) then - targetAttAgent:SetAttitudeTowards(target:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Hostile")) - -- reactionComp:TriggerCombat(target) - end - end - - - - end - end - end - - - + local enti = safeFindEntityByID(obj.id) + + if(enti ~= nil) then + ToggleImmortal(enti, false) + local AIC = enti:GetAIControllerComponent() + local targetAttAgent = enti:GetAttitudeAgent() + local reactionComp = enti.reactionComponent + + local aiRole = NewObject('handle:AIRole') + aiRole:OnRoleSet(enti) + + enti:GetAIControllerComponent():OnAttach() + senseComponent.RequestMainPresetChange(enti, "Combat") + + NPCPuppet.ChangeStanceState(enti, "Combat") + + AIC:SetAIRole(aiRole) + enti.movePolicies:Toggle(true) + cyberscript.EntityManager[entityTag].attitudechanged = true + + local entityGroup = {} + local targetAttGroup = {} + + for i=1, #arrayAttitudeGroup do --from json Attitude, may remork ? + + + if(arrayAttitudeGroup[i].properties['.name'] == attitudegroup) then + entityGroup= arrayAttitudeGroup[i] + end + + if(arrayAttitudeGroup[i].properties['.name'] == attitudegrouptarget) then + targetAttGroup= arrayAttitudeGroup[i] + end + + end + + targetAttAgent:SetAttitudeGroup(CName.new(entityGroup.properties['.name'])) + + Game.GetAttitudeSystem():SetAttitudeRelationFromTweak(TweakDBID.new(entityGroup.path), TweakDBID.new(targetAttGroup.path), Enum.new("EAIAttitude", "AIA_Hostile")) + + reactionComp:SetReactionPreset(GetSingleton("gamedataTweakDBInterface"):GetReactionPresetRecord(TweakDBID.new("ReactionPresets.Ganger_Aggressive"))) + + + + targetAttAgent:SetAttitudeTowardsAgentGroup(targetAttAgent, targetAttAgent, Enum.new("EAIAttitude", "AIA_Friendly")) + + + + + local targetgroup =getGroupfromManager(targetgroup) + logme(2,targetgroup.tag) + for y=1, #targetgroup.entities do + local entityTag2 = targetgroup.entities[i] + + + local obj2 = getEntityFromManager(entityTag2) + + + local target = safeFindEntityByID(obj2.id) + + if(target ~= nil) then + targetAttAgent:SetAttitudeTowards(target:GetAttitudeAgent(), Enum.new("EAIAttitude", "AIA_Hostile")) + -- reactionComp:TriggerCombat(target) + end + end + + + + end + end + end + + + end - + if vehiculeRegion then - --1 garage - --2 beta - --3 prevention - - function spawnVehicleV2(chara, appearance, tag, x, y ,z, spawnlevel, spawn_system ,isAV,from_behind,isMP,wait_for_vehicule, scriptlevel, wait_for_vehicle_second,fakeav,despawntimer,persistState,persistSpawn,AlwaysSpawned,SpawnInView,dontregister,rotation) - if (spawn_system ~= 4 and spawn_system ~= 1) then spawn_system = 4 end - if (('string' == type(chara)) and (string.match(tostring(chara), "AMM_Vehicle.") == nil or (string.match(tostring(chara), "AMM_Vehicle.") ~= nil and AMM ~= nil) ) )then - - - print(spawn_system) - - isprevention = isprevention or false - - isAV = isAV or false - local firstspawn = false - local NPC = nil - - - - - - if despawntimer == nil then despawntimer = 0 end - - - - local player = Game.GetPlayer() - local worldpos = player:GetWorldTransform() - - local postp = Vector4.new( x, y, z,1) - - worldpos:SetPosition(worldpos, postp) - if(rotation ~= nil) then - - local rostp = EulerAngles.new(rotation.roll,rotation.pitch,rotation.yaw) - - worldpos:SetOrientationEuler(worldpos, rostp) - else - rotation = EulerAngles.new(0,0,0) - end - - local npcSpec = DynamicEntitySpec.new() - npcSpec.recordID = chara - npcSpec.appearanceName = appearance - npcSpec.position = postp - npcSpec.orientation = GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(rotation.roll,rotation.pitch,rotation.yaw)) - npcSpec.persistState = persistState or false - npcSpec.persistSpawn = persistSpawn or false - npcSpec.alwaysSpawned = AlwaysSpawned or false - npcSpec.spawnInView = true - CName.add("CyberScript") - CName.add("CyberScript.Vehicle") - CName.add("CyberScript.Vehicle."..tag) - - - npcSpec.tags = {"CyberScript","CyberScript.Vehicle","CyberScript.Vehicle."..tag} - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.Vehicle."..tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.Vehicle."..tag) end - print(chara) - print(appearance) - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.Vehicle."..tag) == false) then - print("dsdddd") - NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) - if dontregister == nil then dontregister = false end - if(NPC ~= nil and dontregister == false) then - local entity = {} - print("test") - entity.id = NPC - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+despawntimer - entity.tag = tag - entity.takenSeat = {} - entity.driver = {} - entity.isAV = isAV - entity.fakeAV = fakeav - entity.spawnlocation = postp - entity.isitem = isitem - entity.tweak = chara - entity.isprevention = isprevention - entity.iscodeware = true - entity.persistState = persistState or false - entity.persistSpawn = persistSpawn or false - entity.alwaysSpawned = AlwaysSpawned or false - entity.spawnInView = true - if(scriptlevel == nil) then - entity.scriptlevel = 0 - else - entity.scriptlevel = scriptlevel - end - entity.isMP = isMPplayer - - if(isitem == nil or isitem == false) then - - local npgc = getNPCByTweakId(chara) - if(npgc ~= nil) then - entity.name = npgc.Names - else - entity.name = tag - end - else - - entity.name = tag - - end - - if(isMPplayer ~= nil and isMPplayer == true)then - entity.name = tag - end - cyberscript.EntityManager[tag]=entity - cyberscript.EntityManager["last_spawned"].tag=tag - - - -- Cron.After(0.5, function() - - - -- if isprevention == true then - -- local postp = Vector4.new( x, y, z,1) - -- teleportTo(Game.FindEntityByID(NPC), postp, 1,false) - -- end - - - - - -- end) - end - - else - print("already spawsn") - end - - - - - - - - - - - - - - - - - - - end - - end - - - function unlockVehicles(vehicles) - local unlockableVehicles = TweakDB:GetFlat(TweakDBID.new('Vehicle.vehicle_list.list')) - - for _, vehiclePath in ipairs(vehicles) do - - local targetVehicleTweakDbId = TweakDBID.new(vehiclePath) - local isVehicleUnlockable = false - - for _, unlockableVehicleTweakDbId in ipairs(unlockableVehicles) do - if tostring(unlockableVehicleTweakDbId) == tostring(targetVehicleTweakDbId) then - isVehicleUnlockable = true - break - end - end - - if not isVehicleUnlockable then - table.insert(unlockableVehicles, targetVehicleTweakDbId) - end - end - - TweakDB:SetFlat('Vehicle.vehicle_list.list', unlockableVehicles) - logme(10,"unlocked") - end - - - function SetVehiculeToGarage(vehiclePath,enable,asAV,tag,fakeAV) - - - - local vehi = getVehiclefromCustomGarage(vehiclePath) - - - if(vehi == nil) then - - local vehio = {} - vehio.path = vehiclePath - vehio.tag = tag - vehio.enabled = enable - vehio.asAV = asAV - vehio.fakeAV = fakeAV - - table.insert(currentSave.garage,vehio) - - logme(10,"added") - else - - - vehi.enabled = enable - vehi.asAV = asAV - vehi.fakeAV = fakeAV - - end - - - Game.GetVehicleSystem():EnablePlayerVehicle(vehiclePath,true,false) - - - end - - - function getVehiclefromCustomGarage(vehiclePath) - --logme(2, #currentSave.garage) - for i = 1, #currentSave.garage do - -- logme(2,currentSave.garage[i].path) - if(currentSave.garage[i].path == vehiclePath) then - - return currentSave.garage[i] - - end - - end - - end - - function getVehiclefromCustomGarageTag(tag) - --logme(2, #currentSave.garage) - for i = 1, #currentSave.garage do - --logme(2,currentSave.garage[i].path) - if(currentSave.garage[i].tag == tag) then - - return currentSave.garage[i] - - end - - end - - end - - - function spawnVehicle(vehiclePath,behind,fromgarage, isAV) - - - fromgarage = fromgarage or true - - isAV = isAV or false - - - - local vehicleSystem = Game.GetVehicleSystem() - - local garageVehicleId = GetSingleton('vehicleGarageVehicleID'):Resolve(vehiclePath) - - if(behind == nil or behind == false) then - Game.GetVehicleSystem():ToggleSummonMode() - end - - vehicleSystem:TogglePlayerActiveVehicle(garageVehicleId, 'Car', true) - - vehicleSystem:SpawnPlayerVehicle('Car') - - if(behind == nil or behind == false) then - Game.GetVehicleSystem():ToggleSummonMode() - end - - - - - Cron.After(0.7, function() - - local NPC = vehicleEntId - logme(2,NPC) - local entity = {} - entity.id = NPC - entity.iscodeware = false - entity.tag = tag - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+despawntimer - entity.tweak = chara - entity.takenSeat = {} - entity.isAV = isAV - entity.name = chara - - local veh = Game.FindEntityByID(NPC) - entity.availableSeat = GetSeats(veh) - --entity.availableSeat = {} - entity.driver = {} - cyberscript.EntityManager[entity.tag] = entity - - - local postp = Vector4.new( x, y, z,1) - teleportTo(Game.FindEntityByID(NPC), postp, 1, false) - - calledfromgarage = true - end) - - - - - - - end - - - - function despawnVehicle(vehiclePath) - local vehicleSystem = Game.GetVehicleSystem() - - local garageVehicleId = GetSingleton('vehicleGarageVehicleID'):Resolve(vehiclePath) - - vehicleSystem:DespawnPlayerVehicle(garageVehicleId); - end - - - - function SetSeat(entitytag, vehiculetag, wait, seat) - - local entity = nil - - - local vehiculeobj = nil - local vehicule = nil - - local entityobj = nil - - - if(entitytag == "player") then - - entityobj = getEntityFromManager(entitytag) - entity = Game.FindEntityByID(entityobj.id) - - else - - if(tag =="lookat") then - - entity = objLook - entityobj = getEntityFromManagerById(objLook:GetEntityID()) - else - - - entityobj = getEntityFromManager(entitytag) - entity = Game.FindEntityByID(entityobj.id) - - - end - - end - - if(vehiculetag =="target") then - - vehicule = Game.FindEntityByID(selectTarget) - - vehiculeobj= {} - - vehiculeobj.id = selectTarget - vehiculeobj.tag = "target_vehicule_"..math.random(50,9999) - vehiculeobj.tweak = vehicule:GetRecordID() - vehiculeobj.takenSeat = {} - vehiculeobj.isAV = false - vehiculeobj.availableSeat = GetSeats(vehicule) - vehiculeobj.driver = nil - - - cyberscript.EntityManager[vehiculeobj.tag] = vehiculeobj - - - else - - - vehiculeobj = getEntityFromManager(vehiculetag) - vehicule = Game.FindEntityByID(vehiculeobj.id) - - - end - - if(vehicule ~= nil and entity ~= nil and vehicule:IsVehicle() == true) then - logme(2,"ok") - - - if seat == "seat_front_left" and vehiculeobj.driver == nil then - - vehiculeobj.driver = entitytag - - elseif vehiculeobj.driver == nil then - - vehiculeobj.driver = "player" - - end - - - - - - - - - - if(seat ~= nil) then - logme(2,seat) - if(entitytag == "player") then - - local player = Game.GetPlayer() - - local data = NewObject('handle:gameMountEventData') - data.isInstant = not wait - data.slotName = seat - data.mountParentEntityId = vehiculeobj.id - data.entryAnimName = "forcedTransition" - - local slotID = NewObject('gamemountingMountingSlotId') - slotID.id = seat - - local mountingInfo = NewObject('gamemountingMountingInfo') - mountingInfo.childId = player:GetEntityID() - mountingInfo.parentId = vehiculeobj.id - mountingInfo.slotId = slotID - - local mountEvent = NewObject('handle:gamemountingMountingRequest') - mountEvent.lowLevelMountingInfo = mountingInfo - mountEvent.mountData = data - AVseat = seat - Game.GetMountingFacility():Mount(mountEvent) - if(vehiculeobj.takenSeat == nil) then vehiculeobj.takenSeat = {} end - table.insert(vehiculeobj.takenSeat,seat) - entityobj.vehicleid = vehiculeobj.id - - else - - local lowLevelMountingInfo = MountingInfo; - local mountingRequest = MountingRequest.new(); - local mountData = MountEventData.new(); - local mountOptions = MountEventOptions.new(); - lowLevelMountingInfo.parentId = vehiculeobj.id; - lowLevelMountingInfo.childId = entityobj.id; - local slotID = NewObject('gamemountingMountingSlotId') - slotID.id = seat - lowLevelMountingInfo.slotId = slotID; - mountingRequest.lowLevelMountingInfo = lowLevelMountingInfo; - mountingRequest.preservePositionAfterMounting = true; - mountingRequest.mountData = mountData; - mountOptions.alive = true; - mountOptions.occupiedByNonFriendly = false; - mountingRequest.mountData.mountEventOptions = mountOptions; - Game.GetMountingFacility():Mount(mountingRequest); - - local command = 'AIMountCommand' - local cmd = NewObject(command) - local mountData = NewObject('handle:gameMountEventData') - mountData.slotName = CName.new(seat) - mountData.ignoreHLS = false - mountData.mountParentEntityId = vehiculeobj.id - mountData.isInstant = true - cmd.mountData = mountData - - - - - -- cmd = cmd:Copy() - - executeCmd(entity,cmd) - -- local mountingRequest = MountingRequest.new(); - -- local mountData = MountEventData.new(); - -- local mountOptions = MountEventOptions.new(); - - - -- lowLevelMountingInfo.parentId = vehiculeobj.id; - -- lowLevelMountingInfo.childId = entityobj.id; - -- lowLevelMountingInfo.slotId.id = seat; - - -- local npcMountInfo = Game.GetMountingFacility():GetMountingInfoSingleWithIds(lowLevelMountingInfo.parentId, lowLevelMountingInfo.slotId); - -- local npcMountInfos = Game.GetMountingFacility():GetMountingInfoMultipleWithIds(lowLevelMountingInfo.parentId); - - - -- mountingRequest.lowLevelMountingInfo = lowLevelMountingInfo; - -- mountingRequest.preservePositionAfterMounting = true; - -- mountingRequest.mountData = mountData; - -- mountOptions.entityID = npcMountInfo.childId; - -- mountOptions.alive = true; - -- mountOptions.occupiedByNonFriendly = false - -- mountingRequest.mountData.mountEventOptions = mountOptions - -- Game.GetMountingFacility():Mount(mountingRequest); - + --1 garage + --2 beta + --3 prevention + + function spawnVehicleV2(chara, appearance, tag, x, y ,z, spawnlevel, spawn_system ,isAV,from_behind,isMP,wait_for_vehicule, scriptlevel, wait_for_vehicle_second,fakeav,despawntimer,persistState,persistSpawn,AlwaysSpawned,SpawnInView,dontregister,rotation) + -- B-04 / B-11 fix: wrap the entire spawn path in pcall so that any + -- failure (missing dynamic-entity component, patch 2.3+ vehicle API + -- change, null entity ref after spawn) is logged and recovered from + -- instead of crashing the game. The 100% CTD when quickhacking + -- "Emergency Brakes" on a Cyberscript-spawned vehicle (GH #9) and the + -- patch 2.3 crash on entering vehicles both originate in this code + -- path. The pcall doesn't fix the underlying component gap but + -- prevents the hard crash; the diagnostic log lets users / modders + -- see exactly which call failed. + local spawnOk, spawnErr = pcall(function() + if (spawn_system ~= 4 and spawn_system ~= 1) then spawn_system = 4 end + if (('string' == type(chara)) and (string.match(tostring(chara), "AMM_Vehicle.") == nil or (string.match(tostring(chara), "AMM_Vehicle.") ~= nil and AMM ~= nil) ) )then + + + print(spawn_system) + + isprevention = isprevention or false + + isAV = isAV or false + local firstspawn = false + local NPC = nil + + + + + + if despawntimer == nil then despawntimer = 0 end + + + + local player = Game.GetPlayer() + local worldpos = player:GetWorldTransform() + + local postp = Vector4.new( x, y, z,1) + + worldpos:SetPosition(worldpos, postp) + if(rotation ~= nil) then + + local rostp = EulerAngles.new(rotation.roll,rotation.pitch,rotation.yaw) + + worldpos:SetOrientationEuler(worldpos, rostp) + else + rotation = EulerAngles.new(0,0,0) + end + + local npcSpec = DynamicEntitySpec.new() + npcSpec.recordID = chara + npcSpec.appearanceName = appearance + npcSpec.position = postp + npcSpec.orientation = GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(rotation.roll,rotation.pitch,rotation.yaw)) + npcSpec.persistState = persistState or false + npcSpec.persistSpawn = persistSpawn or false + npcSpec.alwaysSpawned = AlwaysSpawned or false + npcSpec.spawnInView = true + CName.add("CyberScript") + CName.add("CyberScript.Vehicle") + CName.add("CyberScript.Vehicle."..tag) + + + npcSpec.tags = {"CyberScript","CyberScript.Vehicle","CyberScript.Vehicle."..tag} + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.Vehicle."..tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.Vehicle."..tag) end + print(chara) + print(appearance) + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.Vehicle."..tag) == false) then + print("dsdddd") + NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) + if dontregister == nil then dontregister = false end + if(NPC ~= nil and dontregister == false) then + local entity = {} + print("test") + entity.id = NPC + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+despawntimer + entity.tag = tag + entity.takenSeat = {} + entity.driver = {} + entity.isAV = isAV + entity.fakeAV = fakeav + entity.spawnlocation = postp + entity.isitem = isitem + entity.tweak = chara + entity.isprevention = isprevention + entity.iscodeware = true + entity.persistState = persistState or false + entity.persistSpawn = persistSpawn or false + entity.alwaysSpawned = AlwaysSpawned or false + entity.spawnInView = true + if(scriptlevel == nil) then + entity.scriptlevel = 0 + else + entity.scriptlevel = scriptlevel + end + entity.isMP = isMPplayer + + if(isitem == nil or isitem == false) then + + local npgc = getNPCByTweakId(chara) + if(npgc ~= nil) then + entity.name = npgc.Names + else + entity.name = tag + end + else + + entity.name = tag + + end + + if(isMPplayer ~= nil and isMPplayer == true)then + entity.name = tag + end + cyberscript.EntityManager[tag]=entity + cyberscript.EntityManager["last_spawned"].tag=tag + + + -- Cron.After(0.5, function() + + + -- if isprevention == true then + -- local postp = Vector4.new( x, y, z,1) + -- teleportTo(safeFindEntityByID(NPC), postp, 1,false) + -- end + + + + + -- end) + end + + else + print("already spawsn") + end + + + + + + + + + + + + + + + + + + + end + + end) -- close B-04/B-11 pcall anonymous function + call + if not spawnOk then + logme(1, "[Cyberscript] B-04/B-11: spawnVehicleV2 failed for chara=" .. tostring(chara) .. " tag=" .. tostring(tag) .. " err=" .. tostring(spawnErr)) + end + end + + + function unlockVehicles(vehicles) + local unlockableVehicles = TweakDB:GetFlat(TweakDBID.new('Vehicle.vehicle_list.list')) + + for _, vehiclePath in ipairs(vehicles) do + + local targetVehicleTweakDbId = TweakDBID.new(vehiclePath) + local isVehicleUnlockable = false + + for _, unlockableVehicleTweakDbId in ipairs(unlockableVehicles) do + if tostring(unlockableVehicleTweakDbId) == tostring(targetVehicleTweakDbId) then + isVehicleUnlockable = true + break + end + end + + if not isVehicleUnlockable then + table.insert(unlockableVehicles, targetVehicleTweakDbId) + end + end + + TweakDB:SetFlat('Vehicle.vehicle_list.list', unlockableVehicles) + logme(10,"unlocked") + end + + + function SetVehiculeToGarage(vehiclePath,enable,asAV,tag,fakeAV) + + + + local vehi = getVehiclefromCustomGarage(vehiclePath) + + + if(vehi == nil) then + + local vehio = {} + vehio.path = vehiclePath + vehio.tag = tag + vehio.enabled = enable + vehio.asAV = asAV + vehio.fakeAV = fakeAV + + table.insert(currentSave.garage,vehio) + + logme(10,"added") + else + + + vehi.enabled = enable + vehi.asAV = asAV + vehi.fakeAV = fakeAV + + end + + + Game.GetVehicleSystem():EnablePlayerVehicle(vehiclePath,true,false) + + + end + + + function getVehiclefromCustomGarage(vehiclePath) + --logme(2, #currentSave.garage) + for i = 1, #currentSave.garage do + -- logme(2,currentSave.garage[i].path) + if(currentSave.garage[i].path == vehiclePath) then + + return currentSave.garage[i] + + end + + end + + end + + function getVehiclefromCustomGarageTag(tag) + --logme(2, #currentSave.garage) + for i = 1, #currentSave.garage do + --logme(2,currentSave.garage[i].path) + if(currentSave.garage[i].tag == tag) then + + return currentSave.garage[i] + + end + + end + + end + + + function spawnVehicle(vehiclePath,behind,fromgarage, isAV) + + + fromgarage = fromgarage or true + + isAV = isAV or false + + + + local vehicleSystem = Game.GetVehicleSystem() + + local garageVehicleId = GetSingleton('vehicleGarageVehicleID'):Resolve(vehiclePath) + + if(behind == nil or behind == false) then + Game.GetVehicleSystem():ToggleSummonMode() + end + + vehicleSystem:TogglePlayerActiveVehicle(garageVehicleId, 'Car', true) + + vehicleSystem:SpawnPlayerVehicle('Car') + + if(behind == nil or behind == false) then + Game.GetVehicleSystem():ToggleSummonMode() + end + + + + + Cron.After(0.7, function() + + local NPC = vehicleEntId + logme(2,NPC) + local entity = {} + entity.id = NPC + entity.iscodeware = false + entity.tag = tag + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+despawntimer + entity.tweak = chara + entity.takenSeat = {} + entity.isAV = isAV + entity.name = chara + + local veh = safeFindEntityByID(NPC) + entity.availableSeat = GetSeats(veh) + --entity.availableSeat = {} + entity.driver = {} + cyberscript.EntityManager[entity.tag] = entity + + + local postp = Vector4.new( x, y, z,1) + teleportTo(safeFindEntityByID(NPC), postp, 1, false) + + calledfromgarage = true + end) + + + + + + + end + + + + function despawnVehicle(vehiclePath) + local vehicleSystem = Game.GetVehicleSystem() + + local garageVehicleId = GetSingleton('vehicleGarageVehicleID'):Resolve(vehiclePath) + + vehicleSystem:DespawnPlayerVehicle(garageVehicleId); + end + + + + function SetSeat(entitytag, vehiculetag, wait, seat) + + local entity = nil + + + local vehiculeobj = nil + local vehicule = nil + + local entityobj = nil + + + if(entitytag == "player") then + + entityobj = getEntityFromManager(entitytag) + entity = safeFindEntityByID(entityobj.id) + + else + + if(tag =="lookat") then + + entity = objLook + entityobj = getEntityFromManagerById(objLook:GetEntityID()) + else + + + entityobj = getEntityFromManager(entitytag) + entity = safeFindEntityByID(entityobj.id) + + + end + + end + + if(vehiculetag =="target") then + + vehicule = safeFindEntityByID(selectTarget) + + vehiculeobj= {} + + vehiculeobj.id = selectTarget + vehiculeobj.tag = "target_vehicule_"..math.random(50,9999) + vehiculeobj.tweak = vehicule:GetRecordID() + vehiculeobj.takenSeat = {} + vehiculeobj.isAV = false + vehiculeobj.availableSeat = GetSeats(vehicule) + vehiculeobj.driver = nil + + + cyberscript.EntityManager[vehiculeobj.tag] = vehiculeobj + + + else + + + vehiculeobj = getEntityFromManager(vehiculetag) + vehicule = safeFindEntityByID(vehiculeobj.id) + + + end + + if(vehicule ~= nil and entity ~= nil and vehicule:IsVehicle() == true) then + logme(2,"ok") + + + if seat == "seat_front_left" and vehiculeobj.driver == nil then + + vehiculeobj.driver = entitytag + + elseif vehiculeobj.driver == nil then + + vehiculeobj.driver = "player" + + end + + + + + + + + + + if(seat ~= nil) then + logme(2,seat) + if(entitytag == "player") then + + local player = Game.GetPlayer() + + local data = NewObject('handle:gameMountEventData') + data.isInstant = not wait + data.slotName = seat + data.mountParentEntityId = vehiculeobj.id + data.entryAnimName = "forcedTransition" + + local slotID = NewObject('gamemountingMountingSlotId') + slotID.id = seat + + local mountingInfo = NewObject('gamemountingMountingInfo') + mountingInfo.childId = player:GetEntityID() + mountingInfo.parentId = vehiculeobj.id + mountingInfo.slotId = slotID + + local mountEvent = NewObject('handle:gamemountingMountingRequest') + mountEvent.lowLevelMountingInfo = mountingInfo + mountEvent.mountData = data + AVseat = seat + Game.GetMountingFacility():Mount(mountEvent) + if(vehiculeobj.takenSeat == nil) then vehiculeobj.takenSeat = {} end + table.insert(vehiculeobj.takenSeat,seat) + entityobj.vehicleid = vehiculeobj.id + + else + + local lowLevelMountingInfo = MountingInfo; + local mountingRequest = MountingRequest.new(); + local mountData = MountEventData.new(); + local mountOptions = MountEventOptions.new(); + lowLevelMountingInfo.parentId = vehiculeobj.id; + lowLevelMountingInfo.childId = entityobj.id; + local slotID = NewObject('gamemountingMountingSlotId') + slotID.id = seat + lowLevelMountingInfo.slotId = slotID; + mountingRequest.lowLevelMountingInfo = lowLevelMountingInfo; + mountingRequest.preservePositionAfterMounting = true; + mountingRequest.mountData = mountData; + mountOptions.alive = true; + mountOptions.occupiedByNonFriendly = false; + mountingRequest.mountData.mountEventOptions = mountOptions; + Game.GetMountingFacility():Mount(mountingRequest); + + local command = 'AIMountCommand' + local cmd = NewObject(command) + local mountData = NewObject('handle:gameMountEventData') + mountData.slotName = CName.new(seat) + mountData.ignoreHLS = false + mountData.mountParentEntityId = vehiculeobj.id + mountData.isInstant = true + cmd.mountData = mountData + + + + + -- cmd = cmd:Copy() + + executeCmd(entity,cmd) + -- local mountingRequest = MountingRequest.new(); + -- local mountData = MountEventData.new(); + -- local mountOptions = MountEventOptions.new(); + + + -- lowLevelMountingInfo.parentId = vehiculeobj.id; + -- lowLevelMountingInfo.childId = entityobj.id; + -- lowLevelMountingInfo.slotId.id = seat; + + -- local npcMountInfo = Game.GetMountingFacility():GetMountingInfoSingleWithIds(lowLevelMountingInfo.parentId, lowLevelMountingInfo.slotId); + -- local npcMountInfos = Game.GetMountingFacility():GetMountingInfoMultipleWithIds(lowLevelMountingInfo.parentId); + + + -- mountingRequest.lowLevelMountingInfo = lowLevelMountingInfo; + -- mountingRequest.preservePositionAfterMounting = true; + -- mountingRequest.mountData = mountData; + -- mountOptions.entityID = npcMountInfo.childId; + -- mountOptions.alive = true; + -- mountOptions.occupiedByNonFriendly = false + -- mountingRequest.mountData.mountEventOptions = mountOptions + -- Game.GetMountingFacility():Mount(mountingRequest); + - logme(1,"ok2") - if(vehiculeobj.takenSeat == nil) then - vehiculeobj.takenSeat = {} - end - table.insert(vehiculeobj.takenSeat,seat) - entityobj.vehicleid = vehiculeobj.id - end - - else - - Game.GetPlayer():SetWarningMessage(getLang("npc_car_seat_full")) - - - end - - end - end - - function UnsetSeat(entitytag, vehiculetag, wait, seat) - - - - print("Test11") - local entityobj = nil - local entity = nil - - if(entitytag == "player") then - - entityobj = getEntityFromManager(entitytag) - entity = Game.FindEntityByID(entityobj.id) - - else - - entityobj = getEntityFromManager(entitytag) - entity = Game.FindEntityByID(entityobj.id) - - end - - local vehiculeobj = getEntityFromManager(vehiculetag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - if(vehicule ~= nil and entity ~= nil) then - - - - - - if(seat ~= nil) then - - if(entitytag == "player") then - print("Test11") - local player = Game.GetPlayer() - - local data = NewObject('handle:gameMountEventData') - data.isInstant = true - data.slotName = seat - data.mountParentEntityId = vehiculeobj.id - data.entryAnimName = "forcedTransition" - - local slotID = NewObject('gamemountingMountingSlotId') - slotID.id = seat - - local mountingInfo = NewObject('gamemountingMountingInfo') - mountingInfo.childId = player:GetEntityID() - mountingInfo.parentId = vehiculeobj.id - mountingInfo.slotId = slotID - - local mountEvent = NewObject('handle:gamemountingUnmountingRequest') - mountEvent.lowLevelMountingInfo = mountingInfo - mountEvent.mountData = data - - Game.GetMountingFacility():Unmount(mountEvent) - - - else - - - print("Test11") - -- local command = 'AIUnmountCommand' - -- local cmd = NewObject(command) - -- local mountData = NewObject('handle:gameMountEventData') - -- mountData.mountParentEntityId = vehiculeobj.id - -- mountData.isInstant = not wait - -- mountData.setEntityVisibleWhenMountFinish = true - -- mountData.removePitchRollRotationOnDismount = false - -- mountData.ignoreHLS = true - -- mountData.mountEventOptions = NewObject('handle:gameMountEventOptions') - -- mountData.mountEventOptions.silentUnmount = false - -- mountData.mountEventOptions.entityID = vehiculeobj.id - - -- mountData.slotName = CName.new(seat) - -- cmd.mountData = mountData - -- cmd = cmd:Copy() - - -- executeCmd(entity,cmd) - - -- local command = 'AIUnmountCommand' - -- local cmd = NewObject(command) - -- local mountData = NewObject('handle:gameMountEventData') - -- mountData.slotName = CName.new(seat) - -- mountData.ignoreHLS = false - -- mountData.mountParentEntityId = vehiculeobj.id - -- mountData.isInstant = not wait - -- cmd.mountData = mountData - -- executeCmd(entity,cmd) - - - -- print(tostring(Game.GetWorkspotSystem():IsInVehicleWorkspot(vehicle,entity,CName.new(seat)))) - - -- -- cmd = cmd:Copy() - - -- executeCmd(entity,cmd) - -- Game.GetWorkspotSystem():UnmountFromVehicle(vehicle, entity, true); - -- Game.GetWorkspotSystem():StopNpcInWorkspot(entity) - -- Game.GetWorkspotSystem():StopInDevice(entity) - -- Game.GetWorkspotSystem():SendFastExitSignal(entity, false, false,true); - -- -- local unmountevent = unmountingrequest.new(); - -- -- local mountinginfo = game.getmountingfacility():getmountinginfosinglewithobjects(entity); - -- print(tostring(Game.GetWorkspotSystem():IsActorInWorkspot(entity))) - -- print(tostring(Game.GetWorkspotSystem():IsWorkspotEnabled(entity))) - -- -- unmountevent.lowlevelmountinginfo = mountinginfo; - -- -- game.getmountingfacility():unmount(unmountevent); - -- print(tostring(Game.GetWorkspotSystem():IsInVehicleWorkspot(vehicle,entity,CName.new(seat)))) - local mountingInfo = Game.GetMountingFacility():GetMountingInfoSingleWithObjects(entity) - - local cmd = UnmountingRequest.new() - cmd.lowLevelMountingInfo = mountingInfo; - Game.GetWorkspotSystem():UnmountFromVehicle(vehicle, entity, true); - - Game.GetMountingFacility():Unmount(cmd) - - end - - -- local seatIndex = 0 - -- for i=1,#vehiculeobj.takenSeat do - - -- if(vehiculeobj.takenSeat[i] == entityobj.seat) then - -- seatIndex = i - -- end - - -- end - - -- table.remove(vehiculeobj.takenSeat,seatIndex) - - entityobj.seat = nil - entityobj.vehicleid = nil - - - - - end - - end - end - - - - function IsSeatTaken(vehiculeobj,seat) - - local istaken = false - - if(vehiculeobj.takenSeat ~= nil) then - for i=1,#vehiculeobj.takenSeat do - - if(vehiculeobj.takenSeat[i] == seat)then - istaken = true - end - - end - end - - return istaken - - end - - - - function GetSeats(entityveh) - - - - local vehiculeSeat = {} - - for i=1, #seats do - - if Game['VehicleComponent::HasSlot;GameInstanceVehicleObjectCName'](entityveh, CName.new( seats[i])) then - table.insert(vehiculeSeat, seats[i]) - -- logme(2,seats[i]) - end - end - - return vehiculeSeat - - - end - - - function VehicleFollowEntity(vehiculetag, entitytag, distanceMin,distanceMax,useTraffic,useKinematic,needDriver,stopWhenTargetReached) - - local entity = Game.GetPlayer() - if distanceMin == nil then distanceMin = 2 end - if distanceMax == nil then distanceMax = 50 end - if useTraffic == nil then useTraffic = true end - if useKinematic == nil then useKinematic = true end - if needDriver == nil then needDriver = false end - if stopWhenTargetReached == nil then stopWhenTargetReached = true end - - - - if entitytag ~= "player" then - - local entityobj = getEntityFromManager(entitytag) - entity = Game.FindEntityByID(entityobj.id) - - end - - local vehiculeobj = nil - - - local vehicule = nil - - if(vehiculetag =="target") then - - - vehicule = Game.FindEntityByID(selectTarget) - - else - - vehiculeobj = getEntityFromManager(vehiculetag) - - - vehicule = Game.FindEntityByID(vehiculeobj.id) - - end - - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - vehicule = Game.FindEntityByID(vehiculeobj.id) - - end - - - - if(vehicule ~= nil) then - - - - local cmd = NewObject("handle:AIVehicleFollowCommand") - cmd.target = entity - cmd.distanceMin = distanceMin - cmd.secureTimeOut = 5 - cmd.distanceMax = distanceMax - cmd.useTraffic = useTraffic - cmd.useKinematic =useKinematic - cmd.needDriver = needDriver - cmd.stopWhenTargetReached = stopWhenTargetReached - cmd.trafficTryNeighborsForStart = true - cmd.trafficTryNeighborsForEnd = true - VehicleManageCmd(vehiculeobj,cmd) - - - - local AINPCCommandEvent = NewObject("handle:AINPCCommandEvent") - AINPCCommandEvent.command = cmd - vehicule:QueueEvent(AINPCCommandEvent) - end - end - - - function VehicleGoToGameNode(vehiculetag, noderef, speed, greenlight, needdriver, usetraffic,useKinematic) - - - - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - - - local cmd = NewObject("handle:AIVehicleToNodeCommand") - cmd.nodeRef = noderef - cmd.needDriver = needdriver or false - cmd.trafficTryNeighborsForEnd = true - cmd.stopAtPathEnd = true - cmd.useTraffic = usetraffic or false - cmd.speedInTraffic = speed - cmd.forceGreenLights = greenlight - cmd.useKinematic =useKinematic or true - cmd = cmd:Copy() - - VehicleManageCmd(vehiculeobj,cmd) - local AINPCCommandEvent = NewObject("handle:AINPCCommandEvent") - AINPCCommandEvent.command = cmd - vehicule:QueueEvent(AINPCCommandEvent) - - - - - end - - function VehicleGoToXYZ(vehiculetag, x, y, z,minspeed,maxspeed, cleartraffic) - print(vehiculetag) - print(x) - print(y) - print(z) - print(minspeed) - print(maxspeed) - - - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - - - local cmd = NewObject("handle:AIVehicleDriveToPointAutonomousCommand") - - - cmd.maxSpeed = maxspeed or 15; - cmd.minSpeed = minspeed or 10; - cmd.clearTrafficOnPath = true; - cmd.minimumDistanceToTarget = 0; - cmd.targetPosition = Vector4.Vector4To3(Vector4.new( x, y, z,1)); - cmd.driveDownTheRoadIndefinitely = false - - - - cmd.needDriver = needdriver or false - - cmd.useKinematic =useKinematic or true - cmd = cmd:Copy() - - VehicleManageCmd(vehiculeobj,cmd) - - local AINPCCommandEvent = NewObject("handle:AINPCCommandEvent") - AINPCCommandEvent.command = cmd - vehicule:QueueEvent(AINPCCommandEvent) - - - - - end + logme(1,"ok2") + if(vehiculeobj.takenSeat == nil) then + vehiculeobj.takenSeat = {} + end + table.insert(vehiculeobj.takenSeat,seat) + entityobj.vehicleid = vehiculeobj.id + end + + else + + Game.GetPlayer():SetWarningMessage(getLang("npc_car_seat_full")) + + + end + + end + end + + function UnsetSeat(entitytag, vehiculetag, wait, seat) + + + + print("Test11") + local entityobj = nil + local entity = nil + + if(entitytag == "player") then + + entityobj = getEntityFromManager(entitytag) + entity = safeFindEntityByID(entityobj.id) + + else + + entityobj = getEntityFromManager(entitytag) + entity = safeFindEntityByID(entityobj.id) + + end + + local vehiculeobj = getEntityFromManager(vehiculetag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + + if(vehicule ~= nil and entity ~= nil) then + + + + + + if(seat ~= nil) then + + if(entitytag == "player") then + print("Test11") + local player = Game.GetPlayer() + + local data = NewObject('handle:gameMountEventData') + data.isInstant = true + data.slotName = seat + data.mountParentEntityId = vehiculeobj.id + data.entryAnimName = "forcedTransition" + + local slotID = NewObject('gamemountingMountingSlotId') + slotID.id = seat + + local mountingInfo = NewObject('gamemountingMountingInfo') + mountingInfo.childId = player:GetEntityID() + mountingInfo.parentId = vehiculeobj.id + mountingInfo.slotId = slotID + + local mountEvent = NewObject('handle:gamemountingUnmountingRequest') + mountEvent.lowLevelMountingInfo = mountingInfo + mountEvent.mountData = data + + Game.GetMountingFacility():Unmount(mountEvent) + + + else + + + print("Test11") + -- local command = 'AIUnmountCommand' + -- local cmd = NewObject(command) + -- local mountData = NewObject('handle:gameMountEventData') + -- mountData.mountParentEntityId = vehiculeobj.id + -- mountData.isInstant = not wait + -- mountData.setEntityVisibleWhenMountFinish = true + -- mountData.removePitchRollRotationOnDismount = false + -- mountData.ignoreHLS = true + -- mountData.mountEventOptions = NewObject('handle:gameMountEventOptions') + -- mountData.mountEventOptions.silentUnmount = false + -- mountData.mountEventOptions.entityID = vehiculeobj.id + + -- mountData.slotName = CName.new(seat) + -- cmd.mountData = mountData + -- cmd = cmd:Copy() + + -- executeCmd(entity,cmd) + + -- local command = 'AIUnmountCommand' + -- local cmd = NewObject(command) + -- local mountData = NewObject('handle:gameMountEventData') + -- mountData.slotName = CName.new(seat) + -- mountData.ignoreHLS = false + -- mountData.mountParentEntityId = vehiculeobj.id + -- mountData.isInstant = not wait + -- cmd.mountData = mountData + -- executeCmd(entity,cmd) + + + -- print(tostring(Game.GetWorkspotSystem():IsInVehicleWorkspot(vehicle,entity,CName.new(seat)))) + + -- -- cmd = cmd:Copy() + + -- executeCmd(entity,cmd) + -- Game.GetWorkspotSystem():UnmountFromVehicle(vehicle, entity, true); + -- Game.GetWorkspotSystem():StopNpcInWorkspot(entity) + -- Game.GetWorkspotSystem():StopInDevice(entity) + -- Game.GetWorkspotSystem():SendFastExitSignal(entity, false, false,true); + -- -- local unmountevent = unmountingrequest.new(); + -- -- local mountinginfo = game.getmountingfacility():getmountinginfosinglewithobjects(entity); + -- print(tostring(Game.GetWorkspotSystem():IsActorInWorkspot(entity))) + -- print(tostring(Game.GetWorkspotSystem():IsWorkspotEnabled(entity))) + -- -- unmountevent.lowlevelmountinginfo = mountinginfo; + -- -- game.getmountingfacility():unmount(unmountevent); + -- print(tostring(Game.GetWorkspotSystem():IsInVehicleWorkspot(vehicle,entity,CName.new(seat)))) + local mountingInfo = Game.GetMountingFacility():GetMountingInfoSingleWithObjects(entity) + + local cmd = UnmountingRequest.new() + cmd.lowLevelMountingInfo = mountingInfo; + Game.GetWorkspotSystem():UnmountFromVehicle(vehicle, entity, true); + + Game.GetMountingFacility():Unmount(cmd) + + end + + -- local seatIndex = 0 + -- for i=1,#vehiculeobj.takenSeat do + + -- if(vehiculeobj.takenSeat[i] == entityobj.seat) then + -- seatIndex = i + -- end + + -- end + + -- table.remove(vehiculeobj.takenSeat,seatIndex) + + entityobj.seat = nil + entityobj.vehicleid = nil + + + + + end + + end + end + + + + function IsSeatTaken(vehiculeobj,seat) + + local istaken = false + + if(vehiculeobj.takenSeat ~= nil) then + for i=1,#vehiculeobj.takenSeat do + + if(vehiculeobj.takenSeat[i] == seat)then + istaken = true + end + + end + end + + return istaken + + end + + + + function GetSeats(entityveh) + + + + local vehiculeSeat = {} + + for i=1, #seats do + + if Game['VehicleComponent::HasSlot;GameInstanceVehicleObjectCName'](entityveh, CName.new( seats[i])) then + table.insert(vehiculeSeat, seats[i]) + -- logme(2,seats[i]) + end + end + + return vehiculeSeat + + + end + + + function VehicleFollowEntity(vehiculetag, entitytag, distanceMin,distanceMax,useTraffic,useKinematic,needDriver,stopWhenTargetReached) + + local entity = Game.GetPlayer() + if distanceMin == nil then distanceMin = 2 end + if distanceMax == nil then distanceMax = 50 end + if useTraffic == nil then useTraffic = true end + if useKinematic == nil then useKinematic = true end + if needDriver == nil then needDriver = false end + if stopWhenTargetReached == nil then stopWhenTargetReached = true end + + + + if entitytag ~= "player" then + + local entityobj = getEntityFromManager(entitytag) + entity = safeFindEntityByID(entityobj.id) + + end + + local vehiculeobj = nil + + + local vehicule = nil + + if(vehiculetag =="target") then + + + vehicule = safeFindEntityByID(selectTarget) + + else + + vehiculeobj = getEntityFromManager(vehiculetag) + + + vehicule = safeFindEntityByID(vehiculeobj.id) + + end + + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + vehicule = safeFindEntityByID(vehiculeobj.id) + + end + + + + if(vehicule ~= nil) then + + + + local cmd = NewObject("handle:AIVehicleFollowCommand") + cmd.target = entity + cmd.distanceMin = distanceMin + cmd.secureTimeOut = 5 + cmd.distanceMax = distanceMax + cmd.useTraffic = useTraffic + cmd.useKinematic =useKinematic + cmd.needDriver = needDriver + cmd.stopWhenTargetReached = stopWhenTargetReached + cmd.trafficTryNeighborsForStart = true + cmd.trafficTryNeighborsForEnd = true + VehicleManageCmd(vehiculeobj,cmd) + + + + local AINPCCommandEvent = NewObject("handle:AINPCCommandEvent") + AINPCCommandEvent.command = cmd + vehicule:QueueEvent(AINPCCommandEvent) + end + end + + + function VehicleGoToGameNode(vehiculetag, noderef, speed, greenlight, needdriver, usetraffic,useKinematic) + + + + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + + local vehicule = safeFindEntityByID(vehiculeobj.id) + + + + local cmd = NewObject("handle:AIVehicleToNodeCommand") + cmd.nodeRef = noderef + cmd.needDriver = needdriver or false + cmd.trafficTryNeighborsForEnd = true + cmd.stopAtPathEnd = true + cmd.useTraffic = usetraffic or false + cmd.speedInTraffic = speed + cmd.forceGreenLights = greenlight + cmd.useKinematic =useKinematic or true + cmd = cmd:Copy() + + VehicleManageCmd(vehiculeobj,cmd) + local AINPCCommandEvent = NewObject("handle:AINPCCommandEvent") + AINPCCommandEvent.command = cmd + vehicule:QueueEvent(AINPCCommandEvent) + + + + + end + + function VehicleGoToXYZ(vehiculetag, x, y, z,minspeed,maxspeed, cleartraffic) + print(vehiculetag) + print(x) + print(y) + print(z) + print(minspeed) + print(maxspeed) + + + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + + local vehicule = safeFindEntityByID(vehiculeobj.id) + + + + local cmd = NewObject("handle:AIVehicleDriveToPointAutonomousCommand") + + + cmd.maxSpeed = maxspeed or 15; + cmd.minSpeed = minspeed or 10; + cmd.clearTrafficOnPath = true; + cmd.minimumDistanceToTarget = 0; + cmd.targetPosition = Vector4.Vector4To3(Vector4.new( x, y, z,1)); + cmd.driveDownTheRoadIndefinitely = false + + + + cmd.needDriver = needdriver or false + + cmd.useKinematic =useKinematic or true + cmd = cmd:Copy() + + VehicleManageCmd(vehiculeobj,cmd) + + local AINPCCommandEvent = NewObject("handle:AINPCCommandEvent") + AINPCCommandEvent.command = cmd + vehicule:QueueEvent(AINPCCommandEvent) + + + + + end - function VehicleCancelLastCommand(vehiculetag) - - - - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - if(vehiculeobj.lastcmd ~= nil) then - vehicule:GetAIComponent():CancelCommand(vehiculeobj.lastcmd); - vehicule:GetAIComponent():StopExecutingCommand(vehiculeobj.lastcmd,true) - vehiculeobj.lastcmd = nil - end - - - - - - - end + function VehicleCancelLastCommand(vehiculetag) + + + + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + + local vehicule = safeFindEntityByID(vehiculeobj.id) + + if(vehiculeobj.lastcmd ~= nil) then + vehicule:GetAIComponent():CancelCommand(vehiculeobj.lastcmd); + vehicule:GetAIComponent():StopExecutingCommand(vehiculeobj.lastcmd,true) + vehiculeobj.lastcmd = nil + end + + + + + + + end - function VehicleToggleCollision(vehiculetag,toggle) - - local vehicleSystem = Game.GetVehicleSystem():EnablePlayerVehicleCollision(toggle) - - -- local vehiculeobj = getEntityFromManager(vehiculetag) - -- if(vehiculetag =="lookat") then - - -- local entity = objLook - -- vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - -- end - - -- local vehicule = Game.FindEntityByID(vehiculeobj.id) - - -- if(toggle) then + function VehicleToggleCollision(vehiculetag,toggle) + + local vehicleSystem = Game.GetVehicleSystem():EnablePlayerVehicleCollision(toggle) + + -- local vehiculeobj = getEntityFromManager(vehiculetag) + -- if(vehiculetag =="lookat") then + + -- local entity = objLook + -- vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + -- end + + -- local vehicule = safeFindEntityByID(vehiculeobj.id) + + -- if(toggle) then - -- vehicule:GetAIComponent():EnableCollider() - -- else - -- vehicule:GetAIComponent():DisableCollider() - -- end - - - - - - - end - + -- vehicule:GetAIComponent():EnableCollider() + -- else + -- vehicule:GetAIComponent():DisableCollider() + -- end + + + + + + + end + - function VehicleManageCmd(vehiculeobj,cmd) + function VehicleManageCmd(vehiculeobj,cmd) - if(vehiculeobj.lastcmd ~= nil) then - - VehicleCancelLastCommand(vehiculeobj.tag) - end - - local vehiculeobjs = getEntityFromManager(vehiculeobj.tag) - vehiculeobjs.lastcmd = cmd - - + if(vehiculeobj.lastcmd ~= nil) then + + VehicleCancelLastCommand(vehiculeobj.tag) + end + + local vehiculeobjs = getEntityFromManager(vehiculeobj.tag) + vehiculeobjs.lastcmd = cmd + + - end + end - function VehicleChaseEntity(vehiculetag, entitytag, mindistance,maxdistance,startspeed) - - local entity = Game.GetPlayer() - - if entitytag ~= "player" then - - local entityobj = getEntityFromManager(entitytag) - entity = Game.FindEntityByID(entityobj.id) - - end - - local vehiculeobj = nil - - - local vehicule = nil - - if(vehiculetag =="target") then - - - vehicule = Game.FindEntityByID(selectTarget) - - else - - vehiculeobj = getEntityFromManager(vehiculetag) - - - - end - - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - vehicule = Game.FindEntityByID(vehiculeobj.id) - - end - - - -- local distance = 4 - -- if(vehicule ~= nil) then - - -- if string.find(tostring(vehicule:GetClassName()),"vehicleBikeBaseObject") ~= nil then - -- distance = distance*2 - -- end - - local cmd = NewObject("handle:AIVehicleChaseCommand") - cmd.target = entity - cmd.distanceMin = mindistance - cmd.distanceMax = maxdistance - cmd.forcedStartSpeed = startspeed + function VehicleChaseEntity(vehiculetag, entitytag, mindistance,maxdistance,startspeed) + + local entity = Game.GetPlayer() + + if entitytag ~= "player" then + + local entityobj = getEntityFromManager(entitytag) + entity = safeFindEntityByID(entityobj.id) + + end + + local vehiculeobj = nil + + + local vehicule = nil + + if(vehiculetag =="target") then + + + vehicule = safeFindEntityByID(selectTarget) + + else + + vehiculeobj = getEntityFromManager(vehiculetag) + + + + end + + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + vehicule = safeFindEntityByID(vehiculeobj.id) + + end + + + -- local distance = 4 + -- if(vehicule ~= nil) then + + -- if string.find(tostring(vehicule:GetClassName()),"vehicleBikeBaseObject") ~= nil then + -- distance = distance*2 + -- end + + local cmd = NewObject("handle:AIVehicleChaseCommand") + cmd.target = entity + cmd.distanceMin = mindistance + cmd.distanceMax = maxdistance + cmd.forcedStartSpeed = startspeed - VehicleManageCmd(vehiculeobj,cmd) - - local AICommandEvent = NewObject("handle:AINPCCommandEvent") - AICommandEvent.command = cmd - vehicule:QueueEvent(AINPCCommandEvent) - end - - - - function VehicleDoors(vehiculetag, action) - - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - local getTargetPS = vehicule:GetVehiclePS() - - - if action == "open" then - getTargetPS:OpenAllRegularVehDoors(false) - - elseif action == "close" then - getTargetPS:CloseAllVehDoors(false) - - elseif action == "lock" then - getTargetPS:LockAllVehDoors() - - elseif action == "unlock" then - getTargetPS:UnlockAllVehDoors() - - end - - - end - - function VehicleBrake(vehiculetag, duration,untilstop) - - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(untilstop) then - vehicule:ForceBrakesUntilStoppedOrFor(duration) - else - vehicule:ForceBrakesFor(duration) - end - - end - - function VehicleWindows(vehiculetag, action) - - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - local getTargetPS = vehicule:GetVehiclePS() - - - if action == "open" then - getTargetPS:SetWindowState(0, 1) - getTargetPS:SetWindowState(1, 1) - getTargetPS:SetWindowState(2, 1) - getTargetPS:SetWindowState(3, 1) - getTargetPS:SetWindowState(4, 1) - getTargetPS:SetWindowState(5, 1) - - elseif action == "close" then - getTargetPS:SetWindowState(0, 0) - getTargetPS:SetWindowState(1, 0) - getTargetPS:SetWindowState(2, 0) - getTargetPS:SetWindowState(3, 0) - getTargetPS:SetWindowState(4, 0) - getTargetPS:SetWindowState(5, 0) - - - end - - - end - - - function VehicleDetachAll(vehiculetag) - - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - local vehicule = Game.FindEntityByID(vehiculeobj.id) - vehicule:DetachAllParts() - - end - - function VehicleDestroy(vehiculetag) - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - local getTargetPS = vehicule:GetVehiclePS() - local getTargetVC = vehicule:GetVehicleComponent() - - getTargetVC:DestroyVehicle() - getTargetVC:LoadExplodedState() - getTargetVC:ExplodeVehicle(Game.GetPlayer()) - getTargetPS:ForcePersistentStateChanged() - - end - - function VehicleRepair(vehiculetag) - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - - local getTargetPS = vehicule:GetVehiclePS() - local getTargetVC = vehicule:GetVehicleComponent() - - vehicule:DestructionResetGrid() - vehicule:DestructionResetGlass() - - getTargetVC:RepairVehicle() - getTargetPS:ForcePersistentStateChanged() - - end - - function VehicleHonkFlash(vehiculetag) - - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - if(vehicule ~= nil) then - - local getTargetVC = vehicule:GetVehicleComponent() - - getTargetVC:HonkAndFlash() - end - - - end - --"Off","Normal","High Beams", - function VehicleLights(vehiculetag, state) - local vehiculeobj = getEntityFromManager(vehiculetag) - - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - local getTargetVC = vehicule:GetVehicleComponent() - local getTargetVCPS = getTargetVC:GetVehicleControllerPS() - - getTargetVCPS:SetLightMode(state) - - - end - - function VehicleEngine(vehiculetag, state) - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - local vehicule = Game.FindEntityByID(vehiculeobj.id) - local getTargetVC = vehicule:GetVehicleComponent() - local getTargetVCPS = getTargetVC:GetVehicleControllerPS() - - if state == "on" then - getTargetVCPS:SetState(2) - - elseif state == "off" then - getTargetVCPS:SetState(1) - end - - - end - - function VehicleReset(vehiculetag) - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - local getTargetVC = vehicule:GetVehicleComponent() - - getTargetVC:ResetVehicle() - - end - - function VehicleSetInvincible(vehiculetag) - local vehiculeobj = getEntityFromManager(vehiculetag) - if(vehiculetag =="lookat") then - - local entity = objLook - vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) - - - end - local vehicule = Game.FindEntityByID(vehiculeobj.id) - - if(vehicule ~= nil) then - local getTargetVC = vehicule:GetVehicleComponent() - - getTargetVC:SetImmortalityMode() - end - - end - - - - + VehicleManageCmd(vehiculeobj,cmd) + + local AICommandEvent = NewObject("handle:AINPCCommandEvent") + AICommandEvent.command = cmd + vehicule:QueueEvent(AINPCCommandEvent) + end + + + + function VehicleDoors(vehiculetag, action) + + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + + local vehicule = safeFindEntityByID(vehiculeobj.id) + + local getTargetPS = vehicule:GetVehiclePS() + + + if action == "open" then + getTargetPS:OpenAllRegularVehDoors(false) + + elseif action == "close" then + getTargetPS:CloseAllVehDoors(false) + + elseif action == "lock" then + getTargetPS:LockAllVehDoors() + + elseif action == "unlock" then + getTargetPS:UnlockAllVehDoors() + + end + + + end + + function VehicleBrake(vehiculetag, duration,untilstop) + + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(untilstop) then + vehicule:ForceBrakesUntilStoppedOrFor(duration) + else + vehicule:ForceBrakesFor(duration) + end + + end + + function VehicleWindows(vehiculetag, action) + + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + + local vehicule = safeFindEntityByID(vehiculeobj.id) + + local getTargetPS = vehicule:GetVehiclePS() + + + if action == "open" then + getTargetPS:SetWindowState(0, 1) + getTargetPS:SetWindowState(1, 1) + getTargetPS:SetWindowState(2, 1) + getTargetPS:SetWindowState(3, 1) + getTargetPS:SetWindowState(4, 1) + getTargetPS:SetWindowState(5, 1) + + elseif action == "close" then + getTargetPS:SetWindowState(0, 0) + getTargetPS:SetWindowState(1, 0) + getTargetPS:SetWindowState(2, 0) + getTargetPS:SetWindowState(3, 0) + getTargetPS:SetWindowState(4, 0) + getTargetPS:SetWindowState(5, 0) + + + end + + + end + + + function VehicleDetachAll(vehiculetag) + + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + local vehicule = safeFindEntityByID(vehiculeobj.id) + vehicule:DetachAllParts() + + end + + function VehicleDestroy(vehiculetag) + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + local vehicule = safeFindEntityByID(vehiculeobj.id) + + local getTargetPS = vehicule:GetVehiclePS() + local getTargetVC = vehicule:GetVehicleComponent() + + getTargetVC:DestroyVehicle() + getTargetVC:LoadExplodedState() + getTargetVC:ExplodeVehicle(Game.GetPlayer()) + getTargetPS:ForcePersistentStateChanged() + + end + + function VehicleRepair(vehiculetag) + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + local vehicule = safeFindEntityByID(vehiculeobj.id) + + + local getTargetPS = vehicule:GetVehiclePS() + local getTargetVC = vehicule:GetVehicleComponent() + + vehicule:DestructionResetGrid() + vehicule:DestructionResetGlass() + + getTargetVC:RepairVehicle() + getTargetPS:ForcePersistentStateChanged() + + end + + function VehicleHonkFlash(vehiculetag) + + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + local vehicule = safeFindEntityByID(vehiculeobj.id) + + if(vehicule ~= nil) then + + local getTargetVC = vehicule:GetVehicleComponent() + + getTargetVC:HonkAndFlash() + end + + + end + --"Off","Normal","High Beams", + function VehicleLights(vehiculetag, state) + local vehiculeobj = getEntityFromManager(vehiculetag) + + local vehicule = safeFindEntityByID(vehiculeobj.id) + + local getTargetVC = vehicule:GetVehicleComponent() + local getTargetVCPS = getTargetVC:GetVehicleControllerPS() + + getTargetVCPS:SetLightMode(state) + + + end + + function VehicleEngine(vehiculetag, state) + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + local vehicule = safeFindEntityByID(vehiculeobj.id) + local getTargetVC = vehicule:GetVehicleComponent() + local getTargetVCPS = getTargetVC:GetVehicleControllerPS() + + if state == "on" then + getTargetVCPS:SetState(2) + + elseif state == "off" then + getTargetVCPS:SetState(1) + end + + + end + + function VehicleReset(vehiculetag) + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + local vehicule = safeFindEntityByID(vehiculeobj.id) + + local getTargetVC = vehicule:GetVehicleComponent() + + getTargetVC:ResetVehicle() + + end + + function VehicleSetInvincible(vehiculetag) + local vehiculeobj = getEntityFromManager(vehiculetag) + if(vehiculetag =="lookat") then + + local entity = objLook + vehiculeobj = getEntityFromManagerById(objLook:GetEntityID()) + + + end + local vehicule = safeFindEntityByID(vehiculeobj.id) + + if(vehicule ~= nil) then + local getTargetVC = vehicule:GetVehicleComponent() + + getTargetVC:SetImmortalityMode() + end + + end + + + + end - - \ No newline at end of file + + \ No newline at end of file diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/mappin.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/mappin.lua index 7782982..5dba23e 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/mappin.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/mappin.lua @@ -1,83 +1,90 @@ function BaseMappinBaseController_UpdateRootState(this) - if(observerthread2 == true or moddisabled == true) then return end - local wordpos = this:GetMappin():GetWorldPosition() - for k,v in pairs(mappinManager) do - local mappin = v - if(mappin.position ~= nil and math.floor(mappin.position.x) == math.floor(wordpos.x) and math.floor(mappin.position.y) == math.floor(wordpos.y) and math.floor(mappin.position.z) == math.floor(wordpos.z)) then - - if(mappin.range ~= 0 and mappin.range ~= nil) then - if( check3DPos(curPos, mappin.position.x, mappin.position.y, mappin.position.z, mappin.range) ) then - this:SetRootVisible(true) - else - this:SetRootVisible(false) - end - - end - v.widget = this.iconWidget - v.controller = this - v.mappinEntity = this:GetMappin() - v.distanceToPlayer = getDistance(Game.GetPlayer():GetWorldPosition(), v.position) - - if(v.tracked ~= nil) then - if #this.taggedWidgets > 0 then - - - if this:GetProfile():ShowTrackedIcon() then - - - for i=0, #this.taggedWidgets do - inkWidgetRef.SetVisible(this.taggedWidgets[i], v.tracked) - - - end - - local animPlayer = this:GetAnimPlayer_Tracked() - animPlayer:PlayOrPause(v.tracked) - end - - - end - end - - if(mappin.style ~= nil) then - - if(mappin.style.icon ~= nil) then - - local record = TweakDBInterface.GetUIIconRecord("ChoiceIcons."..mappin.style.icon) - if(record ~= nil) then - v.widget:SetTexturePart(record:AtlasPartName()) - v.widget:SetAtlasResource(record:AtlasResourcePath()) - end - - end - - if(mappin.style.color ~= nil) then - - this.iconWidget:SetTintColor(gamecolorStyle(mappin.style.color)) - end - end - - break - end - end + if(observerthread2 == true or moddisabled == true) then return end + -- B-24 fix: this:GetMappin() can return nil when the mappin is being + -- torn down, causing "attempt to index a nil value" on :GetWorldPosition(). + -- Wrap in pcall so a stale mappin controller can never crash this observer. + local wordpos = nil + local ok = pcall(function() + wordpos = this:GetMappin():GetWorldPosition() + end) + if not ok or wordpos == nil then return end + for k,v in pairs(mappinManager) do + local mappin = v + if(mappin.position ~= nil and math.floor(mappin.position.x) == math.floor(wordpos.x) and math.floor(mappin.position.y) == math.floor(wordpos.y) and math.floor(mappin.position.z) == math.floor(wordpos.z)) then + + if(mappin.range ~= 0 and mappin.range ~= nil) then + if( check3DPos(curPos, mappin.position.x, mappin.position.y, mappin.position.z, mappin.range) ) then + this:SetRootVisible(true) + else + this:SetRootVisible(false) + end + + end + v.widget = this.iconWidget + v.controller = this + v.mappinEntity = this:GetMappin() + v.distanceToPlayer = getDistance(Game.GetPlayer():GetWorldPosition(), v.position) + + if(v.tracked ~= nil) then + if #this.taggedWidgets > 0 then + + + if this:GetProfile():ShowTrackedIcon() then + + + for i=0, #this.taggedWidgets do + inkWidgetRef.SetVisible(this.taggedWidgets[i], v.tracked) + + + end + + local animPlayer = this:GetAnimPlayer_Tracked() + animPlayer:PlayOrPause(v.tracked) + end + + + end + end + + if(mappin.style ~= nil) then + + if(mappin.style.icon ~= nil) then + + local record = TweakDBInterface.GetUIIconRecord("ChoiceIcons."..mappin.style.icon) + if(record ~= nil) then + v.widget:SetTexturePart(record:AtlasPartName()) + v.widget:SetAtlasResource(record:AtlasResourcePath()) + end + + end + + if(mappin.style.color ~= nil) then + + this.iconWidget:SetTintColor(gamecolorStyle(mappin.style.color)) + end + end + + break + end + end end function MappinBaseController_SetRootVisible(this,mappin, mappinVariant, customData) - + - if(observerthread4 == true or moddisabled == true) then return end - local mappinType = mappin:GetVariant() - local wordpos = mappin:GetWorldPosition() - - for _,v in pairs(mappinManager) do - local mappin = v - if(mappin.position ~= nil and math.floor(mappin.position.x) == math.floor(wordpos.x) and math.floor(mappin.position.y) == math.floor(wordpos.y) and math.floor(mappin.position.z) == math.floor(wordpos.z)) then - v.mappinobj = mappin - break - end - end - - return result - + if(observerthread4 == true or moddisabled == true) then return end + local mappinType = mappin:GetVariant() + local wordpos = mappin:GetWorldPosition() + + for _,v in pairs(mappinManager) do + local mappin = v + if(mappin.position ~= nil and math.floor(mappin.position.x) == math.floor(wordpos.x) and math.floor(mappin.position.y) == math.floor(wordpos.y) and math.floor(mappin.position.z) == math.floor(wordpos.z)) then + v.mappinobj = mappin + break + end + end + + return result + end diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/player.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/player.lua index 44304f5..9e37776 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/player.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/player.lua @@ -1,84 +1,92 @@ function PlayerPuppet_ReactToHitProcess(thos,hitEvent) - if(observerthread3 == true or moddisabled == true) then return end - - --targetGodMode = GetImmortality(hitEvent.target) - if hitEvent.target:IsPlayer() == true then - --if (targetGodMode == gameGodModeType.Invulnerable or hitEvent.attackData:HasFlag(hitFlag.WasBlocked) or hitEvent.attackData:HasFlag(hitFlag.WasDeflected) or hitEvent.attackData:HasFlag(hitFlag.DealNoDamage) or hitEvent.attackData:HasFlag(hitFlag.DisableNPCHitReaction)) then - if (hitEvent.attackData:HasFlag(hitFlag.WasBlocked) or hitEvent.attackData:HasFlag(hitFlag.WasDeflected) or hitEvent.attackData:HasFlag(hitFlag.DealNoDamage) or hitEvent.attackData:HasFlag(hitFlag.DisableNPCHitReaction)) then - PlayerisHitten = false - else - PlayerisHitten = true - - end - end - - + if(observerthread3 == true or moddisabled == true) then return end + + --targetGodMode = GetImmortality(hitEvent.target) + if hitEvent.target:IsPlayer() == true then + --if (targetGodMode == gameGodModeType.Invulnerable or hitEvent.attackData:HasFlag(hitFlag.WasBlocked) or hitEvent.attackData:HasFlag(hitFlag.WasDeflected) or hitEvent.attackData:HasFlag(hitFlag.DealNoDamage) or hitEvent.attackData:HasFlag(hitFlag.DisableNPCHitReaction)) then + if (hitEvent.attackData:HasFlag(hitFlag.WasBlocked) or hitEvent.attackData:HasFlag(hitFlag.WasDeflected) or hitEvent.attackData:HasFlag(hitFlag.DealNoDamage) or hitEvent.attackData:HasFlag(hitFlag.DisableNPCHitReaction)) then + PlayerisHitten = false + else + PlayerisHitten = true + + end + end + + end function PlayerPuppet_SetEntityNoticedPlayerBBValue(thos,b) - if(observerthread3 == true or moddisabled == true) then return end - playerNoticed = b - --logme(10,"playerNoticed "..tostring(b)) + if(observerthread3 == true or moddisabled == true) then return end + playerNoticed = b + --logme(10,"playerNoticed "..tostring(b)) end function PlayerPuppet_OnBeingTarget(thos,evt) - if(observerthread3 == true or moddisabled == true) then return end - - if(evt.noLongerTarget == true) then - - local indextoremove = 0 - for i,v in ipairs(entityTargetPlayer) do - - if(evt.objectThatTargets:IsA("entEntity") and v:IsA("entEntity") and evt.objectThatTargets:GetEntityID()==v:GetEntityID()) then - - indextoremove = i - break - - end - - end - if indextoremove > 0 then - table.remove(entityTargetPlayer,indextoremove) - end - - - else - - local isalreadyinsert = true - pcall(function() - for i,v in ipairs(entityTargetPlayer) do - - - if(evt.objectThatTargets:IsA("entEntity") and evt.objectThatTargets:GetEntityID()==v:GetEntityID())then - isalreadyinsert = false - break - end - - - end - end) - if isalreadyinsert == true then - table.insert(entityTargetPlayer,evt.objectThatTargets) - end - end - - - playerTargeted = #entityTargetPlayer>0 - --logme(10,"playerTargeted "..tostring(playerTargeted)) + if(observerthread3 == true or moddisabled == true) then return end + + if(evt.noLongerTarget == true) then + + local indextoremove = 0 + for i,v in ipairs(entityTargetPlayer) do + + -- B-24 fix: evt.objectThatTargets or v can be stale/non-scriptable + -- during teardown, causing "Function 'IsA' context must be 'IScriptable'". + -- Wrap the IsA checks in pcall so a bad reference skips this iteration + -- instead of crashing the observer. + local match = false + pcall(function() + if(evt.objectThatTargets:IsA("entEntity") and v:IsA("entEntity") and evt.objectThatTargets:GetEntityID()==v:GetEntityID()) then + match = true + end + end) + if match then + indextoremove = i + break + end + + end + if indextoremove > 0 then + table.remove(entityTargetPlayer,indextoremove) + end + + + else + + local isalreadyinsert = true + pcall(function() + for i,v in ipairs(entityTargetPlayer) do + + + if(evt.objectThatTargets:IsA("entEntity") and evt.objectThatTargets:GetEntityID()==v:GetEntityID())then + isalreadyinsert = false + break + end + + + end + end) + if isalreadyinsert == true then + table.insert(entityTargetPlayer,evt.objectThatTargets) + end + end + + + playerTargeted = #entityTargetPlayer>0 + --logme(10,"playerTargeted "..tostring(playerTargeted)) end function PlayerPuppet_OnGameAttached(thos) - + - if(observerthread4 == true or moddisabled == true) then return end - GameController["PlayerPuppet"] = thos - startListeners(thos) + if(observerthread4 == true or moddisabled == true) then return end + GameController["PlayerPuppet"] = thos + startListeners(thos) end function PlayerPuppet_OnDeath() - + - if(observerthread4 == true or moddisabled == true) then return end - isdead = true + if(observerthread4 == true or moddisabled == true) then return end + isdead = true end diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/worldmap.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/worldmap.lua index 467b03d..059175f 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/worldmap.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/observers/worldmap.lua @@ -1,301 +1,318 @@ function BaseWorldMapMappinController_SelectMappin(self) - + - if(observerthread4 == true or moddisabled == true) then return end - - GameController["BaseWorldMapMappinController"] = self - if(self.mappin ~= nil and self:IsTracked() == true ) then - - if lastId ~= nil then Game.GetMappinSystem():SetMappinActive(lastId,true) end - SelectedMappinMetro = nil - SelectedScriptMappin = nil - SelectedMappinHouse = nil - ActivecustomMappin = nil - local mappinType = self.mappin:GetVariant() - local wordpos = self.mappin:GetWorldPosition() - - - - - local obj = {} - obj.id = 0 - obj.tag = "selected_mappin" - obj.position = self.mappin:GetWorldPosition() - obj.variant = tostring(mappinType) - obj.wall = true - obj.range = 0 - obj.active = true - obj.title = "" - obj.desc = "" - obj.style = {} - obj.style.color = nil - obj.style.icon = nil - - - if(mappinManager["selected_mappin"] == nil or (mappinManager["selected_mappin"]~= nil and mappinManager["selected_mappin"].position ~= self.mappin:GetWorldPosition())) then - mappinManager["selected_mappin"] = obj - - --print(dump(mappinManager["selected_mappin"].position)) - - end - if mappinType == gamedataMappinVariant.CustomPositionVariant then - - ActivecustomMappin = self.mappin - - local obj = {} - obj.id = 0 - obj.tag = "selected_user_mappin" - obj.position = self.mappin:GetWorldPosition() - obj.variant = tostring(mappinType) - obj.wall = true - obj.range = 0 - obj.active = true - obj.title = "" - obj.desc = "" - obj.style = {} - obj.style.color = nil - obj.style.icon = nil - - - - mappinManager["selected_user_mappin"] = obj - - end - - - if mappinType == gamedataMappinVariant.FastTravelVariant then - ActiveFastTravelMappin = {} - - ActiveFastTravelMappin.markerRef = self.mappin:GetPointData():GetMarkerRef() - ActiveFastTravelMappin.position = self.mappin:GetWorldPosition() - - local obj = {} - obj.id = 0 - obj.tag = "selected_fasttravel_mappin" - obj.position = self.mappin:GetWorldPosition() - obj.variant = "FastTravelVariant" - obj.wall = true - obj.range = 0 - obj.active = true - obj.title = "" - obj.desc = "" - obj.style = {} - obj.style.color = nil - obj.style.icon = nil - - - - mappinManager["selected_fasttravel_mappin"] = obj - - end - if( - mappinType == gamedataMappinVariant.ApartmentVariant or - mappinType == gamedataMappinVariant.Zzz05_ApartmentToPurchaseVariant or - mappinType == gamedataMappinVariant.ServicePointFoodVariant or - mappinType == gamedataMappinVariant.ServicePointBarVariant or - mappinType == gamedataMappinVariant.ServicePointJunkVariant) then - local haveFounded = false - -- local test = {} - - -- table.insert(test,cyberscript.cache["place"]["playerhouse01"]) - for _,v in pairs(cyberscript.cache["place"]) do - if(math.floor(v.data.x) == math.floor(wordpos.x) and math.floor(v.data.y) == math.floor(wordpos.y) and math.floor(v.data.z) == math.floor(wordpos.z)) then - SelectedMappinHouse = v.data - haveFounded = true - end - end - else - if(mappinType == gamedataMappinVariant.Zzz01_CarForPurchaseVariant) then - --logme(2,"Metro ?") - - local haveFounded = false - for k,v in pairs(cyberscript.cache["node"]) do - local mappin = v.data - if(mappin.sort == "metro") then - if(math.floor(mappin.GameplayX) == math.floor(wordpos.x) and math.floor(mappin.GameplayY) == math.floor(wordpos.y) and math.floor(mappin.GameplayZ) == math.floor(wordpos.z)) then - SelectedMappinMetro = mappin - haveFounded = true - --logme(2,"Mine") - break - end - end - end - else - - local haveFounded = false - - for k,v in pairs(mappinManager) do - local mappin = v - - if(k ~= "selected_mappin" and k ~= "selected_fasttravel_mappin" and mappin.position ~= nil and math.floor(mappin.position.x) == math.floor(wordpos.x) and math.floor(mappin.position.y) == math.floor(wordpos.y) and math.floor(mappin.position.z) == math.floor(wordpos.z)) then - - - SelectedScriptMappin = mappin - break - end - end - end - end - - else - - - if(self.mappin ~= nil) then - local wordpos = self.mappin:GetWorldPosition() - - - - for k,v in pairs(mappinManager) do - local mappin = v - - if(k ~= "selected_mappin" and k ~= "selected_fasttravel_mappin" and mappin.position ~= nil and math.floor(mappin.position.x) == math.floor(wordpos.x) and math.floor(mappin.position.y) == math.floor(wordpos.y) and math.floor(mappin.position.z) == math.floor(wordpos.z)) then - --print(k) - - SelectedScriptMappin = mappin - break - end - end - - end - - end + if(observerthread4 == true or moddisabled == true) then return end + + GameController["BaseWorldMapMappinController"] = self + if(self.mappin ~= nil and self:IsTracked() == true ) then + + if lastId ~= nil then Game.GetMappinSystem():SetMappinActive(lastId,true) end + SelectedMappinMetro = nil + SelectedScriptMappin = nil + SelectedMappinHouse = nil + ActivecustomMappin = nil + local mappinType = self.mappin:GetVariant() + local wordpos = self.mappin:GetWorldPosition() + + + + + local obj = {} + obj.id = 0 + obj.tag = "selected_mappin" + obj.position = self.mappin:GetWorldPosition() + obj.variant = tostring(mappinType) + obj.wall = true + obj.range = 0 + obj.active = true + obj.title = "" + obj.desc = "" + obj.style = {} + obj.style.color = nil + obj.style.icon = nil + + + if(mappinManager["selected_mappin"] == nil or (mappinManager["selected_mappin"]~= nil and mappinManager["selected_mappin"].position ~= self.mappin:GetWorldPosition())) then + mappinManager["selected_mappin"] = obj + + --print(dump(mappinManager["selected_mappin"].position)) + + end + if mappinType == gamedataMappinVariant.CustomPositionVariant then + + ActivecustomMappin = self.mappin + + local obj = {} + obj.id = 0 + obj.tag = "selected_user_mappin" + obj.position = self.mappin:GetWorldPosition() + obj.variant = tostring(mappinType) + obj.wall = true + obj.range = 0 + obj.active = true + obj.title = "" + obj.desc = "" + obj.style = {} + obj.style.color = nil + obj.style.icon = nil + + + + mappinManager["selected_user_mappin"] = obj + + end + + + if mappinType == gamedataMappinVariant.FastTravelVariant then + ActiveFastTravelMappin = {} + + ActiveFastTravelMappin.markerRef = self.mappin:GetPointData():GetMarkerRef() + ActiveFastTravelMappin.position = self.mappin:GetWorldPosition() + + local obj = {} + obj.id = 0 + obj.tag = "selected_fasttravel_mappin" + obj.position = self.mappin:GetWorldPosition() + obj.variant = "FastTravelVariant" + obj.wall = true + obj.range = 0 + obj.active = true + obj.title = "" + obj.desc = "" + obj.style = {} + obj.style.color = nil + obj.style.icon = nil + + + + mappinManager["selected_fasttravel_mappin"] = obj + + end + if( + mappinType == gamedataMappinVariant.ApartmentVariant or + mappinType == gamedataMappinVariant.Zzz05_ApartmentToPurchaseVariant or + mappinType == gamedataMappinVariant.ServicePointFoodVariant or + mappinType == gamedataMappinVariant.ServicePointBarVariant or + mappinType == gamedataMappinVariant.ServicePointJunkVariant) then + local haveFounded = false + -- local test = {} + + -- table.insert(test,cyberscript.cache["place"]["playerhouse01"]) + for _,v in pairs(cyberscript.cache["place"]) do + if(math.floor(v.data.x) == math.floor(wordpos.x) and math.floor(v.data.y) == math.floor(wordpos.y) and math.floor(v.data.z) == math.floor(wordpos.z)) then + SelectedMappinHouse = v.data + haveFounded = true + end + end + else + if(mappinType == gamedataMappinVariant.Zzz01_CarForPurchaseVariant) then + --logme(2,"Metro ?") + + local haveFounded = false + for k,v in pairs(cyberscript.cache["node"]) do + local mappin = v.data + if(mappin.sort == "metro") then + if(math.floor(mappin.GameplayX) == math.floor(wordpos.x) and math.floor(mappin.GameplayY) == math.floor(wordpos.y) and math.floor(mappin.GameplayZ) == math.floor(wordpos.z)) then + SelectedMappinMetro = mappin + haveFounded = true + --logme(2,"Mine") + break + end + end + end + else + + local haveFounded = false + + for k,v in pairs(mappinManager) do + local mappin = v + + if(k ~= "selected_mappin" and k ~= "selected_fasttravel_mappin" and mappin.position ~= nil and math.floor(mappin.position.x) == math.floor(wordpos.x) and math.floor(mappin.position.y) == math.floor(wordpos.y) and math.floor(mappin.position.z) == math.floor(wordpos.z)) then + + + SelectedScriptMappin = mappin + break + end + end + end + end + + else + + + if(self.mappin ~= nil) then + local wordpos = self.mappin:GetWorldPosition() + + + + for k,v in pairs(mappinManager) do + local mappin = v + + if(k ~= "selected_mappin" and k ~= "selected_fasttravel_mappin" and mappin.position ~= nil and math.floor(mappin.position.x) == math.floor(wordpos.x) and math.floor(mappin.position.y) == math.floor(wordpos.y) and math.floor(mappin.position.z) == math.floor(wordpos.z)) then + --print(k) + + SelectedScriptMappin = mappin + break + end + end + + end + + end end function WorldMapTooltipController_SetData(self,data,menu) - + - if(observerthread4 == true or moddisabled == true) then return end - local mappinVariant = nil - - if(data ~= nil) then - if( data.mappin ~= nil) then - - mappinVariant = data.mappin:GetVariant() - - end - - if mappinVariant ~= nil and mappinVariant == gamedataMappinVariant.FixerVariant and fixeroldText == nil then fixeroldText = self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):GetText() end - - - if(SelectedScriptMappin ~= nil) then - - if(mappinVariant ~= nil and mappinVariant == gamedataMappinVariant.FixerVariant and SelectedScriptMappin.tag ~= nil) then - - local fixer = getFixerByTag(SelectedScriptMappin.tag) - if(fixer ~= nil) then - -- self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):SetVisible(true) - -- self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(1):SetVisible(true) - - -- self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(2):SetVisible(false) - -- self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(3):SetVisible(false) - local datapack = cyberscript.cache["fixer"][SelectedScriptMappin.tag].datapack - self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):SetText(datapack.." Fixer") - - inkTextRef.SetText(self.gigBarCompletedText, "100") - inkTextRef.SetText(self.gigBarTotalText, "100") - self.gigProgress = 1 - - - inkWidgetRef.SetVisible(self.fixerPanel, true) - inkImageRef.SetVisible(self.icon, false) - - self.descText:SetText("") - - self:PlayAnim("OnTooltipIntro", "OnFixerProgressBarAnim"); - else - - end - else - inkImageRef.SetVisible(self.icon, true) - self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):SetText(fixeroldText) - - end - else - if(mappinVariant ~= nil and mappinVariant == gamedataMappinVariant.FixerVariant) then self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):SetText(fixeroldText) end - inkWidgetRef.SetVisible(self.icon, true) - end - - end + if(observerthread4 == true or moddisabled == true) then return end + local mappinVariant = nil + + -- B-15 fix: gate the gang-info / fixer world-map override behind an + -- opt-in user setting `world_map_gang_info_override`. v5.1.4 removed + -- this override; the code path was still present in the fork and ran + -- unconditionally. We preserve the fork's current behavior by defaulting + -- the setting to true, but downstream mods / users who want the + -- "removed" v5.1.4 behavior can set it to false in + -- user/settings/cyberscript.json. + local gangInfoOverride = true + if getUserSettingWithDefault then + gangInfoOverride = getUserSettingWithDefault("world_map_gang_info_override", true) + end + if gangInfoOverride ~= true then + -- Override disabled by user / downstream mod — skip the rest + -- of this function so the world map shows vanilla tooltips. + return + end + + if(data ~= nil) then + if( data.mappin ~= nil) then + + mappinVariant = data.mappin:GetVariant() + + end + + if mappinVariant ~= nil and mappinVariant == gamedataMappinVariant.FixerVariant and fixeroldText == nil then fixeroldText = self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):GetText() end + + + if(SelectedScriptMappin ~= nil) then + + if(mappinVariant ~= nil and mappinVariant == gamedataMappinVariant.FixerVariant and SelectedScriptMappin.tag ~= nil) then + + local fixer = getFixerByTag(SelectedScriptMappin.tag) + if(fixer ~= nil) then + -- self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):SetVisible(true) + -- self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(1):SetVisible(true) + + -- self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(2):SetVisible(false) + -- self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(3):SetVisible(false) + local datapack = cyberscript.cache["fixer"][SelectedScriptMappin.tag].datapack + self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):SetText(datapack.." Fixer") + + inkTextRef.SetText(self.gigBarCompletedText, "100") + inkTextRef.SetText(self.gigBarTotalText, "100") + self.gigProgress = 1 + + + inkWidgetRef.SetVisible(self.fixerPanel, true) + inkImageRef.SetVisible(self.icon, false) + + self.descText:SetText("") + + self:PlayAnim("OnTooltipIntro", "OnFixerProgressBarAnim"); + else + + end + else + inkImageRef.SetVisible(self.icon, true) + self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):SetText(fixeroldText) + + end + else + if(mappinVariant ~= nil and mappinVariant == gamedataMappinVariant.FixerVariant) then self.fixerPanel.widget:GetWidgetByIndex(1):GetWidgetByIndex(0):SetText(fixeroldText) end + inkWidgetRef.SetVisible(self.icon, true) + end + + end end function WorldMapTooltipContainer_SetData(self,target,data,menu) - + - if(observerthread4 == true or moddisabled == true) then return end - local displayXYZ = getUserSetting("displayXYZ") - local mappinVariant = nil - - if( data.mappin ~= nil) then - - mappinVariant = data.mappin:GetVariant() - - end - - if(SelectedMappinHouse ~= nil or SelectedMappinMetro ~= nil or SelectedScriptMappin ~= nil) then - inkWidgetRef.SetVisible(self.defaultTooltipController.descText, true) - if(SelectedMappinHouse ~= nil) then - inkTextRef.SetText(self.defaultTooltipController.titleText, SelectedMappinHouse.name) - local desc = getLang("bebought")..tostring(SelectedMappinHouse.isbuyable) - desc = desc.."\n"..getLang("price")..tostring(SelectedMappinHouse.price) - desc = desc.."\n"..getLang("canhavebusiness")..tostring(SelectedMappinHouse.isrentable) - desc = desc.."\n"..getLang("defaultsalary")..tostring(SelectedMappinHouse.rent) - desc = desc.."\n"..getLang("prestige")..tostring(SelectedMappinHouse.coef) - local position = ActivecustomMappin:GetWorldPosition() - local postext = "\n X :"..math.floor(position.x).." \n Y: "..math.floor(position.y).." \n Z: "..math.floor(position.z) - if(displayXYZ ~= nil and displayXYZ == 1) then - inkTextRef.SetText(self.defaultTooltipController.descText, desc..postext) - else - inkTextRef.SetText(self.defaultTooltipController.descText, desc) - end - SelectedMappinHouse = nil - elseif(SelectedMappinMetro ~= nil) then - inkTextRef.SetText(self.titleText, getLang("metro_station")..SelectedMappinMetro.name) - local desc = getLang("metro_available") - local position = ActivecustomMappin:GetWorldPosition() - local postext = "\n X :"..math.floor(position.x).." \n Y: "..math.floor(position.y).." \n Z: "..math.floor(position.z) - if(displayXYZ ~= nil and displayXYZ == 1) then - inkTextRef.SetText(self.defaultTooltipController.descText, desc..postext) - else - inkTextRef.SetText(self.defaultTooltipController.descText, desc) - end - SelectedMappinMetro = nil - elseif(SelectedScriptMappin ~= nil) then - - inkTextRef.SetText(self.defaultTooltipController.titleText, getLang(SelectedScriptMappin.title)) - inkTextRef.SetText(self.defaultTooltipController.descText, SelectedScriptMappin.desc) - if(ActivecustomMappin ~= nil) then - if(displayXYZ ~= nil and displayXYZ == 1) then - local position = ActivecustomMappin:GetWorldPosition() - local postext = "\n X :"..math.floor(position.x).." \n Y: "..math.floor(position.y).." \n Z: "..math.floor(position.z) - - inkTextRef.SetText(self.defaultTooltipController.descText, getLang(SelectedScriptMappin.desc)..postext) - else - inkTextRef.SetText(self.defaultTooltipController.descText, getLang(SelectedScriptMappin.desc)) - end - end - SelectedScriptMappin = nil - end - else - if(ActivecustomMappin ~= nil) then - local position = ActivecustomMappin:GetWorldPosition() - local postext = "\n X :"..math.floor(position.x).." \n Y: "..math.floor(position.y).." \n Z: "..math.floor(position.z) - if(displayXYZ ~= nil and displayXYZ == 1) then - inkWidgetRef.SetVisible(self.defaultTooltipController.descText, true) - inkTextRef.SetText(self.defaultTooltipController.descText, self.defaultTooltipController.descText:GetText()..postext) - end - end - end + if(observerthread4 == true or moddisabled == true) then return end + local displayXYZ = getUserSetting("displayXYZ") + local mappinVariant = nil + + if( data.mappin ~= nil) then + + mappinVariant = data.mappin:GetVariant() + + end + + if(SelectedMappinHouse ~= nil or SelectedMappinMetro ~= nil or SelectedScriptMappin ~= nil) then + inkWidgetRef.SetVisible(self.defaultTooltipController.descText, true) + if(SelectedMappinHouse ~= nil) then + inkTextRef.SetText(self.defaultTooltipController.titleText, SelectedMappinHouse.name) + local desc = getLang("bebought")..tostring(SelectedMappinHouse.isbuyable) + desc = desc.."\n"..getLang("price")..tostring(SelectedMappinHouse.price) + desc = desc.."\n"..getLang("canhavebusiness")..tostring(SelectedMappinHouse.isrentable) + desc = desc.."\n"..getLang("defaultsalary")..tostring(SelectedMappinHouse.rent) + desc = desc.."\n"..getLang("prestige")..tostring(SelectedMappinHouse.coef) + local position = ActivecustomMappin:GetWorldPosition() + local postext = "\n X :"..math.floor(position.x).." \n Y: "..math.floor(position.y).." \n Z: "..math.floor(position.z) + if(displayXYZ ~= nil and displayXYZ == 1) then + inkTextRef.SetText(self.defaultTooltipController.descText, desc..postext) + else + inkTextRef.SetText(self.defaultTooltipController.descText, desc) + end + SelectedMappinHouse = nil + elseif(SelectedMappinMetro ~= nil) then + inkTextRef.SetText(self.titleText, getLang("metro_station")..SelectedMappinMetro.name) + local desc = getLang("metro_available") + local position = ActivecustomMappin:GetWorldPosition() + local postext = "\n X :"..math.floor(position.x).." \n Y: "..math.floor(position.y).." \n Z: "..math.floor(position.z) + if(displayXYZ ~= nil and displayXYZ == 1) then + inkTextRef.SetText(self.defaultTooltipController.descText, desc..postext) + else + inkTextRef.SetText(self.defaultTooltipController.descText, desc) + end + SelectedMappinMetro = nil + elseif(SelectedScriptMappin ~= nil) then + + inkTextRef.SetText(self.defaultTooltipController.titleText, getLang(SelectedScriptMappin.title)) + inkTextRef.SetText(self.defaultTooltipController.descText, SelectedScriptMappin.desc) + if(ActivecustomMappin ~= nil) then + if(displayXYZ ~= nil and displayXYZ == 1) then + local position = ActivecustomMappin:GetWorldPosition() + local postext = "\n X :"..math.floor(position.x).." \n Y: "..math.floor(position.y).." \n Z: "..math.floor(position.z) + + inkTextRef.SetText(self.defaultTooltipController.descText, getLang(SelectedScriptMappin.desc)..postext) + else + inkTextRef.SetText(self.defaultTooltipController.descText, getLang(SelectedScriptMappin.desc)) + end + end + SelectedScriptMappin = nil + end + else + if(ActivecustomMappin ~= nil) then + local position = ActivecustomMappin:GetWorldPosition() + local postext = "\n X :"..math.floor(position.x).." \n Y: "..math.floor(position.y).." \n Z: "..math.floor(position.z) + if(displayXYZ ~= nil and displayXYZ == 1) then + inkWidgetRef.SetVisible(self.defaultTooltipController.descText, true) + inkTextRef.SetText(self.defaultTooltipController.descText, self.defaultTooltipController.descText:GetText()..postext) + end + end + end end function WorldMapMenuGameController_UntrackCustomPositionMappin(self) - + - if(observerthread4 == true or moddisabled == true) then return end - ActivecustomMappin = nil - --logme(2,"obs3") + if(observerthread4 == true or moddisabled == true) then return end + ActivecustomMappin = nil + --logme(2,"obs3") end diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/scripting.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/scripting.lua index 59f952d..ecb8690 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/scripting.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/scripting.lua @@ -15,1572 +15,1583 @@ mainrefreshstep7 = true mainrefreshstep8 = true function mainThread(active)-- update event when mod is ready and in game (main thread for execution) - - if active then - - - - --Pause Menu and Ambush timer - if(inMenu) then - if(GameController["SubtitlesGameController"] ~= nil) then - pcall(function() GameController["SubtitlesGameController"]:Cleanup() end) - end - - if(GameController["ChattersGameController"] ~= nil) then - pcall(function() GameController["ChattersGameController"]:Cleanup() end) - end - - if(open1menu == nil) then - - local activeData = CodexListSyncData.new() - local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) - if gameshardscompiled == nil then gameshardscompiled = {} end - for i,v in pairs(gameshards) do - if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end - - - end - - open1menu = true - end - - if(ActiveMenu == "PauseMenu" ) then - if(ExecPauseMenu == false and getUserSetting("AutoRefreshDatapack") == true) then - ExecPauseMenu = true - - loadModule() - - LoadDataPackCache() - - - end - else - if(ExecPauseMenu == true) then - ExecPauseMenu = false - end - end - else - open1menu = nil - if(ExecPauseMenu == true) then - ExecPauseMenu = false - end - - end - - - - - if mainrefreshstep1 then - --AutoAmbush (disable ambush event when MainQuest or SideQuest is active) - if (AutoAmbush == 1) then - -- MainQuest = 0, - -- SideQuest = 1, - -- MinorQuest = 2, - -- StreetStory = 3, - -- Contract = 4, - -- VehicleQuest = 5 - local objective = Game.GetJournalManager():GetTrackedEntry() - if objective ~= nil then - local phase = Game.GetJournalManager():GetParentEntry(objective) - local quest = Game.GetJournalManager():GetParentEntry(phase) - - if(string.match(tostring(quest:GetType()), "MainQuest") or string.match(tostring(quest:GetType()), "SideQuest"))then - if(AmbushEnabled ~= 0)then - AmbushEnabled = 0 - updateUserSetting("AmbushEnabled",AmbushEnabled) - end - else - if(AmbushEnabled ~= 1)then - AmbushEnabled = 1 - updateUserSetting("AmbushEnabled",AmbushEnabled) - end - end - - end - - end - - --refresh global variable - refreshModVariable(refreshModVariabletg) - --refresh widget controller - refreshUIWidgetController(true) - - - - - --Targeted entity - objLook = Game.GetTargetingSystem():GetLookAtObject(Game.GetPlayer(),false,false) - if(objLook ~= nil) then - pcall(function() - if(objLook ~= nil) then - - - - - if(objLook ~= nil) then - tarName = objLook:ToString() - -- logme(10,tostring(objLook:GetHighLevelStateFromBlackboard())) - if(string.match(tarName, "NPCPuppet"))then - -- objLook:MarkAsQuest(true) - -- logme(10,GameDump(objLook:GetCurrentOutline())) - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - targName = tostring(objLook:GetTweakDBDisplayName(true)) - openCompanion, gangscore, lookatgang = checkAttitudeByGangScore(objLook) - - - end - - local obj = getEntityFromManagerById(objLook:GetEntityID(),true) - - if(obj.id ~= nil and obj.tag ~= "lookatnpc") then - cyberscript.EntityManager["lookatentity"].tag = obj.tag - cyberscript.EntityManager["lookatnpc"].id = nil - cyberscript.EntityManager["lookatnpc"].tweak = "None" - if obj.isquest == nil then obj.isquest = false end - - objLook:MarkAsQuest(obj.isquest) - - else - - - cyberscript.EntityManager["lookatentity"].tag = "" - - if cyberscript.EntityManager["lookatnpc"].isquest == nil then cyberscript.EntityManager["lookatnpc"].isquest = false end - - objLook:MarkAsQuest(cyberscript.EntityManager["lookatnpc"].isquest) - - pcall(function () - if(objLook:GetRecordID() ~= nil and objLook:GetRecordID().hash ~= nil and cyberscript.entitieshash[tostring(objLook:GetRecordID().hash)] ~= nil) then - - - cyberscript.EntityManager["lookatnpc"].tweak = cyberscript.entitieshash[tostring(objLook:GetRecordID().hash)].entity_tweak - - end - end) - - -- cyberscript.EntityManager["lookatnpc"].id = nil - cyberscript.EntityManager["lookatnpc"].id = objLook:GetEntityID() - - end - - - - - - -- end - - objLookIsVehicule = objLook:IsVehicle() - local obj = getEntityFromManagerById(objLook:GetEntityID()) - - else - - openCompanion = false - objLookIsVehicule = false - end - else - - if(cyberscript.EntityManager["lookatnpc"].id ~= nil) then - cyberscript.EntityManager["lookatnpc"].id = nil - cyberscript.EntityManager["lookatnpc"].tweak = "None" - currentScannerItem = nil - cyberscript.EntityManager["lookatentity"].tag = "" - openCompanion = false - objLookIsVehicule = false - end - - - - end - end) - end - - - - - --Vehicle - local playerVehicule = Game.GetPlayer():GetQuickSlotsManager():GetVehicleObject() - - - - - if playerVehicule then - local filter = {"lookatnpc"} - local obj = searchEntityFromManagerById(playerVehicule:GetEntityID(), filter) - - if(cyberscript.EntityManager["current_car"].id == nil or cyberscript.EntityManager["current_car"].id.hash ~= playerVehicule:GetEntityID().hash) then - cyberscript.EntityManager["current_car"].id = playerVehicule:GetEntityID() - print("save car") - end - - if obj.tag and cyberscript.EntityManager["current_car"].id ~= obj.id then - - cyberscript.EntityManager["current_car"].tag = obj.tag - - else - cyberscript.EntityManager["current_car"].tag = "current_car" - - end - - - else - if cyberscript.EntityManager["current_car"].id then - cyberscript.EntityManager["current_car"].id = nil - cyberscript.EntityManager["current_car"].tag = "" - print("desave car") - end - end - - - end - - - if mainrefreshstep3 then - --POI Correction (deprecated) - if wantcorrectpoi == true then - - CorrectAllPOI() - - end - - end - - if mainrefreshstep4 then - --Ambush - if (tick % (AmbushMin*60*60) == 0) then --every X second - - if(isEmpty(cyberscript.cache["event"]) == false) then - checkAmbush() - end - - end - - --Timer - if(currentTimer ~= nil) then - - ticktimer = ticktimer +1 - local texttimer = currentTimer.message.." : "..tostring(math.ceil((ticktimer/60))).." seconds" - - if(currentTimer.type == "remaning") then - - - texttimer = currentTimer.message.." : "..tostring(currentTimer.value - math.ceil((ticktimer/60))).." seconds" - - - - end - - setVariable("current_timer","text",texttimer) - - else - setVariable("current_timer","text","") - end - - - end - - if mainrefreshstep5 then - --Timers - if (tick % 6 == 0) then --every 0.5 second - if itemsdirectmod ~= nil and itemsdirectmod.state == true then - - -- playerPos, playerAngle = targetS:GetCrosshairData(Game.GetPlayer()) - -- playerFootPos = Game.GetPlayer():GetWorldPosition() - -- playerPos.z = playerPos.z+0.5 - -- playerDeltaWorldPos = Delta(playerPos, playerFootPos) - -- playerDeltaWorldPos.w = 1 - -- if (playerOldPos == nil) then - -- playerOldPos = playerPos - -- end - -- playerDeltaPos = Delta(playerOldPos, playerPos) - -- phi = math.atan2(playerAngle.y, playerAngle.x) - -- -- if (objPush == true) then - -- -- objectDist = objectDist + 0.5 - -- -- objPush = false - -- -- end - -- -- if (objPull == true) then - -- -- objectDist = objectDist - 0.5 - -- -- objPull = false - -- -- end - -- poss = Vector4.new(((objectDist * math.cos(phi)) + playerPos.x), ((objectDist * math.sin(phi)) + playerPos.y), (objectDist * math.sin(playerAngle.z) + playerPos.z),1) - -- --poss = Vector4Add(targetDeltaPos, poss) - local offset = {} - local testts, playerAngle = targetS:GetCrosshairData(Game.GetPlayer()) - offset.x = -0.5 - offset.y = 2 - offset.z = 1 - local offsetpos = getForwardPosition2(Game.GetPlayer(),3,offset) - print("offsetpos"..dump(offsetpos)) - local poss = offsetpos - poss.z = poss.z + offset.z + playerAngle.z - print(dump(poss)) - -- poss.x = poss.x + playerDeltaPos.x - -- poss.y = poss.y + playerDeltaPos.y - -- poss.z = poss.z + playerDeltaPos.z - - -- print(dump(poss)) - local angless = Game.GetPlayer():GetWorldOrientation():ToEulerAngles() - --local angless = EulerAngles.new(itemsdirectmod.target.Roll, itemsdirectmod.target.Pitch, itemsdirectmod.target.Yaw) - - - if(itemsdirectmod.target.X ~= poss.x and itemsdirectmod.target.Y ~= poss.y ) then - - updateItemPosition(itemsdirectmod.target, poss, angless, true) - - end - - - - - - end - - - if(isEmpty(arrayBoundedEntity) == false) then - for k,v in pairs(arrayBoundedEntity) do - - - - local obj = getEntityFromManager(k) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - local anchorobj = getEntityFromManager(v.anchor) - local anchorenti = Game.FindEntityByID(anchorobj.id) - if(anchorenti ~= nil) then - - local position = anchorenti:GetWorldPosition() - - local qat = anchorenti:GetWorldOrientation() - local rotation = GetSingleton('Quaternion'):ToEulerAngles(qat) - - if(v.copyrotation == false) then - - qat = enti:GetWorldOrientation() - rotation = GetSingleton('Quaternion'):ToEulerAngles(qat) - - end - - - - - - local isplayer = false - if k == "player" then - isplayer = true - end - - position.x = position.x + v.x - position.y = position.y + v.y - position.z = position.z + v.z - - rotation.yaw = rotation.yaw + v.yaw - rotation.pitch = rotation.pitch + v.pitch - rotation.roll = rotation.roll + v.roll - - if( - ( - arrayBoundedEntity[k].lastposition.x ~= position.x or - arrayBoundedEntity[k].lastposition.y ~= position.y or - arrayBoundedEntity[k].lastposition.z ~= position.z - ) - or - ( - v.copyrotation == true and ( - - arrayBoundedEntity[k].lastorientation.yaw ~= rotation.yaw or - arrayBoundedEntity[k].lastorientation.pitch ~= rotation.pitch or - arrayBoundedEntity[k].lastorientation.roll ~= rotation.roll - ) - ) - - - ) then - - - arrayBoundedEntity[k].lastposition.x = position.x - arrayBoundedEntity[k].lastposition.y = position.y - arrayBoundedEntity[k].lastposition.z = position.z - - - - arrayBoundedEntity[k].lastorientation.yaw = rotation.yaw - arrayBoundedEntity[k].lastorientation.pitch = rotation.pitch - arrayBoundedEntity[k].lastorientation.roll = rotation.roll - - - - if(v.isitem == true) then - local item = {} - - enti:GetEntity():Destroy() - - local transform = Game.GetPlayer():GetWorldTransform() - transform:SetPosition(position) - transform:SetOrientationEuler(rotation) - cyberscript.EntityManager[k].id = exEntitySpawner.Spawn(obj.tweak, transform) - - else - - teleportTo(objlook, position, rotation, isplayer) - end - - - - end - - - end - - else - - --arrayBoundedEntity[k] = nil - - end - - - end - end - --TweakDB:SetFlat("PreventionSystem.setup.totalEntitiesLimit", 999999) - --POI Location - if(getUserSetting("AutoCheckPOI") == true) then - - currentPOI = FindPOI("",getVariableKey("current_district","enum"),getVariableKey("current_district","subdistrict_enum"),inVehicule,nil,false,true,getUserSetting("CurrentPOIDetectionRange"),nil,nil,nil,"district","near") - - end - refreshUIWidget() - - if curPos ~= nil and displayHUD["main_root_default"] ~= nil then - - - - - - for k,v in pairs(cyberscript.cache["hud"]) do - if(v.data.requirement == nil or checkTriggerRequirement(v.data.requirement,v.data.trigger))then - if(v.data.type == "widget" or v.data.type == "container")then - - checkContext(v.data) - - end - if(v.data.type == "widget" and displayHUD[k] ~= nil) then - - displayHUD[k]:SetText(v.data.text) - displayHUD[k]:SetFontFamily(v.data.fontfamily) - displayHUD[k]:SetFontStyle(v.data.fontstyle) - displayHUD[k]:SetFontSize(v.data.fontsize) - displayHUD[k]:SetTintColor(gamecolor(v.data.color.red,v.data.color.green,v.data.color.blue,1)) - displayHUD[k]:SetMargin(inkMargin.new({ top = v.data.margin.top, left = v.data.margin.left})) - displayHUD[k]:SetVisible(v.data.visible) - - end - - if(v.data.type == "container" and displayHUD[k] ~= nil) then - - displayHUD[k]:SetMargin(inkMargin.new({ top = v.data.margin.top, left = v.data.margin.left})) - - displayHUD[k]:SetVisible(v.data.visible) - - - end - end - - end - - - for k,v in pairs(cyberscript.cache["hud"]) do - if(v.data.type == "theme" )then - - if(v.data.theme ~= nil) then - for i,thme in ipairs(v.data.theme) do - - if( displayHUD[thme.target] ~= nil) then - - - if(thme.requirement == nil or checkTriggerRequirement(thme.requirement,thme.trigger))then - checkContext(thme) - - - - - if(thme.fontfamily ~= nil) then displayHUD[thme.target]:SetFontFamily(thme.fontfamily) end - if(thme.fontstyle ~= nil) then displayHUD[thme.target]:SetFontStyle(thme.fontstyle) end - if(thme.fontsize ~= nil) then displayHUD[thme.target]:SetFontSize(thme.fontsize) end - if(thme.color ~= nil) then displayHUD[thme.target]:SetTintColor(gamecolor(thme.color.red,thme.color.green,thme.color.blue,1)) end - if(thme.margin ~= nil) then displayHUD[thme.target]:SetMargin(inkMargin.new({ top = thme.margin.top, left = thme.margin.left})) end - if(thme.text ~= nil) then displayHUD[thme.target]:SetText(thme.text) end - if(thme.visible ~= nil) then displayHUD[thme.target]:SetVisible(thme.visible) end - if(thme.anchor ~= nil) then displayHUD[thme.target]:SetAnchor(thme.anchor) end - if(thme.parent ~= nil) then displayHUD[thme.target]:Reparent(displayHUD[thme.parent]) end - if(thme.scrollspeed ~= nil) then displayHUD[thme.target]:SetScrollTextSpeed(thme.scrollspeed) end - end - end - - end - - else - if( displayHUD[v.data.target] ~= nil) then - if(v.data.requirement == nil or checkTriggerRequirement(v.data.requirement,v.data.trigger))then - checkContext(v.data) - - if(v.data.fontfamily ~= nil) then displayHUD[v.data.target]:SetFontFamily(v.data.fontfamily) end - if(v.data.fontstyle ~= nil) then displayHUD[v.data.target]:SetFontStyle(v.data.fontstyle) end - if(v.data.fontsize ~= nil) then displayHUD[v.data.target]:SetFontSize(v.data.fontsize) end - if(v.data.color ~= nil) then displayHUD[v.data.target]:SetTintColor(gamecolor(v.data.color.red,v.data.color.green,v.data.color.blue,1)) end - if(v.data.margin ~= nil) then displayHUD[v.data.target]:SetMargin(inkMargin.new({ top = v.data.margin.top, left = v.data.margin.left})) end - if(v.data.text ~= nil) then displayHUD[v.data.target]:SetText(v.data.text) end - if(v.data.visible ~= nil) then displayHUD[v.data.target]:SetVisible(v.data.visible) end - if(v.data.anchor ~= nil) then displayHUD[v.data.target]:SetAnchor(v.data.anchor) end - if(v.data.parent ~= nil) then displayHUD[v.data.target]:Reparent(v.data.parent) end - if(v.data.scrollspeed ~= nil) then displayHUD[v.data.target]:SetScrollTextSpeed(v.data.scrollspeed) end - end - end - end - - - - end - end - - - if(currentDistricts2 ~= nil)then - - - - - - if(displayHUD["factionwidget"]~= nil)then - displayHUD["factionwidget"]:RemoveAllChildren() - - displayHUD["factionwidget"]:SetVisible(((not inScanner) and GameController["HUDManager"].state == HUDState.ACTIVATED )) - - if(currentDistricts2.districtLabels ~= nil and #currentDistricts2.districtLabels > 0) then - local gangslist = {} - if(#currentDistricts2.districtLabels > 1) then - local gangs = getGangfromDistrict(currentDistricts2.districtLabels[2],20) - - if(#gangs > 0) then - for i=1,#gangs do - if(getScoreKey("Affinity",gangs[i].tag) ~= nil) then - table.insert(gangslist,gangs[i]) - - end - end - end - else - local gangs = getGangfromDistrict(currentDistricts2.districtLabels[1],20) - - if(#gangs > 0) then - for i=1,#gangs do - if(getScoreKey("Affinity",gangs[i].tag) ~= nil) then - table.insert(gangslist,gangs[i]) - - end - end - end - - end - - if(#gangslist > 0) then - for i,v in ipairs(gangslist) do - - - local gang = getFactionByTag(v.tag) - - local top = (i*50) - locationWidgetPlace_top = locationWidgetFactionDisctrict_top + (i*50) + 50 - - local isleader = (i==1) - - displayGangScoreWidget(getScoreKey("Affinity",v.tag),gang.name,displayHUD["factionwidget"],top,isleader) - - - end - - end - - - - end - - end - - - - - end - - if displayHUD["main_root_default"].name ~= nil and displayHUD["main_root_default"]:IsA('inkWidget') then - - displayHUD["main_root_default"]:SetVisible(true) - - - - - - - end - - else - if displayHUD["main_root_default"] ~= nil then - - for k,v in pairs(cyberscript.cache["hud"]) do - if(v.data.requirement == nil or checkTriggerRequirement(v.data.requirement,v.data.trigger))then - if(v.data.type == "widget" or v.data.type == "container")then - - checkContext(v.data) - - end - if(v.data.type == "widget" and displayHUD[k] ~= nil and displayHUD[k].visible == true) then - - - displayHUD[k]:SetVisible(false) - - end - - if(v.data.type == "container" and displayHUD[k] ~= nil) then - - - displayHUD[k]:SetVisible(v.data.visible) - - - end - end - - end - displayHUD["main_root_default"]:SetVisible(false) - end - - - end - - if(isEmpty(cyberscript.soundmanager) == false) then - for k,v in pairs(cyberscript.soundmanager) do - - if(v.isplaying == true and v.endplaying ~=nil) then - - if( os.time(os.date("!*t")) >=v.endplaying+1) then - - if(v.needrepeat == false) then - - Stop(v.tag) - - else - - local obj = deepcopy(v,nil) - Stop(v.tag) - PlaySound(obj.tag,obj.isradio,obj.needrepeat) - - - end - end - - - end - - - - end - end - - if(isEmpty(cyberscript.EntityManager) == false) then - for k,v in pairs(cyberscript.EntityManager) do - - if(v.spawntimespan ~= nil and v.spawntimespan ~= v.despawntimespan) then - - if( os.time(os.date("!*t"))+1 >=v.despawntimespan) then - - despawnEntity(k) - end - - - end - - - - end - end - - end - end - - if mainrefreshstep6 then - if (tick % 60 == 0) then --every 1 second - if(isEmpty(cyberscript.cache["event"]) == false) then - doTriggeredEvent() - end - - if(isEmpty(cyberscript.cache["npc"]) == false) then - checkNPC() - - end - - if(isEmpty(cyberscript.cache["fixer"]) == false) then - checkFixer() - end - - if activeMetroDisplay == true then - MetroCurrentTime = MetroCurrentTime - 1 - logme(10,MetroCurrentTime) - if MetroCurrentTime <= 0 then - activeMetroDisplay = false - end - end - - for k,v in pairs(AIhandler) do - - local cacheaiLoadinganswer = GetAnswer(k) - - if(cacheaiLoadinganswer ~= nil and cacheaiLoadinganswer ~= "") then - logme(1,k) - logme(1,cacheaiLoadinganswer) - AIhandler[k].answer = cacheaiLoadinganswer - - end - end - - - end - end - - if mainrefreshstep7 then - if (tick % 120 == 0) then --every 2 second - playRadio() - -- if(GameController["PhoneHotkeyController"] ~= nil) then - -- PhoneHotkeyController_UpdateData(GameController["PhoneHotkeyController"]) - -- end - end - end - - if mainrefreshstep8 then - if (tick % 180 == 0) then --every 3 second - - - - - if(npcStarSpawn) then - if(timerDespawn ~= nil) then - local currentime = getGameTime() - if(currentime.day > timerDespawn.day or currentime.hour > timerDespawn.hour) then - despawnEntity("current_star") - timerDespawn = nil - npcStarSpawn = nil - end - end - end - end - - - if (tick % 1800 == 0) then --every 30 second - - - local activeData = CodexListSyncData.new() - local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) - if gameshardscompiled == nil then gameshardscompiled = {} end - for i,v in pairs(gameshards) do - if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end - - - end - end - - end - - - - - -- if(collectgarbage("count") > 500000) then - - -- collectgarbage("collect") - -- end - end - - + + if active then + + + + --Pause Menu and Ambush timer + if(inMenu) then + if(GameController["SubtitlesGameController"] ~= nil) then + pcall(function() GameController["SubtitlesGameController"]:Cleanup() end) + end + + if(GameController["ChattersGameController"] ~= nil) then + pcall(function() GameController["ChattersGameController"]:Cleanup() end) + end + + if(open1menu == nil) then + + local activeData = CodexListSyncData.new() + local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) + if gameshardscompiled == nil then gameshardscompiled = {} end + for i,v in pairs(gameshards) do + if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end + + + end + + open1menu = true + end + + if(ActiveMenu == "PauseMenu" ) then + if(ExecPauseMenu == false and getUserSetting("AutoRefreshDatapack") == true) then + ExecPauseMenu = true + + loadModule() + + LoadDataPackCache() + + + end + else + if(ExecPauseMenu == true) then + ExecPauseMenu = false + end + end + else + open1menu = nil + if(ExecPauseMenu == true) then + ExecPauseMenu = false + end + + end + + + + + if mainrefreshstep1 then + --AutoAmbush (disable ambush event when MainQuest or SideQuest is active) + if (AutoAmbush == 1) then + -- MainQuest = 0, + -- SideQuest = 1, + -- MinorQuest = 2, + -- StreetStory = 3, + -- Contract = 4, + -- VehicleQuest = 5 + local objective = Game.GetJournalManager():GetTrackedEntry() + if objective ~= nil then + local phase = Game.GetJournalManager():GetParentEntry(objective) + local quest = Game.GetJournalManager():GetParentEntry(phase) + + if(string.match(tostring(quest:GetType()), "MainQuest") or string.match(tostring(quest:GetType()), "SideQuest"))then + if(AmbushEnabled ~= 0)then + AmbushEnabled = 0 + updateUserSetting("AmbushEnabled",AmbushEnabled) + end + else + if(AmbushEnabled ~= 1)then + AmbushEnabled = 1 + updateUserSetting("AmbushEnabled",AmbushEnabled) + end + end + + end + + end + + --refresh global variable + -- Guard: refreshModVariable can fire before initCore completes + -- (race condition), which throws "arrayDistricts is nil" and + -- "EntityManager is nil" every frame. Skip if init hasn't finished. + if cyberscript and cyberscript.EntityManager and arrayDistricts then + refreshModVariable(refreshModVariabletg) + end + --refresh widget controller + refreshUIWidgetController(true) + + + + + --Targeted entity + objLook = Game.GetTargetingSystem():GetLookAtObject(Game.GetPlayer(),false,false) + if(objLook ~= nil) then + pcall(function() + if(objLook ~= nil) then + + + + + if(objLook ~= nil) then + tarName = objLook:ToString() + -- logme(10,tostring(objLook:GetHighLevelStateFromBlackboard())) + if(string.match(tarName, "NPCPuppet"))then + -- objLook:MarkAsQuest(true) + -- logme(10,GameDump(objLook:GetCurrentOutline())) + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + targName = tostring(objLook:GetTweakDBDisplayName(true)) + openCompanion, gangscore, lookatgang = checkAttitudeByGangScore(objLook) + + + end + + local obj = getEntityFromManagerById(objLook:GetEntityID(),true) + + if(obj.id ~= nil and obj.tag ~= "lookatnpc") then + cyberscript.EntityManager["lookatentity"].tag = obj.tag + cyberscript.EntityManager["lookatnpc"].id = nil + cyberscript.EntityManager["lookatnpc"].tweak = "None" + if obj.isquest == nil then obj.isquest = false end + + objLook:MarkAsQuest(obj.isquest) + + else + + + cyberscript.EntityManager["lookatentity"].tag = "" + + if cyberscript.EntityManager["lookatnpc"].isquest == nil then cyberscript.EntityManager["lookatnpc"].isquest = false end + + objLook:MarkAsQuest(cyberscript.EntityManager["lookatnpc"].isquest) + + pcall(function () + if(objLook:GetRecordID() ~= nil and objLook:GetRecordID().hash ~= nil and cyberscript.entitieshash[tostring(objLook:GetRecordID().hash)] ~= nil) then + + + cyberscript.EntityManager["lookatnpc"].tweak = cyberscript.entitieshash[tostring(objLook:GetRecordID().hash)].entity_tweak + + end + end) + + -- cyberscript.EntityManager["lookatnpc"].id = nil + cyberscript.EntityManager["lookatnpc"].id = objLook:GetEntityID() + + end + + + + + + -- end + + objLookIsVehicule = objLook:IsVehicle() + local obj = getEntityFromManagerById(objLook:GetEntityID()) + + else + + openCompanion = false + objLookIsVehicule = false + end + else + + if(cyberscript.EntityManager["lookatnpc"].id ~= nil) then + cyberscript.EntityManager["lookatnpc"].id = nil + cyberscript.EntityManager["lookatnpc"].tweak = "None" + currentScannerItem = nil + cyberscript.EntityManager["lookatentity"].tag = "" + openCompanion = false + objLookIsVehicule = false + end + + + + end + end) + end + + + + + --Vehicle + -- Guard: cyberscript.EntityManager may be nil if mainThread fires + -- before initCore completes (race condition). Skip the ENTIRE + -- vehicle tracking block until EntityManager is ready. + local playerVehicule = nil + if cyberscript and cyberscript.EntityManager and cyberscript.EntityManager["current_car"] then + playerVehicule = Game.GetPlayer():GetQuickSlotsManager():GetVehicleObject() + end + + + + + if playerVehicule then + local filter = {"lookatnpc"} + local obj = searchEntityFromManagerById(playerVehicule:GetEntityID(), filter) + + if(cyberscript.EntityManager["current_car"].id == nil or cyberscript.EntityManager["current_car"].id.hash ~= playerVehicule:GetEntityID().hash) then + cyberscript.EntityManager["current_car"].id = playerVehicule:GetEntityID() + print("save car") + end + + if obj.tag and cyberscript.EntityManager["current_car"].id ~= obj.id then + + cyberscript.EntityManager["current_car"].tag = obj.tag + + else + cyberscript.EntityManager["current_car"].tag = "current_car" + + end + + + elseif cyberscript and cyberscript.EntityManager and cyberscript.EntityManager["current_car"] then + if cyberscript.EntityManager["current_car"].id then + cyberscript.EntityManager["current_car"].id = nil + cyberscript.EntityManager["current_car"].tag = "" + print("desave car") + end + end + + + end + + + if mainrefreshstep3 then + --POI Correction (deprecated) + if wantcorrectpoi == true then + + CorrectAllPOI() + + end + + end + + if mainrefreshstep4 then + --Ambush + if (tick % (AmbushMin*60*60) == 0) then --every X second + + if(isEmpty(cyberscript.cache["event"]) == false) then + checkAmbush() + end + + end + + --Timer + if(currentTimer ~= nil) then + + ticktimer = ticktimer +1 + local texttimer = currentTimer.message.." : "..tostring(math.ceil((ticktimer/60))).." seconds" + + if(currentTimer.type == "remaning") then + + + texttimer = currentTimer.message.." : "..tostring(currentTimer.value - math.ceil((ticktimer/60))).." seconds" + + + + end + + setVariable("current_timer","text",texttimer) + + else + setVariable("current_timer","text","") + end + + + end + + if mainrefreshstep5 then + --Timers + if (tick % 6 == 0) then --every 0.5 second + if itemsdirectmod ~= nil and itemsdirectmod.state == true then + + -- playerPos, playerAngle = targetS:GetCrosshairData(Game.GetPlayer()) + -- playerFootPos = Game.GetPlayer():GetWorldPosition() + -- playerPos.z = playerPos.z+0.5 + -- playerDeltaWorldPos = Delta(playerPos, playerFootPos) + -- playerDeltaWorldPos.w = 1 + -- if (playerOldPos == nil) then + -- playerOldPos = playerPos + -- end + -- playerDeltaPos = Delta(playerOldPos, playerPos) + -- phi = math.atan2(playerAngle.y, playerAngle.x) + -- -- if (objPush == true) then + -- -- objectDist = objectDist + 0.5 + -- -- objPush = false + -- -- end + -- -- if (objPull == true) then + -- -- objectDist = objectDist - 0.5 + -- -- objPull = false + -- -- end + -- poss = Vector4.new(((objectDist * math.cos(phi)) + playerPos.x), ((objectDist * math.sin(phi)) + playerPos.y), (objectDist * math.sin(playerAngle.z) + playerPos.z),1) + -- --poss = Vector4Add(targetDeltaPos, poss) + local offset = {} + local testts, playerAngle = targetS:GetCrosshairData(Game.GetPlayer()) + offset.x = -0.5 + offset.y = 2 + offset.z = 1 + local offsetpos = getForwardPosition2(Game.GetPlayer(),3,offset) + print("offsetpos"..dump(offsetpos)) + local poss = offsetpos + poss.z = poss.z + offset.z + playerAngle.z + print(dump(poss)) + -- poss.x = poss.x + playerDeltaPos.x + -- poss.y = poss.y + playerDeltaPos.y + -- poss.z = poss.z + playerDeltaPos.z + + -- print(dump(poss)) + local angless = Game.GetPlayer():GetWorldOrientation():ToEulerAngles() + --local angless = EulerAngles.new(itemsdirectmod.target.Roll, itemsdirectmod.target.Pitch, itemsdirectmod.target.Yaw) + + + if(itemsdirectmod.target.X ~= poss.x and itemsdirectmod.target.Y ~= poss.y ) then + + updateItemPosition(itemsdirectmod.target, poss, angless, true) + + end + + + + + + end + + + if(isEmpty(arrayBoundedEntity) == false) then + for k,v in pairs(arrayBoundedEntity) do + + + + local obj = getEntityFromManager(k) + local enti = safeFindEntityByID(obj.id) + if(enti ~= nil) then + + local anchorobj = getEntityFromManager(v.anchor) + local anchorenti = safeFindEntityByID(anchorobj.id) + if(anchorenti ~= nil) then + + local position = anchorenti:GetWorldPosition() + + local qat = anchorenti:GetWorldOrientation() + local rotation = GetSingleton('Quaternion'):ToEulerAngles(qat) + + if(v.copyrotation == false) then + + qat = enti:GetWorldOrientation() + rotation = GetSingleton('Quaternion'):ToEulerAngles(qat) + + end + + + + + + local isplayer = false + if k == "player" then + isplayer = true + end + + position.x = position.x + v.x + position.y = position.y + v.y + position.z = position.z + v.z + + rotation.yaw = rotation.yaw + v.yaw + rotation.pitch = rotation.pitch + v.pitch + rotation.roll = rotation.roll + v.roll + + if( + ( + arrayBoundedEntity[k].lastposition.x ~= position.x or + arrayBoundedEntity[k].lastposition.y ~= position.y or + arrayBoundedEntity[k].lastposition.z ~= position.z + ) + or + ( + v.copyrotation == true and ( + + arrayBoundedEntity[k].lastorientation.yaw ~= rotation.yaw or + arrayBoundedEntity[k].lastorientation.pitch ~= rotation.pitch or + arrayBoundedEntity[k].lastorientation.roll ~= rotation.roll + ) + ) + + + ) then + + + arrayBoundedEntity[k].lastposition.x = position.x + arrayBoundedEntity[k].lastposition.y = position.y + arrayBoundedEntity[k].lastposition.z = position.z + + + + arrayBoundedEntity[k].lastorientation.yaw = rotation.yaw + arrayBoundedEntity[k].lastorientation.pitch = rotation.pitch + arrayBoundedEntity[k].lastorientation.roll = rotation.roll + + + + if(v.isitem == true) then + local item = {} + + enti:GetEntity():Destroy() + + local transform = Game.GetPlayer():GetWorldTransform() + transform:SetPosition(position) + transform:SetOrientationEuler(rotation) + cyberscript.EntityManager[k].id = exEntitySpawner.Spawn(obj.tweak, transform) + + else + + teleportTo(objlook, position, rotation, isplayer) + end + + + + end + + + end + + else + + --arrayBoundedEntity[k] = nil + + end + + + end + end + --TweakDB:SetFlat("PreventionSystem.setup.totalEntitiesLimit", 999999) + --POI Location + if(getUserSetting("AutoCheckPOI") == true) then + + currentPOI = FindPOI("",getVariableKey("current_district","enum"),getVariableKey("current_district","subdistrict_enum"),inVehicule,nil,false,true,getUserSetting("CurrentPOIDetectionRange"),nil,nil,nil,"district","near") + + end + refreshUIWidget() + + if curPos ~= nil and displayHUD["main_root_default"] ~= nil then + + + + + + for k,v in pairs(cyberscript.cache["hud"]) do + if(v.data.requirement == nil or checkTriggerRequirement(v.data.requirement,v.data.trigger))then + if(v.data.type == "widget" or v.data.type == "container")then + + checkContext(v.data) + + end + if(v.data.type == "widget" and displayHUD[k] ~= nil) then + + displayHUD[k]:SetText(v.data.text) + displayHUD[k]:SetFontFamily(v.data.fontfamily) + displayHUD[k]:SetFontStyle(v.data.fontstyle) + displayHUD[k]:SetFontSize(v.data.fontsize) + displayHUD[k]:SetTintColor(gamecolor(v.data.color.red,v.data.color.green,v.data.color.blue,1)) + displayHUD[k]:SetMargin(inkMargin.new({ top = v.data.margin.top, left = v.data.margin.left})) + displayHUD[k]:SetVisible(v.data.visible) + + end + + if(v.data.type == "container" and displayHUD[k] ~= nil) then + + displayHUD[k]:SetMargin(inkMargin.new({ top = v.data.margin.top, left = v.data.margin.left})) + + displayHUD[k]:SetVisible(v.data.visible) + + + end + end + + end + + + for k,v in pairs(cyberscript.cache["hud"]) do + if(v.data.type == "theme" )then + + if(v.data.theme ~= nil) then + for i,thme in ipairs(v.data.theme) do + + if( displayHUD[thme.target] ~= nil) then + + + if(thme.requirement == nil or checkTriggerRequirement(thme.requirement,thme.trigger))then + checkContext(thme) + + + + + if(thme.fontfamily ~= nil) then displayHUD[thme.target]:SetFontFamily(thme.fontfamily) end + if(thme.fontstyle ~= nil) then displayHUD[thme.target]:SetFontStyle(thme.fontstyle) end + if(thme.fontsize ~= nil) then displayHUD[thme.target]:SetFontSize(thme.fontsize) end + if(thme.color ~= nil) then displayHUD[thme.target]:SetTintColor(gamecolor(thme.color.red,thme.color.green,thme.color.blue,1)) end + if(thme.margin ~= nil) then displayHUD[thme.target]:SetMargin(inkMargin.new({ top = thme.margin.top, left = thme.margin.left})) end + if(thme.text ~= nil) then displayHUD[thme.target]:SetText(thme.text) end + if(thme.visible ~= nil) then displayHUD[thme.target]:SetVisible(thme.visible) end + if(thme.anchor ~= nil) then displayHUD[thme.target]:SetAnchor(thme.anchor) end + if(thme.parent ~= nil) then displayHUD[thme.target]:Reparent(displayHUD[thme.parent]) end + if(thme.scrollspeed ~= nil) then displayHUD[thme.target]:SetScrollTextSpeed(thme.scrollspeed) end + end + end + + end + + else + if( displayHUD[v.data.target] ~= nil) then + if(v.data.requirement == nil or checkTriggerRequirement(v.data.requirement,v.data.trigger))then + checkContext(v.data) + + if(v.data.fontfamily ~= nil) then displayHUD[v.data.target]:SetFontFamily(v.data.fontfamily) end + if(v.data.fontstyle ~= nil) then displayHUD[v.data.target]:SetFontStyle(v.data.fontstyle) end + if(v.data.fontsize ~= nil) then displayHUD[v.data.target]:SetFontSize(v.data.fontsize) end + if(v.data.color ~= nil) then displayHUD[v.data.target]:SetTintColor(gamecolor(v.data.color.red,v.data.color.green,v.data.color.blue,1)) end + if(v.data.margin ~= nil) then displayHUD[v.data.target]:SetMargin(inkMargin.new({ top = v.data.margin.top, left = v.data.margin.left})) end + if(v.data.text ~= nil) then displayHUD[v.data.target]:SetText(v.data.text) end + if(v.data.visible ~= nil) then displayHUD[v.data.target]:SetVisible(v.data.visible) end + if(v.data.anchor ~= nil) then displayHUD[v.data.target]:SetAnchor(v.data.anchor) end + if(v.data.parent ~= nil) then displayHUD[v.data.target]:Reparent(v.data.parent) end + if(v.data.scrollspeed ~= nil) then displayHUD[v.data.target]:SetScrollTextSpeed(v.data.scrollspeed) end + end + end + end + + + + end + end + + + if(currentDistricts2 ~= nil)then + + + + + + if(displayHUD["factionwidget"]~= nil)then + displayHUD["factionwidget"]:RemoveAllChildren() + + displayHUD["factionwidget"]:SetVisible(((not inScanner) and GameController["HUDManager"].state == HUDState.ACTIVATED )) + + if(currentDistricts2.districtLabels ~= nil and #currentDistricts2.districtLabels > 0) then + local gangslist = {} + if(#currentDistricts2.districtLabels > 1) then + local gangs = getGangfromDistrict(currentDistricts2.districtLabels[2],20) + + if(#gangs > 0) then + for i=1,#gangs do + if(getScoreKey("Affinity",gangs[i].tag) ~= nil) then + table.insert(gangslist,gangs[i]) + + end + end + end + else + local gangs = getGangfromDistrict(currentDistricts2.districtLabels[1],20) + + if(#gangs > 0) then + for i=1,#gangs do + if(getScoreKey("Affinity",gangs[i].tag) ~= nil) then + table.insert(gangslist,gangs[i]) + + end + end + end + + end + + if(#gangslist > 0) then + for i,v in ipairs(gangslist) do + + + local gang = getFactionByTag(v.tag) + + local top = (i*50) + locationWidgetPlace_top = locationWidgetFactionDisctrict_top + (i*50) + 50 + + local isleader = (i==1) + + displayGangScoreWidget(getScoreKey("Affinity",v.tag),gang.name,displayHUD["factionwidget"],top,isleader) + + + end + + end + + + + end + + end + + + + + end + + if displayHUD["main_root_default"].name ~= nil and displayHUD["main_root_default"]:IsA('inkWidget') then + + displayHUD["main_root_default"]:SetVisible(true) + + + + + + + end + + else + if displayHUD["main_root_default"] ~= nil then + + for k,v in pairs(cyberscript.cache["hud"]) do + if(v.data.requirement == nil or checkTriggerRequirement(v.data.requirement,v.data.trigger))then + if(v.data.type == "widget" or v.data.type == "container")then + + checkContext(v.data) + + end + if(v.data.type == "widget" and displayHUD[k] ~= nil and displayHUD[k].visible == true) then + + + displayHUD[k]:SetVisible(false) + + end + + if(v.data.type == "container" and displayHUD[k] ~= nil) then + + + displayHUD[k]:SetVisible(v.data.visible) + + + end + end + + end + displayHUD["main_root_default"]:SetVisible(false) + end + + + end + + if(isEmpty(cyberscript.soundmanager) == false) then + for k,v in pairs(cyberscript.soundmanager) do + + if(v.isplaying == true and v.endplaying ~=nil) then + + if( os.time(os.date("!*t")) >=v.endplaying+1) then + + if(v.needrepeat == false) then + + Stop(v.tag) + + else + + local obj = deepcopy(v,nil) + Stop(v.tag) + PlaySound(obj.tag,obj.isradio,obj.needrepeat) + + + end + end + + + end + + + + end + end + + if(isEmpty(cyberscript.EntityManager) == false) then + for k,v in pairs(cyberscript.EntityManager) do + + if(v.spawntimespan ~= nil and v.spawntimespan ~= v.despawntimespan) then + + if( os.time(os.date("!*t"))+1 >=v.despawntimespan) then + + despawnEntity(k) + end + + + end + + + + end + end + + end + end + + if mainrefreshstep6 then + if (tick % 60 == 0) then --every 1 second + if(isEmpty(cyberscript.cache["event"]) == false) then + doTriggeredEvent() + end + + if(isEmpty(cyberscript.cache["npc"]) == false) then + checkNPC() + + end + + if(isEmpty(cyberscript.cache["fixer"]) == false) then + checkFixer() + end + + if activeMetroDisplay == true then + MetroCurrentTime = MetroCurrentTime - 1 + logme(10,MetroCurrentTime) + if MetroCurrentTime <= 0 then + activeMetroDisplay = false + end + end + + for k,v in pairs(AIhandler) do + + local cacheaiLoadinganswer = GetAnswer(k) + + if(cacheaiLoadinganswer ~= nil and cacheaiLoadinganswer ~= "") then + logme(1,k) + logme(1,cacheaiLoadinganswer) + AIhandler[k].answer = cacheaiLoadinganswer + + end + end + + + end + end + + if mainrefreshstep7 then + if (tick % 120 == 0) then --every 2 second + playRadio() + -- if(GameController["PhoneHotkeyController"] ~= nil) then + -- PhoneHotkeyController_UpdateData(GameController["PhoneHotkeyController"]) + -- end + end + end + + if mainrefreshstep8 then + if (tick % 180 == 0) then --every 3 second + + + + + if(npcStarSpawn) then + if(timerDespawn ~= nil) then + local currentime = getGameTime() + if(currentime.day > timerDespawn.day or currentime.hour > timerDespawn.hour) then + despawnEntity("current_star") + timerDespawn = nil + npcStarSpawn = nil + end + end + end + end + + + if (tick % 1800 == 0) then --every 30 second + + + local activeData = CodexListSyncData.new() + local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) + if gameshardscompiled == nil then gameshardscompiled = {} end + for i,v in pairs(gameshards) do + if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end + + + end + end + + end + + + + + -- if(collectgarbage("count") > 500000) then + + -- collectgarbage("collect") + -- end + end + + end function inGameInit() -- init some function after save loaded - loadHUD() - - LoadDataPackCache() - candrwMapPinFixer= false - cancheckmission = true - choiceHubData = gameinteractionsvisInteractionChoiceHubData.new() - choiceHubData.active =true - choiceHubData.flags = EVisualizerDefinitionFlags.Undefined - choiceHubData.title = "possibleInteractList" --'Test Interaction Hub' - cyberscript.language = Game.GetSettingsSystem():GetVar("/language", "OnScreen"):GetValue().value - loadUIsetting() - - - local inkSystem = Game.GetInkSystem(); - local layers = inkSystem:GetLayers(); - - for i,layer in ipairs(layers) do - for j,controller in ipairs(layer:GetGameControllers()) do - if(GameController[NameToString(controller:GetClassName())] == nil) then - GameController[NameToString(controller:GetClassName())] = controller - end - - end - end - - - theme = CPS.theme - color = CPS.color - cyberscript.GroupManager = {} - cyberscript.EntityManager = {} - --Game.GetTimeSystem():SetTimeDilation("cyberscript", 0) - + loadHUD() + + LoadDataPackCache() + candrwMapPinFixer= false + cancheckmission = true + choiceHubData = gameinteractionsvisInteractionChoiceHubData.new() + choiceHubData.active =true + choiceHubData.flags = EVisualizerDefinitionFlags.Undefined + choiceHubData.title = "possibleInteractList" --'Test Interaction Hub' + cyberscript.language = Game.GetSettingsSystem():GetVar("/language", "OnScreen"):GetValue().value + loadUIsetting() + + + local inkSystem = Game.GetInkSystem(); + local layers = inkSystem:GetLayers(); + + for i,layer in ipairs(layers) do + for j,controller in ipairs(layer:GetGameControllers()) do + if(GameController[NameToString(controller:GetClassName())] == nil) then + GameController[NameToString(controller:GetClassName())] = controller + end + + end + end + + + theme = CPS.theme + color = CPS.color + cyberscript.GroupManager = {} + cyberscript.EntityManager = {} + --Game.GetTimeSystem():SetTimeDilation("cyberscript", 0) + doInitEvent() - - local entity = {} - entity.id = Game.GetPlayer():GetEntityID() - entity.tag = "player" - entity.tweak = "player" - cyberscript.EntityManager[entity.tag] = entity - - if (Immortal) then - - Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Invulnerable", CName.new("SecondHeart")) - if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then - local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - if veh then - Game.GetGodModeSystem():AddGodMode(veh:GetEntityID(), "Invulnerable", CName.new("Default")) - end - end - else - local hasSecondHeart = false - local ssc = Game.GetScriptableSystemsContainer() - local es = ssc:Get(CName.new('EquipmentSystem')) - local espd = es:GetPlayerData(Game.GetPlayer()) - espd['GetItemInEquipSlot2'] = espd['GetItemInEquipSlot;gamedataEquipmentAreaInt32'] - for i=0,2 do - if espd:GetItemInEquipSlot2("CardiovascularSystemCW", i).tdbid.hash == 3619482064 then - hasSecondHeart = true - end - end - if hasSecondHeart then - Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Immortal", CName.new("SecondHeart")) - else - Game.GetGodModeSystem():DisableOverride(Game.GetPlayer():GetEntityID(), CName.new("SecondHeart")) - end - if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then - local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - if veh then - Game.GetGodModeSystem():ClearGodMode(veh:GetEntityID(), CName.new("Default")) - end - end - - end - - - - InfiniteStamina(InfiniteStaminas) - - - - - - - draw = true - StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - - despawnAll() - local codewareIsInstalled,message = pcall(function() - Game.GetDynamicEntitySystem() - end) - if(codewareIsInstalled == true) then - local storedentity = Game.GetDynamicEntitySystem():GetTaggedIDs("CyberScript") - print("storedentity"..dump(storedentity)) - for i,entid in ipairs(storedentity) do - - local tags = Game.GetDynamicEntitySystem():GetTags(entid) - --print("tags"..dump(tags)) - - local tagsString = {} - - for k,v in ipairs(tags) do - - -- print("vs"..Game.NameToString(v)) - table.insert(tagsString,Game.NameToString(v)) - - end - print("tagsString"..dump(tagsString)) - local cstag = "" - - if(table_contains(tagsString,"CyberScript.NPC")) then - for i,atg in ipairs(tagsString) do - if(string.match(atg,"CyberScript.NPC.")) then - local tagsplit = split(atg, ".") + + local entity = {} + entity.id = Game.GetPlayer():GetEntityID() + entity.tag = "player" + entity.tweak = "player" + cyberscript.EntityManager[entity.tag] = entity + + if (Immortal) then + + Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Invulnerable", CName.new("SecondHeart")) + if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then + local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + if veh then + Game.GetGodModeSystem():AddGodMode(veh:GetEntityID(), "Invulnerable", CName.new("Default")) + end + end + else + local hasSecondHeart = false + local ssc = Game.GetScriptableSystemsContainer() + local es = ssc:Get(CName.new('EquipmentSystem')) + local espd = es:GetPlayerData(Game.GetPlayer()) + espd['GetItemInEquipSlot2'] = espd['GetItemInEquipSlot;gamedataEquipmentAreaInt32'] + for i=0,2 do + if espd:GetItemInEquipSlot2("CardiovascularSystemCW", i).tdbid.hash == 3619482064 then + hasSecondHeart = true + end + end + if hasSecondHeart then + Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Immortal", CName.new("SecondHeart")) + else + Game.GetGodModeSystem():DisableOverride(Game.GetPlayer():GetEntityID(), CName.new("SecondHeart")) + end + if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then + local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + if veh then + Game.GetGodModeSystem():ClearGodMode(veh:GetEntityID(), CName.new("Default")) + end + end + + end + + + + InfiniteStamina(InfiniteStaminas) + + + + + + + draw = true + StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + + despawnAll() + local codewareIsInstalled,message = pcall(function() + Game.GetDynamicEntitySystem() + end) + if(codewareIsInstalled == true) then + local storedentity = Game.GetDynamicEntitySystem():GetTaggedIDs("CyberScript") + print("storedentity"..dump(storedentity)) + for i,entid in ipairs(storedentity) do + + local tags = Game.GetDynamicEntitySystem():GetTags(entid) + --print("tags"..dump(tags)) + + local tagsString = {} + + for k,v in ipairs(tags) do + + -- print("vs"..Game.NameToString(v)) + table.insert(tagsString,Game.NameToString(v)) + + end + print("tagsString"..dump(tagsString)) + local cstag = "" + + if(table_contains(tagsString,"CyberScript.NPC")) then + for i,atg in ipairs(tagsString) do + if(string.match(atg,"CyberScript.NPC.")) then + local tagsplit = split(atg, ".") cstag = tagsplit[3] - end - end - end - - if(table_contains(tagsString,"CyberScript.Vehicle")) then - for i,atg in ipairs(tagsString) do - if(string.match(atg,"CyberScript.Vehicle.")) then - local tagsplit = split(atg, ".") + end + end + end + + if(table_contains(tagsString,"CyberScript.Vehicle")) then + for i,atg in ipairs(tagsString) do + if(string.match(atg,"CyberScript.Vehicle.")) then + local tagsplit = split(atg, ".") cstag = tagsplit[3] - end - end - end - logme(1,"entid "..dump(entid)) - if(cstag ~= "" and Game.FindEntityByID(entid):GetRecordID() ~= nil and cyberscript.entitieshash[tostring(Game.FindEntityByID(entid):GetRecordID().hash)] ~= nil)then - - local entity = {} - entity.id = entid - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+0 - entity.tag = cstag - entity.isitem = false - entity.tweak = cyberscript.entitieshash[tostring(Game.FindEntityByID(entid):GetRecordID().hash)].entity_tweak - -- print("tweak"..entity.tweak) - entity.isprevention = false - entity.iscodeware = true - entity.persistState = true - entity.persistSpawn = true - entity.alwaysSpawned = true - entity.spawnInView = true - entity.scriptlevel = 0 - - entity.isMP = false - - local npgc = getNPCByTweakId(entity.tweak) - if(npgc ~= nil) then - entity.name = npgc.Names - else - entity.name = cstag - end - - cyberscript.EntityManager[cstag]=entity - end - - end - - else - - print("no codeware founded") - - end - if(showcyberscriptfixeronmap) then - setNewFixersPoint() - end - setCustomLocationPoint() - - --createInteraction(true) - local blackboardDefs = Game.GetAllBlackboardDefs() - local blackboardPSM = Game.GetBlackboardSystem():GetLocalInstanced(Game.GetPlayer():GetEntityID(), blackboardDefs.PlayerStateMachine) - blackboardPSM:SetInt(blackboardDefs.PlayerStateMachine.SceneTier, 1, true) -- GameplayTier.Tier1_FullGameplay - --Game.GetTimeSystem():SetTimeDilation("cyberscript", 0) - - - currentObjectiveId = 0 - inkCompoundRef.RemoveAllChildren(GameController["QuestTrackerGameController"].ObjectiveContainer) - local activeData = CodexListSyncData.new() - local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) - gameshardscompiled = {} - for i,v in pairs(gameshards) do - if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end - - - end - + end + end + end + logme(1,"entid "..dump(entid)) + if(cstag ~= "" and safeFindEntityByID(entid):GetRecordID() ~= nil and cyberscript.entitieshash[tostring(safeFindEntityByID(entid):GetRecordID().hash)] ~= nil)then + + local entity = {} + entity.id = entid + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+0 + entity.tag = cstag + entity.isitem = false + entity.tweak = cyberscript.entitieshash[tostring(safeFindEntityByID(entid):GetRecordID().hash)].entity_tweak + -- print("tweak"..entity.tweak) + entity.isprevention = false + entity.iscodeware = true + entity.persistState = true + entity.persistSpawn = true + entity.alwaysSpawned = true + entity.spawnInView = true + entity.scriptlevel = 0 + + entity.isMP = false + + local npgc = getNPCByTweakId(entity.tweak) + if(npgc ~= nil) then + entity.name = npgc.Names + else + entity.name = cstag + end + + cyberscript.EntityManager[cstag]=entity + end + + end + + else + + print("no codeware founded") + + end + if(showcyberscriptfixeronmap) then + setNewFixersPoint() + end + setCustomLocationPoint() + + --createInteraction(true) + local blackboardDefs = Game.GetAllBlackboardDefs() + local blackboardPSM = Game.GetBlackboardSystem():GetLocalInstanced(Game.GetPlayer():GetEntityID(), blackboardDefs.PlayerStateMachine) + blackboardPSM:SetInt(blackboardDefs.PlayerStateMachine.SceneTier, 1, true) -- GameplayTier.Tier1_FullGameplay + --Game.GetTimeSystem():SetTimeDilation("cyberscript", 0) + + + currentObjectiveId = 0 + inkCompoundRef.RemoveAllChildren(GameController["QuestTrackerGameController"].ObjectiveContainer) + local activeData = CodexListSyncData.new() + local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) + gameshardscompiled = {} + for i,v in pairs(gameshards) do + if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end + + + end + pcall(function() - Game.GetSettingsSystem():GetVar("/gameplay/performance", "CrowdDensity"):SetValue("High") - cyberscript.language = Game.GetSettingsSystem():GetVar("/language", "OnScreen"):GetValue().value + Game.GetSettingsSystem():GetVar("/gameplay/performance", "CrowdDensity"):SetValue("High") + cyberscript.language = Game.GetSettingsSystem():GetVar("/language", "OnScreen"):GetValue().value end) - print(getLang("seestarted")) + print(getLang("seestarted")) end function SEERefresh(active) - if active == true then - executeRealTimeActions(false) - executeRealTimeScript(false) - if (autoScript == true) then - CompileCachedThread() - ScriptExecutionEngine() - end - QuestThreadManager() - executeRealTimeActions(true) - executeRealTimeScript(true) - end + if active == true then + executeRealTimeActions(false) + executeRealTimeScript(false) + if (autoScript == true) then + CompileCachedThread() + ScriptExecutionEngine() + end + QuestThreadManager() + executeRealTimeActions(true) + executeRealTimeScript(true) + end end function refresh(delta) -- update event (include thread refresh action and QuestThreadManager) - - if(isGameLoaded == false) then - isGameLoaded = Game.GetPlayer() and Game.GetPlayer():IsAttached() and not GetSingleton('inkMenuScenario'):GetSystemRequestsHandler():IsPreGame() - end - if(ModIsLoaded) then - if isGameLoaded then - if initFinished then - tick = tick +1 - if(tick > 10000000)then - tick = 100 - end - local firstLaunch = tick - Cron.Update(delta) - if(tick > 60)then - if(tick >= 61 and tick <= 62 and draw == false)then - local datapackresult,datapackerror = pcall(function() - DatapackLoading() - LoadDataPackCache() - end) - - if datapackresult == false then - - - logme(1,"!!!!! CYBERSCRIPT : ERROR IN DATAPACK LOADING" .. datapackerror) - - end - inGameInit() --first playable frame - - end - - if(hotreload == true and inMenu == false) then - hotreload = false - Game.GetPlayer():SetWarningMessage(getLang("CyberScript : Hot Reload in progress...")) - loadModule() - - Game.GetPlayer():SetWarningMessage(getLang("CyberScript : Hot Reload finished !")) - - else - - if saveLocationEnabled then - savePath(recordRotation,recordRelative,recordRotationOnly) - end - - if playLocationEnabled then - playPath() - playtick = playtick+1 - end - - SEERefresh(seerefresh) - - mainThread(mainrefresh) - - end - - else - draw = false - end - else - if Game.GetPlayer() and initFinished == false and GameUI.IsLoading() == false then - - if(nativeSettings ~= nil) then - nativesettingEnabled = true - end - - initFinished = true - draw = true - end - end - end - end + + if(isGameLoaded == false) then + isGameLoaded = Game.GetPlayer() and Game.GetPlayer():IsAttached() and not GetSingleton('inkMenuScenario'):GetSystemRequestsHandler():IsPreGame() + end + if(ModIsLoaded) then + if isGameLoaded then + if initFinished then + tick = tick +1 + if(tick > 10000000)then + tick = 100 + end + local firstLaunch = tick + Cron.Update(delta) + if(tick > 60)then + if(tick >= 61 and tick <= 62 and draw == false)then + local datapackresult,datapackerror = pcall(function() + DatapackLoading() + LoadDataPackCache() + end) + + if datapackresult == false then + + + logme(1,"!!!!! CYBERSCRIPT : ERROR IN DATAPACK LOADING" .. datapackerror) + + end + inGameInit() --first playable frame + + end + + if(hotreload == true and inMenu == false) then + hotreload = false + Game.GetPlayer():SetWarningMessage(getLang("CyberScript : Hot Reload in progress...")) + loadModule() + + Game.GetPlayer():SetWarningMessage(getLang("CyberScript : Hot Reload finished !")) + + else + + if saveLocationEnabled then + savePath(recordRotation,recordRelative,recordRotationOnly) + end + + if playLocationEnabled then + playPath() + playtick = playtick+1 + end + + SEERefresh(seerefresh) + + mainThread(mainrefresh) + + end + + else + draw = false + end + else + if Game.GetPlayer() and initFinished == false and GameUI.IsLoading() == false then + + if(nativeSettings ~= nil) then + nativesettingEnabled = true + end + + initFinished = true + draw = true + end + end + end + end end function executeRealTimeScript(after) - - for key,value in pairs(directWorkerTable) do --actualcode - - if((value.after == nil and after == false) or (value.after ~= nil and value.after == after)) then - if workerTable[key] == nil then - runActionList(value.actionlist,value.tag,"interact",false,"nothing") - end - end - end - - + + for key,value in pairs(directWorkerTable) do --actualcode + + if((value.after == nil and after == false) or (value.after ~= nil and value.after == after)) then + if workerTable[key] == nil then + runActionList(value.actionlist,value.tag,"interact",false,"nothing") + end + end + end + + end function executeRealTimeActions(after) - - for key,value in pairs(directActionsWorkerTable) do --actualcode - if((value.after == nil and after == false) or (value.after ~= nil and value.after == after)) then - - for i,v in ipairs(value.actionlist) do - - - local status, retval = pcall(executeAction,v,key,"",i,"interact","see_engine") - - - - if status == false then - - - logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty((value.actionlist[i]))).." tag "..key.." parent ".."".." index "..i) - logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty((value.actionlist[i]))).." tag "..key.." parent ".."".." index "..i) - --Game.GetPlayer():SetWarningMessage("CyberScript Scripting error, check the log for more detail") - - end - end - - - end - end - - + + for key,value in pairs(directActionsWorkerTable) do --actualcode + if((value.after == nil and after == false) or (value.after ~= nil and value.after == after)) then + + for i,v in ipairs(value.actionlist) do + + + local status, retval = pcall(executeAction,v,key,"",i,"interact","see_engine") + + + + if status == false then + + + logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty((value.actionlist[i]))).." tag "..key.." parent ".."".." index "..i) + logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty((value.actionlist[i]))).." tag "..key.." parent ".."".." index "..i) + --Game.GetPlayer():SetWarningMessage("CyberScript Scripting error, check the log for more detail") + + end + end + + + end + end + + end --Script Execution Engine function CompileCachedThread() - workerTableKey = {} - if(workerTable ~= nil)then - - for k in pairs(workerTable) do - table.insert(workerTableKey, k) - end - - end - + workerTableKey = {} + if(workerTable ~= nil)then + + for k in pairs(workerTable) do + table.insert(workerTableKey, k) + end + + end + end function ScriptExecutionEngine() - - - if(workerTable ~= nil )then - - - - for i,v in ipairs(workerTableKey) do - local k = workerTableKey[i] - if(workerTable[k] ~= nil) then - - if(GameUI.IsMenu() == false or (workerTable[k]["bypassMenu"] ~= nil and workerTable[k]["bypassMenu"] == true)) then - local index = workerTable[k]["index"] - local list = workerTable[k]["action"] - local parent = workerTable[k]["parent"] - local pending = workerTable[k]["pending"] - - -- logme(4,k) - -- logme(4,list) - -- logme(4,index) - - if(workerTable[k]["index"] > #workerTable[k]["action"] and workerTable[k]["pending"] == false and workerTable[k]["started"] == true) then - - if workerTable[k]["parent"] ~= nil and workerTable[k]["parent"] ~= ""then - - if(workerTable[workerTable[k]["parent"]] ~= nil) then - workerTable[workerTable[k]["parent"]]["pending"] = false - workerTable[workerTable[k]["parent"]]["last_update"] =tostring(os.date("%x %X", os.time())) - workerTable[workerTable[k]["parent"]]["index"] = workerTable[workerTable[k]["parent"]]["index"] + 1 - end - end - - if workerTable[k]["children"] == "" then - - -- - - if(workerTable[k].quest == nil)then - workerTable[k] = nil - workerTableKey[i] = nil - else - workerTable[k].disabled = true - end - - else - - if workerTable[workerTable[k]["children"]] == nil then - - --workerTable[k] = nil - --workerTableKey[i] = nil - -- workerTable[k].disabled = true - if(workerTable[k].quest == nil or workerTable[k].quest == false)then - workerTable[k] = nil - workerTableKey[i] = nil - else - workerTable[k].disabled = true - end - end - - end - - - end - - if(workerTable[k] ~= nil) then - - if(index <= #list and workerTable[k].disabled == false) then - workerTable[k]["started"] = true - if(pending == false) then - - if(workerTable[k]["index"] ~= nil) then - - if(list[index].name == "goto") then - - if(list[index].parent == true) then - logme(4,"Go to"..list[index].index.." of "..parent) - - workerTable[parent]["index"] = list[index].index-1 - workerTable[k]["index"] = workerTable[k]["index"]+1 - workerTable[parent]["pending"] = false - k = parent - else - logme(4,"Go to"..list[index].index.." of "..k) - - - workerTable[k]["index"] = list[index].index - end - - else - local isfinish = false - - - local action = list[index] - - if(forcecrashSEE == false) then - - local status, retval = pcall(executeAction,action,k,parent,workerTable[k]["index"],workerTable[k]["source"],workerTable[k]["executortag"]) - - - - if status == false then - - - logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty((list[index]))).." tag "..k.." parent "..parent.." index "..workerTable[k]["index"],true) - logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty((list[index]))).." tag "..k.." parent "..parent.." index "..workerTable[k]["index"],true) - --Game.GetPlayer():SetWarningMessage("CyberScript Scripting error, check the log for more detail") - workerTable[k] = nil - else - isfinish = retval - - end - - else - - executeAction(action,k,parent,workerTable[k]["index"],workerTable[k]["source"],workerTable[k]["executortag"]) - isfinish = true - end - - - - if(workerTable[k] ~= nil) then - if(isfinish == true) then - - - workerTable[k]["index"] = workerTable[k]["index"]+1 - - --logme(4,"action finished") - workerTable[k]["pending"] = false - workerTable[k]["last_update"] =tostring(os.date("%x %X", os.time())) - else - - workerTable[k]["pending"] = true - - - - - end - - - end - - end - - else - - -- workerTable[k] = nil - --workerTable[k].disabled = true - -- workerTableKey[i] = nil - if(workerTable[k].quest == nil)then - workerTable[k] = nil - workerTableKey[i] = nil - else - workerTable[k].disabled = true - end - end - else - - - local actionisgood = checkWaitingAction(list[index],k,parent,index) - - workerTable[k]["pending"] = (actionisgood ~= pending) - - if(workerTable[k]["pending"] == false) then - workerTable[k]["last_update"] =tostring(os.date("%x %X", os.time())) - workerTable[k]["index"] = workerTable[k]["index"]+1 - end - - - - - end - - - end - end - - end - end - - end - - - - - end - + + + if(workerTable ~= nil )then + + + + for i,v in ipairs(workerTableKey) do + local k = workerTableKey[i] + if(workerTable[k] ~= nil) then + + if(GameUI.IsMenu() == false or (workerTable[k]["bypassMenu"] ~= nil and workerTable[k]["bypassMenu"] == true)) then + local index = workerTable[k]["index"] + local list = workerTable[k]["action"] + local parent = workerTable[k]["parent"] + local pending = workerTable[k]["pending"] + + -- logme(4,k) + -- logme(4,list) + -- logme(4,index) + + if(workerTable[k]["index"] > #workerTable[k]["action"] and workerTable[k]["pending"] == false and workerTable[k]["started"] == true) then + + if workerTable[k]["parent"] ~= nil and workerTable[k]["parent"] ~= ""then + + if(workerTable[workerTable[k]["parent"]] ~= nil) then + workerTable[workerTable[k]["parent"]]["pending"] = false + workerTable[workerTable[k]["parent"]]["last_update"] =tostring(os.date("%x %X", os.time())) + workerTable[workerTable[k]["parent"]]["index"] = workerTable[workerTable[k]["parent"]]["index"] + 1 + end + end + + if workerTable[k]["children"] == "" then + + -- + + if(workerTable[k].quest == nil)then + workerTable[k] = nil + workerTableKey[i] = nil + else + workerTable[k].disabled = true + end + + else + + if workerTable[workerTable[k]["children"]] == nil then + + --workerTable[k] = nil + --workerTableKey[i] = nil + -- workerTable[k].disabled = true + if(workerTable[k].quest == nil or workerTable[k].quest == false)then + workerTable[k] = nil + workerTableKey[i] = nil + else + workerTable[k].disabled = true + end + end + + end + + + end + + if(workerTable[k] ~= nil) then + + if(index <= #list and workerTable[k].disabled == false) then + workerTable[k]["started"] = true + if(pending == false) then + + if(workerTable[k]["index"] ~= nil) then + + if(list[index].name == "goto") then + + if(list[index].parent == true) then + logme(4,"Go to"..list[index].index.." of "..parent) + + workerTable[parent]["index"] = list[index].index-1 + workerTable[k]["index"] = workerTable[k]["index"]+1 + workerTable[parent]["pending"] = false + k = parent + else + logme(4,"Go to"..list[index].index.." of "..k) + + + workerTable[k]["index"] = list[index].index + end + + else + local isfinish = false + + + local action = list[index] + + if(forcecrashSEE == false) then + + local status, retval = pcall(executeAction,action,k,parent,workerTable[k]["index"],workerTable[k]["source"],workerTable[k]["executortag"]) + + + + if status == false then + + + logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty((list[index]))).." tag "..k.." parent "..parent.." index "..workerTable[k]["index"],true) + logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty((list[index]))).." tag "..k.." parent "..parent.." index "..workerTable[k]["index"],true) + --Game.GetPlayer():SetWarningMessage("CyberScript Scripting error, check the log for more detail") + workerTable[k] = nil + else + isfinish = retval + + end + + else + + executeAction(action,k,parent,workerTable[k]["index"],workerTable[k]["source"],workerTable[k]["executortag"]) + isfinish = true + end + + + + if(workerTable[k] ~= nil) then + if(isfinish == true) then + + + workerTable[k]["index"] = workerTable[k]["index"]+1 + + --logme(4,"action finished") + workerTable[k]["pending"] = false + workerTable[k]["last_update"] =tostring(os.date("%x %X", os.time())) + else + + workerTable[k]["pending"] = true + + + + + end + + + end + + end + + else + + -- workerTable[k] = nil + --workerTable[k].disabled = true + -- workerTableKey[i] = nil + if(workerTable[k].quest == nil)then + workerTable[k] = nil + workerTableKey[i] = nil + else + workerTable[k].disabled = true + end + end + else + + + local actionisgood = checkWaitingAction(list[index],k,parent,index) + + workerTable[k]["pending"] = (actionisgood ~= pending) + + if(workerTable[k]["pending"] == false) then + workerTable[k]["last_update"] =tostring(os.date("%x %X", os.time())) + workerTable[k]["index"] = workerTable[k]["index"]+1 + end + + + + + end + + + end + end + + end + end + + end + + + + + end + end function checkWaitingAction(action,tag,parent,index) - - - - result = false - - - if(action.name == "wait") then - - local temp = getGameTime() - - if(temp.hour > action.hour or (temp.hour == action.hour and temp.min > action.min)) then - result = true - end - - - - - end - if(action.name == "wait_tick") then - - if(tick >= action.tick) then - result = true - end - - - - end - - - - if(action.name == "wait_second") then - - if(os.time(os.date("!*t"))+0 >= action.tick) then - result = true - end - - - - end - - - if(action.name == "subtitle" or action.name == "random_subtitle" or - action.name == "play_random_custom_sound_with_subtitle" or - action.name == "play_custom_sound_with_subtitle" ) then - - if(os.time(os.date("!*t"))+0 >= action.tick) then - result = true - GameController["SubtitlesGameController"]:Cleanup() - end - - - - end - - if(action.name == "npc_chat" or action.name == "random_npc_chat" or - action.name == "play_custom_sound_with_subtitle_as_chat") then - - if(os.time(os.date("!*t"))+0 >= action.tick) then - result = true - GameController["ChattersGameController"]:Cleanup() - - end - - - - end - - - if(action.name == "fade_in") then - - - - isFadeIn = true - --logme(4,opacity) - - - if(os.time(os.date("!*t"))+0 >= action.tick) then - - - opacity = 1 - - - - result = true - - else - local fadeincursor = tonumber(action.tick) - - - - local currentcursor = tonumber(os.time(os.date("!*t"))+0 ) - - - --logme(4,fadeincursor) - --logme(4,currentcursor) - - - opacity = (100/(fadeincursor-currentcursor)) - - - end - end - - if(action.name == "fade_out") then - - - - - --logme(4,opacity) - - - if(os.time(os.date("!*t"))+0 >= action.tick) then - - - opacity = 0 - isFadeIn = false - - - result = true - - else - local fadeoutcursor = tonumber(action.tick) - - - - local currentcursor = tonumber(os.time(os.date("!*t"))+0 ) - - - --logme(4,fadeincursor) - --logme(4,currentcursor) - - - opacity = 1 - (100/(fadeoutcursor-currentcursor)) - - - end - end - - if(action.name == "wait_for_trigger") then - - - local trigger = action.trigger - result = checkTrigger(trigger) - - end - - if(action.name == "wait_for_framework") then - - - - result = (waiting == false) - ------print("wait_for_framework "..tostring(waiting).." "..tostring(result)) - - end - - if(action.name == "wait_for_ai_answer") then - - - - result = (getAIAnswerOrDefault(action.aitag) ~= nil) - ------print("wait_for_framework "..tostring(waiting).." "..tostring(result)) - - end - - - - if(action.name == "wait_for_target") then - - if(selectTarget ~= nil) then - - result = true - - end - - - end - - if(action.name == "wait_for_selection") then - - result = selectedEntity - - - end - - - if(action.name == "while_one") then - - local trigger = action.trigger - result = checkTrigger(trigger) - logme(4,"while one "..tostring(result)) - executeAction(action.action,tag,parent,index,source,executortag) - - - end - - if(action.name == "finish_mission") then - - if currentQuest ~= nil and currentQuest.tag == action.tag then - - result = true - canDoEndAction = true - - else - - if currentQuest == nil or (currentQuest ~= nil and currentQuest.tag ~= action.tag) then - - result = false - - - end - - end - - end - - if(workerTable[tag]["children"] ~= nil and workerTable[workerTable[tag]["children"]] ~= nil) then - - result = false - - - end - - - return result + + + + result = false + + + if(action.name == "wait") then + + local temp = getGameTime() + + if(temp.hour > action.hour or (temp.hour == action.hour and temp.min > action.min)) then + result = true + end + + + + + end + if(action.name == "wait_tick") then + + if(tick >= action.tick) then + result = true + end + + + + end + + + + if(action.name == "wait_second") then + + if(os.time(os.date("!*t"))+0 >= action.tick) then + result = true + end + + + + end + + + if(action.name == "subtitle" or action.name == "random_subtitle" or + action.name == "play_random_custom_sound_with_subtitle" or + action.name == "play_custom_sound_with_subtitle" ) then + + if(os.time(os.date("!*t"))+0 >= action.tick) then + result = true + GameController["SubtitlesGameController"]:Cleanup() + end + + + + end + + if(action.name == "npc_chat" or action.name == "random_npc_chat" or + action.name == "play_custom_sound_with_subtitle_as_chat") then + + if(os.time(os.date("!*t"))+0 >= action.tick) then + result = true + GameController["ChattersGameController"]:Cleanup() + + end + + + + end + + + if(action.name == "fade_in") then + + + + isFadeIn = true + --logme(4,opacity) + + + if(os.time(os.date("!*t"))+0 >= action.tick) then + + + opacity = 1 + + + + result = true + + else + local fadeincursor = tonumber(action.tick) + + + + local currentcursor = tonumber(os.time(os.date("!*t"))+0 ) + + + --logme(4,fadeincursor) + --logme(4,currentcursor) + + + opacity = (100/(fadeincursor-currentcursor)) + + + end + end + + if(action.name == "fade_out") then + + + + + --logme(4,opacity) + + + if(os.time(os.date("!*t"))+0 >= action.tick) then + + + opacity = 0 + isFadeIn = false + + + result = true + + else + local fadeoutcursor = tonumber(action.tick) + + + + local currentcursor = tonumber(os.time(os.date("!*t"))+0 ) + + + --logme(4,fadeincursor) + --logme(4,currentcursor) + + + opacity = 1 - (100/(fadeoutcursor-currentcursor)) + + + end + end + + if(action.name == "wait_for_trigger") then + + + local trigger = action.trigger + result = checkTrigger(trigger) + + end + + if(action.name == "wait_for_framework") then + + + + result = (waiting == false) + ------print("wait_for_framework "..tostring(waiting).." "..tostring(result)) + + end + + if(action.name == "wait_for_ai_answer") then + + + + result = (getAIAnswerOrDefault(action.aitag) ~= nil) + ------print("wait_for_framework "..tostring(waiting).." "..tostring(result)) + + end + + + + if(action.name == "wait_for_target") then + + if(selectTarget ~= nil) then + + result = true + + end + + + end + + if(action.name == "wait_for_selection") then + + result = selectedEntity + + + end + + + if(action.name == "while_one") then + + local trigger = action.trigger + result = checkTrigger(trigger) + logme(4,"while one "..tostring(result)) + executeAction(action.action,tag,parent,index,source,executortag) + + + end + + if(action.name == "finish_mission") then + + if currentQuest ~= nil and currentQuest.tag == action.tag then + + result = true + canDoEndAction = true + + else + + if currentQuest == nil or (currentQuest ~= nil and currentQuest.tag ~= action.tag) then + + result = false + + + end + + end + + end + + if(workerTable[tag]["children"] ~= nil and workerTable[workerTable[tag]["children"]] ~= nil) then + + result = false + + + end + + + return result end function cleanThreadManager() - if GameUI.IsDetached() then - workerTable = {} - actionistaken = false - end - - local count = 0 - if(#workerTable > 0 ) then - - for i=1, #workerTable do - - if workerTable[i].active == false then - count = count + 1 - end - - end - - - if(count == #workerTable) then - ----logme(4,"clean worker table") - workerTable = {} - actionistaken = false - end - - end - + if GameUI.IsDetached() then + workerTable = {} + actionistaken = false + end + + local count = 0 + if(#workerTable > 0 ) then + + for i=1, #workerTable do + + if workerTable[i].active == false then + count = count + 1 + end + + end + + + if(count == #workerTable) then + ----logme(4,"clean worker table") + workerTable = {} + actionistaken = false + end + + end + end @@ -1588,114 +1599,114 @@ end --requirement function checkTriggerRequirement(requirement,triggerlist) - - local result = false - - if GameUI.IsLoading() == false and requirement ~= nil then - - for i=1, #requirement do --pour chaque requirement de la quete - - local requirementcondition = requirement[i] - local count = 0 - - for y =1,#requirementcondition do --pour chaque condition du requirement en cours - - - if(result == false) then --si un requirement n'a pas été validé déja - ----print(requirementcondition[y]) - local trigger = triggerlist[requirementcondition[y]] - - local triggerIsOk = checkTrigger(trigger) --on evalue le trigger - ----print(trigger.name.." "..dump(trigger).." "..tostring(triggerIsOk)) - if(triggerIsOk) then --on incrémente le compteur si le trigger est ok - - - count = count +1 - end - - - end - - - - - end - - if(count == #requirementcondition) then --si le compteur de bon trigger est egale a la totalité du requirementcondition, c'est que tout les parametres sont requis pour ce requirement - result = true - end - - - - - - end - - if(#requirement == 0) or (requirement == nil and triggerlist == nil) then - result = true - - end - - end - - return result + + local result = false + + if GameUI.IsLoading() == false and requirement ~= nil then + + for i=1, #requirement do --pour chaque requirement de la quete + + local requirementcondition = requirement[i] + local count = 0 + + for y =1,#requirementcondition do --pour chaque condition du requirement en cours + + + if(result == false) then --si un requirement n'a pas été validé déja + ----print(requirementcondition[y]) + local trigger = triggerlist[requirementcondition[y]] + + local triggerIsOk = checkTrigger(trigger) --on evalue le trigger + ----print(trigger.name.." "..dump(trigger).." "..tostring(triggerIsOk)) + if(triggerIsOk) then --on incrémente le compteur si le trigger est ok + + + count = count +1 + end + + + end + + + + + end + + if(count == #requirementcondition) then --si le compteur de bon trigger est egale a la totalité du requirementcondition, c'est que tout les parametres sont requis pour ce requirement + result = true + end + + + + + + end + + if(#requirement == 0) or (requirement == nil and triggerlist == nil) then + result = true + + end + + end + + return result end function testTriggerRequirement(requirement,triggerlist, number) - local result = false - if number == nil then number = 10 end - for i=1, #requirement do --pour chaque requirement de la quete - - local requirementcondition = requirement[i] - - local count = 0 - logme(number,"Requirement : "..#requirementcondition) - logme(number,dump(requirementcondition)) - for y =1,#requirementcondition do --pour chaque condition du requirement en cours - - logme(number,"Requirement : "..requirementcondition[y]) - if(result == false) then --si un requirement n'a pas été validé déja - logme(number,"Trigger : "..requirementcondition[y]) - local trigger = triggerlist[requirementcondition[y]] - logme(number,"Trigger : ") - logme(number,trigger.name) - - local triggerIsOk = checkTrigger(trigger) --on evalue le trigger - logme(number,triggerIsOk) - if(triggerIsOk) then --on incrémente le compteur si le trigger est ok - - - - count = count +1 - logme(number,count) - end - - - end - - - - - end - - if(count == #requirementcondition) then --si le compteur de bon trigger est egale a la totalité du requirementcondition, c'est que tout les parametres sont requis pour ce requirement - result = true - end - - - - - - end - - if(#requirement == 0 and #triggerlist == 0) then - result = true - - end - - logme(number,"Test Result : "..tostring(result)) - - return result + local result = false + if number == nil then number = 10 end + for i=1, #requirement do --pour chaque requirement de la quete + + local requirementcondition = requirement[i] + + local count = 0 + logme(number,"Requirement : "..#requirementcondition) + logme(number,dump(requirementcondition)) + for y =1,#requirementcondition do --pour chaque condition du requirement en cours + + logme(number,"Requirement : "..requirementcondition[y]) + if(result == false) then --si un requirement n'a pas été validé déja + logme(number,"Trigger : "..requirementcondition[y]) + local trigger = triggerlist[requirementcondition[y]] + logme(number,"Trigger : ") + logme(number,trigger.name) + + local triggerIsOk = checkTrigger(trigger) --on evalue le trigger + logme(number,triggerIsOk) + if(triggerIsOk) then --on incrémente le compteur si le trigger est ok + + + + count = count +1 + logme(number,count) + end + + + end + + + + + end + + if(count == #requirementcondition) then --si le compteur de bon trigger est egale a la totalité du requirementcondition, c'est que tout les parametres sont requis pour ce requirement + result = true + end + + + + + + end + + if(#requirement == 0 and #triggerlist == 0) then + result = true + + end + + logme(number,"Test Result : "..tostring(result)) + + return result end @@ -1703,80 +1714,80 @@ end --run action Thread function runActionList(actionlist, tag, source,isquest,executortag,bypassMenu) - - if(tag ~= nil) then - if(workerTable[tag] == nil) then - local copy = deepcopy(actionlist, copies) - - -- for k,v in pairs(copy) then - -- copy[k]["active"] = true - -- end - - if(source == nil) then - source = "interact" - end - - - if(workerTable[tag] == nil) then - workerTable[tag] = {} - end - - workerTable[tag]["action"] = copy - workerTable[tag]["index"] = 1 - workerTable[tag]["parent"] = "" - workerTable[tag]["started"] = false - workerTable[tag]["pending"] = false - workerTable[tag]["disabled"] = false - workerTable[tag]["source"] = source - workerTable[tag]["executortag"] = executortag - workerTable[tag]["bypassMenu"] = bypassMenu - workerTable[tag]["started_at"] =tostring(os.date("%x %X", os.time())) - workerTable[tag]["last_update"] =tostring(os.date("%x %X", os.time())) - if(isquest ~= nil) then - workerTable[tag]["quest"] = isquest - end - end - end + + if(tag ~= nil) then + if(workerTable[tag] == nil) then + local copy = deepcopy(actionlist, copies) + + -- for k,v in pairs(copy) then + -- copy[k]["active"] = true + -- end + + if(source == nil) then + source = "interact" + end + + + if(workerTable[tag] == nil) then + workerTable[tag] = {} + end + + workerTable[tag]["action"] = copy + workerTable[tag]["index"] = 1 + workerTable[tag]["parent"] = "" + workerTable[tag]["started"] = false + workerTable[tag]["pending"] = false + workerTable[tag]["disabled"] = false + workerTable[tag]["source"] = source + workerTable[tag]["executortag"] = executortag + workerTable[tag]["bypassMenu"] = bypassMenu + workerTable[tag]["started_at"] =tostring(os.date("%x %X", os.time())) + workerTable[tag]["last_update"] =tostring(os.date("%x %X", os.time())) + if(isquest ~= nil) then + workerTable[tag]["quest"] = isquest + end + end + end end function runSubActionList(actionlist, tag, parent, source, isquest,executortag,bypassMenu) - - if(tag ~= nil) then - - if(workerTable[tag] == nil) then - local copy = deepcopy(actionlist, copies) - print(tag) - -- for k,v in pairs(copy) then - -- copy[k]["active"] = true - -- end - - if(source == nil) then - source = "interact" - end - - if(workerTable[tag] == nil) then - workerTable[tag] = {} - end - - - workerTable[tag]["action"] = copy - workerTable[tag]["index"] = 1 - workerTable[tag]["parent"] = parent - workerTable[tag]["pending"] = false - workerTable[tag]["started"] = false - workerTable[tag]["source"] = source - workerTable[parent]["pending"] = true - workerTable[parent]["children"] = tag - workerTable[tag]["disabled"] = false - workerTable[tag]["executortag"] = executortag - workerTable[tag]["bypassMenu"] = bypassMenu - workerTable[tag]["started_at"] =tostring(os.date("%x %X", os.time())) - workerTable[tag]["last_update"] =tostring(os.date("%x %X", os.time())) - if(isquest ~= nil and isquest == true) then - workerTable[tag]["quest"] = true - end - end - end + + if(tag ~= nil) then + + if(workerTable[tag] == nil) then + local copy = deepcopy(actionlist, copies) + print(tag) + -- for k,v in pairs(copy) then + -- copy[k]["active"] = true + -- end + + if(source == nil) then + source = "interact" + end + + if(workerTable[tag] == nil) then + workerTable[tag] = {} + end + + + workerTable[tag]["action"] = copy + workerTable[tag]["index"] = 1 + workerTable[tag]["parent"] = parent + workerTable[tag]["pending"] = false + workerTable[tag]["started"] = false + workerTable[tag]["source"] = source + workerTable[parent]["pending"] = true + workerTable[parent]["children"] = tag + workerTable[tag]["disabled"] = false + workerTable[tag]["executortag"] = executortag + workerTable[tag]["bypassMenu"] = bypassMenu + workerTable[tag]["started_at"] =tostring(os.date("%x %X", os.time())) + workerTable[tag]["last_update"] =tostring(os.date("%x %X", os.time())) + if(isquest ~= nil and isquest == true) then + workerTable[tag]["quest"] = true + end + end + end end @@ -1784,999 +1795,1007 @@ end --Do and Check object function doEvent(tag) - - local boj = cyberscript.cache["event"][tag] - - if( boj ~= nil) then - local event = boj.data - --testTriggerRequirement(event.requirement,event.trigger) - checkContext(event) - if(checkTriggerRequirement(event.requirement,event.trigger))then - - --logme(10,"CyberScript : Doing event : "..data.name) - - -- doActionof(event.action,"interact") - runActionList(event.action, tag, "interact",false,"nothing") - else - --logme(10,"CyberScript : can't do event : "..data.name) - - end - end + + local boj = cyberscript.cache["event"][tag] + + if( boj ~= nil) then + local event = boj.data + --testTriggerRequirement(event.requirement,event.trigger) + checkContext(event) + if(checkTriggerRequirement(event.requirement,event.trigger))then + + --logme(10,"CyberScript : Doing event : "..data.name) + + -- doActionof(event.action,"interact") + runActionList(event.action, tag, "interact",false,"nothing") + else + --logme(10,"CyberScript : can't do event : "..data.name) + + end + end end function doFunction(tag) - - local boj = cyberscript.cache["functions"][tag] - local event = boj.data - checkContext(event) - runActionList(event.action, tag, "interact",false,"nothing",boj.data.bypassmenu) - + + local boj = cyberscript.cache["functions"][tag] + local event = boj.data + checkContext(event) + runActionList(event.action, tag, "interact",false,"nothing",boj.data.bypassmenu) + end function doTriggeredEvent() - - - - worldprocessing = true - - possibleEvent = {} - - - - for key,value in pairs(cyberscript.cache["event"]) do --actualcode - - local event = cyberscript.cache["event"][key].data - - if(event.way == "world") then - checkContext(event) - ------print("test"..dump(event)) - --logme(4,"check for "..data.name) - --testTriggerRequirement(event.requirement,event.trigger) - ------print(key) - if(checkTriggerRequirement(event.requirement,event.trigger))then - if workerTable[key] == nil then - runActionList(event.action,key,"interact",false,"nothing") - end - end - end - end - - worldprocessing = false - - + + + + worldprocessing = true + + possibleEvent = {} + + + + for key,value in pairs(cyberscript.cache["event"]) do --actualcode + + local event = cyberscript.cache["event"][key].data + + if(event.way == "world") then + checkContext(event) + ------print("test"..dump(event)) + --logme(4,"check for "..data.name) + --testTriggerRequirement(event.requirement,event.trigger) + ------print(key) + if(checkTriggerRequirement(event.requirement,event.trigger))then + if workerTable[key] == nil then + runActionList(event.action,key,"interact",false,"nothing") + end + end + end + end + + worldprocessing = false + + end function doInitEvent() - - - - worldprocessing = true - - possibleEvent = {} - - - - for key,value in pairs(cyberscript.cache["event"]) do --actualcode - - local event = value.data - - if(event.way == "init") then - checkContext(event) - if(checkTriggerRequirement(event.requirement,event.trigger))then - ----print(k) - - - runActionList(event.action,key,"interact",false,"nothing") - end - end - end - - worldprocessing = false - logme(1,"CyberScript : doing init event...") - + + + + worldprocessing = true + + possibleEvent = {} + + + + for key,value in pairs(cyberscript.cache["event"]) do --actualcode + + local event = value.data + + if(event.way == "init") then + checkContext(event) + if(checkTriggerRequirement(event.requirement,event.trigger))then + ----print(k) + + + runActionList(event.action,key,"interact",false,"nothing") + end + end + end + + worldprocessing = false + logme(1,"CyberScript : doing init event...") + end function doIf(action,list,currentindex,listaction) - if(list[1].name ~= "goto" or list[1].name ~= "if") then - local moveindex = #list - local newlist = listaction - for i = 1, moveindex do - newlist[currentindex+moveindex+i] = newlist[currentindex+i] - end - - for i = 1, moveindex do - newlist[currentindex+i] = list[i] - end - - logme(4,"List Is :") - for i=1, #newlist do - logme(4,newlist[i].name) - end - logme(4,"End of ") - action.newlist = newlist - - - - return false - end - + if(list[1].name ~= "goto" or list[1].name ~= "if") then + local moveindex = #list + local newlist = listaction + for i = 1, moveindex do + newlist[currentindex+moveindex+i] = newlist[currentindex+i] + end + + for i = 1, moveindex do + newlist[currentindex+i] = list[i] + end + + logme(4,"List Is :") + for i=1, #newlist do + logme(4,newlist[i].name) + end + logme(4,"End of ") + action.newlist = newlist + + + + return false + end + end function checkIf(action,parent,source,executortag) - - local trigger = action.trigger - if(checkTrigger(trigger)) then - - local tag= parent - local actiontodo = action.if_action - runSubActionList(actiontodo, tag.."_if", parent,source,false,executortag) - - else - - local tag= parent - local actiontodo = action.else_action - runSubActionList(actiontodo, tag.."_else", parent,source,false,executortag) - - - - - end - - - - + + local trigger = action.trigger + if(checkTrigger(trigger)) then + + local tag= parent + local actiontodo = action.if_action + runSubActionList(actiontodo, tag.."_if", parent,source,false,executortag) + + else + + local tag= parent + local actiontodo = action.else_action + runSubActionList(actiontodo, tag.."_else", parent,source,false,executortag) + + + + + end + + + + end function checkEvents() - - getTriggeredActions() - local message = "" - - if(#possibleInteract > 0) then - message = message.."There is some interactions" - else - message = message.."There is no interactions" - end - - if currentQuest == nil then - - if(#possibleQuest > 0) then - message = message.." and some quest" - else - message = message.." and no quest" - end - - - end - - message = message.." available near from you" - Game.GetPlayer():SetWarningMessage(message) - + + getTriggeredActions() + local message = "" + + if(#possibleInteract > 0) then + message = message.."There is some interactions" + else + message = message.."There is no interactions" + end + + if currentQuest == nil then + + if(#possibleQuest > 0) then + message = message.." and some quest" + else + message = message.." and no quest" + end + + + end + + message = message.." available near from you" + Game.GetPlayer():SetWarningMessage(message) + end function checkAmbush() - local ambushevent = {} - - if(AmbushEnabled == true and isAVinService == false) then - --logme(4,"mark1") - if(currentDistricts2.customdistrict ~= nil) then - --logme(4,"mark1") - - - logme(3,"check ambsush") - -- logme(4,"mark1") - for k,v in pairs(cyberscript.cache["event"]) do - - if(cyberscript.cache["event"][k].data.way == "ambush") then - --logme(4,cyberscript.cache["event"][k].data.way) - --table.insert(ambushevent,k) - logme(10,k) - doEvent(k) - - - end - end - - -- if(#ambushevent > 0) then - -- local tag = math.random(1,#ambushevent) - -- logme(4,"doing ambush "..tag) - -- doEvent(ambushevent[tag]) - -- end - - - - - - - - - end - end - + local ambushevent = {} + + if(AmbushEnabled == true and isAVinService == false) then + --logme(4,"mark1") + if(currentDistricts2.customdistrict ~= nil) then + --logme(4,"mark1") + + + logme(3,"check ambsush") + -- logme(4,"mark1") + for k,v in pairs(cyberscript.cache["event"]) do + + if(cyberscript.cache["event"][k].data.way == "ambush") then + --logme(4,cyberscript.cache["event"][k].data.way) + --table.insert(ambushevent,k) + logme(10,k) + doEvent(k) + + + end + end + + -- if(#ambushevent > 0) then + -- local tag = math.random(1,#ambushevent) + -- logme(4,"doing ambush "..tag) + -- doEvent(ambushevent[tag]) + -- end + + + + + + + + + end + end + end function checkSpeakDialog() - - if currentStar ~= nil then - --if string.match(currentStar.Names,targName) then - - - - if tostring(TweakDBID.new(currentStar.TweakIDs)) == tostring(objLook:GetRecordID()) then - - if startSpeak == false then - - selectNPCForSpeak(currentStar) - - - - - end - else - if(currentDialogHub ~= nil) then - openSpeakDialogWindow = false - startSpeak =false - isdialogactivehub = false - removeDialog() - currentDialogHub = nil - logme(4,"totot") - end - end - - - end - - if objLook == nil then - - openSpeakDialogWindow = false - startSpeak =false - - end - + + if currentStar ~= nil then + --if string.match(currentStar.Names,targName) then + + + + if tostring(TweakDBID.new(currentStar.TweakIDs)) == tostring(objLook:GetRecordID()) then + + if startSpeak == false then + + selectNPCForSpeak(currentStar) + + + + + end + else + if(currentDialogHub ~= nil) then + openSpeakDialogWindow = false + startSpeak =false + isdialogactivehub = false + removeDialog() + currentDialogHub = nil + logme(4,"totot") + end + end + + + end + + if objLook == nil then + + openSpeakDialogWindow = false + startSpeak =false + + end + end function checkFixer() - - UpdateFixersPoint() - - - if phonedFixer == false then - if curPos ~= nil then - -- logme(4,curPos) - currentfixer = deepcopy(checkWithFixer(curPos),nil) - end - end - - - - -- pcall(function() - if(currentfixer ~= nil) then --if fixer si founded - - - - - if(checkTriggerRequirement(currentfixer.requirement,currentfixer.trigger)) then --check that fixer can be spawn - - - oldfixer = deepcopy(currentfixer,nil) - if(fixerIsSpawn == false and currentfixer.exist == false and currentfixer.npcexist == false and cyberscript.EntityManager[currentfixer.tag] == nil) then - print(currentfixer.tag) - - - local twkVehi = TweakDBID.new(currentfixer.tweakid) - - - - - if cyberscript.EntityManager[currentfixer.tag] == nil then - cyberscript.EntityManager[currentfixer.tag] = {} - if currentfixer.appearance == nil then currentfixer.appearance = "" end - spawnNPC(currentfixer.tweakid,currentfixer.appearance, currentfixer.tag, currentfixer.x, currentfixer.y, currentfixer.z, 42, false, false, nil, false, nil,0,true,true,true,true,true) - logme(1,"Cyberscript : Spawn Fixer :"..currentfixer.tag) - end - - - - - - end - - -- if(currentfixer.exist == false and currentfixer.npcexist == false and fixerIsSpawn == false) then - -- ------print("spawn") - -- -- if (cyberscript.EntityManager[currentfixer.tag] ~= nil ) then - -- -- despawnEntity(currentfixer.tag) - - -- -- end - - - -- -- local twkVehi = TweakDBID.new(currentfixer.tweakid) - - - - -- -- cyberscript.EntityManager[currentfixer.tag] = {} - -- -- spawnNPC(currentfixer.tweakid,"", currentfixer.tag, currentfixer.x, currentfixer.y, currentfixer.z, 42, true, false, nil, false, nil) - - - - - - - - -- end - - if(fixerIsSpawn == false and currentfixer.spawn_action ~= nil and #currentfixer.spawn_action >0 ) then - - - - runActionList(currentfixer.spawn_action, currentfixer.tag.."_Spawn",nil,nil,currentfixer.tag) - fixerIsSpawn = true - - end - - - - - - - - end - - else -- if we move away from fixer so currentfixer is nil - - - ChangeZoneIndicatorPublic() - - if(oldfixer ~= nil) then - - - - - - if(oldfixer ~= nil and oldfixer.despawn_action ~= nil and #oldfixer.despawn_action >0) then - - --doActionof(currentfixer.action,"interact") - runActionList(oldfixer.despawn_action, oldfixer.tag.."_Despawn",nil, nil,oldfixer.tag) - - - - end - - oldfixer = nil - - - - - end - - fixerIsSpawn = false - - - end - - - - + + UpdateFixersPoint() + + + if phonedFixer == false then + if curPos ~= nil then + -- logme(4,curPos) + currentfixer = deepcopy(checkWithFixer(curPos),nil) + end + end + + + + -- pcall(function() + if(currentfixer ~= nil) then --if fixer si founded + + + + + if(checkTriggerRequirement(currentfixer.requirement,currentfixer.trigger)) then --check that fixer can be spawn + + + oldfixer = deepcopy(currentfixer,nil) + if(fixerIsSpawn == false and currentfixer.exist == false and currentfixer.npcexist == false and cyberscript.EntityManager[currentfixer.tag] == nil) then + print(currentfixer.tag) + + + local twkVehi = TweakDBID.new(currentfixer.tweakid) + + + + + if cyberscript.EntityManager[currentfixer.tag] == nil then + cyberscript.EntityManager[currentfixer.tag] = {} + if currentfixer.appearance == nil then currentfixer.appearance = "" end + -- B-26 fix: only spawn the fixer NPC in the world if the + -- user has not disabled it via "Show Cyberscript Fixer on Street". + -- Map markers are controlled separately by showcyberscriptfixeronmap. + -- Default: true (preserves existing behavior — fixers spawn on street). + if showcyberscriptfixeronstreet ~= false then + spawnNPC(currentfixer.tweakid,currentfixer.appearance, currentfixer.tag, currentfixer.x, currentfixer.y, currentfixer.z, 42, false, false, nil, false, nil,0,true,true,true,true,true) + logme(1,"Cyberscript : Spawn Fixer :"..currentfixer.tag) + else + logme(2,"Cyberscript : Fixer NPC spawn skipped (showcyberscriptfixeronstreet=false): "..currentfixer.tag) + end + end + + + + + + end + + -- if(currentfixer.exist == false and currentfixer.npcexist == false and fixerIsSpawn == false) then + -- ------print("spawn") + -- -- if (cyberscript.EntityManager[currentfixer.tag] ~= nil ) then + -- -- despawnEntity(currentfixer.tag) + + -- -- end + + + -- -- local twkVehi = TweakDBID.new(currentfixer.tweakid) + + + + -- -- cyberscript.EntityManager[currentfixer.tag] = {} + -- -- spawnNPC(currentfixer.tweakid,"", currentfixer.tag, currentfixer.x, currentfixer.y, currentfixer.z, 42, true, false, nil, false, nil) + + + + + + + + -- end + + if(fixerIsSpawn == false and currentfixer.spawn_action ~= nil and #currentfixer.spawn_action >0 ) then + + + + runActionList(currentfixer.spawn_action, currentfixer.tag.."_Spawn",nil,nil,currentfixer.tag) + fixerIsSpawn = true + + end + + + + + + + + end + + else -- if we move away from fixer so currentfixer is nil + + + ChangeZoneIndicatorPublic() + + if(oldfixer ~= nil) then + + + + + + if(oldfixer ~= nil and oldfixer.despawn_action ~= nil and #oldfixer.despawn_action >0) then + + --doActionof(currentfixer.action,"interact") + runActionList(oldfixer.despawn_action, oldfixer.tag.."_Despawn",nil, nil,oldfixer.tag) + + + + end + + oldfixer = nil + + + + + end + + fixerIsSpawn = false + + + end + + + + end function checkContext(item) - - if(item ~= nil and item.context ~= nil) then - - if(isArray(item.context))then - for i,v in ipairs(item.context) do - - if(checkTriggerRequirement(v.requirement,v.trigger))then - - if(v.action ~= nil and #v.action > 0) then - - runActionList(v.action, item.tag, "see", false,"see",false) - end - - - for k,u in pairs(v.prop) do - - - local path = splitDot(k, ".") - setValueToTablePath(item, path, GeneratefromContext(item,u)) - - end - end - end - else - if(checkTriggerRequirement(item.context.requirement,item.context.trigger))then - for k,u in pairs(item.context.prop) do - - - local path = splitDot(k, ".") - - - setValueToTablePath(item, path, GeneratefromContext(item,u)) - end - end - end - - end + + if(item ~= nil and item.context ~= nil) then + + if(isArray(item.context))then + for i,v in ipairs(item.context) do + + if(checkTriggerRequirement(v.requirement,v.trigger))then + + if(v.action ~= nil and #v.action > 0) then + + runActionList(v.action, item.tag, "see", false,"see",false) + end + + + for k,u in pairs(v.prop) do + + + local path = splitDot(k, ".") + setValueToTablePath(item, path, GeneratefromContext(item,u)) + + end + end + end + else + if(checkTriggerRequirement(item.context.requirement,item.context.trigger))then + for k,u in pairs(item.context.prop) do + + + local path = splitDot(k, ".") + + + setValueToTablePath(item, path, GeneratefromContext(item,u)) + end + end + end + + end end function checkNPC() - - - - for k,v in pairs(cyberscript.cache["npc"]) do - - local npc = cyberscript.cache["npc"][k].data - - - - if(cyberscript.EntityManager[k] == nil) then - checkContext(npc) - - - local npcpostion = getPositionFromParameter(npc.location) - - if(npcpostion.x ~= nil and npcpostion.y ~= nil and npcpostion.z~= nil)then - if( check3DPos(curPos, npcpostion.x, npcpostion.y, npcpostion.z, npc.location.player_range) ) then - --if the npc is not spawned - - - if(getEntityFromManager(k).id == nil and checkTriggerRequirement(npc.requirement,npc.triggers)) then - - - - - - local tweakDBnpc = npc.tweakDB - - if(tweakDBnpc== "district") then - - local gangs = getGangfromDistrict(currentDistricts2.Tag,20) - - if(#gangs == 0) then - - break - - end - - local gang = getFactionByTag(gangs[1].tag) - - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - - tweakDBnpc = gang.spawnable_npc[index] - else - break - end - - elseif (tweakDBnpc== "subdistrict") then - - local gangs = {} - - for i, test in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - - - gangs = getGangfromDistrict(test,20) - - if(#gangs == 0) then - - break - - end - end - end - - local gang = getFactionByTag(gangs[1].tag) - - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - - tweakDBnpc = gang.spawnable_npc[index] - else - break - end - - if(tweakDBnpc== "districttag") then - - gangs = getGangfromDistrict(npc.locationtag,20) - - if(#gangs == 0) then - - break - - end - - local gang = getFactionByTag(gangs[1].tag) - - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - - tweakDBnpc = gang.spawnable_npc[index] - else - break - end - - elseif (tweakDBnpc== "subdistricttag") then - - local gangs = {} - - gangs = getGangfromDistrict(npc.locationtag,20) - - local gang = getFactionByTag(gangs[1].tag) - - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - - tweakDBnpc = gang.spawnable_npc[index] - else - break - end - - - - - end - end - - - - cyberscript.EntityManager[npc.tag] = {} - spawnNPC(tweakDBnpc,"", npc.tag, npcpostion.x, npcpostion.y, npcpostion.z, 42, true, false, nil, false, npc.rotation,0) - - npc.isspawn=true - npc.init=false - - end - end - - - - - - end - - else - - local obj = getEntityFromManager(k) - - if(obj ~= nil and obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - - - if(enti ~= nil) then--entity exist - checkContext(npc) - local npcpostion = getPositionFromParameter(npc.location) - if((check3DPos(Game.GetPlayer():GetWorldPosition(), npcpostion.x, npcpostion.y, npcpostion.z, npc.location.player_range) and npc.spawnforced == false) or npc.spawnforced == true) then --ifplayer is in the location - - if(cyberscript.cache["npc"][k].data.init==false) then --if not initiaded - - local npc = cyberscript.cache["npc"][k].data - - if(npc.appeareance ~= nil or npc.appeareance ~= "" and cyberscript.cache["npc"][k].data.appearancesetted == false) then - - local obj = getEntityFromManager(npc.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - - setAppearance(enti,npc.appeareance) - cyberscript.cache["npc"][k].data.appearancesetted = true - end - - - end - - if(workerTable[npc.tag.."_spawn"] == nil and #npc.spawnaction > 0 and npc.dospawnaction == true) then - - - - runActionList(npc.spawnaction, npc.tag.."_spawn", "interact",false,npc.tag) - - end - - if(workerTable[npc.tag.."_routine"] == nil and #npc.routineaction > 0 and npc.doroutineaction == true) then - runActionList(npc.routineaction, npc.tag.."_routine", "interact",false,npc.tag) - - end - - - cyberscript.cache["npc"][k].data.init = true - - else - - - - if(workerTable[npc.tag.."_routine"] == nil and npc.repeat_routine == true and #npc.routineaction > 0 and npc.doroutineaction == true) then - runActionList(npc.routineaction, npc.tag.."_routine", "interact",false,npc.tag) - -- logme(4,"doing routine of "..npc.name) - - end - - - if (workerTable[npc.tag.."_death"] == nil and npc.deathaction ~= nil and #npc.deathaction > 0 and (enti:IsDead() == true or enti:IsActive() == false) and npc.dodeathaction == true)then - runActionList(npc.deathaction, npc.tag.."_death", "interact",false,npc.tag) - - npc.dodeathaction= false - end - end - - - else - - - if(npc.auto_despawn == true) then - - cyberscript.cache["npc"][k].data.isspawn=false - cyberscript.cache["npc"][k].data.init=false - cyberscript.cache["npc"][k].data.appearancesetted = nil - - if(workerTable[npc.tag.."_spawn"] ~= nil) then - - workerTable[npc.tag.."_spawn"] = nil - - end - - if(workerTable[npc.tag.."_routine"] ~= nil) then - - workerTable[npc.tag.."_routine"] = nil - - end - - if(workerTable[npc.tag.."_death"] ~= nil) then - - workerTable[npc.tag.."_death"] = nil - - end - - despawnEntity(npc.tag) - ----print("despawn "..npc.tag) - if(workerTable[npc.tag.."_despawn"] == nil and #npc.despawnaction > 0 and npc.dospawnaction == true) then - runActionList(npc.despawnaction, npc.tag.."_despawn", "interact",false,npc.tag) - - end - - end - - end - - end - end - - - end - - - end - - + + + + for k,v in pairs(cyberscript.cache["npc"]) do + + local npc = cyberscript.cache["npc"][k].data + + + + if(cyberscript.EntityManager[k] == nil) then + checkContext(npc) + + + local npcpostion = getPositionFromParameter(npc.location) + + if(npcpostion.x ~= nil and npcpostion.y ~= nil and npcpostion.z~= nil)then + if( check3DPos(curPos, npcpostion.x, npcpostion.y, npcpostion.z, npc.location.player_range) ) then + --if the npc is not spawned + + + if(getEntityFromManager(k).id == nil and checkTriggerRequirement(npc.requirement,npc.triggers)) then + + + + + + local tweakDBnpc = npc.tweakDB + + if(tweakDBnpc== "district") then + + local gangs = getGangfromDistrict(currentDistricts2.Tag,20) + + if(#gangs == 0) then + + break + + end + + local gang = getFactionByTag(gangs[1].tag) + + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + + tweakDBnpc = gang.spawnable_npc[index] + else + break + end + + elseif (tweakDBnpc== "subdistrict") then + + local gangs = {} + + for i, test in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + + + gangs = getGangfromDistrict(test,20) + + if(#gangs == 0) then + + break + + end + end + end + + local gang = getFactionByTag(gangs[1].tag) + + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + + tweakDBnpc = gang.spawnable_npc[index] + else + break + end + + if(tweakDBnpc== "districttag") then + + gangs = getGangfromDistrict(npc.locationtag,20) + + if(#gangs == 0) then + + break + + end + + local gang = getFactionByTag(gangs[1].tag) + + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + + tweakDBnpc = gang.spawnable_npc[index] + else + break + end + + elseif (tweakDBnpc== "subdistricttag") then + + local gangs = {} + + gangs = getGangfromDistrict(npc.locationtag,20) + + local gang = getFactionByTag(gangs[1].tag) + + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + + tweakDBnpc = gang.spawnable_npc[index] + else + break + end + + + + + end + end + + + + cyberscript.EntityManager[npc.tag] = {} + spawnNPC(tweakDBnpc,"", npc.tag, npcpostion.x, npcpostion.y, npcpostion.z, 42, true, false, nil, false, npc.rotation,0) + + npc.isspawn=true + npc.init=false + + end + end + + + + + + end + + else + + local obj = getEntityFromManager(k) + + if(obj ~= nil and obj.id ~= nil) then + local enti = safeFindEntityByID(obj.id) + + + if(enti ~= nil) then--entity exist + checkContext(npc) + local npcpostion = getPositionFromParameter(npc.location) + if((check3DPos(Game.GetPlayer():GetWorldPosition(), npcpostion.x, npcpostion.y, npcpostion.z, npc.location.player_range) and npc.spawnforced == false) or npc.spawnforced == true) then --ifplayer is in the location + + if(cyberscript.cache["npc"][k].data.init==false) then --if not initiaded + + local npc = cyberscript.cache["npc"][k].data + + if(npc.appeareance ~= nil or npc.appeareance ~= "" and cyberscript.cache["npc"][k].data.appearancesetted == false) then + + local obj = getEntityFromManager(npc.tag) + local enti = safeFindEntityByID(obj.id) + if(enti ~= nil) then + + + setAppearance(enti,npc.appeareance) + cyberscript.cache["npc"][k].data.appearancesetted = true + end + + + end + + if(workerTable[npc.tag.."_spawn"] == nil and #npc.spawnaction > 0 and npc.dospawnaction == true) then + + + + runActionList(npc.spawnaction, npc.tag.."_spawn", "interact",false,npc.tag) + + end + + if(workerTable[npc.tag.."_routine"] == nil and #npc.routineaction > 0 and npc.doroutineaction == true) then + runActionList(npc.routineaction, npc.tag.."_routine", "interact",false,npc.tag) + + end + + + cyberscript.cache["npc"][k].data.init = true + + else + + + + if(workerTable[npc.tag.."_routine"] == nil and npc.repeat_routine == true and #npc.routineaction > 0 and npc.doroutineaction == true) then + runActionList(npc.routineaction, npc.tag.."_routine", "interact",false,npc.tag) + -- logme(4,"doing routine of "..npc.name) + + end + + + if (workerTable[npc.tag.."_death"] == nil and npc.deathaction ~= nil and #npc.deathaction > 0 and (enti:IsDead() == true or enti:IsActive() == false) and npc.dodeathaction == true)then + runActionList(npc.deathaction, npc.tag.."_death", "interact",false,npc.tag) + + npc.dodeathaction= false + end + end + + + else + + + if(npc.auto_despawn == true) then + + cyberscript.cache["npc"][k].data.isspawn=false + cyberscript.cache["npc"][k].data.init=false + cyberscript.cache["npc"][k].data.appearancesetted = nil + + if(workerTable[npc.tag.."_spawn"] ~= nil) then + + workerTable[npc.tag.."_spawn"] = nil + + end + + if(workerTable[npc.tag.."_routine"] ~= nil) then + + workerTable[npc.tag.."_routine"] = nil + + end + + if(workerTable[npc.tag.."_death"] ~= nil) then + + workerTable[npc.tag.."_death"] = nil + + end + + despawnEntity(npc.tag) + ----print("despawn "..npc.tag) + if(workerTable[npc.tag.."_despawn"] == nil and #npc.despawnaction > 0 and npc.dospawnaction == true) then + runActionList(npc.despawnaction, npc.tag.."_despawn", "interact",false,npc.tag) + + end + + end + + end + + end + end + + + end + + + end + + end function checkValue(operator,value1,value2, min, max) - - return ( - (value1 ~= nil and value2 ~= nil and - ( - (operator == "<" and value1 < value2) or - (operator == "<=" and value1 <= value2) or - (operator == ">" and value1 > value2) or - (operator == ">=" and value1 >= value2) or - (operator == "!=" and value1 ~= value2) or - (operator == "=" and value1 == value2) or - - (operator == "><" and min ~= nil and max ~= nil and value1 > min and value1 < max ) or - (operator == ">=<" and min ~= nil and max ~= nil and value1 >= min and value1 < max ) or - (operator == "><=" and min ~= nil and max ~= nil and value1 > min and value1 <= max ) or - (operator == ">=<=" and min ~= nil and max ~= nil and value1 >= min and value1 <= max ) or - - (operator == "<>" and min ~= nil and max ~= nil and (value1 < min or value1 > max )) or - (operator == "<=>" and min ~= nil and max ~= nil and (value1 <= min or value1 > max )) or - (operator == "<>=" and min ~= nil and max ~= nil and (value1 < min or value1 >= max )) or - (operator == "<=>=" and min ~= nil and max ~= nil and (value1 <= min or value1 >= max )) - ) - ) or - (operator == "empty" and value1 == nil) or - (operator == "notempty" and value1 ~= nil) - - or - (operator == "nothing" and value1 == nil) or - (operator == "notnothing" and value1 ~= nil) - - - ) + + return ( + (value1 ~= nil and value2 ~= nil and + ( + (operator == "<" and value1 < value2) or + (operator == "<=" and value1 <= value2) or + (operator == ">" and value1 > value2) or + (operator == ">=" and value1 >= value2) or + (operator == "!=" and value1 ~= value2) or + (operator == "=" and value1 == value2) or + + (operator == "><" and min ~= nil and max ~= nil and value1 > min and value1 < max ) or + (operator == ">=<" and min ~= nil and max ~= nil and value1 >= min and value1 < max ) or + (operator == "><=" and min ~= nil and max ~= nil and value1 > min and value1 <= max ) or + (operator == ">=<=" and min ~= nil and max ~= nil and value1 >= min and value1 <= max ) or + + (operator == "<>" and min ~= nil and max ~= nil and (value1 < min or value1 > max )) or + (operator == "<=>" and min ~= nil and max ~= nil and (value1 <= min or value1 > max )) or + (operator == "<>=" and min ~= nil and max ~= nil and (value1 < min or value1 >= max )) or + (operator == "<=>=" and min ~= nil and max ~= nil and (value1 <= min or value1 >= max )) + ) + ) or + (operator == "empty" and value1 == nil) or + (operator == "notempty" and value1 ~= nil) + + or + (operator == "nothing" and value1 == nil) or + (operator == "notnothing" and value1 ~= nil) + + + ) end --Get List function getInteractGroup() - - currentInteractGroup ={} - - local groupof = {} - - for key,value in pairs(cyberscript.cache["interact"]) do --actualcode - - - local interact2 = cyberscript.cache["interact"][key].data - local canadd = true - - for i=1,#currentInteractGroup do - - if(currentInteractGroup[i] == interact2.group) then - canadd = false - - end - - end - - if(canadd == true) then - - table.insert(currentInteractGroup, interact2.group) - - end - - - end - - - - + + currentInteractGroup ={} + + local groupof = {} + + for key,value in pairs(cyberscript.cache["interact"]) do --actualcode + + + local interact2 = cyberscript.cache["interact"][key].data + local canadd = true + + for i=1,#currentInteractGroup do + + if(currentInteractGroup[i] == interact2.group) then + canadd = false + + end + + end + + if(canadd == true) then + + table.insert(currentInteractGroup, interact2.group) + + end + + + end + + + + end function getTriggeredActions() - - - - worldprocessing = true - local possibleinteractchunk = {} - possibleInteract = {} - local possibleinteractchunked = {} - - - for key,value in pairs(cyberscript.cache["interact"]) do --actualcode - - local interact2 = cyberscript.cache["interact"][key].data - - --testTriggerRequirement(interact2.requirement,interact2.trigger) - if(checkTriggerRequirement(interact2.requirement,interact2.trigger)) and (interact2.group == currentInteractGroup[currentInteractGroupIndex] or key == "default_open_datapack_group_ui") then - - --logme(4,"check for "..data2.name.." "..tostring(checkTriggerRequirement(interact2.requirement,interact2.trigger))) - table.insert(possibleinteractchunk, interact2) - else - - if(#currentInputHintList > 0) then - - for i = 1, #currentInputHintList do - - if(currentInputHintList[i]~= nil and currentInputHintList[i].tag == interact2.tag) then - hideCustomHints(interact2.tag) - - currentInputHintList[i] = nil - end - - - end - - - end - - end - end - local chunk = {} - local count = 1 - - - for i=1,#possibleinteractchunk+1 do - - -- - if(#chunk < 4 and i<#possibleinteractchunk+1) then - - - if(possibleinteractchunk[i] ~= nil) then - - table.insert(chunk,possibleinteractchunk[i]) - count = count + 1 - - end - - else - - - - local chunkcopy = {} - for z=1,#chunk do - - table.insert(chunkcopy,chunk[z]) - - end - - table.insert(possibleInteract,chunkcopy) - - - if(possibleinteractchunk[i] ~= nil) then - chunk = {} - table.insert(chunk,possibleinteractchunk[i]) - - count = 1 - - end - end - - - end - - - - - - - worldprocessing = false - - + + + + worldprocessing = true + local possibleinteractchunk = {} + possibleInteract = {} + local possibleinteractchunked = {} + + + for key,value in pairs(cyberscript.cache["interact"]) do --actualcode + + local interact2 = cyberscript.cache["interact"][key].data + + --testTriggerRequirement(interact2.requirement,interact2.trigger) + if(checkTriggerRequirement(interact2.requirement,interact2.trigger)) and (interact2.group == currentInteractGroup[currentInteractGroupIndex] or key == "default_open_datapack_group_ui") then + + --logme(4,"check for "..data2.name.." "..tostring(checkTriggerRequirement(interact2.requirement,interact2.trigger))) + table.insert(possibleinteractchunk, interact2) + else + + if(#currentInputHintList > 0) then + + for i = 1, #currentInputHintList do + + if(currentInputHintList[i]~= nil and currentInputHintList[i].tag == interact2.tag) then + hideCustomHints(interact2.tag) + + currentInputHintList[i] = nil + end + + + end + + + end + + end + end + local chunk = {} + local count = 1 + + + for i=1,#possibleinteractchunk+1 do + + -- + if(#chunk < 4 and i<#possibleinteractchunk+1) then + + + if(possibleinteractchunk[i] ~= nil) then + + table.insert(chunk,possibleinteractchunk[i]) + count = count + 1 + + end + + else + + + + local chunkcopy = {} + for z=1,#chunk do + + table.insert(chunkcopy,chunk[z]) + + end + + table.insert(possibleInteract,chunkcopy) + + + if(possibleinteractchunk[i] ~= nil) then + chunk = {} + table.insert(chunk,possibleinteractchunk[i]) + + count = 1 + + end + end + + + end + + + + + + + worldprocessing = false + + end function getTriggeredActionsDisplay() - - -- if(#currentInputHintList > 0) then - - -- for i = 1, #currentInputHintList do - - -- hideCustomHints(currentInputHintList[i].tag) - - -- end - - -- end - - - possibleinteractchunk = {} - - local possibleinteractchunked = {} - possibleInteractDisplay = {} - for i=1,#possibleInteract do - - for z=1,#possibleInteract[i] do - - - if((possibleInteract[i][z].display == "event_interact" - or - (currentHouse ~= nil and (possibleInteract[i][z].display == "place" - or possibleInteract[i][z].display == "place_main" or - possibleInteract[i][z].display == "event_interact")))) then - table.insert(possibleinteractchunk,possibleInteract[i][z]) - end - - - end - - - end - - - local chunk = {} - - for i=1,#possibleinteractchunk+1 do - - -- - if(#chunk < 4 and i<#possibleinteractchunk+1) then - - - if(possibleinteractchunk[i] ~= nil) then - - table.insert(chunk,possibleinteractchunk[i]) - - - end - - else - - - - local chunkcopy = {} - for z=1,#chunk do - chunk[z].input=z - table.insert(chunkcopy,chunk[z]) - - end - - table.insert(possibleInteractDisplay,chunkcopy) - - if(possibleinteractchunk[i] ~= nil) then - chunk = {} - table.insert(chunk,possibleinteractchunk[i]) - - - end - end - - - end - - - - - - - + + -- if(#currentInputHintList > 0) then + + -- for i = 1, #currentInputHintList do + + -- hideCustomHints(currentInputHintList[i].tag) + + -- end + + -- end + + + possibleinteractchunk = {} + + local possibleinteractchunked = {} + possibleInteractDisplay = {} + for i=1,#possibleInteract do + + for z=1,#possibleInteract[i] do + + + if((possibleInteract[i][z].display == "event_interact" + or + (currentHouse ~= nil and (possibleInteract[i][z].display == "place" + or possibleInteract[i][z].display == "place_main" or + possibleInteract[i][z].display == "event_interact")))) then + table.insert(possibleinteractchunk,possibleInteract[i][z]) + end + + + end + + + end + + + local chunk = {} + + for i=1,#possibleinteractchunk+1 do + + -- + if(#chunk < 4 and i<#possibleinteractchunk+1) then + + + if(possibleinteractchunk[i] ~= nil) then + + table.insert(chunk,possibleinteractchunk[i]) + + + end + + else + + + + local chunkcopy = {} + for z=1,#chunk do + chunk[z].input=z + table.insert(chunkcopy,chunk[z]) + + end + + table.insert(possibleInteractDisplay,chunkcopy) + + if(possibleinteractchunk[i] ~= nil) then + chunk = {} + table.insert(chunk,possibleinteractchunk[i]) + + + end + end + + + end + + + + + + + end function getMissionByTrigger() - - - --find new mission - - - possibleQuest = {} - - for key,value in pairs(cyberscript.cache["mission"]) do --actualcode - - if(checkQuestStatutByTag(key, nil) == true or checkQuestStatutByTag(key, -1) == true) then - local quest = cyberscript.cache["mission"][key].data - - if(HaveTriggerCondition(quest))then - - - --if(possibleQuest[quest] ~= nil) then - - table.insert(possibleQuest, quest) - - if(QuestManager.GetQuestState(quest.tag).isActive == false) then - - if(quest.unlock_action ~= nil and #quest.unlock_action > 0) then - runActionList(quest.unlock_action,quest.tag.."_unlockaction","quest",true,"see_engine",true) - end - - - QuestManager.MarkQuestAsActive(quest.tag) - - - end - --end - - else - --logme(4,tostring(QuestManager.isVisited(key))) - if not QuestManager.isVisited(key) then - QuestManager.MarkQuestAsInactive(key) - --logme(4,"remove"..key) - end - end - - else - if(checkQuestStatutByTag(key, 3) == true) then - --QuestManager.MarkQuestAsInactive(key) - QuestManager.MarkQuestASucceeded(key) - end - - end - - end - - - - - - - takenQuest = {} - - for key,value in pairs(cyberscript.cache["mission"]) do --actualcode - local statuQue = checkQuestStatutByTag(key, 0) or checkQuestStatutByTag(key, 1) or checkQuestStatutByTag(key, 2) - - if( statuQue== true) then - - local quest = cyberscript.cache["mission"][key].data - - - - - --if(possibleQuest[quest] ~= nil) then - --table.insert(takenQuest, quest) - QuestManager.MarkQuestAsActive(quest.tag) - --end - - end - - end - - - + + + --find new mission + + + possibleQuest = {} + + for key,value in pairs(cyberscript.cache["mission"]) do --actualcode + + if(checkQuestStatutByTag(key, nil) == true or checkQuestStatutByTag(key, -1) == true) then + local quest = cyberscript.cache["mission"][key].data + + if(HaveTriggerCondition(quest))then + + + --if(possibleQuest[quest] ~= nil) then + + table.insert(possibleQuest, quest) + + if(QuestManager.GetQuestState(quest.tag).isActive == false) then + + if(quest.unlock_action ~= nil and #quest.unlock_action > 0) then + runActionList(quest.unlock_action,quest.tag.."_unlockaction","quest",true,"see_engine",true) + end + + + QuestManager.MarkQuestAsActive(quest.tag) + + + end + --end + + else + --logme(4,tostring(QuestManager.isVisited(key))) + if not QuestManager.isVisited(key) then + QuestManager.MarkQuestAsInactive(key) + --logme(4,"remove"..key) + end + end + + else + if(checkQuestStatutByTag(key, 3) == true) then + --QuestManager.MarkQuestAsInactive(key) + QuestManager.MarkQuestASucceeded(key) + end + + end + + end + + + + + + + takenQuest = {} + + for key,value in pairs(cyberscript.cache["mission"]) do --actualcode + local statuQue = checkQuestStatutByTag(key, 0) or checkQuestStatutByTag(key, 1) or checkQuestStatutByTag(key, 2) + + if( statuQue== true) then + + local quest = cyberscript.cache["mission"][key].data + + + + + --if(possibleQuest[quest] ~= nil) then + --table.insert(takenQuest, quest) + QuestManager.MarkQuestAsActive(quest.tag) + --end + + end + + end + + + end @@ -2786,520 +2805,520 @@ end --GET objects function CorrectAllPOI() - - if poicorrectready == true and activeEditedPOI["locations"][currentpoicorrectindex] ~= nil then - - ----print("TP to "..activeEditedPOI["locations"][currentpoicorrectindex].Tag) - poicorrectready = false - local correctpoi = activeEditedPOI["locations"][currentpoicorrectindex] - local loca = {} - loca.x = correctpoi.x - loca.y = correctpoi.y - loca.z = correctpoi.z - - if activeEditedPOI["locations"][currentpoicorrectindex+1] ~= nil then - teleportTo(Game.GetPlayer(), loca, 1,true) - - Cron.After(0.1, function() - - activeEditedPOI["locations"][currentpoicorrectindex].district = getVariableKey("current_district","enum") - activeEditedPOI["locations"][currentpoicorrectindex].subdistrict = getVariableKey("current_district","subdistrict_enum") - activeEditedPOI["locations"][currentpoicorrectindex].Tag = activeEditedPOI.tag.."_"..currentpoicorrectindex - -- ----print("Correct "..activeEditedPOI["locations"][currentpoicorrectindex].Tag.." on "..#activeEditedPOI["locations"]) - currentpoicorrectindex = currentpoicorrectindex+1 - poicorrectready = true - -- if isprevention == true then - -- local postp = Vector4.new( x, y, z,1) - -- teleportTo(Game.FindEntityByID(NPC), postp, 1,false) - -- end - - - - - end) - else - ----print("nope") - end - - else - if poicorrectready == true and activeEditedPOI["locations"][currentpoicorrectindex] == nil then - wantcorrectpoi = false - ----print("nope2") - end - - end - - + + if poicorrectready == true and activeEditedPOI["locations"][currentpoicorrectindex] ~= nil then + + ----print("TP to "..activeEditedPOI["locations"][currentpoicorrectindex].Tag) + poicorrectready = false + local correctpoi = activeEditedPOI["locations"][currentpoicorrectindex] + local loca = {} + loca.x = correctpoi.x + loca.y = correctpoi.y + loca.z = correctpoi.z + + if activeEditedPOI["locations"][currentpoicorrectindex+1] ~= nil then + teleportTo(Game.GetPlayer(), loca, 1,true) + + Cron.After(0.1, function() + + activeEditedPOI["locations"][currentpoicorrectindex].district = getVariableKey("current_district","enum") + activeEditedPOI["locations"][currentpoicorrectindex].subdistrict = getVariableKey("current_district","subdistrict_enum") + activeEditedPOI["locations"][currentpoicorrectindex].Tag = activeEditedPOI.tag.."_"..currentpoicorrectindex + -- ----print("Correct "..activeEditedPOI["locations"][currentpoicorrectindex].Tag.." on "..#activeEditedPOI["locations"]) + currentpoicorrectindex = currentpoicorrectindex+1 + poicorrectready = true + -- if isprevention == true then + -- local postp = Vector4.new( x, y, z,1) + -- teleportTo(safeFindEntityByID(NPC), postp, 1,false) + -- end + + + + + end) + else + ----print("nope") + end + + else + if poicorrectready == true and activeEditedPOI["locations"][currentpoicorrectindex] == nil then + wantcorrectpoi = false + ----print("nope2") + end + + end + + end function getEventByTag(tag) - logme(4,"d,f, ") - for i=1,#cyberscript.cache["event"] do - logme(4,cyberscript.cache["event"][i].data.name) - if(cyberscript.cache["event"][i].data.tag == tag)then - - return cyberscript.cache["event"][i].data - - end - - end - - return nil + logme(4,"d,f, ") + for i=1,#cyberscript.cache["event"] do + logme(4,cyberscript.cache["event"][i].data.name) + if(cyberscript.cache["event"][i].data.tag == tag)then + + return cyberscript.cache["event"][i].data + + end + + end + + return nil end function getSubtitleByTag(tag) - - for i=1,#arraySubtitle do - - if(arraySubtitle[i].tag == tag)then - - return arraySubtitle[i] - - end - - end - - return nil + + for i=1,#arraySubtitle do + + if(arraySubtitle[i].tag == tag)then + + return arraySubtitle[i] + + end + + end + + return nil end function getShardByTag(tag) - - - if(cyberscript.cache["shard"][tag] ~= nil)then - - return cyberscript.cache["shard"][tag].data - - end - return nil - + + + if(cyberscript.cache["shard"][tag] ~= nil)then + + return cyberscript.cache["shard"][tag].data + + end + return nil + end function getCustomNPCByTag(tag) - - - if(cyberscript.cache["npc"][tag] ~= nil)then - - return cyberscript.cache["npc"][tag].data - - end - return nil - + + + if(cyberscript.cache["npc"][tag] ~= nil)then + + return cyberscript.cache["npc"][tag].data + + end + return nil + end function getInteractByTag(tag) - - return cyberscript.cache["interact"][tag].data - - + + return cyberscript.cache["interact"][tag].data + + end function getInteractsBySortTag(tag) - local result = {} - - for i = 1, #possibleInteract do - - for z = 1, #possibleInteract[i] do - --logme(4,possibleInteract[i].name) - if(possibleInteract[i][z].sorttag == tag)then - - table.insert(result, possibleInteract[i][z]) - - end - - end - - end - - return result + local result = {} + + for i = 1, #possibleInteract do + + for z = 1, #possibleInteract[i] do + --logme(4,possibleInteract[i].name) + if(possibleInteract[i][z].sorttag == tag)then + + table.insert(result, possibleInteract[i][z]) + + end + + end + + end + + return result end function getPhoneConversationByTag(tag) - - if(cyberscript.cache["phone_dialog"][tag] ~= tag)then - - return cyberscript.cache["phone_dialog"][tag].conv - - end - - return nil - + + if(cyberscript.cache["phone_dialog"][tag] ~= tag)then + + return cyberscript.cache["phone_dialog"][tag].conv + + end + + return nil + end function getPath(tag) - - - if(cyberscript.cache["path"][tag] ~= nil) then - return cyberscript.cache["path"][tag].data - end - return nil - + + + if(cyberscript.cache["path"][tag] ~= nil) then + return cyberscript.cache["path"][tag].data + end + return nil + end function tablelength(T) - local count = 0 - for _ in pairs(T) do count = count + 1 end - return count + local count = 0 + for _ in pairs(T) do count = count + 1 end + return count end function getPOI(tag) - - - if(cyberscript.cache["poi"][tag] ~= nil) then - return cyberscript.cache["poi"][tag].poi - end - return nil - - + + + if(cyberscript.cache["poi"][tag] ~= nil) then + return cyberscript.cache["poi"][tag].poi + end + return nil + + end function FindPOI(tag,district,subdistrict,iscar,poitype,locationtag,fromposition,range,frompositionx,frompositiony,frompositionz,listargument,distancename) - - - - local currentpoilist = {} - local frompos = curPos - - if(frompositionx ~= nil and frompositiony ~= nil and frompositionz ~= nil) then - - frompos.x = frompositionx - frompos.y = frompositiony - frompos.z = frompositionz - - end - - if(listargument == "type" and poi_type[tostring(poitype)] ~= nil) then - - local list = poi_type[tostring(poitype)]["outVehicule"] - - if(iscar) then - - list = poi_type[tostring(poitype)]["inVehicule"] - - end - - - - for k,location in pairs(list) do - --print(k) - -- ----print(tostring((tag == nil or tag == "" or k == tag))) - -- ----print(tostring((district == nil or district == "" or (district ~= nil and location.district == district)))) - -- ----print(tostring(subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict))) - ------print(tostring((fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))))) - ------print(tostring(check3DPos(frompos, location.x, location.y, location.z, range))) - - if - ( - - (tag == nil or tag == "" or k == tag) and - - (district == nil or district == "" or (district ~= nil and location.district == district)) and - - (subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)) and - - -- (poitype == nil or poitype == 1 or (poitype == location.type) and - - (fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))) - - - ) - then - - - - table.insert(currentpoilist,location) - - - - - - - - end - - end - - - - end - - if(listargument == "subdistrict" and poi_subdistrict[subdistrict] ~= nil) then - - local list = poi_subdistrict[subdistrict]["outVehicule"] - - if(iscar) then - - list = poi_subdistrict[subdistrict]["inVehicule"] - - end - - for k,location in pairs(list) do - - if - ( - - - - (district == nil or district == "" or (district ~= nil and location.district == district)) and - - (tag == nil or tag == "" or k == tag) and - - (district == nil or district == "" or (district ~= nil and location.district == district)) and - - -- (subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)) and - - (poitype == nil or poitype == 1 or (poitype == location.type)) and - - (fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))) - - - ) - then - - - - table.insert(currentpoilist,location) - - - - - - - - end - - end - - end - - if(listargument == "district" and poi_district[district] ~= nil) then - - local list = poi_district[district]["outVehicule"] - - if(iscar) then - - list = poi_district[district]["inVehicule"] - - end - - for k,location in pairs(list) do - - if - ( - - (tag == nil or tag == "" or k == tag) and - - -- (district == nil or district == "" or (district ~= nil and location.district == district)) and - - (subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)) and - - (poitype == nil or poitype == 1 or (poitype == location.type)) and - - (fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))) - - - ) - then - - - - table.insert(currentpoilist,location) - - - - - - - - end - - end - - end - - if(listargument == "tag") then - - local location = poi_tag[tag] - if(location ~= nil) then - - table.insert(currentpoilist,location) - end - - end - - - if true then - -- for k,v in pairs(cyberscript.cache["poi"]) do - - - - - -- if - -- (#v.data.locations > 0) then - - -- for y=1,#v.data.locations do - - -- local location = v.data.locations[y] - - -- -- logme(4,"TEST POI ---") - -- -- logme(4,"tag : "..tostring(( - -- -- ((tag == nil or tag == "" or (v.data.tag ~= nil and v.data.tag == tag)) and locationtag == false) or - -- -- ((tag == nil or tag == "" or (location.Tag ~= nil and location.Tag == tag)) and locationtag == true) - -- -- ))) - - -- -- logme(4,"district : "..tostring((district == nil or district == "" or (district ~= nil and location.district == district)))) - -- -- logme(4,"subdistrict : "..tostring((subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)))) - - -- -- logme(4,"iscar : "..tostring((iscar == nil or (iscar ~= nil and location.inVehicule == iscar)))) - -- -- logme(4,"poitype : "..tostring((poitype == nil or poitype == 1 or (poitype == v.data.isFor)))) - -- -- logme(4,"fromposition : "..tostring((fromposition == false or (fromposition == true and check3DPos(curPos, location.x, location.y, location.z, range))))) - -- -- logme(4,"TEST POI ---") - - -- if - -- ( - -- ( - -- ((tag == nil or tag == "" or (v.data.tag ~= nil and v.data.tag == tag)) and locationtag == false) or - -- ((tag == nil or tag == "" or (location.Tag ~= nil and location.Tag == tag)) and locationtag == true) - -- ) - - -- and - - -- (district == nil or district == "" or (district ~= nil and location.district == district)) and - -- (subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)) and - -- (iscar == nil or (iscar ~= nil and location.inVehicule == iscar)) and - - - -- (poitype == nil or - - -- ( - -- (isArray(poitype) == false and isArray(v.data.isFor) == false and (poitype == 1 or (poitype == v.data.isFor))) or - -- (isArray(poitype) == true and isArray(v.data.isFor) == false and table_contains(poitype,v.data.isFor)) or - -- (isArray(poitype) == false and isArray(v.data.isFor) == true and table_contains(v.data.isFor,poitype)) or - -- (isArray(poitype) == true and isArray(v.data.isFor) == true and table.compare(poitype, v.data.isFor)) - -- ) - - -- ) and - - - -- (fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))) - - - -- ) - -- then - - - -- local location = deepcopy(v.data.locations[y],nil) - -- location.parent = deepcopy(v.data,nil) - -- location.parent.locations = nil - -- table.insert(currentpoilist,location) - - - - - - - - -- end - - - - - - -- end - - - -- end - - -- end - end - - if(#currentpoilist > 0) then - - - - if(distancename == "near") then - -- local currentpoi = nil - -- --currentpoi = currentpoilist[math.random(#currentpoilist)] - - - -- local distance = function(start) - -- return math.abs(start.x - frompos.x) + math.abs(start.y - frompos.y) - -- end - - -- -- Define a comparator that compares locations based on - -- -- distance to final position - -- local comparator = function(a, b) - -- return distance(a) < distance(b) - -- end - - -- local adj_tiles - -- -- Set adj_tiles to an array of grid positions - - -- table.sort(currentpoilist, comparator) -- Sort adjacent tiles based on distance - - - currentpoilist = sortPositionsByDistance(currentpoilist, frompos,100000,range) - -- ----print(dump(currentpoilist[1])) - -- print(dump(currentpoilist[1])) - return currentpoilist[1] - - end - - if(distancename == "far") then - - currentpoilist = sortPositionsByDistance(currentpoilist, frompos,100000,range) - -- local currentpoi = nil - -- --currentpoi = currentpoilist[math.random(#currentpoilist)] - - - -- local distance = function(start) - -- return math.abs(start.x - frompos.x) + math.abs(start.y - frompos.y) - -- end - - -- -- Define a comparator that compares locations based on - -- -- distance to final position - -- local comparator = function(a, b) - -- return distance(a) < distance(b) - -- end - - -- local adj_tiles - -- -- Set adj_tiles to an array of grid positions - - -- table.sort(currentpoilist, comparator) -- Sort adjacent tiles based on distance - - - - -- ------print(dump(currentpoilist[#currentpoilist])) - -- ------print(dump(currentpoilist)) - - return currentpoilist[#currentpoilist] - - end - - if(distancename == "random") then - local currentpoi = nil - --currentpoi = currentpoilist[math.random(#currentpoilist)] - - - - - - ----print(dump(currentpoilist[math.random(1,#currentpoilist)])) - return currentpoilist[math.random(1,#currentpoilist)] - - end - - - - else - return nil - end - + + + + local currentpoilist = {} + local frompos = curPos + + if(frompositionx ~= nil and frompositiony ~= nil and frompositionz ~= nil) then + + frompos.x = frompositionx + frompos.y = frompositiony + frompos.z = frompositionz + + end + + if(listargument == "type" and poi_type[tostring(poitype)] ~= nil) then + + local list = poi_type[tostring(poitype)]["outVehicule"] + + if(iscar) then + + list = poi_type[tostring(poitype)]["inVehicule"] + + end + + + + for k,location in pairs(list) do + --print(k) + -- ----print(tostring((tag == nil or tag == "" or k == tag))) + -- ----print(tostring((district == nil or district == "" or (district ~= nil and location.district == district)))) + -- ----print(tostring(subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict))) + ------print(tostring((fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))))) + ------print(tostring(check3DPos(frompos, location.x, location.y, location.z, range))) + + if + ( + + (tag == nil or tag == "" or k == tag) and + + (district == nil or district == "" or (district ~= nil and location.district == district)) and + + (subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)) and + + -- (poitype == nil or poitype == 1 or (poitype == location.type) and + + (fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))) + + + ) + then + + + + table.insert(currentpoilist,location) + + + + + + + + end + + end + + + + end + + if(listargument == "subdistrict" and poi_subdistrict[subdistrict] ~= nil) then + + local list = poi_subdistrict[subdistrict]["outVehicule"] + + if(iscar) then + + list = poi_subdistrict[subdistrict]["inVehicule"] + + end + + for k,location in pairs(list) do + + if + ( + + + + (district == nil or district == "" or (district ~= nil and location.district == district)) and + + (tag == nil or tag == "" or k == tag) and + + (district == nil or district == "" or (district ~= nil and location.district == district)) and + + -- (subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)) and + + (poitype == nil or poitype == 1 or (poitype == location.type)) and + + (fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))) + + + ) + then + + + + table.insert(currentpoilist,location) + + + + + + + + end + + end + + end + + if(listargument == "district" and poi_district[district] ~= nil) then + + local list = poi_district[district]["outVehicule"] + + if(iscar) then + + list = poi_district[district]["inVehicule"] + + end + + for k,location in pairs(list) do + + if + ( + + (tag == nil or tag == "" or k == tag) and + + -- (district == nil or district == "" or (district ~= nil and location.district == district)) and + + (subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)) and + + (poitype == nil or poitype == 1 or (poitype == location.type)) and + + (fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))) + + + ) + then + + + + table.insert(currentpoilist,location) + + + + + + + + end + + end + + end + + if(listargument == "tag") then + + local location = poi_tag[tag] + if(location ~= nil) then + + table.insert(currentpoilist,location) + end + + end + + + if true then + -- for k,v in pairs(cyberscript.cache["poi"]) do + + + + + -- if + -- (#v.data.locations > 0) then + + -- for y=1,#v.data.locations do + + -- local location = v.data.locations[y] + + -- -- logme(4,"TEST POI ---") + -- -- logme(4,"tag : "..tostring(( + -- -- ((tag == nil or tag == "" or (v.data.tag ~= nil and v.data.tag == tag)) and locationtag == false) or + -- -- ((tag == nil or tag == "" or (location.Tag ~= nil and location.Tag == tag)) and locationtag == true) + -- -- ))) + + -- -- logme(4,"district : "..tostring((district == nil or district == "" or (district ~= nil and location.district == district)))) + -- -- logme(4,"subdistrict : "..tostring((subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)))) + + -- -- logme(4,"iscar : "..tostring((iscar == nil or (iscar ~= nil and location.inVehicule == iscar)))) + -- -- logme(4,"poitype : "..tostring((poitype == nil or poitype == 1 or (poitype == v.data.isFor)))) + -- -- logme(4,"fromposition : "..tostring((fromposition == false or (fromposition == true and check3DPos(curPos, location.x, location.y, location.z, range))))) + -- -- logme(4,"TEST POI ---") + + -- if + -- ( + -- ( + -- ((tag == nil or tag == "" or (v.data.tag ~= nil and v.data.tag == tag)) and locationtag == false) or + -- ((tag == nil or tag == "" or (location.Tag ~= nil and location.Tag == tag)) and locationtag == true) + -- ) + + -- and + + -- (district == nil or district == "" or (district ~= nil and location.district == district)) and + -- (subdistrict == nil or subdistrict == "" or (subdistrict ~= nil and location.subdistrict == subdistrict)) and + -- (iscar == nil or (iscar ~= nil and location.inVehicule == iscar)) and + + + -- (poitype == nil or + + -- ( + -- (isArray(poitype) == false and isArray(v.data.isFor) == false and (poitype == 1 or (poitype == v.data.isFor))) or + -- (isArray(poitype) == true and isArray(v.data.isFor) == false and table_contains(poitype,v.data.isFor)) or + -- (isArray(poitype) == false and isArray(v.data.isFor) == true and table_contains(v.data.isFor,poitype)) or + -- (isArray(poitype) == true and isArray(v.data.isFor) == true and table.compare(poitype, v.data.isFor)) + -- ) + + -- ) and + + + -- (fromposition == false or (fromposition == true and check3DPos(frompos, location.x, location.y, location.z, range))) + + + -- ) + -- then + + + -- local location = deepcopy(v.data.locations[y],nil) + -- location.parent = deepcopy(v.data,nil) + -- location.parent.locations = nil + -- table.insert(currentpoilist,location) + + + + + + + + -- end + + + + + + -- end + + + -- end + + -- end + end + + if(#currentpoilist > 0) then + + + + if(distancename == "near") then + -- local currentpoi = nil + -- --currentpoi = currentpoilist[math.random(#currentpoilist)] + + + -- local distance = function(start) + -- return math.abs(start.x - frompos.x) + math.abs(start.y - frompos.y) + -- end + + -- -- Define a comparator that compares locations based on + -- -- distance to final position + -- local comparator = function(a, b) + -- return distance(a) < distance(b) + -- end + + -- local adj_tiles + -- -- Set adj_tiles to an array of grid positions + + -- table.sort(currentpoilist, comparator) -- Sort adjacent tiles based on distance + + + currentpoilist = sortPositionsByDistance(currentpoilist, frompos,100000,range) + -- ----print(dump(currentpoilist[1])) + -- print(dump(currentpoilist[1])) + return currentpoilist[1] + + end + + if(distancename == "far") then + + currentpoilist = sortPositionsByDistance(currentpoilist, frompos,100000,range) + -- local currentpoi = nil + -- --currentpoi = currentpoilist[math.random(#currentpoilist)] + + + -- local distance = function(start) + -- return math.abs(start.x - frompos.x) + math.abs(start.y - frompos.y) + -- end + + -- -- Define a comparator that compares locations based on + -- -- distance to final position + -- local comparator = function(a, b) + -- return distance(a) < distance(b) + -- end + + -- local adj_tiles + -- -- Set adj_tiles to an array of grid positions + + -- table.sort(currentpoilist, comparator) -- Sort adjacent tiles based on distance + + + + -- ------print(dump(currentpoilist[#currentpoilist])) + -- ------print(dump(currentpoilist)) + + return currentpoilist[#currentpoilist] + + end + + if(distancename == "random") then + local currentpoi = nil + --currentpoi = currentpoilist[math.random(#currentpoilist)] + + + + + + ----print(dump(currentpoilist[math.random(1,#currentpoilist)])) + return currentpoilist[math.random(1,#currentpoilist)] + + end + + + + else + return nil + end + end function calculateDistance(point1, point2) local dx = point1.x - point2.x local dy = point1.y - point2.y local dz = point1.z - point2.z - + return math.floor(math.sqrt(dx * dx + dy * dy + dz * dz)) end @@ -3312,1784 +3331,1806 @@ function sortPositionsByDistance(positions, targetPosition, bucketCount,range) -- Calculate and place positions into buckets based on distance for _, position in ipairs(positions) do local distance = calculateDistance(position, targetPosition) - - if(distance >= 0 and distance <= range) then - local bucketIndex = distance+1 - - if buckets[bucketIndex] == nil then buckets[bucketIndex] = {} end - - table.insert(buckets[bucketIndex], position) - end + + if(distance >= 0 and distance <= range) then + local bucketIndex = distance+1 + + if buckets[bucketIndex] == nil then buckets[bucketIndex] = {} end + + table.insert(buckets[bucketIndex], position) + end end - - + + -- Concatenate the buckets to get the sorted positions local sortedPositions = {} for i, buk in pairs(buckets) do - + for _, position in ipairs(buckets[i]) do table.insert(sortedPositions, position) - + end end - + return sortedPositions end function getNodeIndexFromCircuit(tag,listnodes) - for i=1,#listnodes do - - - - - if(listnodes[i] == tag)then - return i - end - - - - - - - end + for i=1,#listnodes do + + + + + if(listnodes[i] == tag)then + return i + end + + + + + + + end end function getPathBetweenTwoNode(CurrentNode, NextNode) - logme(4,"CurrentNode"..CurrentNode) - logme(4,"NextNode"..NextNode) - for k,v in pairs(cyberscript.cache["path"])do - - - local path = v.data - logme(4,"startNode"..path.startNode) - logme(4,"endNode"..path.endNode) - - if(path.startNode == CurrentNode and path.endNode == NextNode)then - return path - end - - - - - - - end + logme(4,"CurrentNode"..CurrentNode) + logme(4,"NextNode"..NextNode) + for k,v in pairs(cyberscript.cache["path"])do + + + local path = v.data + logme(4,"startNode"..path.startNode) + logme(4,"endNode"..path.endNode) + + if(path.startNode == CurrentNode and path.endNode == NextNode)then + return path + end + + + + + + + end end function getNodefromPosition(x,y,z,range) - local vec4 = {} - vec4.x = x - vec4.y = y - vec4.z = z - - for k,v in pairs(cyberscript.cache["node"]) do - - - local node = v.data - - - - if(check3DPos(vec4,node.x,node.y,node.z,range) or check3DPos(vec4,node.gameplay_x,node.gameplay_y,node.gameplay_z,range))then - return node - end - - - - - - - end - - + local vec4 = {} + vec4.x = x + vec4.y = y + vec4.z = z + + for k,v in pairs(cyberscript.cache["node"]) do + + + local node = v.data + + + + if(check3DPos(vec4,node.x,node.y,node.z,range) or check3DPos(vec4,node.gameplay_x,node.gameplay_y,node.gameplay_z,range))then + return node + end + + + + + + + end + + end function getTrack(tag) - - for i=1,#arrayTrack do - - - local location = arrayTrack[i] - - if(location.tag == tag)then - return location - end - - - - - - - end - - + + for i=1,#arrayTrack do + + + local location = arrayTrack[i] + + if(location.tag == tag)then + return location + end + + + + + + + end + + end function getCurrentTrack(tag) - - for i=1,#enabledTrack do - - - local location = enabledTrack[i] - - if(location.tag == tag)then - return location - end - - - - - - - end - - + + for i=1,#enabledTrack do + + + local location = enabledTrack[i] + + if(location.tag == tag)then + return location + end + + + + + + + end + + end function getCurrentTrackIndex(tag) - - for i=1,#enabledTrack do - - - local location = enabledTrack[i] - - if(location.tag == tag)then - return i - end - - - - - - - end - - + + for i=1,#enabledTrack do + + + local location = enabledTrack[i] + + if(location.tag == tag)then + return i + end + + + + + + + end + + end function checkQuestStatutByTag(tag, statut) - local result = false - - - - - - - - - if(currentSave.Variable[tag] ~= nil) then - - - - if( currentSave.Variable[tag]["Score"] == statut) then - result = true - end - - else - - if(currentSave.Variable[tag] == statut) then - - result = true - - end - - end - - return result + local result = false + + + + + + + + + if(currentSave.Variable[tag] ~= nil) then + + + + if( currentSave.Variable[tag]["Score"] == statut) then + result = true + end + + else + + if(currentSave.Variable[tag] == statut) then + + result = true + + end + + end + + return result end function getCircuit(tag) - - - - if(cyberscript.cache["circuit"][tag] ~= nil) then - return cyberscript.cache["circuit"][tag].data - end - - + + + + if(cyberscript.cache["circuit"][tag] ~= nil) then + return cyberscript.cache["circuit"][tag].data + end + + end function getNode(tag) - - - if(cyberscript.cache["node"][tag] ~= nil) then - return cyberscript.cache["node"][tag].data - end - - - - - - + + + if(cyberscript.cache["node"][tag] ~= nil) then + return cyberscript.cache["node"][tag].data + end + + + + + + end function getRadioByTag(tag) - - - - if(cyberscript.cache["radio"][tag] ~= nil)then - return cyberscript.cache["radio"][tag].data - end - - - return nil - -end + + + + if(cyberscript.cache["radio"][tag] ~= nil)then + return cyberscript.cache["radio"][tag].data + end + + + return nil + +end function getMappinByTag(tag) - - - return mappinManager[tag] - + + + return mappinManager[tag] + end function getPNJ (tab, val) - for index, value in ipairs(tab) do - if value.ID == val then - - return value - end - end - - return false + for index, value in ipairs(tab) do + if value.ID == val then + + return value + end + end + + return false end function getGameTime() - - local temp = {} - local gameTime = Game.GetTimeSystem():GetGameTime() - - temp.hour = GetSingleton('GameTime'):Hours(gameTime) - temp.min = GetSingleton('GameTime'):Minutes(gameTime) - temp.sec = GetSingleton('GameTime'):Seconds(gameTime) - temp.day = GetSingleton('GameTime'):Days(gameTime) - - return temp - + + local temp = {} + local gameTime = Game.GetTimeSystem():GetGameTime() + + temp.hour = GetSingleton('GameTime'):Hours(gameTime) + temp.min = GetSingleton('GameTime'):Minutes(gameTime) + temp.sec = GetSingleton('GameTime'):Seconds(gameTime) + temp.day = GetSingleton('GameTime'):Days(gameTime) + + return temp + end function getDistrictfromEnum(enum) - - for i = 1, #arrayDistricts do - if arrayDistricts[i].EnumName:upper() == Game.GetLocalizedText(enum):upper() then - return arrayDistricts[i] - - - end - - end - + + for i = 1, #arrayDistricts do + if arrayDistricts[i].EnumName:upper() == Game.GetLocalizedText(enum):upper() then + return arrayDistricts[i] + + + end + + end + end function getDistrictBySubfromEnum(enum) - - for i = 1, #arrayDistricts do - if(#arrayDistricts[i].SubDistrict > 0) then - for j=1,#arrayDistricts[i].SubDistrict do - if arrayDistricts[i].SubDistrict[j]:upper() == Game.GetLocalizedText(enum):upper() then - return arrayDistricts[i] - - - end - end - end - end - + + for i = 1, #arrayDistricts do + if(#arrayDistricts[i].SubDistrict > 0) then + for j=1,#arrayDistricts[i].SubDistrict do + if arrayDistricts[i].SubDistrict[j]:upper() == Game.GetLocalizedText(enum):upper() then + return arrayDistricts[i] + + + end + end + end + end + end function getDistrictByTag(district) - - for i = 1, #arrayDistricts do - if(arrayDistricts[i].Tag == district) then - - - return arrayDistricts[i] - - - - end - end + + for i = 1, #arrayDistricts do + if(arrayDistricts[i].Tag == district) then + + + return arrayDistricts[i] + + + + end + end end function getMappinByGroup(group) - local mapLot = {} - - for k,v in pairs(mappinManager) do - if(v.group and v.group == group )then - table.insert(mapLot,v) - end - end - - return mapLot + local mapLot = {} + + for k,v in pairs(mappinManager) do + if(v.group and v.group == group )then + table.insert(mapLot,v) + end + end + + return mapLot end function GetPlayerGender() - -- True = Female / False = Male - if string.find(tostring(Game.GetPlayer():GetResolvedGenderName()), "Female") then - return "female" - else - return "male" - end + -- True = Female / False = Male + if string.find(tostring(Game.GetPlayer():GetResolvedGenderName()), "Female") then + return "female" + else + return "male" + end end function GetEntityGender(entity) - -- True = Female / False = Male - logme(4,tostring(Game.NameToString(entity:GetBodyType()))) - logme(4,tostring(string.find(string.lower(tostring(Game.NameToString(entity:GetBodyType()))), "woman"))) - if string.match(string.lower(tostring(Game.NameToString(entity:GetBodyType()))), "woman") then - return "female" - else - return "male" - end + -- True = Female / False = Male + logme(4,tostring(Game.NameToString(entity:GetBodyType()))) + logme(4,tostring(string.find(string.lower(tostring(Game.NameToString(entity:GetBodyType()))), "woman"))) + if string.match(string.lower(tostring(Game.NameToString(entity:GetBodyType()))), "woman") then + return "female" + else + return "male" + end end function getQuestByTag(tag) - - local parentquest = cyberscript.cache["mission"][tag] - local quest = nil - if(parentquest ~= nil) then - quest = parentquest.data - --logme(4,parentquest.file) - end - return quest - - + + local parentquest = cyberscript.cache["mission"][tag] + local quest = nil + if(parentquest ~= nil) then + quest = parentquest.data + --logme(4,parentquest.file) + end + return quest + + end function getQuestStatut(tag) - - - - local score = getScoreKey(tag,"Score") - - if(score ~= nil) then - return score - - end - - return nil - - + + + + local score = getScoreKey(tag,"Score") + + if(score ~= nil) then + return score + + end + + return nil + + end function getMarketScoreByTag(tag) - - local result = nil - - for i=1,#arrayMarket do - - if(arrayMarket[i].tag == tag) then - return arrayMarket[i] - end - - - - end - - return result - + + local result = nil + + for i=1,#arrayMarket do + + if(arrayMarket[i].tag == tag) then + return arrayMarket[i] + end + + + + end + + return result + end function getScorebyTag(tag) - - local score = 0 - - score = getScoreKey(tag,"Score") - if(score == nil)then - score = 0 - end - - - - return score - + + local score = 0 + + score = getScoreKey(tag,"Score") + if(score == nil)then + score = 0 + end + + + + return score + end function getFactionByDistrictTag(tag) - - local factiontable = {} - - for k,v in pairs(cyberscript.cache["faction"]) do - checkContext(v) - if(cyberscript.cache["faction"][k].data.district_tag == tag) then - - table.insert(factiontable,cyberscript.cache["faction"][k].data) - - end - - - - end - - return factiontable - + + local factiontable = {} + + for k,v in pairs(cyberscript.cache["faction"]) do + checkContext(v) + if(cyberscript.cache["faction"][k].data.district_tag == tag) then + + table.insert(factiontable,cyberscript.cache["faction"][k].data) + + end + + + + end + + return factiontable + end function getVIPfromfactionbyscore(factiontag) - local tempvip = {} - - local faction = getFactionByTag(factiontag) - - local playerscore = getScorebyTag(factiontag) - - - if(#faction.vip > 0) then - for i=1,#faction.vip do - - if(faction.vip[i].score <= playerscore) then - - local npc = getNPCByName(faction.vip[i].name) - - table.insert(tempvip,npc.TweakIDs) - - end - - - end - end - - if(#tempvip == 0) then - logme(10,getLang("scripting_novip01")..factiontag..getLang("scripting_novip02")..playerscore) - end - - return tempvip + local tempvip = {} + + local faction = getFactionByTag(factiontag) + + local playerscore = getScorebyTag(factiontag) + + + if(#faction.vip > 0) then + for i=1,#faction.vip do + + if(faction.vip[i].score <= playerscore) then + + local npc = getNPCByName(faction.vip[i].name) + + table.insert(tempvip,npc.TweakIDs) + + end + + + end + end + + if(#tempvip == 0) then + logme(10,getLang("scripting_novip01")..factiontag..getLang("scripting_novip02")..playerscore) + end + + return tempvip end function getGangfromDistrict(district,minimum) - - local factiontable = {} - - for k,v in pairs(cyberscript.cache["faction"]) do - - if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][district] ~= nil and currentSave.Variable[k][district] >= minimum) then - - local factionscore= {} - factionscore.tag = k - factionscore.score = currentSave.Variable[k][district] - table.insert(factiontable,factionscore) - - else - - - getVariableKeyWithDefault(k, district,0) - - - end - - - - end - - table.sort(factiontable, function(a,b) return a.score > b.score end) - - return factiontable - + + local factiontable = {} + + for k,v in pairs(cyberscript.cache["faction"]) do + + if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][district] ~= nil and currentSave.Variable[k][district] >= minimum) then + + local factionscore= {} + factionscore.tag = k + factionscore.score = currentSave.Variable[k][district] + table.insert(factiontable,factionscore) + + else + + + getVariableKeyWithDefault(k, district,0) + + + end + + + + end + + table.sort(factiontable, function(a,b) return a.score > b.score end) + + return factiontable + end function getGangRivalsFromGang(gang) - - local factiontable = {} - if(currentSave.Variable[gang] ~= nil) then - for k,v in pairs(currentSave.Variable[gang]) do - if(k ~= "Score") then - local factionscore= {} - factionscore.tag = k - factionscore.score =getFactionRelation(gang,k) - table.insert(factiontable,factionscore) - end - end - end - table.sort(factiontable, function(a,b) return a.score < b.score end) - - return factiontable - + + local factiontable = {} + if(currentSave.Variable[gang] ~= nil) then + for k,v in pairs(currentSave.Variable[gang]) do + if(k ~= "Score") then + local factionscore= {} + factionscore.tag = k + factionscore.score =getFactionRelation(gang,k) + table.insert(factiontable,factionscore) + end + end + end + table.sort(factiontable, function(a,b) return a.score < b.score end) + + return factiontable + end function getGangRivalfromDistrict(gang,district,minimum) - - local districttable = {} - local factiontable = {} - - for k,v in pairs(cyberscript.cache["faction"]) do - - if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][district] ~= nil and currentSave.Variable[k][district] >= minimum) then - - local factionscore= {} - factionscore.tag = k - factionscore.score = currentSave.Variable[k][district] - table.insert(districttable,factionscore) - - else - - getVariableKeyWithDefault(k,district,0) - - - end - - - - end - - - - - for i=1,#districttable do - - local factionscore= {} - factionscore.tag = districttable[i].tag - factionscore.score = getFactionRelation(gang,districttable[i].tag) - table.insert(factiontable,factionscore) - - end - - - table.sort(factiontable, function(a,b) return a.score > b.score end) - return factiontable - + + local districttable = {} + local factiontable = {} + + for k,v in pairs(cyberscript.cache["faction"]) do + + if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][district] ~= nil and currentSave.Variable[k][district] >= minimum) then + + local factionscore= {} + factionscore.tag = k + factionscore.score = currentSave.Variable[k][district] + table.insert(districttable,factionscore) + + else + + getVariableKeyWithDefault(k,district,0) + + + end + + + + end + + + + + for i=1,#districttable do + + local factionscore= {} + factionscore.tag = districttable[i].tag + factionscore.score = getFactionRelation(gang,districttable[i].tag) + table.insert(factiontable,factionscore) + + end + + + table.sort(factiontable, function(a,b) return a.score > b.score end) + return factiontable + end function getGangfromDistrictAndSubdistrict(district,minimum) - - local factiontable = {} - - - local mydistrict = getDistrictByTag(district) - - for k,v in pairs(cyberscript.cache["faction"]) do - - - if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][mydistrict.Tag] ~= nil and currentSave.Variable[k][mydistrict.Tag] >= minimum) then - -- logme(4,k) - - local obj = {} - obj.tag = k - obj.score = currentSave.Variable[k][mydistrict.Tag] - table.insert(factiontable,obj) - - - - - else - getVariableKeyWithDefault(k,mydistrict.Tag,0) - - - end - - - - end - - - - - table.sort(factiontable, function(a,b) return a.score > b.score end) - - return factiontable - + + local factiontable = {} + + + local mydistrict = getDistrictByTag(district) + + for k,v in pairs(cyberscript.cache["faction"]) do + + + if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][mydistrict.Tag] ~= nil and currentSave.Variable[k][mydistrict.Tag] >= minimum) then + -- logme(4,k) + + local obj = {} + obj.tag = k + obj.score = currentSave.Variable[k][mydistrict.Tag] + table.insert(factiontable,obj) + + + + + else + getVariableKeyWithDefault(k,mydistrict.Tag,0) + + + end + + + + end + + + + + table.sort(factiontable, function(a,b) return a.score > b.score end) + + return factiontable + end function getGangAffinityfromDistrictAndSubdistrict(district,minimum) - - local factiontable = {} - - - - local mydistrict = getDistrictByTag(district) - - for k,v in pairs(cyberscript.cache["faction"]) do - - - if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][mydistrict.Tag] ~= nil and currentSave.Variable[k][mydistrict.Tag] >= minimum) then - - - local obj = {} - obj.tag = k - obj.score = getScorebyTag(k) - table.insert(factiontable,obj) - - - - - else - getVariableKeyWithDefault(k,mydistrict.Tag,0) - - - end - - - - end - - for i=1,#mydistrict.SubDistrict do - - local subdist = mydistrict.SubDistrict[i] - logme(4,subdist) - for k,v in pairs(cyberscript.cache["faction"]) do - - - if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][subdist] ~= nil and currentSave.Variable[k][subdist] >= minimum) then - for i=1,#factiontable do - if(factiontable[i].tag == k) then - - factiontable[i].score = factiontable[i].score + getScorebyTag(k) - else - - local obj = {} - obj.tag = k - obj.score = getScorebyTag(k) - table.insert(factiontable,obj) - logme(4,k) - - end - - - - end - end - - - end - end - - - - table.sort(factiontable, function(a,b) return a.score > b.score end) - - return factiontable - + + local factiontable = {} + + + + local mydistrict = getDistrictByTag(district) + + for k,v in pairs(cyberscript.cache["faction"]) do + + + if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][mydistrict.Tag] ~= nil and currentSave.Variable[k][mydistrict.Tag] >= minimum) then + + + local obj = {} + obj.tag = k + obj.score = getScorebyTag(k) + table.insert(factiontable,obj) + + + + + else + getVariableKeyWithDefault(k,mydistrict.Tag,0) + + + end + + + + end + + for i=1,#mydistrict.SubDistrict do + + local subdist = mydistrict.SubDistrict[i] + logme(4,subdist) + for k,v in pairs(cyberscript.cache["faction"]) do + + + if(currentSave.Variable[k] ~= nil and currentSave.Variable[k][subdist] ~= nil and currentSave.Variable[k][subdist] >= minimum) then + for i=1,#factiontable do + if(factiontable[i].tag == k) then + + factiontable[i].score = factiontable[i].score + getScorebyTag(k) + else + + local obj = {} + obj.tag = k + obj.score = getScorebyTag(k) + table.insert(factiontable,obj) + logme(4,k) + + end + + + + end + end + + + end + end + + + + table.sort(factiontable, function(a,b) return a.score > b.score end) + + return factiontable + end function getFactionByTag(tag) - - local factiontable = {} - - for k,v in pairs(cyberscript.cache["faction"]) do - checkContext(v) - if(cyberscript.cache["faction"][k].data.tag == tag) then - - return cyberscript.cache["faction"][k].data - - end - - - - end - - return factiontable - + + local factiontable = {} + + for k,v in pairs(cyberscript.cache["faction"]) do + checkContext(v) + if(cyberscript.cache["faction"][k].data.tag == tag) then + + return cyberscript.cache["faction"][k].data + + end + + + + end + + return factiontable + end function getItemEntityFromManager(entid) - - local obj = nil - - if(#currentItemSpawned > 0) then - for i = 1, #currentItemSpawned do - - local enti = currentItemSpawned[i] - - - - if type(enti.entityId) ~= "number" then - - if(enti.entityId.hash == entid.hash) then - - obj = enti - - end - - end - - - - - - end - end - return obj - - - + + local obj = nil + + if(#currentItemSpawned > 0) then + for i = 1, #currentItemSpawned do + + local enti = currentItemSpawned[i] + + + + if type(enti.entityId) ~= "number" then + + if(enti.entityId.hash == entid.hash) then + + obj = enti + + end + + end + + + + + + end + end + return obj + + + end function getItemEntityIndexFromManager(entid) - - - - if(#currentItemSpawned > 0) then - for i = 1, #currentItemSpawned do - - local enti = currentItemSpawned[i] - - - - if type(enti.entityId) ~= "number" then - - if(enti.entityId.hash == entid.hash) then - - return i - - end - - end - - - - - - end - end - - return nil - - - + + + + if(#currentItemSpawned > 0) then + for i = 1, #currentItemSpawned do + + local enti = currentItemSpawned[i] + + + + if type(enti.entityId) ~= "number" then + + if(enti.entityId.hash == entid.hash) then + + return i + + end + + end + + + + + + end + end + + return nil + + + end function getItemByHouseTagandTagFromManager(tag,housetag) - - - - if(#currentItemSpawned > 0) then - for i = 1, #currentItemSpawned do - - local enti = currentItemSpawned[i] - - - - if enti.HouseTag == housetag and enti.Tag == tag then - - - - return i - - - - end - - - - - - end - end - - return nil - - - + + + + if(#currentItemSpawned > 0) then + for i = 1, #currentItemSpawned do + + local enti = currentItemSpawned[i] + + + + if enti.HouseTag == housetag and enti.Tag == tag then + + + + return i + + + + end + + + + + + end + end + + return nil + + + end function getItemEntityFromManagerByPlayerLookinAt() - - local obj = nil - - if(#currentItemSpawned > 0) then - for i = 1, #currentItemSpawned do - - local enti = currentItemSpawned[i] - local playerlook = getForwardPosition(Game.GetPlayer(),2) - - - - if type(enti.entityId) ~= "number" then - local postion = Vector4.new(enti.X, enti.Y, enti.Z, 1) - - if(check3DPos(postion, playerlook.x, playerlook.y, playerlook.z,1, 3)) then - - obj = enti - - end - - end - - - - - - end - end - return obj - - - + + local obj = nil + + if(#currentItemSpawned > 0) then + for i = 1, #currentItemSpawned do + + local enti = currentItemSpawned[i] + local playerlook = getForwardPosition(Game.GetPlayer(),2) + + + + if type(enti.entityId) ~= "number" then + local postion = Vector4.new(enti.X, enti.Y, enti.Z, 1) + + if(check3DPos(postion, playerlook.x, playerlook.y, playerlook.z,1, 3)) then + + obj = enti + + end + + end + + + + + + end + end + return obj + + + end function getItemFromUserHousing(tag,X,Y,Z,HouseTag,ItemPath) - - for i=1,#currentSave.arrayHousing do - - if(currentSave.arrayHousing[i].Tag == tag and currentSave.arrayHousing[i].HouseTag == HouseTag and currentSave.arrayHousing[i].ItemPath == ItemPath) then - return currentSave.arrayHousing[i] - end - - end - - return nil + + for i=1,#currentSave.arrayHousing do + + if(currentSave.arrayHousing[i].Tag == tag and currentSave.arrayHousing[i].HouseTag == HouseTag and currentSave.arrayHousing[i].ItemPath == ItemPath) then + return currentSave.arrayHousing[i] + end + + end + + return nil end function getItemCountInCart(tag) - - local count = 0 - - for i=1,#ItemsCart do - - if(ItemsCart[i].tag == tag) then - - count = count + 1 - - end - - end - - - return count - + + local count = 0 + + for i=1,#ItemsCart do + + if(ItemsCart[i].tag == tag) then + + count = count + 1 + + end + + end + + + return count + end function getExpression(name) - - for i = 1, #reactionlist do - - local enti = reactionlist[i] - if(enti.name == name) then - return enti - end - - - end - + + for i = 1, #reactionlist do + + local enti = reactionlist[i] + if(enti.name == name) then + return enti + end + + + end + end function getScannerdataFromEntityOrGroupOfEntity(entity) - - if (ScannerInfoManager[entity.tag] ~= nil) then - print(dump(ScannerInfoManager[entity.tag])) - return ScannerInfoManager[entity.tag] - - else - local group= getEntityGroupfromEntityTag(entity.tag) - if group ~= nil then - - if (ScannerInfoManager[group.tag] ~= nil) then - return ScannerInfoManager[group.tag] - end - end - - end - - return nil - - + + if (ScannerInfoManager[entity.tag] ~= nil) then + print(dump(ScannerInfoManager[entity.tag])) + return ScannerInfoManager[entity.tag] + + else + local group= getEntityGroupfromEntityTag(entity.tag) + if group ~= nil then + + if (ScannerInfoManager[group.tag] ~= nil) then + return ScannerInfoManager[group.tag] + end + end + + end + + return nil + + end function getGroupfromManager(tag) - - - - return cyberscript.GroupManager[tag] - - + -- B-23 fix: return nil gracefully if the group doesn't exist. + -- Callers that iterate group.entities should check for nil first; + -- the call sites in see.lua have been updated to do so. + if cyberscript == nil or cyberscript.GroupManager == nil then return nil end + return cyberscript.GroupManager[tag] + + end function getEntityGroupfromEntityTag(tag) - local goodgroup = nil - - for k,v in pairs(cyberscript.GroupManager)do - - local group = v - if(#group.entities > 0) then - - for y=1,#group.entities do - - local entity = group.entities[y] - - if(entity == tag) then - goodgroup = group - end - - - - end - end - end - - return goodgroup + local goodgroup = nil + + for k,v in pairs(cyberscript.GroupManager)do + + local group = v + if(#group.entities > 0) then + + for y=1,#group.entities do + + local entity = group.entities[y] + + if(entity == tag) then + goodgroup = group + end + + + + end + end + end + + return goodgroup end function getEntityIndexIntoGroup(grouptag, tag) - local group = getGroupfromManager(grouptag) - local index = nil - for i, v in ipairs (group) do - if (v == tag) then - index = i - end - end - return index + local group = getGroupfromManager(grouptag) + local index = nil + for i, v in ipairs (group) do + if (v == tag) then + index = i + end + end + return index end function getCustomNPCbyTag(tag) - - - - if (cyberscript.cache["npc"][tag] ~= nil) then - - return cyberscript.cache["npc"][tag].data - - end - - - - return nil - + + + + if (cyberscript.cache["npc"][tag] ~= nil) then + + return cyberscript.cache["npc"][tag].data + + end + + + + return nil + end function getInkWidget(tag) - - - for k, interface in pairs(currentInterfaceWidget) do - - for i,control in ipairs(interface.controls) do - - if(control.tag == tag) then - - return control - - end - - end - - - end - + + + for k, interface in pairs(currentInterfaceWidget) do + + for i,control in ipairs(interface.controls) do + + if(control.tag == tag) then + + return control + + end + + end + + + end + end function getInkWidgetControl(uitag,tag) - - - if(currentInterfaceWidget[uitag] ~= nil) then - - for i,control in ipairs(currentInterfaceWidget[uitag].controls) do - - if(control.tag == tag) then - - return control - - end - - end - - end - - + + + if(currentInterfaceWidget[uitag] ~= nil) then + + for i,control in ipairs(currentInterfaceWidget[uitag].controls) do + + if(control.tag == tag) then + + return control + + end + + end + + end + + end function GetInterfaceChildren(interface,tag) - - - - - for i,control in ipairs(interface.controls) do - - if(control.tag == tag) then - - return control - - end - - end - - - - + + + + + for i,control in ipairs(interface.controls) do + + if(control.tag == tag) then + + return control + + end + + end + + + + end function RemoveInterfaceChildren(interface,tag) - - - - - for i,control in ipairs(interface.controls) do - - if(control.tag == tag) then - - control = nil - - end - - end - - - - + + + + + for i,control in ipairs(interface.controls) do + + if(control.tag == tag) then + + control = nil + + end + + end + + + + end function getCustomAction(house,roomTypeId) - - - for i=1, #arrayPlaceInteract do - if(has_value(arrayPlaceInteract[i].place,house.type)) then - - if(arrayPlaceInteract[i].type == roomTypeId) then - - if(arrayPlaceInteract[i].placetag ~= "")then - - - customActionUI(arrayPlaceInteract[i]) - - - else - if(arrayPlaceInteract[i].placeTag == house.tag)then - - customActionUI(arrayPlaceInteract[i]) - - end - end - - - end - - - end - - end + + + for i=1, #arrayPlaceInteract do + if(has_value(arrayPlaceInteract[i].place,house.type)) then + + if(arrayPlaceInteract[i].type == roomTypeId) then + + if(arrayPlaceInteract[i].placetag ~= "")then + + + customActionUI(arrayPlaceInteract[i]) + + + else + if(arrayPlaceInteract[i].placeTag == house.tag)then + + customActionUI(arrayPlaceInteract[i]) + + end + end + + + end + + + end + + end end function getHouseByTag(tag) - - return cyberscript.cache["place"][tag].data + + return cyberscript.cache["place"][tag].data end function getRoomByTag(tag, housetag) - - for i=1,#cyberscript.cache["place"][housetag].data.rooms do - - if(cyberscript.cache["place"][housetag].data.rooms[i].tag == tag) then - return cyberscript.cache["place"][housetag].data.rooms[i] - end - end - return nil + + for i=1,#cyberscript.cache["place"][housetag].data.rooms do + + if(cyberscript.cache["place"][housetag].data.rooms[i].tag == tag) then + return cyberscript.cache["place"][housetag].data.rooms[i] + end + end + return nil end function getHouseStatut(houseTag) - - - return getScoreKey(houseTag,"Statut") - - + + + return getScoreKey(houseTag,"Statut") + + end function getHouseProperties(houseTag) - - - return getScore(houseTag) - - - + + + return getScore(houseTag) + + + end function getNPCById(npcId) - - for k,v in pairs(cyberscript.entitieshash) do - - if v.entity_id == npcId then - - - - return v - end - - end - - - + + for k,v in pairs(cyberscript.entitieshash) do + + if v.entity_id == npcId then + + + + return v + end + + end + + + end function getNPCByTweakId(tweak) - - for k,v in pairs(cyberscript.entitieshash) do - - if v.entity_tweak == tweak then - - - - return v - end - - end + + for k,v in pairs(cyberscript.entitieshash) do + + if v.entity_tweak == tweak then + + + + return v + end + + end end function getNPCByName(name) - - for k,v in pairs(cyberscript.entitieshash) do - - if v.entity_name == name then - - - - return v - end - - end + + for k,v in pairs(cyberscript.entitieshash) do + + if v.entity_name == name then + + + + return v + end + + end end function getPhonedNPCByName(name) - - for i=1, #arrayPhoneNPC do - - if arrayPhoneNPC[i].Names == name then - - - - return arrayPhoneNPC[i] - end - - end + + for i=1, #arrayPhoneNPC do + + if arrayPhoneNPC[i].Names == name then + + + + return arrayPhoneNPC[i] + end + + end end function findPhonedNPCByName(name) - logme(4,#arrayPhoneNPC) - for i=1, #arrayPhoneNPC do - - if string.find(string.lower(name),string.lower(arrayPhoneNPC[i].Names) ) then - - - - return arrayPhoneNPC[i] - end - - end + logme(4,#arrayPhoneNPC) + for i=1, #arrayPhoneNPC do + + if string.find(string.lower(name),string.lower(arrayPhoneNPC[i].Names) ) then + + + + return arrayPhoneNPC[i] + end + + end end function getPhonedNPCByTweakDBId(tweak) - - for i=1, #arrayPhoneNPC do - - if arrayPhoneNPC[i].TweakIDs == tweak then - - - - return arrayPhoneNPC[i] - end - - end + + for i=1, #arrayPhoneNPC do + + if arrayPhoneNPC[i].TweakIDs == tweak then + + + + return arrayPhoneNPC[i] + end + + end end function getFixerByTag(tag) - - - - if cyberscript.cache["fixer"][tag] ~= nil then - - local fixer = cyberscript.cache["fixer"][tag].data - checkContext(fixer) - - - - return fixer - end - - return nil + + + + if cyberscript.cache["fixer"][tag] ~= nil then + + local fixer = cyberscript.cache["fixer"][tag].data + checkContext(fixer) + + + + return fixer + end + + return nil end function getSoundByName(name) - - for k,v in pairs(cyberscript.cache["sound"]) do - - if v.data.name == name then - - - - return v.data - end - - end - - return nil + + for k,v in pairs(cyberscript.cache["sound"]) do + + if v.data.name == name then + + + + return v.data + end + + end + + return nil end function getLang(text) - - - - - if(cyberscript.language ~= nil and cyberscript.cache["lang"] ~= nil )then - - for k,languagefile in pairs(cyberscript.cache["lang"]) do - - if(languagefile.data.languages[cyberscript.language] ~= nil and languagefile.data.languages[cyberscript.language][text] ~= nil) then - - return languagefile.data.languages[cyberscript.language][text] - - end - - - - end - - - for k,languagefile in pairs(cyberscript.cache["lang"]) do - - if(languagefile.data.languages["default"] ~= nil and languagefile.data.languages["default"][text] ~= nil) then - - return languagefile.data.languages["default"][text] - - end - - - - end - - end - - if(lang["default"] ~= nil and lang["default"][text] ~= nil and lang["default"][text] ~= "" )then - - return lang["default"][text] - - end - - return text - + + + + + if(cyberscript.language ~= nil and cyberscript.cache["lang"] ~= nil )then + + for k,languagefile in pairs(cyberscript.cache["lang"]) do + + if(languagefile.data.languages[cyberscript.language] ~= nil and languagefile.data.languages[cyberscript.language][text] ~= nil) then + + return languagefile.data.languages[cyberscript.language][text] + + end + + + + end + + + for k,languagefile in pairs(cyberscript.cache["lang"]) do + + if(languagefile.data.languages["default"] ~= nil and languagefile.data.languages["default"][text] ~= nil) then + + return languagefile.data.languages["default"][text] + + end + + + + end + + end + + if(lang["default"] ~= nil and lang["default"][text] ~= nil and lang["default"][text] ~= "" )then + + return lang["default"][text] + + end + + return text + end function getCustomScorebyTag(tag) - - return getScore(tag) - + + return getScore(tag) + end function getPlayerItemsbyTag(tag) - - for i=1,#currentSave.arrayPlayerItems do - if(currentSave.arrayPlayerItems[i].Tag == tag) then - return currentSave.arrayPlayerItems[i] - end - end - + + for i=1,#currentSave.arrayPlayerItems do + if(currentSave.arrayPlayerItems[i].Tag == tag) then + return currentSave.arrayPlayerItems[i] + end + end + end function getSoundByNameNamespace(name,namespace) - - for k,v in pairs(cyberscript.cache["sound"]) do - - if k == name and v.sound.namespace == namespace then - - logme(4,"sound founded") - - return v.data - end - - end - - return nil + + for k,v in pairs(cyberscript.cache["sound"]) do + + if k == name and v.sound.namespace == namespace then + + logme(4,"sound founded") + + return v.data + end + + end + + return nil end function GetSoundSettingValue(volumTag) - - local SfxVolume = Game.GetSettingsSystem():GetVar("/audio/volume", volumTag) - return SfxVolume:GetValue() + + local SfxVolume = Game.GetSettingsSystem():GetVar("/audio/volume", volumTag) + return SfxVolume:GetValue() end function getHelpByTag(tag) - for i=1, #cyberscript.cache["help"] do - - if cyberscript.cache["help"][i].tag == tag then - return cyberscript.cache["help"][i].data - end - end - return + for i=1, #cyberscript.cache["help"] do + + if cyberscript.cache["help"][i].tag == tag then + return cyberscript.cache["help"][i].data + end + end + return end function getTextureByTag(tag) - - - - if cyberscript.cache["texture"][tag] ~= nil then - - - - return cyberscript.cache["texture"][tag].data - end - - return nil -end + + + + if cyberscript.cache["texture"][tag] ~= nil then + + + + return cyberscript.cache["texture"][tag].data + end + + return nil +end function printbool(bool) - print(tostring(bool)) + print(tostring(bool)) end function refreshUIWidgetController(active) - if active == true then - pcall(function() - if(GameController["MinimapContainerController"] ~= nil and displayHUD["default_minimap_root"] == nil ) then - - --print("MinimapContainerController") - displayHUD["default_minimap_root"] = GameController["MinimapContainerController"]:GetRootWidget() - - displayHUD["default_minimap_container"] = GameController["MinimapContainerController"]:GetRootWidget():GetWidgetByIndex(4) - - end - end) - pcall(function() - if(GameController["healthbarWidgetGameController"] ~= nil and displayHUD["default_healthbar"] == nil ) then - --print("healthbarWidgetGameController") - displayHUD["default_healthbar"] = GameController["healthbarWidgetGameController"]:GetRootWidget() - - end - end) - pcall(function() - if(GameController["StaminabarWidgetGameController"] ~= nil and displayHUD["default_staminabar"] == nil ) then - --print("StaminabarWidgetGameController") - displayHUD["default_staminabar"] = GameController["StaminabarWidgetGameController"]:GetRootWidget() - - end - end) - pcall(function() - if(GameController["HotkeysWidgetController"] ~= nil and displayHUD["default_hotkey"] == nil ) then - - --print("HotkeysWidgetController") - displayHUD["default_hotkey"] = GameController["HotkeysWidgetController"].root - displayHUD["default_hotkey_phone"] = GameController["HotkeysWidgetController"].phone - displayHUD["default_hotkey_car"] = GameController["HotkeysWidgetController"].car - displayHUD["default_hotkey_consumables"] = GameController["HotkeysWidgetController"].consumables - displayHUD["default_hotkey_gadgets"] = GameController["HotkeysWidgetController"].gadgets - end - end) - local result,err = pcall(function() - if(GameController["BraindanceGameControllerRoot"] ~= nil and displayHUD["main_root_default"] == nil) then - --print("BraindanceGameControllerRoot") - ----print("setting HUD") - - local rootContainerHUD = GameController["BraindanceGameControllerRoot"] - pcall(function() - rootContainerHUD:SetVisible(true) - end) - - local cscontainer = rootContainerHUD:GetWidget(CName("default_cs")) - local makenew = false - local hudprocessing = false - - - if(cscontainer == nil) or (cscontainer:GetName() ~= CName("default_cs")) then - ----print("No container") - CName.add("default_cs") - local cscontainer = nil - cscontainer = inkCanvas.new() - cscontainer:SetName(CName("default_cs")) - cscontainer:SetAnchor(0) - cscontainer:SetFitToContent(false) - cscontainer:SetSize(rootContainerHUD:GetWidth(),rootContainerHUD:GetHeight() ) - cscontainer:Reparent(rootContainerHUD, -1) - makenew = true - - - end - - - - displayHUD["main_root_default"] = cscontainer - - - - if(makenew == true) then - ----print("redo HUD") - hudprocessing = true - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "container") then - displayHUD[k] = inkCanvas.new() - displayHUD[k]:SetName(CName.new(hud.tag)) - displayHUD[k]:SetAnchor(inkEAnchor.Fill) - displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) - - - end - end - - - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "container") then - if(hud.container == nil or hud.container == "default" or hud.container == "") then - displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) - else - displayHUD[k]:Reparent(displayHUD[hud.container], -1) - end - - - end - end - - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "widget") then - displayHUD[k] = inkText.new() - displayHUD[k]:SetName(CName.new(hud.tag)) - displayHUD[k]:SetMargin(inkMargin.new({ top = hud.margin.top, left = hud.margin.left})) - displayHUD[k]:SetFontFamily(hud.fontfamily) - displayHUD[k]:SetFontStyle(hud.fontstyle) - displayHUD[k]:SetFontSize(hud.fontsize) - displayHUD[k]:SetTintColor(gamecolor(hud.color.red,hud.color.green,hud.color.blue,1)) - displayHUD[k]:SetVisible(hud.visible) - displayHUD[k]:SetHorizontalAlignment(textHorizontalAlignment.Center) - displayHUD[k]:SetVerticalAlignment(textVerticalAlignment.Center) - - if(hud.container == nil or hud.container == "default" or hud.container == "") then - displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) - else - displayHUD[k]:Reparent(displayHUD[hud.container], -1) - end - - end - - end - - ----print("HUD created") - else - if hudprocessing == false then - ----print("recreate HUD") - displayHUD["main_root_default"]:RemoveAllChildren() - - - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "container") then - - - displayHUD[k] = inkCanvas.new() - displayHUD[k]:SetName(CName.new(hud.tag)) - displayHUD[k]:SetAnchor(inkEAnchor.Fill) - displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) - - - - end - end - - - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "container") then - if(hud.container == nil or hud.container == "default" or hud.container == "") then - displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) - else - displayHUD[k]:Reparent(displayHUD[hud.container], -1) - end - - - end - end - - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "widget") then - - - displayHUD[k] = inkText.new() - displayHUD[k]:SetName(CName.new(hud.tag)) - displayHUD[k]:SetMargin(inkMargin.new({ top = hud.margin.top, left = hud.margin.left})) - displayHUD[k]:SetFontFamily(hud.fontfamily) - displayHUD[k]:SetFontStyle(hud.fontstyle) - displayHUD[k]:SetFontSize(hud.fontsize) - displayHUD[k]:SetTintColor(gamecolor(hud.color.red,hud.color.green,hud.color.blue,1)) - displayHUD[k]:SetVisible(hud.visible) - displayHUD[k]:SetHorizontalAlignment(textHorizontalAlignment.Center) - displayHUD[k]:SetVerticalAlignment(textVerticalAlignment.Center) - - if(hud.container == nil or hud.container == "default" or hud.container == "") then - displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) - else - displayHUD[k]:Reparent(displayHUD[hud.container], -1) - end - end - - - - - end - - ----print("HUD initialised") - end - end - end - end) - - if(result == false) then - logme(1,err) - end - - - pcall(function() - if(GameController["hudCorpoController"] ~= nil and displayHUD["hud_corpo"] == nil ) then - - displayHUD["hud_corpo"] = GameController["hudCorpoController"].root - - --print("hudCorpoController") - - displayHUD["hud_corpo_market"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0) - displayHUD["hud_corpo_market_marketFluffIcon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(0) - displayHUD["hud_corpo_market_marketFluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(1) - displayHUD["hud_corpo_market_marketConnection"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(2) - displayHUD["hud_corpo_market_marketHolderIcon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(3) - displayHUD["hud_corpo_market_marketHolderFluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(4) - - displayHUD["hud_corpo_market_marketWindowWrapperA"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5) - displayHUD["hud_corpo_market_marketWindowWrapperA_container"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0) - displayHUD["hud_corpo_market_marketWindowWrapperA_marketText"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(0) - displayHUD["hud_corpo_market_marketWindowWrapperA_marketWindow"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(1) - displayHUD["hud_corpo_market_marketWindowWrapperA_marketMask"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(2) - displayHUD["hud_corpo_market_marketWindowWrapperA_FluffTxt_bottom2"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(3) - displayHUD["hud_corpo_market_marketWindowWrapperA_Flufftxt_Bottom"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(4) - displayHUD["hud_corpo_market_marketWindowWrapperA_logoArasaka"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(5) - displayHUD["hud_corpo_market_marketWindowWrapperA_FluffTxt_bottom3"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(6) - displayHUD["hud_corpo_market_marketWindowWrapperA_03_mt_bottfluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(7) - - displayHUD["hud_corpo_market_marketWindowWrapperB"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(6) - displayHUD["hud_corpo_market_marketWindowWrapperB_markerGraph"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(0) - displayHUD["hud_corpo_market_marketWindowWrapperB_marketWindow"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(1) - displayHUD["hud_corpo_market_marketWindowWrapperB_marketMask"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(2) - - displayHUD["hud_corpo_assistant"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1) - displayHUD["hud_corpo_assistant_header"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(0) - displayHUD["hud_corpo_assistant_text"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(1) - displayHUD["hud_corpo_assistant_connection"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(2) - displayHUD["hud_corpo_assistant_holderfluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(3) - displayHUD["hud_corpo_assistant_holdericon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(4) - displayHUD["hud_corpo_assistant_holderplate"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(5) - - - - displayHUD["hud_corpo_stock"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2) - displayHUD["hud_corpo_stock_stockConnection"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(0) - displayHUD["hud_corpo_stock_stockFluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(1) - displayHUD["hud_corpo_stock_stockLogo"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(2) - displayHUD["hud_corpo_stock_stockHolderIcon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(3) - displayHUD["hud_corpo_stock_stockHolderFluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(4) - displayHUD["hud_corpo_stock_stockBorder"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(5) - displayHUD["hud_corpo_stock_marqueeUnit"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6) - - displayHUD["hud_corpo_stock_marqueeUnit_name_pet"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(2) - displayHUD["hud_corpo_stock_marqueeUnit_name_orb"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(5) - displayHUD["hud_corpo_stock_marqueeUnit_name_mil"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(8) - displayHUD["hud_corpo_stock_marqueeUnit_name_ara"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(11) - - displayHUD["hud_corpo_stock_marqueeUnit_value_pet"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(0) - displayHUD["hud_corpo_stock_marqueeUnit_value_orb"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(3) - displayHUD["hud_corpo_stock_marqueeUnit_value_mil"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(6) - displayHUD["hud_corpo_stock_marqueeUnit_value_ara"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(9) - - displayHUD["hud_corpo_stock_marqueeUnit_arrow_pet"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(1) - displayHUD["hud_corpo_stock_marqueeUnit_arrow_orb"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(4) - displayHUD["hud_corpo_stock_marqueeUnit_arrow_mil"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(7) - displayHUD["hud_corpo_stock_marqueeUnit_arrow_ara"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(10) - - displayHUD["hud_corpo_logo"] = GameController["hudCorpoController"].root:GetWidgetByIndex(3) - - displayHUD["hud_corpo_news"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5) - displayHUD["hud_corpo_news_stockHolderIcon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(0) - displayHUD["hud_corpo_news_hudFluffRight"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(1) - displayHUD["hud_corpo_news_title"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(2) - displayHUD["hud_corpo_news_inkFlexWidget9"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(3) - displayHUD["hud_corpo_news_content"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(3):GetWidgetByIndex(0) - displayHUD["hud_corpo_news_inkBorderWidget14"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(4) - - end - end) - - -- local panzer = VehiclePanzerBootupUIQuestEvent.new() - -- panzer.mode = 3 - - -- Game.GetUISystem():QueueEvent(panzer) - - end - -end + if active == true then + pcall(function() + if(GameController["MinimapContainerController"] ~= nil and displayHUD["default_minimap_root"] == nil ) then + + --print("MinimapContainerController") + displayHUD["default_minimap_root"] = GameController["MinimapContainerController"]:GetRootWidget() + + displayHUD["default_minimap_container"] = GameController["MinimapContainerController"]:GetRootWidget():GetWidgetByIndex(4) + + end + end) + pcall(function() + if(GameController["healthbarWidgetGameController"] ~= nil and displayHUD["default_healthbar"] == nil ) then + --print("healthbarWidgetGameController") + displayHUD["default_healthbar"] = GameController["healthbarWidgetGameController"]:GetRootWidget() + + end + end) + pcall(function() + if(GameController["StaminabarWidgetGameController"] ~= nil and displayHUD["default_staminabar"] == nil ) then + --print("StaminabarWidgetGameController") + displayHUD["default_staminabar"] = GameController["StaminabarWidgetGameController"]:GetRootWidget() + + end + end) + pcall(function() + if(GameController["HotkeysWidgetController"] ~= nil and displayHUD["default_hotkey"] == nil ) then + + --print("HotkeysWidgetController") + displayHUD["default_hotkey"] = GameController["HotkeysWidgetController"].root + displayHUD["default_hotkey_phone"] = GameController["HotkeysWidgetController"].phone + displayHUD["default_hotkey_car"] = GameController["HotkeysWidgetController"].car + displayHUD["default_hotkey_consumables"] = GameController["HotkeysWidgetController"].consumables + displayHUD["default_hotkey_gadgets"] = GameController["HotkeysWidgetController"].gadgets + end + end) + local result,err = pcall(function() + if(GameController["BraindanceGameControllerRoot"] ~= nil and displayHUD["main_root_default"] == nil) then + --print("BraindanceGameControllerRoot") + ----print("setting HUD") + + local rootContainerHUD = GameController["BraindanceGameControllerRoot"] + pcall(function() + rootContainerHUD:SetVisible(true) + end) + + local cscontainer = rootContainerHUD:GetWidget(CName("default_cs")) + local makenew = false + local hudprocessing = false + + + if(cscontainer == nil) or (cscontainer:GetName() ~= CName("default_cs")) then + ----print("No container") + CName.add("default_cs") + local cscontainer = nil + cscontainer = inkCanvas.new() + cscontainer:SetName(CName("default_cs")) + cscontainer:SetAnchor(0) + cscontainer:SetFitToContent(false) + cscontainer:SetSize(rootContainerHUD:GetWidth(),rootContainerHUD:GetHeight() ) + cscontainer:Reparent(rootContainerHUD, -1) + makenew = true + + + end + + + + displayHUD["main_root_default"] = cscontainer + + + + if(makenew == true) then + ----print("redo HUD") + hudprocessing = true + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "container") then + displayHUD[k] = inkCanvas.new() + displayHUD[k]:SetName(CName.new(hud.tag)) + displayHUD[k]:SetAnchor(inkEAnchor.Fill) + displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) + + + end + end + + + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "container") then + if(hud.container == nil or hud.container == "default" or hud.container == "") then + displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) + else + displayHUD[k]:Reparent(displayHUD[hud.container], -1) + end + + + end + end + + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "widget") then + displayHUD[k] = inkText.new() + displayHUD[k]:SetName(CName.new(hud.tag)) + displayHUD[k]:SetMargin(inkMargin.new({ top = hud.margin.top, left = hud.margin.left})) + displayHUD[k]:SetFontFamily(hud.fontfamily) + displayHUD[k]:SetFontStyle(hud.fontstyle) + displayHUD[k]:SetFontSize(hud.fontsize) + displayHUD[k]:SetTintColor(gamecolor(hud.color.red,hud.color.green,hud.color.blue,1)) + displayHUD[k]:SetVisible(hud.visible) + displayHUD[k]:SetHorizontalAlignment(textHorizontalAlignment.Center) + displayHUD[k]:SetVerticalAlignment(textVerticalAlignment.Center) + + if(hud.container == nil or hud.container == "default" or hud.container == "") then + displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) + else + displayHUD[k]:Reparent(displayHUD[hud.container], -1) + end + + end + + end + + ----print("HUD created") + else + if hudprocessing == false then + ----print("recreate HUD") + displayHUD["main_root_default"]:RemoveAllChildren() + + + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "container") then + + + displayHUD[k] = inkCanvas.new() + displayHUD[k]:SetName(CName.new(hud.tag)) + displayHUD[k]:SetAnchor(inkEAnchor.Fill) + displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) + + + + end + end + + + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "container") then + if(hud.container == nil or hud.container == "default" or hud.container == "") then + displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) + else + displayHUD[k]:Reparent(displayHUD[hud.container], -1) + end + + + end + end + + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "widget") then + + + displayHUD[k] = inkText.new() + displayHUD[k]:SetName(CName.new(hud.tag)) + displayHUD[k]:SetMargin(inkMargin.new({ top = hud.margin.top, left = hud.margin.left})) + displayHUD[k]:SetFontFamily(hud.fontfamily) + displayHUD[k]:SetFontStyle(hud.fontstyle) + displayHUD[k]:SetFontSize(hud.fontsize) + displayHUD[k]:SetTintColor(gamecolor(hud.color.red,hud.color.green,hud.color.blue,1)) + displayHUD[k]:SetVisible(hud.visible) + displayHUD[k]:SetHorizontalAlignment(textHorizontalAlignment.Center) + displayHUD[k]:SetVerticalAlignment(textVerticalAlignment.Center) + + if(hud.container == nil or hud.container == "default" or hud.container == "") then + displayHUD[k]:Reparent(displayHUD["main_root_default"], -1) + else + displayHUD[k]:Reparent(displayHUD[hud.container], -1) + end + end + + + + + end + + ----print("HUD initialised") + end + end + end + end) + + if(result == false) then + logme(1,err) + end + + + pcall(function() + if(GameController["hudCorpoController"] ~= nil and displayHUD["hud_corpo"] == nil ) then + + displayHUD["hud_corpo"] = GameController["hudCorpoController"].root + + --print("hudCorpoController") + + displayHUD["hud_corpo_market"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0) + displayHUD["hud_corpo_market_marketFluffIcon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(0) + displayHUD["hud_corpo_market_marketFluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(1) + displayHUD["hud_corpo_market_marketConnection"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(2) + displayHUD["hud_corpo_market_marketHolderIcon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(3) + displayHUD["hud_corpo_market_marketHolderFluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(4) + + displayHUD["hud_corpo_market_marketWindowWrapperA"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5) + displayHUD["hud_corpo_market_marketWindowWrapperA_container"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0) + displayHUD["hud_corpo_market_marketWindowWrapperA_marketText"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(0) + displayHUD["hud_corpo_market_marketWindowWrapperA_marketWindow"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(1) + displayHUD["hud_corpo_market_marketWindowWrapperA_marketMask"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(2) + displayHUD["hud_corpo_market_marketWindowWrapperA_FluffTxt_bottom2"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(3) + displayHUD["hud_corpo_market_marketWindowWrapperA_Flufftxt_Bottom"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(4) + displayHUD["hud_corpo_market_marketWindowWrapperA_logoArasaka"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(5) + displayHUD["hud_corpo_market_marketWindowWrapperA_FluffTxt_bottom3"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(6) + displayHUD["hud_corpo_market_marketWindowWrapperA_03_mt_bottfluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(5):GetWidgetByIndex(0):GetWidgetByIndex(7) + + displayHUD["hud_corpo_market_marketWindowWrapperB"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(6) + displayHUD["hud_corpo_market_marketWindowWrapperB_markerGraph"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(0) + displayHUD["hud_corpo_market_marketWindowWrapperB_marketWindow"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(1) + displayHUD["hud_corpo_market_marketWindowWrapperB_marketMask"] = GameController["hudCorpoController"].root:GetWidgetByIndex(0):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(2) + + displayHUD["hud_corpo_assistant"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1) + displayHUD["hud_corpo_assistant_header"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(0) + displayHUD["hud_corpo_assistant_text"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(1) + displayHUD["hud_corpo_assistant_connection"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(2) + displayHUD["hud_corpo_assistant_holderfluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(3) + displayHUD["hud_corpo_assistant_holdericon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(4) + displayHUD["hud_corpo_assistant_holderplate"] = GameController["hudCorpoController"].root:GetWidgetByIndex(1):GetWidgetByIndex(5) + + + + displayHUD["hud_corpo_stock"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2) + displayHUD["hud_corpo_stock_stockConnection"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(0) + displayHUD["hud_corpo_stock_stockFluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(1) + displayHUD["hud_corpo_stock_stockLogo"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(2) + displayHUD["hud_corpo_stock_stockHolderIcon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(3) + displayHUD["hud_corpo_stock_stockHolderFluff"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(4) + displayHUD["hud_corpo_stock_stockBorder"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(5) + displayHUD["hud_corpo_stock_marqueeUnit"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6) + + displayHUD["hud_corpo_stock_marqueeUnit_name_pet"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(2) + displayHUD["hud_corpo_stock_marqueeUnit_name_orb"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(5) + displayHUD["hud_corpo_stock_marqueeUnit_name_mil"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(8) + displayHUD["hud_corpo_stock_marqueeUnit_name_ara"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(11) + + displayHUD["hud_corpo_stock_marqueeUnit_value_pet"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(0) + displayHUD["hud_corpo_stock_marqueeUnit_value_orb"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(3) + displayHUD["hud_corpo_stock_marqueeUnit_value_mil"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(6) + displayHUD["hud_corpo_stock_marqueeUnit_value_ara"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(9) + + displayHUD["hud_corpo_stock_marqueeUnit_arrow_pet"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(1) + displayHUD["hud_corpo_stock_marqueeUnit_arrow_orb"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(4) + displayHUD["hud_corpo_stock_marqueeUnit_arrow_mil"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(7) + displayHUD["hud_corpo_stock_marqueeUnit_arrow_ara"] = GameController["hudCorpoController"].root:GetWidgetByIndex(2):GetWidgetByIndex(6):GetWidgetByIndex(0):GetWidgetByIndex(10) + + displayHUD["hud_corpo_logo"] = GameController["hudCorpoController"].root:GetWidgetByIndex(3) + + displayHUD["hud_corpo_news"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5) + displayHUD["hud_corpo_news_stockHolderIcon"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(0) + displayHUD["hud_corpo_news_hudFluffRight"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(1) + displayHUD["hud_corpo_news_title"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(2) + displayHUD["hud_corpo_news_inkFlexWidget9"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(3) + displayHUD["hud_corpo_news_content"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(3):GetWidgetByIndex(0) + displayHUD["hud_corpo_news_inkBorderWidget14"] = GameController["hudCorpoController"].root:GetWidgetByIndex(5):GetWidgetByIndex(4) + + end + end) + + -- local panzer = VehiclePanzerBootupUIQuestEvent.new() + -- panzer.mode = 3 + + -- Game.GetUISystem():QueueEvent(panzer) + + end + +end function refreshModVariable(active) - if active == true then - if(GameController["HUDManager"] ~= nil) then inScanner = GameController["HUDManager"].uiScannerVisible else inScanner = false end - player = Game.GetPlayer() - currentTime = getGameTime() - curPos = player:GetWorldPosition() - - next_ambush = next_ambush + 1 - loadCustomPlace() - --itemMover() - - curRot = GetSingleton('Quaternion'):ToEulerAngles(Game.GetPlayer():GetWorldOrientation()) - - districtState = getLang("Friendly") - getCurrentDistrict2() - - - - if(currentDistricts2 ~= nil)then - - setVariable("current_district","tag", currentDistricts2.Tag) - local district = getDistrictByTag(currentDistricts2.Tag) - if district~= nil then setVariable("current_district","enum", district.EnumName) end - if(districtState == nil) then - districtState = "loading" - - end - - local disstate = isHostileDistrict() - setVariable("current_district","state",disstate) - - if(disstate == 0) then - - setVariable("current_district","stateName",getLang("Friendly")) - districtState = getLang("Friendly") - - end - - if(disstate == 1) then - - setVariable("current_district","stateName",getLang("Neutral")) - districtState = getLang("Neutral") - - end - - if(disstate == 2) then - - setVariable("current_district","stateName",getLang("Hostile")) - districtState = getLang("Hostile") - - end - - - - - local districttext = "" - if(currentDistricts2.districtLabels ~=nil and #currentDistricts2.districtLabels > 0) then - - if(currentDistricts2.districtLabels ~=nil and #currentDistricts2.districtLabels > 1) then - - setVariable("current_district","subdistrict_enum", currentDistricts2.districtLabels[2]) - else - setVariable("current_district","subdistrict_enum", "") - end - - for i, test in ipairs(currentDistricts2.districtLabels) do - if i == 1 then - if(#currentDistricts2.districtLabels == 1) then - - - districttext = districttext.." | "..test.." ("..districtState..")" - else - - districttext = districttext..test - - end - else - districttext = districttext.." | "..test.." ("..districtState..")" - end - end - - setVariable("current_district","districttext",districttext) - - else - setVariable("current_district","tag", "") - setVariable("current_district","enum", "") - setVariable("current_district","districttext","") - setVariable("current_district","subdistrict_enum", "") - setVariable("current_district","state","") - setVariable("current_district","stateName","") - - end - - - else - setVariable("current_district","tag", "") - setVariable("current_district","enum", "") - setVariable("current_district","districttext","") - setVariable("current_district","subdistrict_enum", "") - setVariable("current_district","state","") - setVariable("current_district","stateName","") - - end - - - - setVariable("player_position","x",ftos(curPos.x)) - setVariable("player_position","y",ftos(curPos.y)) - setVariable("player_position","z",ftos(curPos.z)) - - setVariable("player_rotation","yaw",ftos(curRot.yaw)) - setVariable("player_rotation","pitch",ftos(curRot.pitch)) - setVariable("player_rotation","roll",ftos(curRot.roll)) - - - setVariable("game_time","day",GetSingleton('GameTime'):Days(gameTime)) - setVariable("game_time","hour",GetSingleton('GameTime'):Hours(gameTime)) - setVariable("game_time","min",GetSingleton('GameTime'):Minutes(gameTime)) - setVariable("game_time","sec",GetSingleton('GameTime'):Seconds(gameTime)) - - - - setScore("player","money",getStackableItemAmount("Items.money")) - - if(currentHouse ~= nil) then - interactautohide = false - setVariable("current_place","tag",currentHouse.tag) - setVariable("current_place","name",currentHouse.name) - if(currentRoom ~= nil) then - - setVariable("current_place","room_tag",currentRoom.tag) - setVariable("current_place","room_name",currentRoom.name) - else - setVariable("current_place","room_tag","") - setVariable("current_place","room_name","") - - end - else - setVariable("current_place","tag","") - setVariable("current_place","name","") - setVariable("current_place","room_tag","") - setVariable("current_place","room_name","") - end - - - end + -- B-03 / B-18 fix: throttle to ~20 Hz (every 3 frames at 60 fps). + -- refreshModVariable recomputes player position, rotation, district, + -- game_time, money, etc. every frame and is the single biggest per-tick + -- cost in Cyberscript — compounded by the B-01 GameTime error which + -- fired every frame and is now fixed. 20 Hz is well above any reasonable + -- polling rate for UI displays / script-variable reads, so this is + -- imperceptible to users and downstream mods, but cuts the per-tick + -- cost by ~3x and eliminates the periodic stutter reported on NexusMods. + -- The first call after a session load always runs so initial state is + -- populated immediately. + refreshModVariableFrameCounter = (refreshModVariableFrameCounter or 0) + 1 + if active == true and refreshModVariableFrameCounter < 3 and refreshModVariableHasRun then + return + end + refreshModVariableFrameCounter = 0 + refreshModVariableHasRun = true + if active == true then + if(GameController["HUDManager"] ~= nil) then inScanner = GameController["HUDManager"].uiScannerVisible else inScanner = false end + player = Game.GetPlayer() + currentTime = getGameTime() + curPos = player:GetWorldPosition() + + next_ambush = next_ambush + 1 + loadCustomPlace() + --itemMover() + + curRot = GetSingleton('Quaternion'):ToEulerAngles(Game.GetPlayer():GetWorldOrientation()) + + districtState = getLang("Friendly") + getCurrentDistrict2() + + + + if(currentDistricts2 ~= nil)then + + setVariable("current_district","tag", currentDistricts2.Tag) + local district = getDistrictByTag(currentDistricts2.Tag) + if district~= nil then setVariable("current_district","enum", district.EnumName) end + if(districtState == nil) then + districtState = "loading" + + end + + local disstate = isHostileDistrict() + setVariable("current_district","state",disstate) + + if(disstate == 0) then + + setVariable("current_district","stateName",getLang("Friendly")) + districtState = getLang("Friendly") + + end + + if(disstate == 1) then + + setVariable("current_district","stateName",getLang("Neutral")) + districtState = getLang("Neutral") + + end + + if(disstate == 2) then + + setVariable("current_district","stateName",getLang("Hostile")) + districtState = getLang("Hostile") + + end + + + + + local districttext = "" + if(currentDistricts2.districtLabels ~=nil and #currentDistricts2.districtLabels > 0) then + + if(currentDistricts2.districtLabels ~=nil and #currentDistricts2.districtLabels > 1) then + + setVariable("current_district","subdistrict_enum", currentDistricts2.districtLabels[2]) + else + setVariable("current_district","subdistrict_enum", "") + end + + for i, test in ipairs(currentDistricts2.districtLabels) do + if i == 1 then + if(#currentDistricts2.districtLabels == 1) then + + + districttext = districttext.." | "..test.." ("..districtState..")" + else + + districttext = districttext..test + + end + else + districttext = districttext.." | "..test.." ("..districtState..")" + end + end + + setVariable("current_district","districttext",districttext) + + else + setVariable("current_district","tag", "") + setVariable("current_district","enum", "") + setVariable("current_district","districttext","") + setVariable("current_district","subdistrict_enum", "") + setVariable("current_district","state","") + setVariable("current_district","stateName","") + + end + + + else + setVariable("current_district","tag", "") + setVariable("current_district","enum", "") + setVariable("current_district","districttext","") + setVariable("current_district","subdistrict_enum", "") + setVariable("current_district","state","") + setVariable("current_district","stateName","") + + end + + + + setVariable("player_position","x",ftos(curPos.x)) + setVariable("player_position","y",ftos(curPos.y)) + setVariable("player_position","z",ftos(curPos.z)) + + setVariable("player_rotation","yaw",ftos(curRot.yaw)) + setVariable("player_rotation","pitch",ftos(curRot.pitch)) + setVariable("player_rotation","roll",ftos(curRot.roll)) + + + -- B-01 fix (PR #19 by GoogleRa, attributed to Zoliquen & Gilgamesh): + -- `gameTime` was the LOCAL variable inside getGameTime() and is NOT in scope here, + -- so each call passed nil to GetSingleton('GameTime'):Days/Hours/Minutes/Seconds, + -- which fired the CET type-check error "Function 'Days' parameter 1 must be GameTime." + -- on every refresh tick. Use the already-populated `currentTime` table instead. + setVariable("game_time","day", currentTime.day) + setVariable("game_time","hour", currentTime.hour) + setVariable("game_time","min", currentTime.min) + setVariable("game_time","sec", currentTime.sec) + + + + setScore("player","money",getStackableItemAmount("Items.money")) + + if(currentHouse ~= nil) then + interactautohide = false + setVariable("current_place","tag",currentHouse.tag) + setVariable("current_place","name",currentHouse.name) + if(currentRoom ~= nil) then + + setVariable("current_place","room_tag",currentRoom.tag) + setVariable("current_place","room_name",currentRoom.name) + else + setVariable("current_place","room_tag","") + setVariable("current_place","room_name","") + + end + else + setVariable("current_place","tag","") + setVariable("current_place","name","") + setVariable("current_place","room_tag","") + setVariable("current_place","room_name","") + end + + + end end function getAIContextOrDefault(tag) - - if(AIhandler[tag] ~= nil and AIhandler[tag].context ~= nil) then - return {"System", AIhandler[tag].context} - end - - return nil - + + if(AIhandler[tag] ~= nil and AIhandler[tag].context ~= nil) then + return {"System", AIhandler[tag].context} + end + + return nil + end function getAIAnswerOrDefault(tag) - - if(AIhandler[tag] ~= nil and AIhandler[tag].answer ~= nil) then - print(AIhandler[tag].answer) - return AIhandler[tag].answer - end - - return nil - + + if(AIhandler[tag] ~= nil and AIhandler[tag].answer ~= nil) then + print(AIhandler[tag].answer) + return AIhandler[tag].answer + end + + return nil + end function setupAIkey(tag) - - if(AIhandler[tag] == nil) then AIhandler[tag] = {} end - AIhandler[tag].answer = nil + + if(AIhandler[tag] == nil) then AIhandler[tag] = {} end + AIhandler[tag].answer = nil end @@ -5100,15 +5141,15 @@ prevRandom = nil -- Function to generate a new random number that is different from the previous one function random2(mind,maxd) local newRandom - + repeat - newRandom = 0 + newRandom = 0 newRandom = math.random(mind,maxd) -- Adjust the range as needed until newRandom ~= prevRandom -- Update the previous random number prevRandom = newRandom - + return newRandom end @@ -5137,97 +5178,106 @@ end -function getEntityFromManager(tag) - local obj = {} - obj.id = nil - - - local enti = cyberscript.EntityManager[tag] - if(enti ~= nil) then - - if(enti.tag ~= tag) then - - local enti2 = cyberscript.EntityManager[enti.tag] - - if(enti ~= nil) then - - obj = enti2 - - end - - else - obj = enti - end - end - - - - - - - return obj +function getEntityFromManager(tag) + local obj = {} + obj.id = nil + + + local enti = cyberscript.EntityManager[tag] + if(enti ~= nil) then + + if(enti.tag ~= tag) then + + local enti2 = cyberscript.EntityManager[enti.tag] + + if(enti ~= nil) then + + obj = enti2 + + end + + else + obj = enti + end + end + + + + + + + return obj end function getTrueEntityFromManager(tag) - - - - local enti = cyberscript.EntityManager[tag] - - - if(tag ~= enti.tag) then - - local enti2 = cyberscript.EntityManager[enti.tag] - - if(enti2 ~= nil) then - - return enti2 - - end - - - else - - return enti - - - end - - + -- B-23 fix: handle nil entity gracefully. The original code accessed + -- enti.tag without checking enti ~= nil, which crashed when the tag + -- didn't exist in cyberscript.EntityManager (mod referenced a + -- non-existent or already-despawned entity). + local enti = cyberscript.EntityManager[tag] + if enti == nil then + -- Entity not found — return a stub with nil id so callers + -- that check obj.id ~= nil will skip safely. + local stub = {} + stub.id = nil + stub.tag = tag + return stub + end + + + if(tag ~= enti.tag) then + + local enti2 = cyberscript.EntityManager[enti.tag] + + if(enti2 ~= nil) then + + return enti2 + + end + + + else + + return enti + + + end + + end function setEntityFromManager(tag,obju) - cyberscript.EntityManager[tag] = obju + cyberscript.EntityManager[tag] = obju end function getEntityFromManagerById(Id, avoid) - local obj = {} - obj.id = nil - local key = nil - - for k,v in pairs(cyberscript.EntityManager) do - - local enti = v - - if type(enti.id) ~= "number" then - - if(enti.id ~= nil and Id ~= nil and enti.id.hash == Id.hash) then - obj = v - key = k - break - end - - end - - end - - if(obj.id ~= nil and obj.tag ~= key) then - obj = getEntityFromManager(obj.tag) - end - - return obj - + local obj = {} + obj.id = nil + local key = nil + + for k,v in pairs(cyberscript.EntityManager) do + + local enti = v + + if type(enti.id) ~= "number" then + + if(enti.id ~= nil and Id ~= nil and enti.id.hash == Id.hash) then + obj = v + key = k + break + end + + end + + end + + if(obj.id ~= nil and obj.tag ~= key) then + obj = getEntityFromManager(obj.tag) + end + + return obj + end function InTable(tbl, value) for _, v in ipairs(tbl) do @@ -5238,30 +5288,30 @@ function InTable(tbl, value) return false -- Value not found in the table end function searchEntityFromManagerById(Id, avoidfilter) - local obj = {} - obj.id = nil - local key = nil - - for k,v in pairs(cyberscript.EntityManager) do - - local enti = v - - if type(enti.id) ~= "number" then - - if(enti.id ~= nil and Id ~= nil and enti.id.hash == Id.hash and not InTable(avoidfilter,k)) then - obj = v - key = k - break - end - - end - - end - - if(obj.id ~= nil and obj.tag ~= key) then - obj = getEntityFromManager(obj.tag) - end - - return obj - + local obj = {} + obj.id = nil + local key = nil + + for k,v in pairs(cyberscript.EntityManager) do + + local enti = v + + if type(enti.id) ~= "number" then + + if(enti.id ~= nil and Id ~= nil and enti.id.hash == Id.hash and not InTable(avoidfilter,k)) then + obj = v + key = k + break + end + + end + + end + + if(obj.id ~= nil and obj.tag ~= key) then + obj = getEntityFromManager(obj.tag) + end + + return obj + end diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/see.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/see.lua index 6644dc6..6fb9494 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/see.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/see.lua @@ -1,15124 +1,15304 @@ logme(1,"CyberScript: see module loaded") + +-- B-23 fix: safe wrapper for Game.FindEntityByID. +-- Accepts either a manager entry (table with .id) or a raw entityID. +-- Handles nil, missing .id, and invalid id types without crashing. +-- Returns nil on any failure; callers should check `if enti ~= nil`. +-- +-- DEBUGGING: if the user enables "debugEntityLookups" in +-- user/settings/cyberscript.json (or via the native settings UI), +-- every nil/skipped lookup is logged with the tag and reason so mod +-- authors can see which entity references are invalid. +-- Default: OFF (silent). Turn on only when debugging missing entities. +function safeFindEntityByID(idOrObj, contextTag) + local id = idOrObj + if idOrObj == nil then + if debugEntityLookups == true then + logme(3, "[safeFindEntityByID] nil input" .. (contextTag and (" tag=" .. tostring(contextTag)) or "")) + end + return nil + end + -- If passed a manager entry (table with .id), extract the id + if type(idOrObj) == "table" and idOrObj.id ~= nil then + id = idOrObj.id + end + if id == nil then + if debugEntityLookups == true then + logme(3, "[safeFindEntityByID] nil id" .. (contextTag and (" tag=" .. tostring(contextTag)) or "")) + end + return nil + end + local ok, res = pcall(function() return Game.FindEntityByID(id) end) + if ok then + if res == nil and debugEntityLookups == true then + logme(3, "[safeFindEntityByID] entity not found" .. (contextTag and (" tag=" .. tostring(contextTag)) or "") .. " id=" .. tostring(id)) + end + return res + end + if debugEntityLookups == true then + logme(2, "[safeFindEntityByID] pcall failed" .. (contextTag and (" tag=" .. tostring(contextTag)) or "") .. " err=" .. tostring(res)) + end + return nil +end + cyberscript.module = cyberscript.module +1 vitesseParLettre = 1 / 12 function checkTrigger(trigger) - - local status, result = pcall(scriptcheckTrigger,trigger) - - - - if status == false then - logme(1,dump(trigger),true) - if(trigger.output == true) then - - logme(1,trigger.name,true) - logme(1,dump(trigger),true) - logme(1,tostring(result),true) - - end - - logme(1,getLang("see_trigger_error") .. result.." Trigger : "..tostring(JSON:encode_pretty(trigger)),true) - if(trigger.fail_action ~= nil and #trigger.fail_action > 0) then - runActionList(trigger.fail_action, trigger.name.."_failure", "see",false,nil) - - end - --Game.GetPlayer():SetWarningMessage("CyberScript Trigger error, check the log for more detail") - return false - else - return result - - end - - - + + local status, result = pcall(scriptcheckTrigger,trigger) + + + + if status == false then + logme(1,dump(trigger),true) + if(trigger.output == true) then + + logme(1,trigger.name,true) + logme(1,dump(trigger),true) + logme(1,tostring(result),true) + + end + + logme(1,getLang("see_trigger_error") .. result.." Trigger : "..tostring(JSON:encode_pretty(trigger)),true) + if(trigger.fail_action ~= nil and #trigger.fail_action > 0) then + runActionList(trigger.fail_action, trigger.name.."_failure", "see",false,nil) + + end + --Game.GetPlayer():SetWarningMessage("CyberScript Trigger error, check the log for more detail") + return false + else + return result + + end + + + end --Check trigger core function function scriptcheckTrigger(trigger) - local result = false - if trigger ~= nil then - - local entityregion = true - local groupregion = true - local vehiculeregion = true - local scoreregion = true - local houseregion = true - local gangregion = true - local miscregion = true - local relationregion = true - local questregion = true - local noderegion = true - local soundregion = true - local logicregion = true - local uiregion = true - local avregion = true - local customnpcregion = true - local multiregion = true - local frameworkregion = true - local playerregion = true - local scannerregion = true - local airegion = true - - checkContext(trigger) - - - - if entityregion then - if(trigger.name == "npc") then - if(trigger.way == "phone") then - if currentNPC ~= nil then - if(currentNPC.Names == (trigger.value))then - result = true - end - end - end - if(trigger.way == "speak") then - if currentStar ~= nil then - if(currentStar.Names == (trigger.value))then - result = true - end - end - end - if(trigger.way == "fixer") then - if currentfixer ~= nil then - if(currentfixer.tag == trigger.value)then - result = true - end - end - end - end - - if(trigger.name == "entity_is_spawn") then - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - ----logme(3,"entity is active"..tostring(enti:IsAttached())) - if (enti:IsAttached() == true)then - ----logme(3,"entity is actived"..tostring(enti:IsAttached())) - result = true - end - end - end - end - if(trigger.name == "entity_is_vehicle") then - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - ----logme(3,"entity is active"..tostring(enti:IsAttached())) - - ----logme(3,"entity is actived"..tostring(enti:IsAttached())) - result = enti:IsVehicle() - - end - end - end - if(trigger.name == "choice_is_opened") then - result = currentDialogHub ~= nil - end - if(trigger.name == "native_choice_is_opened") then - result = nativeDialogOpen ~= nil and nativeDialogOpen == true - end - if(trigger.name == "inject_dialog_pending") then - - result = interactionUI.injectdialog ~= nil and #interactionUI.injectdialog ~= 0 - end - if(trigger.name == "specific_choice_is_opened") then - ----print(currentDialogHub.dial.tag) - result = currentDialogHub ~= nil and currentDialogHub.dial.tag == trigger.tag - end - if(trigger.name == "entity_tag_exist") then - result = cyberscript.EntityManager[trigger.tag] ~= nil - end - if(trigger.name == "entity_is_scanned") then - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - ----logme(3,"entity is active"..tostring(enti:IsAttached())) - if (enti:IsScanned() == true)then - ----logme(3,"entity is actived"..tostring(enti:IsAttached())) - result = true - end - end - end - end - if(trigger.name == "entity_is_crowd") then - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - ----logme(3,"entity is active"..tostring(enti:IsAttached())) - result = enti:IsCrowd() - end - end - end - if(trigger.name == "look_at_object") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - if(tarName ~= nil and appName ~= nil)then - if( - string.match(tarName, trigger.value) or - string.match(appName, trigger.value) or - string.match(dipName, trigger.value) or - (trigger.value == "isnpc" and objLook:IsA("NPCPuppet")))then - result = true - end - end - end - end - if(trigger.name == "scanned_entity") then - if scannedEntity ~= nil then - local obj = getEntityFromManager(trigger.value) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - if(enti:GetEntityID().hash == scannedEntity:GetEntityID().hash and (trigger.npc_only == false or (trigger.npc_only == true and enti:IsA("NPCPuppet"))))then - result = true - end - end - - end - end - end - if(trigger.name == "entity_is_a") then - - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - if(enti:IsA(trigger.value))then - result = true - end - end - - end - - end - if(trigger.name == "look_at_entity") then - if objLook ~= nil then - local obj = getEntityFromManager(trigger.value) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - if(enti:GetEntityID().hash == objLook:GetEntityID().hash)then - result = true - end - end - - end - - end - end - if(trigger.name == "look_at_hash") then - if objLook ~= nil then - - if(trigger.value == tostring(objLook:GetEntityID().hash))then - result = true - end - - - end - end - if(trigger.name == "killed_entity") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - result = (enti:IsDead() == true or enti:IsActive() == false) - - end - end - if(trigger.name == "entity_is_alive") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - result = enti:IsDead() == false and enti:IsActive() == true - end - end - if(trigger.name == "entity_looked_is_follower") then - local isFollower = false - if objLook ~= nil then - tarbName = objLook:ToString() - end - if objLook ~= nil and (string.match(tarbName, "NPCPuppet"))then - local aicontrol = nil - pcall(function() - aicontrol = objLook:GetAIControllerComponent() - end) - if(aicontrol ~= nil) then - local currentRole =aicontrol:GetAIRole() - isFollower = (currentRole and (currentRole:IsA('AIFollowerRole')) ) - if(isFollower == nil) then - isFollower = false - end - end - end - result = isFollower - end - if(trigger.name == "entity_looked_is_registered") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local entity = getEntityFromManagerById(entid) - if(entity.id ~= nil) then - result = true - end - end - end - if(trigger.name == "entity_at_position") then - local obj = getEntityFromManager(trigger.tag) - --logme(3,obj.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - if(trigger.position == nil) then trigger.position = "at" end - - local targetPosition = getPositionFromParameter(trigger) - - - if (targetPosition.x ~= nil and check3DPos(enti:GetWorldPosition(), targetPosition.x, targetPosition.y, targetPosition.z,trigger.range)) then - result = true - else - result = false - end - else - --logme(3,"entity not found : "..trigger.tag) - end - end - if(trigger.name == "entity_in_state") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local testres, err = pcall(function() - local levelstate = enti:GetHighLevelStateFromBlackboard() - local triggerlevelstate = gamedataNPCHighLevelState.Any - if(trigger.value == 0) then - triggerlevelstate = gamedataNPCHighLevelState.Alerted - end - if(trigger.value == 2) then - triggerlevelstate = gamedataNPCHighLevelState.Combat - end - if(trigger.value == 3) then - triggerlevelstate = gamedataNPCHighLevelState.Dead - end - if(trigger.value == 4) then - triggerlevelstate = gamedataNPCHighLevelState.Fear - end - if(trigger.value == 5) then - triggerlevelstate = gamedataNPCHighLevelState.Relaxed - end - if(trigger.value == 6) then - triggerlevelstate = gamedataNPCHighLevelState.Stealth - end - if(trigger.value == 7) then - triggerlevelstate = gamedataNPCHighLevelState.Unconscious - end - if(trigger.value == 8) then - triggerlevelstate = gamedataNPCHighLevelState.Wounded - end - if(trigger.value == 9) then - triggerlevelstate = gamedataNPCHighLevelState.Count - end - if(trigger.value == 10) then - triggerlevelstate = gamedataNPCHighLevelState.Invalid - end - - end) - if testres == false then - triggerlevelstate= gamedataNPCHighLevelState.Invalid - ------print(triggerlevelstate) - end - - if(levelstate == triggerlevelstate) then - result = true - end - end - end - if(trigger.name == "entity_inbuilding")then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - result = Game.IsEntityInInteriorArea(enti) - end - if(trigger.name == "entity_gender") then - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - logme(1,GetEntityGender(enti)) - logme(1,trigger.value) - if(trigger.value == tostring(GetEntityGender(enti))) then - result = true - else - result = false - end - end - end - - end - if(trigger.name == "entity_hash") then - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - if(trigger.value == tostring(enti:GetEntityID().hash)) then - result = true - - end - end - end - - - end - if(trigger.name == "entity_script_level") then - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - if(checkValue(trigger.operator,obj.scriptlevel,trigger.scriptlevel,trigger.min,trigger.max)) then - - result = true - - end - - end - end - - if(trigger.name == "last_killed_entity_is_registred") then - if getEntityFromManager("last_killed").id ~= nil then - - - result = true - - end - end - if(trigger.name == "if_entity_contains_value") then - local obj = getEntityFromManager(trigger.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local entName = enti:ToString() - local entAppName = Game.NameToString(enti:GetCurrentAppearanceName()) - local entDispName = enti:GetDisplayName() - - if(entName ~= nil and entAppName ~= nil)then - for i,filter in ipairs(trigger.filter) do - - if(string.match(entName, filter) or string.match(entAppName, filter) or string.match(entDispName, filter) or filter == tostring(newent:GetEntityID().hash))then - result = true - end - end - end - end - end - - end - if(trigger.name == "if_entities_around_entity") then - - local obj = getEntityFromManager(trigger.tag) - local goodEntity = false - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - player = Game.GetPlayer() - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects - searchQuery.maxDistance = trigger.range - searchQuery.filterObjectByDistance = true - searchQuery.includeSecondaryTargets = true - success, parts = targetingSystem:GetTargetParts(enti, searchQuery) - - - - - for _, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - - - - if(trigger.filter ~= nil and #trigger.filter > 0) then - - - local entName = newent:ToString() - local entAppName = Game.NameToString(newent:GetCurrentAppearanceName()) - local entDispName = newent:GetDisplayName() - - if(entName ~= nil and entAppName ~= nil)then - for i,filter in ipairs(trigger.filter) do - - if(goodEntity == false and - (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and - string.match(entName, filter) ~= nil or - string.match(entAppName, filter) ~= nil or - string.match(entDispName, filter) ~= nil or - filter == tostring(newent:GetEntityID().hash) or (filter == "vehicle" and newent:IsVehicle()))then - - goodEntity = true - end - end - end - - - - else - - goodEntity = true - - end - - - - - - end - - - end - result = goodEntity - end - - - if(trigger.name == "if_entities_around_you") then - player = Game.GetPlayer() - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects - searchQuery.maxDistance = trigger.range - success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) - - - - local goodEntity = false - - for _, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - - - - if(trigger.filter ~= nil and #trigger.filter > 0) then - - - local entName = newent:ToString() - local entAppName = Game.NameToString(newent:GetCurrentAppearanceName()) - local entDispName = newent:GetDisplayName() - - if(entName ~= nil and entAppName ~= nil)then - for i,filter in ipairs(trigger.filter) do - - if(goodEntity == false and - (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and - string.match(entName, filter) ~= nil or - string.match(entAppName, filter) ~= nil or - string.match(entDispName, filter) ~= nil or - filter == tostring(newent:GetEntityID().hash) or (filter == "vehicle" and newent:IsVehicle()))then - - if(trigger.output) then - print(tostring(goodEntity == false)) - print(tostring((filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))))) - print(tostring(string.match(entName, filter))) - print(tostring(string.match(entAppName, filter))) - print(tostring(string.match(entDispName, filter))) - print(tostring(filter == tostring(newent:GetEntityID().hash))) - print((filter == "vehicle" and newent:IsVehicle())) + local result = false + if trigger ~= nil then + + local entityregion = true + local groupregion = true + local vehiculeregion = true + local scoreregion = true + local houseregion = true + local gangregion = true + local miscregion = true + local relationregion = true + local questregion = true + local noderegion = true + local soundregion = true + local logicregion = true + local uiregion = true + local avregion = true + local customnpcregion = true + local multiregion = true + local frameworkregion = true + local playerregion = true + local scannerregion = true + local airegion = true + + checkContext(trigger) + + + + if entityregion then + if(trigger.name == "npc") then + if(trigger.way == "phone") then + if currentNPC ~= nil then + if(currentNPC.Names == (trigger.value))then + result = true + end + end + end + if(trigger.way == "speak") then + if currentStar ~= nil then + if(currentStar.Names == (trigger.value))then + result = true + end + end + end + if(trigger.way == "fixer") then + if currentfixer ~= nil then + if(currentfixer.tag == trigger.value)then + result = true + end + end + end + end + + if(trigger.name == "entity_is_spawn") then + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + ----logme(3,"entity is active"..tostring(enti:IsAttached())) + if (enti:IsAttached() == true)then + ----logme(3,"entity is actived"..tostring(enti:IsAttached())) + result = true + end + end + end + end + if(trigger.name == "entity_is_vehicle") then + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + ----logme(3,"entity is active"..tostring(enti:IsAttached())) + + ----logme(3,"entity is actived"..tostring(enti:IsAttached())) + result = enti:IsVehicle() + + end + end + end + if(trigger.name == "choice_is_opened") then + result = currentDialogHub ~= nil + end + if(trigger.name == "native_choice_is_opened") then + result = nativeDialogOpen ~= nil and nativeDialogOpen == true + end + if(trigger.name == "inject_dialog_pending") then + + result = interactionUI.injectdialog ~= nil and #interactionUI.injectdialog ~= 0 + end + if(trigger.name == "specific_choice_is_opened") then + ----print(currentDialogHub.dial.tag) + result = currentDialogHub ~= nil and currentDialogHub.dial.tag == trigger.tag + end + if(trigger.name == "entity_tag_exist") then + result = cyberscript.EntityManager[trigger.tag] ~= nil + end + if(trigger.name == "entity_is_scanned") then + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + ----logme(3,"entity is active"..tostring(enti:IsAttached())) + if (enti:IsScanned() == true)then + ----logme(3,"entity is actived"..tostring(enti:IsAttached())) + result = true + end + end + end + end + if(trigger.name == "entity_is_crowd") then + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + ----logme(3,"entity is active"..tostring(enti:IsAttached())) + result = enti:IsCrowd() + end + end + end + if(trigger.name == "look_at_object") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + if(tarName ~= nil and appName ~= nil)then + if( + string.match(tarName, trigger.value) or + string.match(appName, trigger.value) or + string.match(dipName, trigger.value) or + (trigger.value == "isnpc" and objLook:IsA("NPCPuppet")))then + result = true + end + end + end + end + if(trigger.name == "scanned_entity") then + if scannedEntity ~= nil then + local obj = getEntityFromManager(trigger.value) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + if(enti:GetEntityID().hash == scannedEntity:GetEntityID().hash and (trigger.npc_only == false or (trigger.npc_only == true and enti:IsA("NPCPuppet"))))then + result = true + end + end + + end + end + end + if(trigger.name == "entity_is_a") then + + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + if(enti:IsA(trigger.value))then + result = true + end + end + + end + + end + if(trigger.name == "look_at_entity") then + if objLook ~= nil then + local obj = getEntityFromManager(trigger.value) + if(obj and obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + if(enti:GetEntityID().hash == objLook:GetEntityID().hash)then + result = true + end + end + + end + + end + end + if(trigger.name == "look_at_hash") then + if objLook ~= nil then + + if(trigger.value == tostring(objLook:GetEntityID().hash))then + result = true + end + + + end + end + if(trigger.name == "killed_entity") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + + result = (enti:IsDead() == true or enti:IsActive() == false) + + end + end + if(trigger.name == "entity_is_alive") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + + result = enti:IsDead() == false and enti:IsActive() == true + end + end + if(trigger.name == "entity_looked_is_follower") then + local isFollower = false + if objLook ~= nil then + tarbName = objLook:ToString() + end + if objLook ~= nil and (string.match(tarbName, "NPCPuppet"))then + local aicontrol = nil + pcall(function() + aicontrol = objLook:GetAIControllerComponent() + end) + if(aicontrol ~= nil) then + local currentRole =aicontrol:GetAIRole() + isFollower = (currentRole and (currentRole:IsA('AIFollowerRole')) ) + if(isFollower == nil) then + isFollower = false + end + end + end + result = isFollower + end + if(trigger.name == "entity_looked_is_registered") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local entity = getEntityFromManagerById(entid) + if(entity.id ~= nil) then + result = true + end + end + end + if(trigger.name == "entity_at_position") then + local obj = getEntityFromManager(trigger.tag) + --logme(3,obj.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + if(trigger.position == nil) then trigger.position = "at" end + + local targetPosition = getPositionFromParameter(trigger) + + + if (targetPosition.x ~= nil and check3DPos(enti:GetWorldPosition(), targetPosition.x, targetPosition.y, targetPosition.z,trigger.range)) then + result = true + else + result = false + end + else + --logme(3,"entity not found : "..trigger.tag) + end + end + if(trigger.name == "entity_in_state") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + local testres, err = pcall(function() + local levelstate = enti:GetHighLevelStateFromBlackboard() + local triggerlevelstate = gamedataNPCHighLevelState.Any + if(trigger.value == 0) then + triggerlevelstate = gamedataNPCHighLevelState.Alerted + end + if(trigger.value == 2) then + triggerlevelstate = gamedataNPCHighLevelState.Combat + end + if(trigger.value == 3) then + triggerlevelstate = gamedataNPCHighLevelState.Dead + end + if(trigger.value == 4) then + triggerlevelstate = gamedataNPCHighLevelState.Fear + end + if(trigger.value == 5) then + triggerlevelstate = gamedataNPCHighLevelState.Relaxed + end + if(trigger.value == 6) then + triggerlevelstate = gamedataNPCHighLevelState.Stealth + end + if(trigger.value == 7) then + triggerlevelstate = gamedataNPCHighLevelState.Unconscious + end + if(trigger.value == 8) then + triggerlevelstate = gamedataNPCHighLevelState.Wounded + end + if(trigger.value == 9) then + triggerlevelstate = gamedataNPCHighLevelState.Count + end + if(trigger.value == 10) then + triggerlevelstate = gamedataNPCHighLevelState.Invalid + end + + end) + if testres == false then + triggerlevelstate= gamedataNPCHighLevelState.Invalid + ------print(triggerlevelstate) + end + + if(levelstate == triggerlevelstate) then + result = true + end + end + end + if(trigger.name == "entity_inbuilding")then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +result = Game.IsEntityInInteriorArea(enti) + end + if(trigger.name == "entity_gender") then + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + logme(1,GetEntityGender(enti)) + logme(1,trigger.value) + if(trigger.value == tostring(GetEntityGender(enti))) then + result = true + else + result = false + end + end + end + + end + if(trigger.name == "entity_hash") then + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + if(trigger.value == tostring(enti:GetEntityID().hash)) then + result = true + + end + end + end + + + end + if(trigger.name == "entity_script_level") then + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + if(checkValue(trigger.operator,obj.scriptlevel,trigger.scriptlevel,trigger.min,trigger.max)) then + + result = true + + end + + end + end + + if(trigger.name == "last_killed_entity_is_registred") then + if getEntityFromManager("last_killed").id ~= nil then + + + result = true + + end + end + if(trigger.name == "if_entity_contains_value") then + local obj = getEntityFromManager(trigger.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local entName = enti:ToString() + local entAppName = Game.NameToString(enti:GetCurrentAppearanceName()) + local entDispName = enti:GetDisplayName() + + if(entName ~= nil and entAppName ~= nil)then + for i,filter in ipairs(trigger.filter) do + + if(string.match(entName, filter) or string.match(entAppName, filter) or string.match(entDispName, filter) or filter == tostring(newent:GetEntityID().hash))then + result = true + end + end + end + end + end + + end + if(trigger.name == "if_entities_around_entity") then + + local obj = getEntityFromManager(trigger.tag) + local goodEntity = false + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + player = Game.GetPlayer() + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects + searchQuery.maxDistance = trigger.range + searchQuery.filterObjectByDistance = true + searchQuery.includeSecondaryTargets = true + success, parts = targetingSystem:GetTargetParts(enti, searchQuery) + + + + + for _, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + + + + if(trigger.filter ~= nil and #trigger.filter > 0) then + + + local entName = newent:ToString() + local entAppName = Game.NameToString(newent:GetCurrentAppearanceName()) + local entDispName = newent:GetDisplayName() + + if(entName ~= nil and entAppName ~= nil)then + for i,filter in ipairs(trigger.filter) do + + if(goodEntity == false and + (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and + string.match(entName, filter) ~= nil or + string.match(entAppName, filter) ~= nil or + string.match(entDispName, filter) ~= nil or + filter == tostring(newent:GetEntityID().hash) or (filter == "vehicle" and newent:IsVehicle()))then + + goodEntity = true + end + end + end + + + + else + + goodEntity = true + + end + + + + + + end + + + end + result = goodEntity + end + + + if(trigger.name == "if_entities_around_you") then + player = Game.GetPlayer() + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects + searchQuery.maxDistance = trigger.range + success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) + + + + local goodEntity = false + + for _, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + + + + if(trigger.filter ~= nil and #trigger.filter > 0) then + + + local entName = newent:ToString() + local entAppName = Game.NameToString(newent:GetCurrentAppearanceName()) + local entDispName = newent:GetDisplayName() + + if(entName ~= nil and entAppName ~= nil)then + for i,filter in ipairs(trigger.filter) do + + if(goodEntity == false and + (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and + string.match(entName, filter) ~= nil or + string.match(entAppName, filter) ~= nil or + string.match(entDispName, filter) ~= nil or + filter == tostring(newent:GetEntityID().hash) or (filter == "vehicle" and newent:IsVehicle()))then + + if(trigger.output) then + print(tostring(goodEntity == false)) + print(tostring((filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))))) + print(tostring(string.match(entName, filter))) + print(tostring(string.match(entAppName, filter))) + print(tostring(string.match(entDispName, filter))) + print(tostring(filter == tostring(newent:GetEntityID().hash))) + print((filter == "vehicle" and newent:IsVehicle())) - print(dump(trigger.filter)) - print(entName) - print(entAppName) - print(entDispName) - end - goodEntity = true - end - end - end - - - - else - - goodEntity = true - - end - - - - - - end - - result = goodEntity - end - end - - if groupregion then - if(trigger.name == "group_is_spawn") then - local enemy_count = 0 - local group =getGroupfromManager(trigger.tag) - --logme(3,group.tag) - --logme(3,#group.entities) - if(group ~= nil) then - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - --logme(3,obj.tag) - --logme(3,obj.id) - --logme(3,enti) - if(enti ~= nil) then - --logme(3,"entity is active"..tostring(enti:IsAttached())) - if (enti:IsAttached() == true)then - --logme(3,"npc have be killed") - enemy_count = enemy_count + 1 - end - end - end - if (enemy_count == #group.entities) then - result = true - end - end - end - if(trigger.name == "killed_group") then - local enemy_count = 0 - local group =getGroupfromManager(trigger.tag) - if(group ~= nil ) then - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - --logme(3,"entity is active"..tostring(enti:IsActive())) - if (enti:IsDead() == true or enti:IsActive() == false)then - - enemy_count = enemy_count + 1 - end - elseif(obj.id == nil or enti == nil) then - enemy_count = enemy_count + 1 - end - end - if (enemy_count == #group.entities) then - result = true - --logme(3,tostring(result)) - end - end - end - if(trigger.name == "group_script_level") then - local group =getGroupfromManager(trigger.tag) - local count = 0 - if(group ~= nil ) then - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - if(obj.id ~= nil) then - if(checkValue(trigger.operator,obj.scriptlevel,trigger.scriptlevel,trigger.min,trigger.max)) then - - count = count +1 - - end - end - end - result = (count == #group.entities) - end - - - - - end - end - - if playerregion then - if(trigger.name == "position") then - result = checkPos(curPos, trigger.x, trigger.y,trigger.range) - end - if(trigger.name == "player_is_noticed") then - result = playerNoticed - end - if(trigger.name == "player_is_targeted") then - result = playerTargeted - end - - if(trigger.name == "player_is_hit") then - result = PlayerisHitten - end - - if(trigger.name == "player_death") then - if(inMenu and ActiveMenu == "DeathMenu")then - result = true - - end - end - - -- if(trigger.name == "check_perk") then - - -- local PDS = GameInstance.GetScriptableSystemsContainer():Get("PlayerDevelopmentSystem") - -- PDS:HasPerk(trigger.value) - - -- end - - if(trigger.name == "3Dposition") then - result = check3DPos(Game.GetPlayer():GetWorldPosition(), trigger.x, trigger.y, trigger.z, trigger.range) - end - if(trigger.name == "stat") then - --https://nativedb.red4ext.com/gamedataStatType - local mod_score = Game.GetStatsSystem():GetStatValue(Game.GetPlayer():GetEntityID(), trigger.value) - -- logme(3,mod_score) - if(trigger.score~= nil and tonumber(mod_score) >= tonumber(trigger.score)) then - result = true - end - end - if(trigger.name == "statpool") then - --https://nativedb.red4ext.com/gamedataStatPoolType - local mod_score = Game.GetStatPoolsSystem():GetStatPoolValue(Game.GetPlayer():GetEntityID(), Enum.new('gamedataStatPoolType', trigger.value), trigger.perc) - --logme(3,mod_score) - if(trigger.score~= nil and tonumber(mod_score) >= tonumber(trigger.score)) then - result = true - end - end - if(trigger.name == "item") then - result = checkItem(trigger.value) - end - if(trigger.name == "item_amount") then - result = checkItemAmount(trigger.value,trigger.score) - end - if(trigger.name == "money") then - result = checkStackableItemAmount("Items.money",trigger.value) - end - - - if(trigger.name == "player_in_poi") then - local resultpos = nil - - - if(trigger.district == "current") then - trigger.district = currentDistricts2.EnumName - end - if(trigger.subdistrict == "current") then - - if(currentDistricts2.districtLabels ~=nil and #currentDistricts2.districtLabels > 1) then - - trigger.subdistrict = currentDistricts2.districtLabels[2] - - else - - trigger.district = currentDistricts2.EnumName - - end - end - - if trigger.position_poi_search == nil then trigger.position_poi_search = "type" end - if trigger.position_poi_searchdistance == nil then trigger.position_poi_searchdistance = "random" end - - resultpos = FindPOI(trigger.tag,trigger.district,trigger.subdistrict,trigger.iscar,trigger.type,trigger.uselocationtag,true,trigger.range,nil,nil,nil,trigger.position_poi_search,trigger.position_poi_searchdistance) - if(resultpos ~= nil)then - result = true - end - end - - if(trigger.name == "player_lifepath") then - - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) - local path = playerDevSystem:GetLifePath(player) - if(trigger.output == true) then - ----print("player_lifepath result "..tostring((path))) - end - result = (trigger.value == EnumInt(path)) - - end - - if(trigger.name == "player_have_combatstate") then - local player = Game.GetPlayer() - local state = player:GetCurrentCombatState() - result = (trigger.value == EnumInt(state)) - if(trigger.output == true) then - ----print("player_have_combatstate result "..tostring((state))) - end - end - if(trigger.name == "wanted_level") then - local level = Game.GetBlackboardSystem():Get(Game.GetAllBlackboardDefs().UI_WantedBar):GetInt(Game.GetAllBlackboardDefs().UI_WantedBar.CurrentWantedLevel) - if level >= trigger.value then - result = true - end - end - if(trigger.name == "player_gender") then - if(trigger.value == GetPlayerGender()) then - result = true - else - result = false - end - end - if(trigger.name == "player_current_gang"or trigger.name == "player_current_faction") then - - local score = getVariableKey("player","current_gang") - if(score ~= nil and score == trigger.value) then - result = true - end - end - - end - - if vehiculeregion then - if(trigger.name == "in_car") then - local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - if (inVehicule) then - local vehicule = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - result = vehicule ~= nil - end - end + print(dump(trigger.filter)) + print(entName) + print(entAppName) + print(entDispName) + end + goodEntity = true + end + end + end + + + + else + + goodEntity = true + + end + + + + + + end + + result = goodEntity + end + end + + if groupregion then + if(trigger.name == "group_is_spawn") then + local enemy_count = 0 + local group =getGroupfromManager(trigger.tag) + --logme(3,group.tag) + --logme(3,#(group and (group and group.entities or {}) or {})) + if(group ~= nil) then + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + --logme(3,obj.tag) + --logme(3,obj.id) + --logme(3,enti) + if(enti ~= nil) then + --logme(3,"entity is active"..tostring(enti:IsAttached())) + if (enti:IsAttached() == true)then + --logme(3,"npc have be killed") + enemy_count = enemy_count + 1 + end + end + end + if (enemy_count == #(group and (group and group.entities or {}) or {})) then + result = true + end + end + end + if(trigger.name == "killed_group") then + local enemy_count = 0 + local group =getGroupfromManager(trigger.tag) + if(group ~= nil ) then + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + --logme(3,"entity is active"..tostring(enti:IsActive())) + if (enti:IsDead() == true or enti:IsActive() == false)then + + enemy_count = enemy_count + 1 + end + elseif(obj.id == nil or enti == nil) then + enemy_count = enemy_count + 1 + end + end + if (enemy_count == #(group and (group and group.entities or {}) or {})) then + result = true + --logme(3,tostring(result)) + end + end + end + if(trigger.name == "group_script_level") then + local group =getGroupfromManager(trigger.tag) + local count = 0 + if(group ~= nil ) then + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + if(obj.id ~= nil) then + if(checkValue(trigger.operator,obj.scriptlevel,trigger.scriptlevel,trigger.min,trigger.max)) then + + count = count +1 + + end + end + end + result = (count == #(group and (group and group.entities or {}) or {})) + end + + + + + end + end + + if playerregion then + if(trigger.name == "position") then + result = checkPos(curPos, trigger.x, trigger.y,trigger.range) + end + if(trigger.name == "player_is_noticed") then + result = playerNoticed + end + if(trigger.name == "player_is_targeted") then + result = playerTargeted + end + + if(trigger.name == "player_is_hit") then + result = PlayerisHitten + end + + if(trigger.name == "player_death") then + if(inMenu and ActiveMenu == "DeathMenu")then + result = true + + end + end + + -- if(trigger.name == "check_perk") then + + -- local PDS = GameInstance.GetScriptableSystemsContainer():Get("PlayerDevelopmentSystem") + -- PDS:HasPerk(trigger.value) + + -- end + + if(trigger.name == "3Dposition") then + result = check3DPos(Game.GetPlayer():GetWorldPosition(), trigger.x, trigger.y, trigger.z, trigger.range) + end + if(trigger.name == "stat") then + --https://nativedb.red4ext.com/gamedataStatType + local mod_score = Game.GetStatsSystem():GetStatValue(Game.GetPlayer():GetEntityID(), trigger.value) + -- logme(3,mod_score) + if(trigger.score~= nil and tonumber(mod_score) >= tonumber(trigger.score)) then + result = true + end + end + if(trigger.name == "statpool") then + --https://nativedb.red4ext.com/gamedataStatPoolType + local mod_score = Game.GetStatPoolsSystem():GetStatPoolValue(Game.GetPlayer():GetEntityID(), Enum.new('gamedataStatPoolType', trigger.value), trigger.perc) + --logme(3,mod_score) + if(trigger.score~= nil and tonumber(mod_score) >= tonumber(trigger.score)) then + result = true + end + end + if(trigger.name == "item") then + result = checkItem(trigger.value) + end + if(trigger.name == "item_amount") then + result = checkItemAmount(trigger.value,trigger.score) + end + if(trigger.name == "money") then + result = checkStackableItemAmount("Items.money",trigger.value) + end + + + if(trigger.name == "player_in_poi") then + local resultpos = nil + + + if(trigger.district == "current") then + trigger.district = currentDistricts2.EnumName + end + if(trigger.subdistrict == "current") then + + if(currentDistricts2.districtLabels ~=nil and #currentDistricts2.districtLabels > 1) then + + trigger.subdistrict = currentDistricts2.districtLabels[2] + + else + + trigger.district = currentDistricts2.EnumName + + end + end + + if trigger.position_poi_search == nil then trigger.position_poi_search = "type" end + if trigger.position_poi_searchdistance == nil then trigger.position_poi_searchdistance = "random" end + + resultpos = FindPOI(trigger.tag,trigger.district,trigger.subdistrict,trigger.iscar,trigger.type,trigger.uselocationtag,true,trigger.range,nil,nil,nil,trigger.position_poi_search,trigger.position_poi_searchdistance) + if(resultpos ~= nil)then + result = true + end + end + + if(trigger.name == "player_lifepath") then + + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) + local path = playerDevSystem:GetLifePath(player) + if(trigger.output == true) then + ----print("player_lifepath result "..tostring((path))) + end + result = (trigger.value == EnumInt(path)) + + end + + if(trigger.name == "player_have_combatstate") then + local player = Game.GetPlayer() + local state = player:GetCurrentCombatState() + result = (trigger.value == EnumInt(state)) + if(trigger.output == true) then + ----print("player_have_combatstate result "..tostring((state))) + end + end + if(trigger.name == "wanted_level") then + local level = Game.GetBlackboardSystem():Get(Game.GetAllBlackboardDefs().UI_WantedBar):GetInt(Game.GetAllBlackboardDefs().UI_WantedBar.CurrentWantedLevel) + if level >= trigger.value then + result = true + end + end + if(trigger.name == "player_gender") then + if(trigger.value == GetPlayerGender()) then + result = true + else + result = false + end + end + if(trigger.name == "player_current_gang"or trigger.name == "player_current_faction") then + + local score = getVariableKey("player","current_gang") + if(score ~= nil and score == trigger.value) then + result = true + end + end + + end + + if vehiculeregion then + if(trigger.name == "in_car") then + local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + if (inVehicule) then + local vehicule = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + result = vehicule ~= nil + end + end - if(trigger.name == "in_entity_car") then - local vehicule = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - - if (vehicule ~= nil) then - - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - result = (obj.id == vehicule:GetEntityID()) - end - end + if(trigger.name == "in_entity_car") then + local vehicule = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + + if (vehicule ~= nil) then + + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + result = (obj.id == vehicule:GetEntityID()) + end + end - end - if(trigger.name == "entity_in_car") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(enti) - if (inVehicule) then - local vehicule = Game['GetMountedVehicle;GameObject'](enti) - result = vehicule ~= nil - end - end - end - if(trigger.name == "vehicle_entity_is_moving") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil and enti:IsVehicle()) then - result = not (enti:GetCurrentSpeed() == 0 or enti:GetCurrentSpeed() == -0 ) - - end - end - - if(trigger.name == "in_car_specific") then - local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - if (inVehicule) then - local vehicule = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - if(vehicule ~= nil) then - local isThiscar = (string.find(string.lower(Game.NameToString(vehicule:GetCurrentAppearanceName())), trigger.value) ~= nil) - if isThiscar then - result = true - end - end - end - end - if(trigger.name == "entity_in_car_specific") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(enti) - if (inVehicule) then - local vehicule = Game['GetMountedVehicle;GameObject'](enti) - if(vehicule ~= nil) then - local isThiscar = (string.find(string.lower(Game.NameToString(vehicule:GetCurrentAppearanceName())), trigger.value) ~= nil) - if isThiscar then - result = true - end - end - end - end - end - if(trigger.name == "vehicule_is_in_custom_garage") then - local test = getVehiclefromCustomGarage(trigger.value) - if(test ~= nil) then - result = true - end - end - end - - if scoreregion then - if(trigger.name == "npc_star_affinity") then - local score = 0 - if(currentStar ~= nil) then - score = getScoreKey("Affinity",currentStar.Names) - end - if(score ~= nil and score >= trigger.value)then - result = true - end - end - if(trigger.name == "npc_phone_affinity") then - local score = 0 - if(currentNPC ~= nil) then - score = getScoreKey("Affinity",currentNPC.Names) - end - if(score ~= nil and score >= trigger.value)then - result = true - end - end - if(trigger.name == "npc_affinity") then - local score = getScoreKey("Affinity",trigger.value) - if(score ~= nil and score >= trigger.score)then - result = true - end - end - if(trigger.name == "entity_affinity") then - local obj = getEntityFromManager(trigger.tag) - local score = getScoreKey("Affinity",obj.name) - if(score ~= nil and score >= trigger.score)then - result = true - end - end - - if(trigger.name == "check_variable") then - local score = getVariableKey(trigger.variable,trigger.key) - - if(trigger.operator== nil) then - - if(score ~= nil and score == trigger.value) then - result = true - end - - else - if(type(score) == "number") then - - - if(checkValue(trigger.operator,score,trigger.value, trigger.min, trigger.max)) then - - result = true - - end - else - - if(trigger.operator == "=") then - - if(score ~= nil and score == trigger.value) then - - result = true - end - - end - - if(trigger.operator == "!=") then - - if(score ~= trigger.value) then - result = true - end - - end - - if(trigger.operator == "contains") then - - if(score ~= nil and string.match(score, trigger.value)) then - result = true - end - - end - - if(trigger.operator == "empty" or trigger.operator == "nothing") then - - - result = score == nil or score == "" - - - end - - if(trigger.operator == "notempty" or trigger.operator == "notnothing") then - - - result = score ~= nil and score ~= "" - - - end - end - end - end - - if(trigger.name == "check_value") then - - - if(trigger.operator== nil) then - - if(trigger.value ~= nil and trigger.value == trigger.target) then - result = true - end - - else - if(type(trigger.value) == "number") then - - - if(checkValue(trigger.operator,trigger.value,trigger.target, trigger.min, trigger.max)) then - - result = true - - end - else - - - if(trigger.operator == "=") then - - if(trigger.value ~= nil and trigger.value == trigger.target) then - result = true - end - - end - - if(trigger.operator == "!=") then - - if(trigger.value ~= nil and trigger.value ~= trigger.target) then - result = true - end - - end - - if(trigger.operator == "contains") then - - if(trigger.value ~= nil and string.match(trigger.value, trigger.target)) then - result = true - end - - end - - if(trigger.operator == "empty" or trigger.operator == "nothing") then - - - result = trigger.value == nil or trigger.value == "" - - - end - - - if(trigger.operator == "notempty" or trigger.operator == "notnothing") then - - - result = trigger.value ~= nil and trigger.value ~= "" - - - end - - - end - - - end - end - end - if scannerregion then - if(trigger.name == "check_scannerdata_for_entity") then - - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil and ScannerInfoManager[trigger.tag]) then - - - - if(trigger.prop == "primaryname" or trigger.prop == "secondaryname" or trigger.prop == "text" or trigger.prop == "entityname") then - - - - result = string.match(ScannerInfoManager[trigger.tag][trigger.prop], trigger.value) - - - - end - - if(trigger.prop == "level" or trigger.prop == "rarity" or trigger.prop == "attitude") then - - - - result = checkValue(trigger.operator,ScannerInfoManager[trigger.tag][trigger.prop],trigger.value,trigger.min,trigger.max) - - - - end - - - if(trigger.prop == "reward" or trigger.prop == "streetreward" or trigger.prop == "danger") then - - - - result = checkValue(trigger.operator,ScannerInfoManager[trigger.tag]["bounty"][trigger.prop],trigger.value,trigger.min,trigger.max) - - - - end - - - if(trigger.prop == "issuedby" ) then - - - - result = string.match(ScannerInfoManager[trigger.tag]["bounty"][trigger.prop], trigger.value) - - - - end - - - - - - if(trigger.prop == "customtransgressions" or trigger.prop == "transgressions" ) then - - result = table_contains(ScannerInfoManager[trigger.tag]["bounty"][trigger.prop],trigger.value,false) - - - - end - - - - - - - - - end - - end - - if(trigger.name == "check_current_scannerdata") then - if(currentScannerItem ~= nil) then - if(trigger.prop == "primaryname" or trigger.prop == "secondaryname" or trigger.prop == "entityname") then - - - - result = string.match(currentScannerItem[trigger.prop], trigger.value) - - - - end - - if(trigger.prop == "level" or trigger.prop == "rarity" or trigger.prop == "attitude") then - - - - result = checkValue(trigger.operator,currentScannerItem[trigger.prop],trigger.value,trigger.min,trigger.max) - - - - end - - - if(trigger.prop == "reward" or trigger.prop == "streetreward" or trigger.prop == "danger") then - - - - result = checkValue(trigger.operator,currentScannerItem["bounty"][trigger.prop],trigger.value,trigger.min,trigger.max) - - - - end - - - if(trigger.prop == "issuedby" ) then - - - - result = string.match(currentScannerItem["bounty"][trigger.prop], trigger.value) - - - - end - - - - - - if(trigger.prop == "transgressions" or trigger.prop == "customtransgressions" ) then - - result = table_contains(currentScannerItem["bounty"][trigger.prop],trigger.value) - - - - end - end - end - - - end - if houseregion then - - if(trigger.name == "is_in_custom_place") then - if currentHouse ~= nil then - if(trigger.value == "current") or (currentHouse.tag == trigger.value)then - result = true - end - - end - end - if(trigger.name == "is_in_custom_room") then - if currentRoom ~= nil then - if("current" == trigger.value) or (currentRoom.tag == trigger.value)then - result = true - end - end - end - if(trigger.name == "is_in_buyed_place") then - if currentHouse ~= nil then - if(getHouseStatut(currentHouse.tag) ~= nil and getHouseStatut(currentHouse.tag) >= 1) then - result = true - end - end - end - if(trigger.name == "is_in_rented_place") then - if currentHouse ~= nil then - if(getHouseStatut(currentHouse.tag) ~= nil and getHouseStatut(currentHouse.tag) >= 2) then - result = true - end - end - end - if(trigger.name == "place_canbe_buyed") then - if currentHouse ~= nil then - local statut = getHouseStatut(currentHouse.tag) - if(currentHouse.isbuyable == true and getStackableItemAmount("Items.money") > currentHouse.price and (statut == nil or statut < 1)) then - result = true - end - end - end - if(trigger.name == "place_canbe_rented") then - if currentHouse ~= nil then - local statut = getHouseStatut(currentHouse.tag) - if(currentHouse.isrentable == true and getStackableItemAmount("Items.money") > (currentHouse.price*currentHouse.coef) and (statut ~= nil and statut == 1)) then - result = true - end - end - end - if(trigger.name == "custom_place_type") then - if currentHouse ~= nil then - if(trigger.value == currentHouse.type) then - result = true - end - end - end - if(trigger.name == "custom_room_type") then - if currentRoom ~= nil then - ------logme(3,currentRoom.type[i]) - for i=1,#currentRoom.type do - ------logme(3,currentRoom.type[i]) - if(trigger.value == currentRoom.type[i]) then - result = true - end - end - end - end - if(trigger.name == "entity_is_in_custom_place_type") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil and currentHouse ~= nil )then - if(trigger.value == currentHouse.type) then - local targetPosition = enti:GetWorldPosition() - if check3DPos(targetPosition, currentHouse.x, currentHouse.x, currentHouse.z,currentHouse.range,currentHouse.range_z) then - result = true - else - result = false - end - end - end - end - if(trigger.name == "entity_is_in_custom_room_type") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil and currentRoom ~= nil )then - local targetPosition = enti:GetWorldPosition() - if( check3DPos(targetPosition, currentRoom.x, currentRoom.x, currentRoom.z,currentRoom.range,currentRoom.range_z)) then - for i=1,#currentRoom.type do - - if(trigger.value == currentRoom.type[i]) then - result = true - end - end - end - - end - end - if(trigger.name == "item_looked_is_registered") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local entity = getItemEntityFromManager(entid) - if(entity ~= nil) then - result = true - else - entity = getItemEntityFromManagerByPlayerLookinAt() - if(entity ~= nil) then - result = true - end - end - end - end - if(trigger.name == "have_selected_item") then - if selectedItem ~= nil then - result = true - end - end - if(trigger.name == "have_selected_item_can_be_grabbed") then - if selectedItem ~= nil and selectedItem.entityId ~= nil and Game.FindEntityByID(selectedItem.entityId)~=nil then - result = Game.FindEntityByID(selectedItem.entityId):IsA('gameObject') - end - end - end - - if gangregion then - if(trigger.name == "gang_affinity") then - local score = 0 - score = getScoreKey("Affinity",trigger.value) - if(score ~= nil and score >= trigger.score)then - result = true - end - end - if(trigger.name == "entity_looked_is_gangfriendly") then - if objLook ~= nil then - result = openCompanion - end - end - if(trigger.name == "entity_looked_gang_score") then - if objLook ~= nil then - if(gangscore ~= nil and gangscore == trigger.value) then - result = true - end - end - end - if(trigger.name == "entity_looked_is_gang") then - if lookatgang ~= nil then - result = true - end - end - if(trigger.name == "entity_looked_is_specific_gang") then - if lookatgang ~= nil and lookatgang.tag == trigger.value then - result = true - end - end - if(trigger.name == "entity_in_faction") then - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local targetAttAgent = enti:GetAttitudeAgent() - local group = Game.NameToString(targetAttAgent:GetAttitudeGroup()) - local npcCurrentName = Game.NameToString(enti:GetCurrentAppearanceName()) - local faction = getFactionByTag(trigger.faction) - - local resultent,msg = pcall(function() enti:GetRecordID() end) - - - if(resultent == true and enti:GetRecordID().hash ~= nil and cyberscript.entitieshash[tostring(enti:GetRecordID().hash)] ~= nil) then - - local entity = cyberscript.entitieshash[tostring(enti:GetRecordID().hash)] - - - if(entity ~= nil) then - - if(faction ~= nil) then - for y=1,#faction.spawnable_npc do - - - - if(string.find(entity.entity_tweak,faction.spawnable_npc[y]) ~= nil)then - result = true - end - end - if(result == false) then - for y=1,#faction.keyword do - - - - if(string.find(entity.entity_tweak,faction.keyword[y]) ~= nil)then - result = true - end - end - end - end - - end - else - - if(faction ~= nil) then - for y=1,#faction.attitude_group do - - - - if(string.find(group,faction.attitude_group[y]) ~= nil or string.find(npcCurrentName,faction.attitude_group[y]) ~= nil)then - result = true - end - end - end - end - end - end - if(trigger.name == "check_gang_district_score") then - if getVariableKey(trigger.faction,trigger.district) ~= nil then - if getVariableKey(trigger.faction,trigger.district) >= trigger.value then - result = true - end - end - end - - if(trigger.name == "check_gang_relation") then - - if(trigger.tag == "player") then - - trigger.tag = getVariableKey("player","current_gang") - - end - - if(trigger.tag ~= "") then - - if(trigger.mode == "gang") then - - - if(trigger.target ~= trigger.tag ) then - - local score = getFactionRelation(trigger.tag,trigger.target) - if(checkValue(trigger.operator,score,trigger.score,trigger.min,trigger.max)) then - - result = true - - end - - - - end - - end - - if(trigger.mode == "district_leader" or trigger.mode == "district_subleader") then - - local gangs = getGangfromDistrict(trigger.target,20) - if(#gangs > 0) then - - - - if(gangs[1].tag ~= trigger.tag) then - - local score = getFactionRelation(trigger.tag,gangs[1].tag) - if(checkValue(trigger.operator,score,trigger.score,trigger.min,trigger.max)) then - result = true - end - - - end - end - - - end - - if(trigger.mode == "current_district_leader") then - - if currentDistricts2 ~= nil then - local gangs = getGangfromDistrict(currentDistricts2.Tag,20) - if(#gangs > 0) then - if(gangs[1].tag ~= trigger.tag) then - - local score = getFactionRelation(trigger.tag,gangs[1].tag) - if(checkValue(trigger.operator,score,trigger.score,trigger.min,trigger.max)) then - - result = true - end - end - end - - end - - end - if(trigger.mode == "current_district_subleader") then - if currentDistricts2 ~= nil then - if currentDistricts2.districtLabels[2] ~= nil then - local gangs = getGangfromDistrict(currentDistricts2.districtLabels[2],20) - if(#gangs > 0) then - - if(gangs[1].tag ~= trigger.tag) then - - local score = getFactionRelation(trigger.tag,gangs[1].tag) - if(checkValue(trigger.operator,score,trigger.score,trigger.min,trigger.max)) then - result = true - end - end - end - end - - end - - end - - - end - - - - end - - - if(trigger.name == "last_killed_entity_is_in_specific_gang") then - if lastTargetKilled ~= nil then - local killComp, killGangScore, killGang = checkAttitudeByGangScore(lastTargetKilled) - - if killGang ~= nil and killGang.tag == trigger.value then - result = true - end - end - end - - if(trigger.name == "last_killed_entity") then - if lastTargetKilled ~= nil then - result = true - end - - end - - if(trigger.name == "last_killed_entity_is_in_gang") then - if lastTargetKilled ~= nil then - local killComp, killGangScore, killGang = checkAttitudeByGangScore(lastTargetKilled) - if killGang ~= nil then - result = true - end - end - end - - - if(trigger.name == "last_killed_entity_gang_score") then - if lastTargetKilled ~= nil then - local killComp, killGangScore, killGang = checkAttitudeByGangScore(lastTargetKilled) - - if(checkValue(trigger.operator,killGangScore,trigger.score,trigger.min,trigger.max)) then - result = true - end - - end - end - - end - - if miscregion then - if(trigger.name == "auto")then - result = true - end - if(trigger.name == "tracked_game_quest")then - local objective = Game.GetJournalManager():GetTrackedEntry() - - if objective ~= nil then - local phase = Game.GetJournalManager():GetParentEntry(objective) - local quest = Game.GetJournalManager():GetParentEntry(phase) - - result= (string.match(tostring(quest.id), trigger.value) ~= nil) - end - end - if(trigger.name == "tracked_game_phase")then - local objective = Game.GetJournalManager():GetTrackedEntry() - - if objective ~= nil then - local phase = Game.GetJournalManager():GetParentEntry(objective) - - result= (string.match(tostring(phase.id), trigger.value) ~= nil) - end - end - if(trigger.name == "tracked_game_objective")then - local objective = Game.GetJournalManager():GetTrackedEntry() - - if objective ~= nil then - - result= (string.match(tostring(objective.id), trigger.value) ~= nil) - end - end - if(trigger.name == "time") then - local currentime = tonumber(getGameTimeHHmm()) - ----logme(3,"currentime "..currentime) - if(tonumber(currentime) >= tonumber(trigger.min) and tonumber(currentime) <= tonumber(trigger.max)) then - result = true - end - end - if(trigger.name == "os_time") then - local currentime = getOsTimeHHmm() - ----logme(3,"currentime "..currentime) - local times = currentime.hour*100 + currentime.min - if(tonumber(times) >= tonumber(trigger.min) and tonumber(times) <= tonumber(trigger.max)) then - result = true - end - end - if(trigger.name == "os_date") then - local currentime = getOsTimeHHmm() - ----logme(3,"currentime "..currentime) - if((tonumber(currentime.month) == tonumber(trigger.month) or trigger.month == "") and (tonumber(currentime.day) == tonumber(trigger.day)) or trigger.day == "") and (tonumber(currentime.year) == tonumber(trigger.year) or trigger.year == "") then - result = true - end - end - if(trigger.name == "check_setting") then - local score = 0 - score = getUserSetting(trigger.value) - if(score ~= nil and score == trigger.score)then - result = true - end - end - if(trigger.name == "debug") then - result = cyberscript.debug - end - if(trigger.name == "current_district") then - if currentDistricts2 ~= nil and currentDistricts2.customdistrict ~= nil then - if(string.lower(currentDistricts2.customdistrict.EnumName) == string.lower(trigger.value))then - --logme(3,"district OK") - result = true - end - end - end - if(trigger.name == "current_subdistrict") then - if currentDistricts2 ~= nil then - if(currentDistricts2.districtLabels~=nil)then - for i, subd in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - if(string.lower(subd) == string.lower(trigger.value))then - --logme(3,"subdistrict OK") - result = true - end - end - end - end - end - end - if(trigger.name == "salary_is_possible") then - result = SalaryIsPossible - end - if(trigger.name == "have_custom_mappin_placed") then - if(mappinManager["selected_mappin"] ~= nil) then - result = true - end - end - if(trigger.name == "have_fasttravel_mappin_placed") then - - if(ActiveFastTravelMappin ~= nil) then - result = true - logme(3,"toto"..dump(ActiveFastTravelMappin)) - end - end - if(trigger.name == "event_is_finished") then - if(workerTable[trigger.tag] == nil ) then - result = true - end - end - - if(trigger.name == "event_exist") then - if(workerTable[trigger.tag] ~= nil ) then - result = true - end - end - if(trigger.name == "metro_time_is_finished") then - if MetroCurrentTime <=0 and activeMetroDisplay == false then - result = true - end - end - if(trigger.name == "area_security_level") then - local level = FromVariant(GetPlayer():GetPlayerStateMachineBlackboard():GetVariant(GetAllBlackboardDefs().PlayerStateMachine.SecurityZoneData)) - if level == trigger.value then - result = true - end - end - if(trigger.name == "is_recording_mode_active") then - if recordingMode then - result = true - end - end - - if(trigger.name == "interact_is_forceloaded") then - if(#loadInteract > 0) then - - for i,v in ipairs(loadInteract) do - - if(v == trigger.tag) then - - result = true - - end - - end - - - - - end - - - - end - if(trigger.name== "check_mod") then - - result = GetMod(trigger.value) ~= nil - - end - - if(trigger.name== "have_collision") then - - local collision = false - trigger.output = true - local from = Vector4.new( - trigger.from_x, - trigger.from_y, - trigger.from_z, - 1 - ) - - - local to = Vector4.new( - trigger.to_x, - trigger.to_y, - trigger.to_z, - 1 - ) - - - -- local filters = { - - -- 'Static', -- Buildings, Concrete Roads, Crates, etc. - - -- 'Terrain' - - -- } - -- local filters = { - -- -- 'Dynamic', -- Movable Objects - -- -- 'Vehicle', - -- 'Static', -- Buildings, Concrete Roads, Crates, etc. - -- 'Water', - -- 'Terrain', - -- -- 'PlayerBlocker', -- Trees, Billboards, Barriers - -- } - local filters = trigger.filters - local results = {} - - - - - - - - for _, filter in ipairs(filters) do - local success, physicsTraceResult = Game.GetSpatialQueriesSystem():SyncRaycastByCollisionGroup(from, to, filter, false, false) - - if success then - collision = true - - - - end - end - - result = collision - - - - end - - - if(trigger.name== "check_raycasting") then - - local collision = false - - local from = Vector4.new( - trigger.from_x, - trigger.from_y, - trigger.from_z, - 1 - ) - - - local to = Vector4.new( - trigger.to_x, - trigger.to_y, - trigger.to_z, - 1 - ) - - - - local filters = trigger.filters - local results = {} - - local points = {} - for i=1,action.points do - points[i] = {} - if(to.x > from.x) then - points[i].x = (math.abs(to.x - from.x) / action.points) * i + from.x; - else - - points[i].x = 0-((math.abs(from.x - to.x) / action.points) * i - from.x); - end - - - if(to.y > from.y) then - points[i].y = (math.abs(to.y - from.y) / action.points) * i + from.y; - else - - points[i].y = 0-((math.abs(from.y - to.y) / action.points) * i - from.y); - end - - - if(to.z > from.z) then - points[i].z = (math.abs(to.z - from.z) / action.points) * i + from.z; - else - - points[i].z = 0-((math.abs(from.z - to.z) / action.points) * i - from.z); - end - - - end - - for i=1,#points do - local mypoint = Vector4.new( - points[i].x, - points[i].y, - points[i].z, - 1 - ) - - - for _, filter in ipairs(filters) do - local success, physicsTraceResult = Game.GetSpatialQueriesSystem():SyncRaycastByCollisionGroup(from, mypoint, filter, false, false) - - if success then - collision = true - - - - end - end - - - end - - - - - result = collision - - - - end - - if(trigger.name== "game_language") then - - result = cyberscript.language == trigger.value - - end - - if(trigger.name== "device_active_radio_channel_id") then - - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - result = ps.activeStation == trigger.value - - - end - end - - if(trigger.name== "device_active_tv_channel_id") then - - local obj = getEntityFromManager(trigger.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetController():GetPS():GetActiveStationIndex() - result = ps.activeStation == trigger.value - - - end - end - - if(trigger.name== "have_shard") then - - - if(gameshardscompiled == nil) then - - local activeData = CodexListSyncData.new() - local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) - if gameshardscompiled == nil then gameshardscompiled = {} end - for i,v in pairs(gameshards) do - if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end - - - end - end - - result = gameshardscompiled[trigger.value] ~= nil - end - - if(trigger.name== "mappin_exist") then - - result = mappinManager[trigger.tag] ~= nil - end - - end - - if relationregion then - if(trigger.name == "current_phoned_npc_is_defined") then - if(currentNPC ~= nil) then - result = true - end - end - - if(trigger.name == "current_phoned_npc_name") then - if(currentNPC ~= nil) then - - if(currentNPC.Names == trigger.value) then - result = true - end - end - end - - if(trigger.name == "current_star_name") then - if(currentStar ~= nil) then - - if(currentStar.Names == trigger.value) then - result = true - end - end - end - end - - if questregion then - if(trigger.name == "quest_fact") then - isquestok =Game.GetQuestsSystem():GetFactStr(trigger.value) - if(isquestok == 1)then - result = true - end - end - if(trigger.name == "mission_fact") then - local score = getScoreKey(trigger.value,"Score") - if(score ~= nil and score == 1) then - result = true - end - end + end + if(trigger.name == "entity_in_car") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(enti) + if (inVehicule) then + local vehicule = Game['GetMountedVehicle;GameObject'](enti) + result = vehicule ~= nil + end + end + end + if(trigger.name == "vehicle_entity_is_moving") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil and enti:IsVehicle()) then + result = not (enti:GetCurrentSpeed() == 0 or enti:GetCurrentSpeed() == -0 ) + + end + end + + if(trigger.name == "in_car_specific") then + local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + if (inVehicule) then + local vehicule = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + if(vehicule ~= nil) then + local isThiscar = (string.find(string.lower(Game.NameToString(vehicule:GetCurrentAppearanceName())), trigger.value) ~= nil) + if isThiscar then + result = true + end + end + end + end + if(trigger.name == "entity_in_car_specific") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(enti) + if (inVehicule) then + local vehicule = Game['GetMountedVehicle;GameObject'](enti) + if(vehicule ~= nil) then + local isThiscar = (string.find(string.lower(Game.NameToString(vehicule:GetCurrentAppearanceName())), trigger.value) ~= nil) + if isThiscar then + result = true + end + end + end + end + end + if(trigger.name == "vehicule_is_in_custom_garage") then + local test = getVehiclefromCustomGarage(trigger.value) + if(test ~= nil) then + result = true + end + end + end + + if scoreregion then + if(trigger.name == "npc_star_affinity") then + local score = 0 + if(currentStar ~= nil) then + score = getScoreKey("Affinity",currentStar.Names) + end + if(score ~= nil and score >= trigger.value)then + result = true + end + end + if(trigger.name == "npc_phone_affinity") then + local score = 0 + if(currentNPC ~= nil) then + score = getScoreKey("Affinity",currentNPC.Names) + end + if(score ~= nil and score >= trigger.value)then + result = true + end + end + if(trigger.name == "npc_affinity") then + local score = getScoreKey("Affinity",trigger.value) + if(score ~= nil and score >= trigger.score)then + result = true + end + end + if(trigger.name == "entity_affinity") then + local obj = getEntityFromManager(trigger.tag) + local score = getScoreKey("Affinity",obj.name) + if(score ~= nil and score >= trigger.score)then + result = true + end + end + + if(trigger.name == "check_variable") then + local score = getVariableKey(trigger.variable,trigger.key) + + if(trigger.operator== nil) then + + if(score ~= nil and score == trigger.value) then + result = true + end + + else + if(type(score) == "number") then + + + if(checkValue(trigger.operator,score,trigger.value, trigger.min, trigger.max)) then + + result = true + + end + else + + if(trigger.operator == "=") then + + if(score ~= nil and score == trigger.value) then + + result = true + end + + end + + if(trigger.operator == "!=") then + + if(score ~= trigger.value) then + result = true + end + + end + + if(trigger.operator == "contains") then + + if(score ~= nil and string.match(score, trigger.value)) then + result = true + end + + end + + if(trigger.operator == "empty" or trigger.operator == "nothing") then + + + result = score == nil or score == "" + + + end + + if(trigger.operator == "notempty" or trigger.operator == "notnothing") then + + + result = score ~= nil and score ~= "" + + + end + end + end + end + + if(trigger.name == "check_value") then + + + if(trigger.operator== nil) then + + if(trigger.value ~= nil and trigger.value == trigger.target) then + result = true + end + + else + if(type(trigger.value) == "number") then + + + if(checkValue(trigger.operator,trigger.value,trigger.target, trigger.min, trigger.max)) then + + result = true + + end + else + + + if(trigger.operator == "=") then + + if(trigger.value ~= nil and trigger.value == trigger.target) then + result = true + end + + end + + if(trigger.operator == "!=") then + + if(trigger.value ~= nil and trigger.value ~= trigger.target) then + result = true + end + + end + + if(trigger.operator == "contains") then + + if(trigger.value ~= nil and string.match(trigger.value, trigger.target)) then + result = true + end + + end + + if(trigger.operator == "empty" or trigger.operator == "nothing") then + + + result = trigger.value == nil or trigger.value == "" + + + end + + + if(trigger.operator == "notempty" or trigger.operator == "notnothing") then + + + result = trigger.value ~= nil and trigger.value ~= "" + + + end + + + end + + + end + end + end + if scannerregion then + if(trigger.name == "check_scannerdata_for_entity") then + + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil and ScannerInfoManager[trigger.tag]) then + + + + if(trigger.prop == "primaryname" or trigger.prop == "secondaryname" or trigger.prop == "text" or trigger.prop == "entityname") then + + + + result = string.match(ScannerInfoManager[trigger.tag][trigger.prop], trigger.value) + + + + end + + if(trigger.prop == "level" or trigger.prop == "rarity" or trigger.prop == "attitude") then + + + + result = checkValue(trigger.operator,ScannerInfoManager[trigger.tag][trigger.prop],trigger.value,trigger.min,trigger.max) + + + + end + + + if(trigger.prop == "reward" or trigger.prop == "streetreward" or trigger.prop == "danger") then + + + + result = checkValue(trigger.operator,ScannerInfoManager[trigger.tag]["bounty"][trigger.prop],trigger.value,trigger.min,trigger.max) + + + + end + + + if(trigger.prop == "issuedby" ) then + + + + result = string.match(ScannerInfoManager[trigger.tag]["bounty"][trigger.prop], trigger.value) + + + + end + + + + + + if(trigger.prop == "customtransgressions" or trigger.prop == "transgressions" ) then + + result = table_contains(ScannerInfoManager[trigger.tag]["bounty"][trigger.prop],trigger.value,false) + + + + end + + + + + + + + + end + + end + + if(trigger.name == "check_current_scannerdata") then + if(currentScannerItem ~= nil) then + if(trigger.prop == "primaryname" or trigger.prop == "secondaryname" or trigger.prop == "entityname") then + + + + result = string.match(currentScannerItem[trigger.prop], trigger.value) + + + + end + + if(trigger.prop == "level" or trigger.prop == "rarity" or trigger.prop == "attitude") then + + + + result = checkValue(trigger.operator,currentScannerItem[trigger.prop],trigger.value,trigger.min,trigger.max) + + + + end + + + if(trigger.prop == "reward" or trigger.prop == "streetreward" or trigger.prop == "danger") then + + + + result = checkValue(trigger.operator,currentScannerItem["bounty"][trigger.prop],trigger.value,trigger.min,trigger.max) + + + + end + + + if(trigger.prop == "issuedby" ) then + + + + result = string.match(currentScannerItem["bounty"][trigger.prop], trigger.value) + + + + end + + + + + + if(trigger.prop == "transgressions" or trigger.prop == "customtransgressions" ) then + + result = table_contains(currentScannerItem["bounty"][trigger.prop],trigger.value) + + + + end + end + end + + + end + if houseregion then + + if(trigger.name == "is_in_custom_place") then + if currentHouse ~= nil then + if(trigger.value == "current") or (currentHouse.tag == trigger.value)then + result = true + end + + end + end + if(trigger.name == "is_in_custom_room") then + if currentRoom ~= nil then + if("current" == trigger.value) or (currentRoom.tag == trigger.value)then + result = true + end + end + end + if(trigger.name == "is_in_buyed_place") then + if currentHouse ~= nil then + if(getHouseStatut(currentHouse.tag) ~= nil and getHouseStatut(currentHouse.tag) >= 1) then + result = true + end + end + end + if(trigger.name == "is_in_rented_place") then + if currentHouse ~= nil then + if(getHouseStatut(currentHouse.tag) ~= nil and getHouseStatut(currentHouse.tag) >= 2) then + result = true + end + end + end + if(trigger.name == "place_canbe_buyed") then + if currentHouse ~= nil then + local statut = getHouseStatut(currentHouse.tag) + if(currentHouse.isbuyable == true and getStackableItemAmount("Items.money") > currentHouse.price and (statut == nil or statut < 1)) then + result = true + end + end + end + if(trigger.name == "place_canbe_rented") then + if currentHouse ~= nil then + local statut = getHouseStatut(currentHouse.tag) + if(currentHouse.isrentable == true and getStackableItemAmount("Items.money") > (currentHouse.price*currentHouse.coef) and (statut ~= nil and statut == 1)) then + result = true + end + end + end + if(trigger.name == "custom_place_type") then + if currentHouse ~= nil then + if(trigger.value == currentHouse.type) then + result = true + end + end + end + if(trigger.name == "custom_room_type") then + if currentRoom ~= nil then + ------logme(3,currentRoom.type[i]) + for i=1,#currentRoom.type do + ------logme(3,currentRoom.type[i]) + if(trigger.value == currentRoom.type[i]) then + result = true + end + end + end + end + if(trigger.name == "entity_is_in_custom_place_type") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil and currentHouse ~= nil )then + if(trigger.value == currentHouse.type) then + local targetPosition = enti:GetWorldPosition() + if check3DPos(targetPosition, currentHouse.x, currentHouse.x, currentHouse.z,currentHouse.range,currentHouse.range_z) then + result = true + else + result = false + end + end + end + end + if(trigger.name == "entity_is_in_custom_room_type") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil and currentRoom ~= nil )then + local targetPosition = enti:GetWorldPosition() + if( check3DPos(targetPosition, currentRoom.x, currentRoom.x, currentRoom.z,currentRoom.range,currentRoom.range_z)) then + for i=1,#currentRoom.type do + + if(trigger.value == currentRoom.type[i]) then + result = true + end + end + end + + end + end + if(trigger.name == "item_looked_is_registered") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local entity = getItemEntityFromManager(entid) + if(entity ~= nil) then + result = true + else + entity = getItemEntityFromManagerByPlayerLookinAt() + if(entity ~= nil) then + result = true + end + end + end + end + if(trigger.name == "have_selected_item") then + if selectedItem ~= nil then + result = true + end + end + if(trigger.name == "have_selected_item_can_be_grabbed") then + if selectedItem ~= nil and selectedItem.entityId ~= nil and safeFindEntityByID(selectedItem.entityId)~=nil then + result = safeFindEntityByID(selectedItem.entityId):IsA('gameObject') + end + end + end + + if gangregion then + if(trigger.name == "gang_affinity") then + local score = 0 + score = getScoreKey("Affinity",trigger.value) + if(score ~= nil and score >= trigger.score)then + result = true + end + end + if(trigger.name == "entity_looked_is_gangfriendly") then + if objLook ~= nil then + result = openCompanion + end + end + if(trigger.name == "entity_looked_gang_score") then + if objLook ~= nil then + if(gangscore ~= nil and gangscore == trigger.value) then + result = true + end + end + end + if(trigger.name == "entity_looked_is_gang") then + if lookatgang ~= nil then + result = true + end + end + if(trigger.name == "entity_looked_is_specific_gang") then + if lookatgang ~= nil and lookatgang.tag == trigger.value then + result = true + end + end + if(trigger.name == "entity_in_faction") then + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + local targetAttAgent = nil + pcall(function() targetAttAgent = enti:GetAttitudeAgent() end) + if targetAttAgent == nil then + -- Entity doesn't have an AttitudeAgent (not an NPC / special entity type). + -- Skip the faction check for this entity. + return + end + local group = Game.NameToString(targetAttAgent:GetAttitudeGroup()) + local npcCurrentName = Game.NameToString(enti:GetCurrentAppearanceName()) + local faction = getFactionByTag(trigger.faction) + + local resultent,msg = pcall(function() enti:GetRecordID() end) + + + if(resultent == true and enti:GetRecordID().hash ~= nil and cyberscript.entitieshash[tostring(enti:GetRecordID().hash)] ~= nil) then + + local entity = cyberscript.entitieshash[tostring(enti:GetRecordID().hash)] + + + if(entity ~= nil) then + + if(faction ~= nil) then + for y=1,#faction.spawnable_npc do + + + + if(string.find(entity.entity_tweak,faction.spawnable_npc[y]) ~= nil)then + result = true + end + end + if(result == false) then + for y=1,#faction.keyword do + + + + if(string.find(entity.entity_tweak,faction.keyword[y]) ~= nil)then + result = true + end + end + end + end + + end + else + + if(faction ~= nil) then + for y=1,#faction.attitude_group do + + + + if(string.find(group,faction.attitude_group[y]) ~= nil or string.find(npcCurrentName,faction.attitude_group[y]) ~= nil)then + result = true + end + end + end + end + end + end + if(trigger.name == "check_gang_district_score") then + if getVariableKey(trigger.faction,trigger.district) ~= nil then + if getVariableKey(trigger.faction,trigger.district) >= trigger.value then + result = true + end + end + end + + if(trigger.name == "check_gang_relation") then + + if(trigger.tag == "player") then + + trigger.tag = getVariableKey("player","current_gang") + + end + + if(trigger.tag ~= "") then + + if(trigger.mode == "gang") then + + + if(trigger.target ~= trigger.tag ) then + + local score = getFactionRelation(trigger.tag,trigger.target) + if(checkValue(trigger.operator,score,trigger.score,trigger.min,trigger.max)) then + + result = true + + end + + + + end + + end + + if(trigger.mode == "district_leader" or trigger.mode == "district_subleader") then + + local gangs = getGangfromDistrict(trigger.target,20) + if(#gangs > 0) then + + + + if(gangs[1].tag ~= trigger.tag) then + + local score = getFactionRelation(trigger.tag,gangs[1].tag) + if(checkValue(trigger.operator,score,trigger.score,trigger.min,trigger.max)) then + result = true + end + + + end + end + + + end + + if(trigger.mode == "current_district_leader") then + + if currentDistricts2 ~= nil then + local gangs = getGangfromDistrict(currentDistricts2.Tag,20) + if(#gangs > 0) then + if(gangs[1].tag ~= trigger.tag) then + + local score = getFactionRelation(trigger.tag,gangs[1].tag) + if(checkValue(trigger.operator,score,trigger.score,trigger.min,trigger.max)) then + + result = true + end + end + end + + end + + end + if(trigger.mode == "current_district_subleader") then + if currentDistricts2 ~= nil then + if currentDistricts2.districtLabels[2] ~= nil then + local gangs = getGangfromDistrict(currentDistricts2.districtLabels[2],20) + if(#gangs > 0) then + + if(gangs[1].tag ~= trigger.tag) then + + local score = getFactionRelation(trigger.tag,gangs[1].tag) + if(checkValue(trigger.operator,score,trigger.score,trigger.min,trigger.max)) then + result = true + end + end + end + end + + end + + end + + + end + + + + end + + + if(trigger.name == "last_killed_entity_is_in_specific_gang") then + if lastTargetKilled ~= nil then + local killComp, killGangScore, killGang = checkAttitudeByGangScore(lastTargetKilled) + + if killGang ~= nil and killGang.tag == trigger.value then + result = true + end + end + end + + if(trigger.name == "last_killed_entity") then + if lastTargetKilled ~= nil then + result = true + end + + end + + if(trigger.name == "last_killed_entity_is_in_gang") then + if lastTargetKilled ~= nil then + local killComp, killGangScore, killGang = checkAttitudeByGangScore(lastTargetKilled) + if killGang ~= nil then + result = true + end + end + end + + + if(trigger.name == "last_killed_entity_gang_score") then + if lastTargetKilled ~= nil then + local killComp, killGangScore, killGang = checkAttitudeByGangScore(lastTargetKilled) + + if(checkValue(trigger.operator,killGangScore,trigger.score,trigger.min,trigger.max)) then + result = true + end + + end + end + + end + + if miscregion then + if(trigger.name == "auto")then + result = true + end + if(trigger.name == "tracked_game_quest")then + local objective = Game.GetJournalManager():GetTrackedEntry() + + if objective ~= nil then + local phase = Game.GetJournalManager():GetParentEntry(objective) + local quest = Game.GetJournalManager():GetParentEntry(phase) + + result= (string.match(tostring(quest.id), trigger.value) ~= nil) + end + end + if(trigger.name == "tracked_game_phase")then + local objective = Game.GetJournalManager():GetTrackedEntry() + + if objective ~= nil then + local phase = Game.GetJournalManager():GetParentEntry(objective) + + result= (string.match(tostring(phase.id), trigger.value) ~= nil) + end + end + if(trigger.name == "tracked_game_objective")then + local objective = Game.GetJournalManager():GetTrackedEntry() + + if objective ~= nil then + + result= (string.match(tostring(objective.id), trigger.value) ~= nil) + end + end + if(trigger.name == "time") then + local currentime = tonumber(getGameTimeHHmm()) + ----logme(3,"currentime "..currentime) + if(tonumber(currentime) >= tonumber(trigger.min) and tonumber(currentime) <= tonumber(trigger.max)) then + result = true + end + end + if(trigger.name == "os_time") then + local currentime = getOsTimeHHmm() + ----logme(3,"currentime "..currentime) + local times = currentime.hour*100 + currentime.min + if(tonumber(times) >= tonumber(trigger.min) and tonumber(times) <= tonumber(trigger.max)) then + result = true + end + end + if(trigger.name == "os_date") then + local currentime = getOsTimeHHmm() + ----logme(3,"currentime "..currentime) + if((tonumber(currentime.month) == tonumber(trigger.month) or trigger.month == "") and (tonumber(currentime.day) == tonumber(trigger.day)) or trigger.day == "") and (tonumber(currentime.year) == tonumber(trigger.year) or trigger.year == "") then + result = true + end + end + if(trigger.name == "check_setting") then + local score = 0 + score = getUserSetting(trigger.value) + if(score ~= nil and score == trigger.score)then + result = true + end + end + if(trigger.name == "debug") then + result = cyberscript.debug + end + if(trigger.name == "current_district") then + if currentDistricts2 ~= nil and currentDistricts2.customdistrict ~= nil then + if(string.lower(currentDistricts2.customdistrict.EnumName) == string.lower(trigger.value))then + --logme(3,"district OK") + result = true + end + end + end + if(trigger.name == "current_subdistrict") then + if currentDistricts2 ~= nil then + if(currentDistricts2.districtLabels~=nil)then + for i, subd in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + if(string.lower(subd) == string.lower(trigger.value))then + --logme(3,"subdistrict OK") + result = true + end + end + end + end + end + end + if(trigger.name == "salary_is_possible") then + result = SalaryIsPossible + end + if(trigger.name == "have_custom_mappin_placed") then + if(mappinManager["selected_mappin"] ~= nil) then + result = true + end + end + if(trigger.name == "have_fasttravel_mappin_placed") then + + if(ActiveFastTravelMappin ~= nil) then + result = true + logme(3,"toto"..dump(ActiveFastTravelMappin)) + end + end + if(trigger.name == "event_is_finished") then + if(workerTable[trigger.tag] == nil ) then + result = true + end + end + + if(trigger.name == "event_exist") then + if(workerTable[trigger.tag] ~= nil ) then + result = true + end + end + if(trigger.name == "metro_time_is_finished") then + if MetroCurrentTime <=0 and activeMetroDisplay == false then + result = true + end + end + if(trigger.name == "area_security_level") then + local level = FromVariant(GetPlayer():GetPlayerStateMachineBlackboard():GetVariant(GetAllBlackboardDefs().PlayerStateMachine.SecurityZoneData)) + if level == trigger.value then + result = true + end + end + if(trigger.name == "is_recording_mode_active") then + if recordingMode then + result = true + end + end + + if(trigger.name == "interact_is_forceloaded") then + if(#loadInteract > 0) then + + for i,v in ipairs(loadInteract) do + + if(v == trigger.tag) then + + result = true + + end + + end + + + + + end + + + + end + if(trigger.name== "check_mod") then + + result = GetMod(trigger.value) ~= nil + + end + + if(trigger.name== "have_collision") then + + local collision = false + trigger.output = true + local from = Vector4.new( + trigger.from_x, + trigger.from_y, + trigger.from_z, + 1 + ) + + + local to = Vector4.new( + trigger.to_x, + trigger.to_y, + trigger.to_z, + 1 + ) + + + -- local filters = { + + -- 'Static', -- Buildings, Concrete Roads, Crates, etc. + + -- 'Terrain' + + -- } + -- local filters = { + -- -- 'Dynamic', -- Movable Objects + -- -- 'Vehicle', + -- 'Static', -- Buildings, Concrete Roads, Crates, etc. + -- 'Water', + -- 'Terrain', + -- -- 'PlayerBlocker', -- Trees, Billboards, Barriers + -- } + local filters = trigger.filters + local results = {} + + + + + + + + for _, filter in ipairs(filters) do + local success, physicsTraceResult = Game.GetSpatialQueriesSystem():SyncRaycastByCollisionGroup(from, to, filter, false, false) + + if success then + collision = true + + + + end + end + + result = collision + + + + end + + + if(trigger.name== "check_raycasting") then + + local collision = false + + local from = Vector4.new( + trigger.from_x, + trigger.from_y, + trigger.from_z, + 1 + ) + + + local to = Vector4.new( + trigger.to_x, + trigger.to_y, + trigger.to_z, + 1 + ) + + + + local filters = trigger.filters + local results = {} + + local points = {} + for i=1,action.points do + points[i] = {} + if(to.x > from.x) then + points[i].x = (math.abs(to.x - from.x) / action.points) * i + from.x; + else + + points[i].x = 0-((math.abs(from.x - to.x) / action.points) * i - from.x); + end + + + if(to.y > from.y) then + points[i].y = (math.abs(to.y - from.y) / action.points) * i + from.y; + else + + points[i].y = 0-((math.abs(from.y - to.y) / action.points) * i - from.y); + end + + + if(to.z > from.z) then + points[i].z = (math.abs(to.z - from.z) / action.points) * i + from.z; + else + + points[i].z = 0-((math.abs(from.z - to.z) / action.points) * i - from.z); + end + + + end + + for i=1,#points do + local mypoint = Vector4.new( + points[i].x, + points[i].y, + points[i].z, + 1 + ) + + + for _, filter in ipairs(filters) do + local success, physicsTraceResult = Game.GetSpatialQueriesSystem():SyncRaycastByCollisionGroup(from, mypoint, filter, false, false) + + if success then + collision = true + + + + end + end + + + end + + + + + result = collision + + + + end + + if(trigger.name== "game_language") then + + result = cyberscript.language == trigger.value + + end + + if(trigger.name== "device_active_radio_channel_id") then + + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + local ps = enti:GetDevicePS() + result = ps.activeStation == trigger.value + + + end + end + + if(trigger.name== "device_active_tv_channel_id") then + + local obj = getEntityFromManager(trigger.tag) + local enti = nil + if obj and obj.id then + local _ok, _res = pcall(function() return safeFindEntityByID(obj) end) + if _ok then enti = _res end + end +if(enti ~= nil) then + local ps = enti:GetController():GetPS():GetActiveStationIndex() + result = ps.activeStation == trigger.value + + + end + end + + if(trigger.name== "have_shard") then + + + if(gameshardscompiled == nil) then + + local activeData = CodexListSyncData.new() + local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) + if gameshardscompiled == nil then gameshardscompiled = {} end + for i,v in pairs(gameshards) do + if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end + + + end + end + + result = gameshardscompiled[trigger.value] ~= nil + end + + if(trigger.name== "mappin_exist") then + + result = mappinManager[trigger.tag] ~= nil + end + + end + + if relationregion then + if(trigger.name == "current_phoned_npc_is_defined") then + if(currentNPC ~= nil) then + result = true + end + end + + if(trigger.name == "current_phoned_npc_name") then + if(currentNPC ~= nil) then + + if(currentNPC.Names == trigger.value) then + result = true + end + end + end + + if(trigger.name == "current_star_name") then + if(currentStar ~= nil) then + + if(currentStar.Names == trigger.value) then + result = true + end + end + end + end + + if questregion then + if(trigger.name == "quest_fact") then + isquestok =Game.GetQuestsSystem():GetFactStr(trigger.value) + if(isquestok == 1)then + result = true + end + end + if(trigger.name == "mission_fact") then + local score = getScoreKey(trigger.value,"Score") + if(score ~= nil and score == 1) then + result = true + end + end - if(trigger.name == "tracked_custom_quest") then - - if currentQuest ~= nil then - - result= currentQuest.tag == trigger.value - - - - end - end + if(trigger.name == "tracked_custom_quest") then + + if currentQuest ~= nil then + + result= currentQuest.tag == trigger.value + + + + end + end - if(trigger.name == "tracked_custom_objective") then - - if currentQuest ~= nil then - - - for i=1, #currentQuest.objectives do - - local objective = currentQuest.objectives[i] - - if(QuestManager.GetObjectiveState(objective.tag).isTracked) then + if(trigger.name == "tracked_custom_objective") then + + if currentQuest ~= nil then + + + for i=1, #currentQuest.objectives do + + local objective = currentQuest.objectives[i] + + if(QuestManager.GetObjectiveState(objective.tag).isTracked) then - result= objective.tag == trigger.value + result= objective.tag == trigger.value - end - end - - - end - end - + end + end + + + end + end + - if(trigger.name == "completed_native_quest") then - local context = JournalRequestContext.new() - local filter = JournalRequestStateFilter.new() - filter.succeeded = true; - context.stateFilter = filter; - local quest = Game.GetJournalManager():GetQuests(context) - - for i,v in ipairs(quest) do - - if ( tostring(v.id) == trigger.value) then - result = true - break - end - end + if(trigger.name == "completed_native_quest") then + local context = JournalRequestContext.new() + local filter = JournalRequestStateFilter.new() + filter.succeeded = true; + context.stateFilter = filter; + local quest = Game.GetJournalManager():GetQuests(context) + + for i,v in ipairs(quest) do + + if ( tostring(v.id) == trigger.value) then + result = true + break + end + end - end + end - if(trigger.name == "completed_native_phase") then - local context = JournalRequestContext.new() - local filter = JournalRequestStateFilter.new() - filter.succeeded = true; - context.stateFilter = filter; - local quest = Game.GetJournalManager():GetQuests(context) - - for i,v in ipairs(quest) do - if( v.id == trigger.questvalue) then - local children = Game.GetJournalManager():GetChildren(v,filter) - for j,c in ipairs(children) do - if ( c.id == trigger.value) then - result = true - break - end - end + if(trigger.name == "completed_native_phase") then + local context = JournalRequestContext.new() + local filter = JournalRequestStateFilter.new() + filter.succeeded = true; + context.stateFilter = filter; + local quest = Game.GetJournalManager():GetQuests(context) + + for i,v in ipairs(quest) do + if( v.id == trigger.questvalue) then + local children = Game.GetJournalManager():GetChildren(v,filter) + for j,c in ipairs(children) do + if ( c.id == trigger.value) then + result = true + break + end + end - end - end - + end + end + - end + end - if(trigger.name == "completed_native_objective") then - local context = JournalRequestContext.new() - local filter = JournalRequestStateFilter.new() - filter.succeeded = true; - context.stateFilter = filter; - local quest = Game.GetJournalManager():GetQuests(context) - - for i,v in ipairs(quest) do - if( v.id == trigger.questvalue) then - local children = Game.GetJournalManager():GetChildren(v,filter) - for j,c in ipairs(children) do - if ( c.id == trigger.phasevalue) then - local children2 = Game.GetJournalManager():GetChildren(c,filter) - for k,o in ipairs(children2) do - if ( o.id == trigger.value) then - result = true - break - end - end - break - end - end + if(trigger.name == "completed_native_objective") then + local context = JournalRequestContext.new() + local filter = JournalRequestStateFilter.new() + filter.succeeded = true; + context.stateFilter = filter; + local quest = Game.GetJournalManager():GetQuests(context) + + for i,v in ipairs(quest) do + if( v.id == trigger.questvalue) then + local children = Game.GetJournalManager():GetChildren(v,filter) + for j,c in ipairs(children) do + if ( c.id == trigger.phasevalue) then + local children2 = Game.GetJournalManager():GetChildren(c,filter) + for k,o in ipairs(children2) do + if ( o.id == trigger.value) then + result = true + break + end + end + break + end + end - end - end - + end + end + - end + end - if(trigger.name == "tracked_native_quest") then - local objective = Game.GetJournalManager():GetTrackedEntry() - if objective ~= nil then - local phase = Game.GetJournalManager():GetParentEntry(objective) - local quest = Game.GetJournalManager():GetParentEntry(phase) - return quest.id == trigger.value - - - - end - end + if(trigger.name == "tracked_native_quest") then + local objective = Game.GetJournalManager():GetTrackedEntry() + if objective ~= nil then + local phase = Game.GetJournalManager():GetParentEntry(objective) + local quest = Game.GetJournalManager():GetParentEntry(phase) + return quest.id == trigger.value + + + + end + end - if(trigger.name == "tracked_native_phase") then - local objective = Game.GetJournalManager():GetTrackedEntry() - if objective ~= nil then - local phase = Game.GetJournalManager():GetParentEntry(objective) - - return phase.id == trigger.value - - - - end - end + if(trigger.name == "tracked_native_phase") then + local objective = Game.GetJournalManager():GetTrackedEntry() + if objective ~= nil then + local phase = Game.GetJournalManager():GetParentEntry(objective) + + return phase.id == trigger.value + + + + end + end - if(trigger.name == "tracked_native_objective") then - local objective = Game.GetJournalManager():GetTrackedEntry() - if objective ~= nil then - - return objective.id == trigger.value - - - - end - end - - end - - if noderegion then - if(trigger.name == "entity_path_is_finish") then - local founded = false - local obj = getEntityFromManager(trigger.tag) - if(obj.path ~= nil) then - result = obj.path.finish - else - result = true - end - end - if(trigger.name == "is_arrived_to_destination") then - local obj = getEntityFromManager(trigger.tag) - --logme(3,obj.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local targetPosition = enti:GetWorldPosition() - if obj.destination ~= nil then - - if check3DPos(targetPosition, obj.destination.x, obj.destination.y, obj.destination.z,trigger.range) then - result = true - else - result = false - end - else - --logme(3,"entity not found : "..trigger.tag) - result = false - end - end - end - end - - if soundregion then - if(trigger.name == "gameVolume") then - if (GetSoundSettingValue(trigger.value) >= trigger.score) then - result = true - end - end - if(trigger.name == "soundmanager_isplaying") then - --logme(3,"soundmanager_isplaying "..tostring(IsPlaying(trigger.channel))) - if IsPlaying(trigger.channel) == true then - result = true - end - end - end - - if logicregion then - if(trigger.name == "compare") then - local res = checkTrigger(trigger.trigger) - --logme(3,tostring(res)) - result = (res == trigger.expected) - --logme(3,tostring(result)) - end - if(trigger.name == "testFor") then - local count = 0 - local counttrigger = 0 - if(isArray(trigger.triggers))then - for i=1, #trigger.triggers do - counttrigger = #trigger.triggers - - - local trig = trigger.triggers[i] - - local rs = checkTrigger(trig) - if(rs == true ) then - count = count +1 - end - end - else - - for k,v in pairs(trigger.triggers) do - counttrigger = counttrigger+1 - - - local trig = v - - local rs = checkTrigger(trig) - if(rs == true ) then - count = count +1 - end - end - - end - - if(trigger.logic == "or") then - --logme(3,tostring(count >=1)) - result = (count >=1 ) - else - result = (count == counttrigger) - end - end - end - - if uiregion then - - if(trigger.name == "timer_is_finished") then - if(currentTimer ~= nil) then - - if( os.time(os.date("!*t"))+0 > currentTimer.time) then - - - result = true - - end - - - end - end - if(trigger.name == "interact_is_inprogress") then - result = actionistaken - end - if(trigger.name == "is_in_menu") then - result = inMenu - end - if(trigger.name == "is_phone_opened") then - result = GameController["NewHudPhoneGameController"]:IsPhoneActive() - end - if(trigger.name == "scanner_active") then - result = (inScanner ~= nil and inScanner == true) - end - if(trigger.name == "is_in_specific_menu") then - if(inMenu and ActiveMenu == trigger.menu)then - result = true - else - result = false - end - end - if(trigger.name == "texture_is_visible") then - result = (currentLoadedTexture[trigger.tag] ~= nil) - end - end - - if avregion then - if(trigger.name == "player_is_in_av") then - local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - if (inVehicule) then - --print("ok1") - local vehicule = Game.GetMountedVehicle(Game.GetPlayer()) - - if(vehicule ~=nil) then - - local entid = vehicule:GetEntityID() - local entity = getEntityFromManagerById(entid) - - if(entity ~= nil and entity.isAV ~= nil) then - - --print(tostring(entity.isAV)) - result = entity.isAV or JackFlight - end - end - end - end - if(trigger.name == "entity_looked_is_custom_av") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - --logme(3,appName) - local entid = objLook:GetEntityID() - local entity = getEntityFromManagerById(entid) - if(entity ~= nil) then - - if(entity.isAV == true or entity.tag == "fake_av") then - result = true - end - end - end - end - end - - if frameworkregion then - if(trigger.name =="datapack_is_enabled")then - if( arrayDatapack[trigger.tag] ~= nil) then - - result = true - - end - end - - if(trigger.name =="datapack_version")then - - local localversion = arrayDatapack[trigger.tag].metadata.version - result = checkVersionNumber(localversion,trigger.value) - end - - if(trigger.name =="datapack_is_outdated")then - - local serverversion = "0.0.0" - - for i = 1,#arrayDatapack3 do - - local datapack = arrayDatapack3[i] - if(datapack.tag == trigger.tag) then - serverversion = datapack.version - end - - end - local localversion = arrayDatapack[trigger.tag].metadata.version - result = checkVersionNumber(localversion,serverversion) - - end - - if(trigger.name =="mod_is_outdated")then - if(CurrentServerModVersion.version ~= "unknown" and CurrentServerModVersion.version ~= "0.16000069" and checkVersionNumber(cyberscript.version,CurrentServerModVersion.version))then - result = true - end - end - - end - - if airegion then - if(trigger.name =="ai_answer_is_ready")then - return (getAIAnswerOrDefault(trigger.aitag) ~= nil ) - end - end - - - - - end - - if(trigger.expected ~= nil and trigger.name ~= "compare") then result = result == trigger.expected end - if(trigger.output == true) then - - ----print(trigger.name) - ----print(dump(trigger)) - ----print(tostring(result)) - logme(1,dump(trigger).." || result : "..tostring(result),true) - end - return result + if(trigger.name == "tracked_native_objective") then + local objective = Game.GetJournalManager():GetTrackedEntry() + if objective ~= nil then + + return objective.id == trigger.value + + + + end + end + + end + + if noderegion then + if(trigger.name == "entity_path_is_finish") then + local founded = false + local obj = getEntityFromManager(trigger.tag) + if(obj.path ~= nil) then + result = obj.path.finish + else + result = true + end + end + if(trigger.name == "is_arrived_to_destination") then + local obj = getEntityFromManager(trigger.tag) + --logme(3,obj.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local targetPosition = enti:GetWorldPosition() + if obj.destination ~= nil then + + if check3DPos(targetPosition, obj.destination.x, obj.destination.y, obj.destination.z,trigger.range) then + result = true + else + result = false + end + else + --logme(3,"entity not found : "..trigger.tag) + result = false + end + end + end + end + + if soundregion then + if(trigger.name == "gameVolume") then + if (GetSoundSettingValue(trigger.value) >= trigger.score) then + result = true + end + end + if(trigger.name == "soundmanager_isplaying") then + --logme(3,"soundmanager_isplaying "..tostring(IsPlaying(trigger.channel))) + if IsPlaying(trigger.channel) == true then + result = true + end + end + end + + if logicregion then + if(trigger.name == "compare") then + local res = checkTrigger(trigger.trigger) + --logme(3,tostring(res)) + result = (res == trigger.expected) + --logme(3,tostring(result)) + end + if(trigger.name == "testFor") then + local count = 0 + local counttrigger = 0 + if(isArray(trigger.triggers))then + for i=1, #trigger.triggers do + counttrigger = #trigger.triggers + + + local trig = trigger.triggers[i] + + local rs = checkTrigger(trig) + if(rs == true ) then + count = count +1 + end + end + else + + for k,v in pairs(trigger.triggers) do + counttrigger = counttrigger+1 + + + local trig = v + + local rs = checkTrigger(trig) + if(rs == true ) then + count = count +1 + end + end + + end + + if(trigger.logic == "or") then + --logme(3,tostring(count >=1)) + result = (count >=1 ) + else + result = (count == counttrigger) + end + end + end + + if uiregion then + + if(trigger.name == "timer_is_finished") then + if(currentTimer ~= nil) then + + if( os.time(os.date("!*t"))+0 > currentTimer.time) then + + + result = true + + end + + + end + end + if(trigger.name == "interact_is_inprogress") then + result = actionistaken + end + if(trigger.name == "is_in_menu") then + result = inMenu + end + if(trigger.name == "is_phone_opened") then + result = GameController["NewHudPhoneGameController"]:IsPhoneActive() + end + if(trigger.name == "scanner_active") then + result = (inScanner ~= nil and inScanner == true) + end + if(trigger.name == "is_in_specific_menu") then + if(inMenu and ActiveMenu == trigger.menu)then + result = true + else + result = false + end + end + if(trigger.name == "texture_is_visible") then + result = (currentLoadedTexture[trigger.tag] ~= nil) + end + end + + if avregion then + if(trigger.name == "player_is_in_av") then + local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + if (inVehicule) then + --print("ok1") + local vehicule = Game.GetMountedVehicle(Game.GetPlayer()) + + if(vehicule ~=nil) then + + local entid = vehicule:GetEntityID() + local entity = getEntityFromManagerById(entid) + + if(entity ~= nil and entity.isAV ~= nil) then + + --print(tostring(entity.isAV)) + result = entity.isAV or JackFlight + end + end + end + end + if(trigger.name == "entity_looked_is_custom_av") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + --logme(3,appName) + local entid = objLook:GetEntityID() + local entity = getEntityFromManagerById(entid) + if(entity ~= nil) then + + if(entity.isAV == true or entity.tag == "fake_av") then + result = true + end + end + end + end + end + + if frameworkregion then + if(trigger.name =="datapack_is_enabled")then + if( arrayDatapack[trigger.tag] ~= nil) then + + result = true + + end + end + + if(trigger.name =="datapack_version")then + + local localversion = arrayDatapack[trigger.tag].metadata.version + result = checkVersionNumber(localversion,trigger.value) + end + + if(trigger.name =="datapack_is_outdated")then + + local serverversion = "0.0.0" + + for i = 1,#arrayDatapack3 do + + local datapack = arrayDatapack3[i] + if(datapack.tag == trigger.tag) then + serverversion = datapack.version + end + + end + local localversion = arrayDatapack[trigger.tag].metadata.version + result = checkVersionNumber(localversion,serverversion) + + end + + if(trigger.name =="mod_is_outdated")then + if(CurrentServerModVersion.version ~= "unknown" and CurrentServerModVersion.version ~= "0.16000069" and checkVersionNumber(cyberscript.version,CurrentServerModVersion.version))then + result = true + end + end + + end + + if airegion then + if(trigger.name =="ai_answer_is_ready")then + return (getAIAnswerOrDefault(trigger.aitag) ~= nil ) + end + end + + + + + end + + if(trigger.expected ~= nil and trigger.name ~= "compare") then result = result == trigger.expected end + if(trigger.output == true) then + + ----print(trigger.name) + ----print(dump(trigger)) + ----print(tostring(result)) + logme(1,dump(trigger).." || result : "..tostring(result),true) + end + return result end --execute actions core function function executeAction(action,tag,parent,index,source,executortag) - local result = true - - local canDoaction = true - actionistaken = true - - if(action.tag == "this") then - action.tag = executortag - action.executortag = executortag - print("sss"..executortag) - end - - checkContext(action) - - if(action.requirement ~= nil and action.triggers ~= nil)then - - canDoaction = checkTriggerRequirement(action.requirement,action.triggers) - - end - - if(canDoaction) then - - local entityregion = true - local groupregion = true - local vehiculeregion = true - local scoreregion = true - local houseregion = true - local gangregion = true - local miscregion = true - local relationregion = true - local questregion = true - local noderegion = true - local soundregion = true - local logicregion = true - local uiregion = true - local avregion = true - local customnpcregion = true - local multiregion = true - local framework = true - local scene = true - local scannerregion = true - local hudregion = true - local animationregion = true - local airegion = true - - local status, retval = pcall(function() - - if groupregion then - if(action.name == "create_group") then - local group = {} - group.tag = action.tag - group.entities = {} - cyberscript.GroupManager[action.tag] = group - - logme(3,"group created") - end - if(action.name == "add_entity_to_group") then - - for i=1, #action.entities do - table.insert(cyberscript.GroupManager[action.tag].entities,action.entities[i]) - end - - end - if(action.name == "set_entity_to_group") then - - cyberscript.GroupManager[action.tag].entities = action.entities - - end - if(action.name == "despawn_group") then - local group =getGroupfromManager(action.tag) - if group ~= nil then - for i=1, #group.entities do - local entityTag = group.entities[i] - - despawnEntity(entityTag) - - end - end - end - if(action.name == "remove_group") then - cyberscript.GroupManager[action.tag] = nil - end - if(action.name == "remove_entity_from_group") then - - for i=1, #cyberscript.GroupManager[action.tag].entities do - local entityTag = cyberscript.GroupManager[action.tag].entities[i] - for y=1, action.entities do - if(entityTag == action.entities[y]) then - table.remove(cyberscript.GroupManager[action.tag].entities,i) - end - end - end - end - - if(action.name == "clear_entity_from_group_and_manager") then - - for i,entitygroup in ipairs(cyberscript.GroupManager[action.tag].entities) do - - cyberscript.EntityManager[entitygroup] = nil - - end - - - cyberscript.GroupManager[action.tag].entities = {} - end - - if(action.name == "for_entity_in_group") then - - local group =getGroupfromManager(action.tag) - if group ~= nil then - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - if(#action.action > 0) then - - runActionList(action.action, entityTag.."_forentitygroup",source,false,entityTag,false) - end - - end - end - - - - - - - - end + local result = true + + local canDoaction = true + actionistaken = true + + if(action.tag == "this") then + action.tag = executortag + action.executortag = executortag + print("sss"..executortag) + end + + checkContext(action) + + if(action.requirement ~= nil and action.triggers ~= nil)then + + canDoaction = checkTriggerRequirement(action.requirement,action.triggers) + + end + + if(canDoaction) then + + local entityregion = true + local groupregion = true + local vehiculeregion = true + local scoreregion = true + local houseregion = true + local gangregion = true + local miscregion = true + local relationregion = true + local questregion = true + local noderegion = true + local soundregion = true + local logicregion = true + local uiregion = true + local avregion = true + local customnpcregion = true + local multiregion = true + local framework = true + local scene = true + local scannerregion = true + local hudregion = true + local animationregion = true + local airegion = true + + local status, retval = pcall(function() + + if groupregion then + if(action.name == "create_group") then + local group = {} + group.tag = action.tag + group.entities = {} + cyberscript.GroupManager[action.tag] = group + + logme(3,"group created") + end + if(action.name == "add_entity_to_group") then + + for i=1, #action.entities do + table.insert(cyberscript.GroupManager[action.tag].entities,action.entities[i]) + end + + end + if(action.name == "set_entity_to_group") then + + cyberscript.GroupManager[action.tag].entities = action.entities + + end + if(action.name == "despawn_group") then + local group =getGroupfromManager(action.tag) + if group ~= nil then + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + + despawnEntity(entityTag) + + end + end + end + if(action.name == "remove_group") then + cyberscript.GroupManager[action.tag] = nil + end + if(action.name == "remove_entity_from_group") then + + for i=1, #cyberscript.GroupManager[action.tag].entities do + local entityTag = cyberscript.GroupManager[action.tag].entities[i] + for y=1, action.entities do + if(entityTag == action.entities[y]) then + table.remove(cyberscript.GroupManager[action.tag].entities,i) + end + end + end + end + + if(action.name == "clear_entity_from_group_and_manager") then + + for i,entitygroup in ipairs(cyberscript.GroupManager[action.tag].entities) do + + cyberscript.EntityManager[entitygroup] = nil + + end + + + cyberscript.GroupManager[action.tag].entities = {} + end + + if(action.name == "for_entity_in_group") then + + local group =getGroupfromManager(action.tag) + if group ~= nil then + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + if(#action.action > 0) then + + runActionList(action.action, entityTag.."_forentitygroup",source,false,entityTag,false) + end + + end + end + + + + + + + + end - if(action.name == "attitude_group_against_entity") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - checkAttitudeCounter(obj) + if(action.name == "attitude_group_against_entity") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + checkAttitudeCounter(obj) - Cron.After(0.5, function() - if action.attitude == "hostile" then - setAggressiveAgainst(entityTag, action.entity) - end - if action.attitude == "passive" then - setPassiveAgainst(entityTag, action.entity) - end - if action.attitude == "companion" then - setFollower(entityTag) - end - if action.attitude == "friendly" then - setFriendAgainst(entityTag, action.entity) - end - if action.attitude == "psycho" then - setPsycho(entityTag, action.entity) - end - end) - end - end - if(action.name == "attitude_group_against_group") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - - - local obj = getEntityFromManager(entityTag) - - checkAttitudeCounter(obj) - end + Cron.After(0.5, function() + if action.attitude == "hostile" then + setAggressiveAgainst(entityTag, action.entity) + end + if action.attitude == "passive" then + setPassiveAgainst(entityTag, action.entity) + end + if action.attitude == "companion" then + setFollower(entityTag) + end + if action.attitude == "friendly" then + setFriendAgainst(entityTag, action.entity) + end + if action.attitude == "psycho" then + setPsycho(entityTag, action.entity) + end + end) + end + end + if(action.name == "attitude_group_against_group") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + + + local obj = getEntityFromManager(entityTag) + + checkAttitudeCounter(obj) + end - Cron.After(0.5, function() - if action.attitude == "hostile" then - setAggressiveAgainstAttitudeGroup(action.tag, action.target, action.attitudegroup, action.attitudegrouptarget) - end - if action.attitude == "passive" then - setPassiveAgainstAttitudeGroup(action.tag, action.target, action.attitudegroup, action.attitudegrouptarget) - end - end) - end - if(action.name == "play_group_voice") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - talk(enti,action.voice) - end - end - end - if(action.name == "play_group_facial") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - local reaction = getExpression(action.value) - if(enti ~= nil) then - makeFacial(enti,reaction) - end - end - end - if(action.name == "reset_group_facial") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - resetFacial(enti) - end - end - end - - if(action.name == "look_at_entity_group") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - if(action.entity == "player") then - lookAtPlayer(enti) - else - lookAtEntity(enti,action.entity) - end - end - end - end - if(action.name == "execute_at_script_level_group") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - if(obj.scriptlevel == nil or obj.scriptlevel <= action.scriptlevel) then - - runSubActionList(action.action, tag.."_execute_at_level", tag,source,false,obj.tag) - - end - end - end - - end - if(action.name == "ressurect_group") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - local sp = Game.GetScriptableSystemsContainer():Get(CName.new("ScriptedPuppet")) - sp:SendResurrectEvent(enti) - - - end - - end - - end - if(action.name == "set_script_level_group") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - obj.scriptlevel = action.scriptlevel - end - end - - end - - if(action.name == "apply_effect_to_group") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - print(obj.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - StatusEffectHelper.ApplyStatusEffectForTimeWindow(enti, TweakDBID.new(action.value),obj.id, 0,1000) - end - end - end - if(action.name == "remove_effect_to_group") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - StatusEffectHelper.RemoveStatusEffect(enti, TweakDBID.new(action.value)) - end - end - end - - - end - - if vehiculeregion then - - if(action.name == "spawn_vehicule_v2" or action.name == "spawn_vehicule") then - local chara = "" - if(action.amount == nil) then - action.amount = 1 - end - if(action.amount == 0) then - action.amount = math.random(1,6) - end - for i=1,action.amount do - if(action.source == "random") then - local indexchara = math.random(1,#arrayVehicles) - chara = arrayVehicles[indexchara] - end - if(action.source == "from_list") then - local indexchara = math.random(1,#action.source_list) - chara = action.source_list[indexchara] - end - if(action.source == "vehicle") then - chara = action.source_tag - end - if(action.source == "faction") then - local gang = getFactionByTag(action.source_tag) - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - if(#gang.spawnable_vehicle > 0) then - local index = math.random(1,#gang.spawnable_vehicle) - chara = gang.spawnable_vehicle[index] - end - end - if(action.source == "district_leader" or action.source == "subdistrict_leader") then - local gangs = getGangfromDistrict(action.source_tag,20) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - if(#gang.spawnable_vehicle > 0) then - local index = math.random(1,#gang.spawnable_vehicle) - chara = gang.spawnable_vehicle[index] - end - end - end - if(action.source == "current_district_leader") then - local gangs = getGangfromDistrict(currentDistricts2.Tag,20) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - if(#gang.spawnable_vehicle > 0) then - local index = math.random(1,#gang.spawnable_vehicle) - chara = gang.spawnable_vehicle[index] - end - end - end - if(action.source == "current_subdistrict_leader") then - local gangs = {} - for j, test in ipairs(currentDistricts2.districtLabels) do - if j > 1 then - gangs = getGangfromDistrict(test,20) - if(#gangs > 0) then - break - end - end - end - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - - if(#gang.spawnable_vehicle > 0) then - local index = math.random(1,#gang.spawnable_vehicle) - chara = gang.spawnable_vehicle[index] - end - - end - end - - if(action.source == "district_rival" or action.source == "subdistrict_rival") then - - if(action.source_gang == "player") then - - action.source_gang = getVariableKey("player","current_gang") - - end - - local gangs = getGangRivalfromDistrict(action.source_gang,action.source_tag,20) - - - - if(#gangs > 0) then - - - local gang = getFactionByTag(gangs[1].tag) - - if(#gang.spawnable_vehicle > 0) then - local index = math.random(1,#gang.spawnable_vehicle) - chara = gang.spawnable_vehicle[index] - end - end - end - if(action.source == "current_district_rival") then - - if(action.source_gang == "player") then - - action.source_gang = getVariableKey("player","current_gang") - - end - - local gangs = getGangRivalfromDistrict(action.source_gang,currentDistricts2.Tag,20) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - - if(#gang.spawnable_vehicle > 0) then - local index = math.random(1,#gang.spawnable_vehicle) - chara = gang.spawnable_vehicle[index] - end - end - end - if(action.source == "current_subdistrict_rival") then - - if(action.source_gang == "player") then - - action.source_gang = getVariableKey("player","current_gang") - - end - - - local gangs = {} - for j, test in ipairs(currentDistricts2.districtLabels) do - if j > 1 then - gangs = getGangRivalfromDistrict(action.source_gang,test,20) - if(#gangs > 0) then - break - end - end - end - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - - if(#gang.spawnable_vehicle > 0) then - local index = math.random(1,#gang.spawnable_vehicle) - chara = gang.spawnable_vehicle[index] - end - end - end - - local tag = action.tag - if(action.amount > 1) then - tag = action.tag.."_"..i - end - - local rotation = {} - if(action.yaw == nil) then - action.yaw = 0 - action.pitch = 0 - action.roll = 0 - end - - local position = getPositionFromParameter(action) - - rotation.yaw = action.yaw - rotation.pitch = action.pitch - rotation.roll = action.roll - - if(chara ~= "" and position.x ~= nil) then - if(action.amount > 1) then - if(action.amountoffsetx ~= nil and action.amountoffsetx ~= 0) then - position.x = position.x + (i * action.amountoffsetx) - else - position.x = position.x + (i * 0.5) - end + Cron.After(0.5, function() + if action.attitude == "hostile" then + setAggressiveAgainstAttitudeGroup(action.tag, action.target, action.attitudegroup, action.attitudegrouptarget) + end + if action.attitude == "passive" then + setPassiveAgainstAttitudeGroup(action.tag, action.target, action.attitudegroup, action.attitudegrouptarget) + end + end) + end + if(action.name == "play_group_voice") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + talk(enti,action.voice) + end + end + end + if(action.name == "play_group_facial") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + local reaction = getExpression(action.value) + if(enti ~= nil) then + makeFacial(enti,reaction) + end + end + end + if(action.name == "reset_group_facial") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + resetFacial(enti) + end + end + end + + if(action.name == "look_at_entity_group") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + if(action.entity == "player") then + lookAtPlayer(enti) + else + lookAtEntity(enti,action.entity) + end + end + end + end + if(action.name == "execute_at_script_level_group") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + if(obj.scriptlevel == nil or obj.scriptlevel <= action.scriptlevel) then + + runSubActionList(action.action, tag.."_execute_at_level", tag,source,false,obj.tag) + + end + end + end + + end + if(action.name == "ressurect_group") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + local sp = Game.GetScriptableSystemsContainer():Get(CName.new("ScriptedPuppet")) + sp:SendResurrectEvent(enti) + + + end + + end + + end + if(action.name == "set_script_level_group") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + obj.scriptlevel = action.scriptlevel + end + end + + end + + if(action.name == "apply_effect_to_group") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + print(obj.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + StatusEffectHelper.ApplyStatusEffectForTimeWindow(enti, TweakDBID.new(action.value),obj.id, 0,1000) + end + end + end + if(action.name == "remove_effect_to_group") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + StatusEffectHelper.RemoveStatusEffect(enti, TweakDBID.new(action.value)) + end + end + end + + + end + + if vehiculeregion then + + if(action.name == "spawn_vehicule_v2" or action.name == "spawn_vehicule") then + local chara = "" + if(action.amount == nil) then + action.amount = 1 + end + if(action.amount == 0) then + action.amount = math.random(1,6) + end + for i=1,action.amount do + if(action.source == "random") then + local indexchara = math.random(1,#arrayVehicles) + chara = arrayVehicles[indexchara] + end + if(action.source == "from_list") then + local indexchara = math.random(1,#action.source_list) + chara = action.source_list[indexchara] + end + if(action.source == "vehicle") then + chara = action.source_tag + end + if(action.source == "faction") then + local gang = getFactionByTag(action.source_tag) + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + if(#gang.spawnable_vehicle > 0) then + local index = math.random(1,#gang.spawnable_vehicle) + chara = gang.spawnable_vehicle[index] + end + end + if(action.source == "district_leader" or action.source == "subdistrict_leader") then + local gangs = getGangfromDistrict(action.source_tag,20) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + if(#gang.spawnable_vehicle > 0) then + local index = math.random(1,#gang.spawnable_vehicle) + chara = gang.spawnable_vehicle[index] + end + end + end + if(action.source == "current_district_leader") then + local gangs = getGangfromDistrict(currentDistricts2.Tag,20) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + if(#gang.spawnable_vehicle > 0) then + local index = math.random(1,#gang.spawnable_vehicle) + chara = gang.spawnable_vehicle[index] + end + end + end + if(action.source == "current_subdistrict_leader") then + local gangs = {} + for j, test in ipairs(currentDistricts2.districtLabels) do + if j > 1 then + gangs = getGangfromDistrict(test,20) + if(#gangs > 0) then + break + end + end + end + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + + if(#gang.spawnable_vehicle > 0) then + local index = math.random(1,#gang.spawnable_vehicle) + chara = gang.spawnable_vehicle[index] + end + + end + end + + if(action.source == "district_rival" or action.source == "subdistrict_rival") then + + if(action.source_gang == "player") then + + action.source_gang = getVariableKey("player","current_gang") + + end + + local gangs = getGangRivalfromDistrict(action.source_gang,action.source_tag,20) + + + + if(#gangs > 0) then + + + local gang = getFactionByTag(gangs[1].tag) + + if(#gang.spawnable_vehicle > 0) then + local index = math.random(1,#gang.spawnable_vehicle) + chara = gang.spawnable_vehicle[index] + end + end + end + if(action.source == "current_district_rival") then + + if(action.source_gang == "player") then + + action.source_gang = getVariableKey("player","current_gang") + + end + + local gangs = getGangRivalfromDistrict(action.source_gang,currentDistricts2.Tag,20) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + + if(#gang.spawnable_vehicle > 0) then + local index = math.random(1,#gang.spawnable_vehicle) + chara = gang.spawnable_vehicle[index] + end + end + end + if(action.source == "current_subdistrict_rival") then + + if(action.source_gang == "player") then + + action.source_gang = getVariableKey("player","current_gang") + + end + + + local gangs = {} + for j, test in ipairs(currentDistricts2.districtLabels) do + if j > 1 then + gangs = getGangRivalfromDistrict(action.source_gang,test,20) + if(#gangs > 0) then + break + end + end + end + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + + if(#gang.spawnable_vehicle > 0) then + local index = math.random(1,#gang.spawnable_vehicle) + chara = gang.spawnable_vehicle[index] + end + end + end + + local tag = action.tag + if(action.amount > 1) then + tag = action.tag.."_"..i + end + + local rotation = {} + if(action.yaw == nil) then + action.yaw = 0 + action.pitch = 0 + action.roll = 0 + end + + local position = getPositionFromParameter(action) + + rotation.yaw = action.yaw + rotation.pitch = action.pitch + rotation.roll = action.roll + + if(chara ~= "" and position.x ~= nil) then + if(action.amount > 1) then + if(action.amountoffsetx ~= nil and action.amountoffsetx ~= 0) then + position.x = position.x + (i * action.amountoffsetx) + else + position.x = position.x + (i * 0.5) + end - if(action.amountoffsety ~= nil and action.amountoffsety ~= 0) then - - position.y = position.y + (i * action.amountoffsety) - - end - end - spawnVehicleV2(chara,action.appearance,tag, position.x, position.y ,position.z,action.spawnlevel,action.spawn_system,action.isAV,action.appears_from_behind,false,action.wait_for_vehicle, action.scriptlevel, action.wait_for_vehicle_second,action.fakeav,action.despawntimer,action.persiststate,action.persistspawn,action.alwaysspawned,action.spawninview,action.dontregister,rotation) - if(action.group ~= nil and action.group ~= "") then - - if(cyberscript.GroupManager[action.group] == nil and action.create_group_if_not_exist == true) then - local group = {} - group.tag = action.group - group.entities = {} - cyberscript.GroupManager[action.group] = group - logme(3,"group created") - - end - if(cyberscript.GroupManager[action.group] ~= nil) then - table.insert(cyberscript.GroupManager[action.group].entities,tag) - else - logme(3,"group with tag : "..action.group.." doesn't exist") - end - end - else - logme(10,getLang("see_action_novehicle")) - end - end - end - if(action.name == "entity_set_seat") then - SetSeat(action.tag, action.vehicle, action.waitforsit, action.seat) - end - if(action.name == "entity_set_seat_looked_av") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local entity = getEntityFromManagerById(entid) - if(entity ~= nil) then - local garagVeh = getVehiclefromCustomGarageTag(entity.tag) - if(garagVeh ~= nil and garagVeh.asAV == true) then - SetSeat(action.tag, entity.tag, true, action.seat) - end - end - end - end - if(action.name == "set_vehicule_to_garage") then - SetVehiculeToGarage(action.tweakid,action.enabled,action.asAV,action.tag,action.fakeAV) - end - if(action.name == "entity_unset_seat") then - UnsetSeat(action.tag, action.vehicle, action.waitforsit, action.seat) - end - if(action.name == "vehicle_follow_entity") then - - VehicleFollowEntity(action.vehicle, action.tag, action.distanceMin,action.distanceMax,action.useTraffic,action.useKinematic,action.needDriver,action.stopWhenTargetReached) - end - if(action.name == "vehicle_chase_entity") then - VehicleChaseEntity(action.vehicle, action.tag, action.min,action.max,action.startspeed) - end - if(action.name == "change_av_velocity") then - AVVelocity = action.value - end - if(action.name == "reset_av_velocity") then - AVVelocity = 0.005 - end - if(action.name == "vehicle_change_doors") then - VehicleDoors(action.tag,action.value) - end - if(action.name == "vehicle_force_brake") then - VehicleBrake(action.tag,action.value,false) - end - if(action.name == "vehicle_force_brake_until_stop") then - VehicleBrake(action.tag,action.value,true) - end - if(action.name == "vehicle_change_windows") then - VehicleWindows(action.tag,action.value) - end - if(action.name == "vehicle_detach_all_part") then - VehicleDetachAll(action.tag) - end - if(action.name == "vehicle_explose") then - VehicleDestroy(action.tag) - end - if(action.name == "vehicle_repair") then - VehicleRepair(action.tag) - end - if(action.name == "vehicle_honk_and_flash") then - VehicleHonkFlash(action.tag) - end - if(action.name == "vehicle_change_light") then - VehicleLights(action.tag,action.value) - end - if(action.name == "vehicle_change_engine") then - VehicleEngine(action.tag,action.value) - end - if(action.name == "vehicle_reset") then - VehicleReset(action.tag) - end - if(action.name == "vehicle_add_to_traffic") then - local vehiculeobj = getEntityFromManager(action.tag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(vehicule ~= nil) then - VehicleGoToXYZ(action.tag, 0,0,0 ,1,5,true) - end - end - if(action.name == "vehicle_go_to_position") then - local vehiculeobj = getTrueEntityFromManager(action.tag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(vehicule ~= nil) then - - - - - local position = getPositionFromParameter(action) - vehiculeobj.destination = position - VehicleGoToXYZ(action.tag, position.x,position.y,position.z,action.minspeed,action.maxspeed,action.cleartraffic) - - end - end + if(action.amountoffsety ~= nil and action.amountoffsety ~= 0) then + + position.y = position.y + (i * action.amountoffsety) + + end + end + spawnVehicleV2(chara,action.appearance,tag, position.x, position.y ,position.z,action.spawnlevel,action.spawn_system,action.isAV,action.appears_from_behind,false,action.wait_for_vehicle, action.scriptlevel, action.wait_for_vehicle_second,action.fakeav,action.despawntimer,action.persiststate,action.persistspawn,action.alwaysspawned,action.spawninview,action.dontregister,rotation) + if(action.group ~= nil and action.group ~= "") then + + if(cyberscript.GroupManager[action.group] == nil and action.create_group_if_not_exist == true) then + local group = {} + group.tag = action.group + group.entities = {} + cyberscript.GroupManager[action.group] = group + logme(3,"group created") + + end + if(cyberscript.GroupManager[action.group] ~= nil) then + table.insert(cyberscript.GroupManager[action.group].entities,tag) + else + logme(3,"group with tag : "..action.group.." doesn't exist") + end + end + else + logme(10,getLang("see_action_novehicle")) + end + end + end + if(action.name == "entity_set_seat") then + SetSeat(action.tag, action.vehicle, action.waitforsit, action.seat) + end + if(action.name == "entity_set_seat_looked_av") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local entity = getEntityFromManagerById(entid) + if(entity ~= nil) then + local garagVeh = getVehiclefromCustomGarageTag(entity.tag) + if(garagVeh ~= nil and garagVeh.asAV == true) then + SetSeat(action.tag, entity.tag, true, action.seat) + end + end + end + end + if(action.name == "set_vehicule_to_garage") then + SetVehiculeToGarage(action.tweakid,action.enabled,action.asAV,action.tag,action.fakeAV) + end + if(action.name == "entity_unset_seat") then + UnsetSeat(action.tag, action.vehicle, action.waitforsit, action.seat) + end + if(action.name == "vehicle_follow_entity") then + + VehicleFollowEntity(action.vehicle, action.tag, action.distanceMin,action.distanceMax,action.useTraffic,action.useKinematic,action.needDriver,action.stopWhenTargetReached) + end + if(action.name == "vehicle_chase_entity") then + VehicleChaseEntity(action.vehicle, action.tag, action.min,action.max,action.startspeed) + end + if(action.name == "change_av_velocity") then + AVVelocity = action.value + end + if(action.name == "reset_av_velocity") then + AVVelocity = 0.005 + end + if(action.name == "vehicle_change_doors") then + VehicleDoors(action.tag,action.value) + end + if(action.name == "vehicle_force_brake") then + VehicleBrake(action.tag,action.value,false) + end + if(action.name == "vehicle_force_brake_until_stop") then + VehicleBrake(action.tag,action.value,true) + end + if(action.name == "vehicle_change_windows") then + VehicleWindows(action.tag,action.value) + end + if(action.name == "vehicle_detach_all_part") then + VehicleDetachAll(action.tag) + end + if(action.name == "vehicle_explose") then + VehicleDestroy(action.tag) + end + if(action.name == "vehicle_repair") then + VehicleRepair(action.tag) + end + if(action.name == "vehicle_honk_and_flash") then + VehicleHonkFlash(action.tag) + end + if(action.name == "vehicle_change_light") then + VehicleLights(action.tag,action.value) + end + if(action.name == "vehicle_change_engine") then + VehicleEngine(action.tag,action.value) + end + if(action.name == "vehicle_reset") then + VehicleReset(action.tag) + end + if(action.name == "vehicle_add_to_traffic") then + -- B-12 fix: the original handler hard-coded VehicleGoToXYZ(tag, 0,0,0, 1, 5, true) + -- with no way to override min/max speed or destination, while the + -- comparable vehicle_go_to_position action exposed all three. + -- Now reads optional action.minspeed / action.maxspeed / action.x|y|z + -- (and action.position via getPositionFromParameter), defaulting + -- to the historical values so existing JSON actions keep working. + local vehiculeobj = getEntityFromManager(action.tag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(vehicule ~= nil) then + local minspeed = action.minspeed or action.min_speed or 1 + local maxspeed = action.maxspeed or action.max_speed or 5 + local cleartraffic = action.cleartraffic + if cleartraffic == nil then cleartraffic = true end + local position = getPositionFromParameter(action) + if position == nil then + position = { x = 0, y = 0, z = 0 } + end + VehicleGoToXYZ(action.tag, position.x, position.y, position.z, minspeed, maxspeed, cleartraffic) + end + end + if(action.name == "vehicle_go_to_position") then + local vehiculeobj = getTrueEntityFromManager(action.tag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(vehicule ~= nil) then + + + + + local position = getPositionFromParameter(action) + vehiculeobj.destination = position + VehicleGoToXYZ(action.tag, position.x,position.y,position.z,action.minspeed,action.maxspeed,action.cleartraffic) + + end + end - if(action.name == "vehicle_cancel_last_cmd") then - local vehiculeobj = getTrueEntityFromManager(action.tag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(vehicule ~= nil) then - - - - - - VehicleCancelLastCommand(action.tag) - - end - end + if(action.name == "vehicle_cancel_last_cmd") then + local vehiculeobj = getTrueEntityFromManager(action.tag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(vehicule ~= nil) then + + + + + + VehicleCancelLastCommand(action.tag) + + end + end - if(action.name == "vehicle_toggle_collision") then - local vehiculeobj = getTrueEntityFromManager(action.tag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(vehicule ~= nil) then - - - - - - VehicleToggleCollision(action.tag,action.value) - - end - end - if(action.name == "vehicle_set_invincible") then - VehicleSetInvincible(action.tag) - end - if(action.name == "vehicle_go_to_current_fasttravel_point") then - local vehiculeobj = getTrueEntityFromManager(action.tag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(vehicule ~= nil and ActiveFastTravelMappin ~= nil) then - - vehiculeobj.destination = ActiveFastTravelMappin.position - VehicleGoToGameNode(action.tag, ActiveFastTravelMappin.markerRef, action.speed, action.forcegreenlight, action.needdriver, action.usetraffic, action.useKinematic) - - end - end - if(action.name == "vehicle_go_to_current_mappin_point") then - local vehiculeobj = getTrueEntityFromManager(action.tag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(vehicule ~= nil and mappinManager["selected_mappin"] ~= nil) then - - - vehiculeobj.destination = mappinManager["selected_mappin"].position - - local mappin = mappinManager["selected_mappin"].position - VehicleGoToXYZ(action.tag, mappin.x,mappin.y,mappin.z,action.minspeed,action.maxspeed,false) - - end - end - if(action.name == "vehicle_go_to_fasttravel_point") then - local vehiculeobj = getEntityFromManager(action.tag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(vehicule ~= nil) then - local markerref = nil - local position = nil - for i=1, #mappedFastTravelPoint do - local point = mappedFastTravelPoint[i] - if(point.markerref == action.destination) then - markerref = point.markerrefdata - position = point.position - end - if(markerref ~= nil) then - vehiculeobj.destination =position - VehicleGoToGameNode(action.tag, markerref, action.speed, action.forcegreenlight, action.needdriver, action.usetraffic) - end - end - end - end - if(action.name == "vehicle_go_to_fasttravel_point_from_mappin") then - local mappin = getMappinByTag(tag) - local vehiculeobj = getTrueEntityFromManager(action.tag) - local vehicule = Game.FindEntityByID(vehiculeobj.id) - if(mappin)then - if(vehicule ~= nil) then - vehiculeobj.destination =position - VehicleGoToGameNode(action.tag, point.markerrefdata, action.speed, action.forcegreenlight, action.needdriver, action.usetraffic) - end - end - end - end - - if scoreregion then - - if(action.name == "do_math") then - local score = tonumber(action.value) - local score2 = tonumber(action.modifier) - if(score == nil) then score = 0 end - - if(action.operator == "+") then - score = score + score2 - end - if(action.operator == "-") then - score = score - score2 - end - if(action.operator == "*") then - score = score * score2 - end - if(action.operator == "/") then - score = score / score2 - end - if(action.operator == "floor") then - score = math.floor(score) - end - if(action.operator == "ceil") then - score = math.ceil(score) - end - if(action.operator == "positive") then - if(score > 0) then - score = 0 + score - else - score = 0 - score - end - end - if(action.operator == "negative") then - if(score > 0) then - score = 0 - score - else - score = 0 + score - end - end - if(action.operator == "random") then - score = math.random(action.min,action.max) - end - - if(action.store ~= nil) then - - setScore(action.store.score,action.store.key,score) - - end - - - end - - if(action.name == "set_variable") then - local text = action.value + if(action.name == "vehicle_toggle_collision") then + local vehiculeobj = getTrueEntityFromManager(action.tag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(vehicule ~= nil) then + + + + + + VehicleToggleCollision(action.tag,action.value) + + end + end + if(action.name == "vehicle_set_invincible") then + VehicleSetInvincible(action.tag) + end + if(action.name == "vehicle_go_to_current_fasttravel_point") then + local vehiculeobj = getTrueEntityFromManager(action.tag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(vehicule ~= nil and ActiveFastTravelMappin ~= nil) then + + vehiculeobj.destination = ActiveFastTravelMappin.position + VehicleGoToGameNode(action.tag, ActiveFastTravelMappin.markerRef, action.speed, action.forcegreenlight, action.needdriver, action.usetraffic, action.useKinematic) + + end + end + if(action.name == "vehicle_go_to_current_mappin_point") then + local vehiculeobj = getTrueEntityFromManager(action.tag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(vehicule ~= nil and mappinManager["selected_mappin"] ~= nil) then + + + vehiculeobj.destination = mappinManager["selected_mappin"].position + + local mappin = mappinManager["selected_mappin"].position + VehicleGoToXYZ(action.tag, mappin.x,mappin.y,mappin.z,action.minspeed,action.maxspeed,false) + + end + end + if(action.name == "vehicle_go_to_fasttravel_point") then + local vehiculeobj = getEntityFromManager(action.tag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(vehicule ~= nil) then + local markerref = nil + local position = nil + for i=1, #mappedFastTravelPoint do + local point = mappedFastTravelPoint[i] + if(point.markerref == action.destination) then + markerref = point.markerrefdata + position = point.position + end + if(markerref ~= nil) then + vehiculeobj.destination =position + VehicleGoToGameNode(action.tag, markerref, action.speed, action.forcegreenlight, action.needdriver, action.usetraffic) + end + end + end + end + if(action.name == "vehicle_go_to_fasttravel_point_from_mappin") then + local mappin = getMappinByTag(tag) + local vehiculeobj = getTrueEntityFromManager(action.tag) + local vehicule = safeFindEntityByID(vehiculeobj.id) + if(mappin)then + if(vehicule ~= nil) then + vehiculeobj.destination =position + VehicleGoToGameNode(action.tag, point.markerrefdata, action.speed, action.forcegreenlight, action.needdriver, action.usetraffic) + end + end + end + end + + if scoreregion then + + if(action.name == "do_math") then + local score = tonumber(action.value) + local score2 = tonumber(action.modifier) + if(score == nil) then score = 0 end + + if(action.operator == "+") then + score = score + score2 + end + if(action.operator == "-") then + score = score - score2 + end + if(action.operator == "*") then + score = score * score2 + end + if(action.operator == "/") then + score = score / score2 + end + if(action.operator == "floor") then + score = math.floor(score) + end + if(action.operator == "ceil") then + score = math.ceil(score) + end + if(action.operator == "positive") then + if(score > 0) then + score = 0 + score + else + score = 0 - score + end + end + if(action.operator == "negative") then + if(score > 0) then + score = 0 - score + else + score = 0 + score + end + end + if(action.operator == "random") then + score = math.random(action.min,action.max) + end + + if(action.store ~= nil) then + + setScore(action.store.score,action.store.key,score) + + end + + + end + + if(action.name == "set_variable") then + local text = action.value - if(action.type ~= nil and action.type == "lang") then - text = getLang(action.value) - end - - setVariable(action.variable,action.key,text) - end - - - if(action.name == "concate_variable") then - local var = getVariableKey(action.variable,action.key) - var = var .. action.value - setVariable(action.variable,action.key,var) - end - - - - if(action.name == "operate_score") then - local score = getScoreKey(action.score,action.key) - if(score == nil) then score = 0 end - - if(action.operator == "+") then - score = score + action.value - end - if(action.operator == "-") then - score = score - action.value - end - if(action.operator == "*") then - score = score * action.value - end - if(action.operator == "/") then - score = score / action.value - end - if(action.operator == "positive") then - if(score > 0) then - score = 0 + score - else - score = 0 - score - end - end - if(action.operator == "negative") then - if(score > 0) then - score = 0 - score - else - score = 0 + score - end - end - if(action.operator == "random") then - score = math.random(action.min,action.max) - end - if(action.operator == "floor") then - score = math.floor(score) - end - if(action.operator == "ceil") then - score = math.ceil(score) - end - - - setScore(action.score,action.key,score) - end - - - - - - end - - if houseregion then - if(action.name == "change_house_statut") then - - setScore(action.value,"Statut",action.score) - end - if(action.name == "change_house_score") then - - setScore(action.value,"Score",action.score) - end - - - - if(action.name == "open_placed_item_ui") then - if currentHouse ~= nil then - if(getHouseStatut(currentHouse.tag) == 1) then - PlacedItemsUI() - end - end - end - if(action.name == "open_buyed_item_ui") then - if currentHouse ~= nil then - if(getHouseStatut(currentHouse.tag) == 1) then - - BuyedItemsUI() - end - end - end - if(action.name == "move_looked_item_to_player_position") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local obj = getItemEntityFromManager(entid) - if(obj == nil) then - obj = getItemEntityFromManagerByPlayerLookinAt() - end - if(obj ~= nil) then - local objpos = Game.GetPlayer():GetWorldPosition() - local qat = Game.GetPlayer():GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - updateItemPosition(obj, objpos, angle, true) - end - end - end - if(action.name == "move_looked_item_Z") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local obj = getItemEntityFromManager(entid) - if(obj == nil) then - obj = getItemEntityFromManagerByPlayerLookinAt() - end - if(obj ~= nil) then - local objpos = objLook:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - objpos.z = objpos.z + action.value - local qat = objLook:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - updateItemPosition(obj, objpos, angle, true) - else - logme(3,"null") - end - end - end - if(action.name == "move_looked_item_X") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local obj = getItemEntityFromManager(entid) - if(obj == nil) then - obj = getItemEntityFromManagerByPlayerLookinAt() - end - if(obj ~= nil) then - local objpos = objLook:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - objpos.x = objpos.x + action.value - local qat = objLook:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - updateItemPosition(obj, objpos, angle, true) - end - end - end - if(action.name == "move_looked_item_Y") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local obj = getItemEntityFromManager(entid) - if(obj == nil) then - obj = getItemEntityFromManagerByPlayerLookinAt() - end - if(obj ~= nil) then - local objpos = objLook:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - objpos.y = objpos.y + action.value - local qat = objLook:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - updateItemPosition(obj, objpos, angle, true) - end - end - end - if(action.name == "yaw_looked_item") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local obj = getItemEntityFromManager(entid) - if(obj == nil) then - obj = getItemEntityFromManagerByPlayerLookinAt() - end - if(obj ~= nil) then - local objpos = objLook:GetWorldPosition() - local qat = objLook:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - angle.yaw = angle.yaw + action.value - updateItemPosition(obj, objpos, angle, true) - end - end - end - if(action.name == "roll_looked_item") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local entity = getItemEntityFromManager(entid) - if(entity == nil) then - entity = getItemEntityFromManagerByPlayerLookinAt() - end - if(entity ~= nil) then - local worldpos = entity:GetWorldTransform() - local pos = worldpos.Position:ToVector4(worldpos.Position) - local qat = worldpos:GetOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - angle.roll = angle.roll + action.value - updateItemPosition(obj, pos, angle) - end - end - end - if(action.name == "pitch_looked_item") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local entity = getItemEntityFromManager(entid) - if(entity == nil) then - entity = getItemEntityFromManagerByPlayerLookinAt() - end - if(entity ~= nil) then - local worldpos = entity:GetWorldTransform() - local pos = worldpos.Position:ToVector4(worldpos.Position) - local qat = worldpos:GetOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - angle.roll = angle.roll + action.value - updateItemPosition(obj, pos, angle) - end - end - end - if(action.name == "set_item") then - if grabbedTarget ~= nil then - -- tp:Teleport(grabbedTarget, targetPos, targetAngle) - -- if(Game.FindEntityByID(selectedItem.entityId):IsA('gameObject') == false)then - -- grabbedTarget:Destroy() - -- end - updateItemPosition(selectedItem, targetPos, targetAngle,true) - grabbedTarget = nil - grabbed = false - objPush = false - objPull = false - enabled = false - id = false - end - end - if(action.name == "looked_item_remove") then - if objLook ~= nil then - tarName = objLook:ToString() - appName = Game.NameToString(objLook:GetCurrentAppearanceName()) - dipName = objLook:GetDisplayName() - local entid = objLook:GetEntityID() - local entity = getItemEntityFromManager(entid) - if(entity == nil) then - entity = getItemEntityFromManagerByPlayerLookinAt() - end - -- if(entity ~= nil) then - logme(3,entity.Tag) - logme(3,entity.Tag) - logme(3,#currentSave.arrayPlayerItems) - for i =1, #currentSave.arrayPlayerItems do - local mitem = currentSave.arrayPlayerItems[i] - logme(3,mitem.Tag) - if(mitem.Tag == entity.Tag) then - local housingitem = getHousing(entity.Tag,entity.X,entity.Y,entity.Z) - deleteHousing(housingitem.Id) - updatePlayerItemsQuantity(mitem,1) - despawnItem(entid) - end - end - else - logme(3,"nope") - end - end - - if(action.name == "grab_select_item") then - if selectedItem ~= nil then - enabled = true - id = true - grabbedTarget = Game.FindEntityByID(selectedItem.entityId) - if(grabbedTarget:IsA('gameObject') == false)then - grabbedTarget = nil - grabbed = false - objPush = false - objPull = false - enabled = false - id = false - --Game.GetPlayer():SetWarningMessage(getLang(action.value)) - -- local objpos = grabbedTarget:GetWorldPosition() - -- local worldpos = Game.GetPlayer():GetWorldTransform() - -- local qat = grabbedTarget:GetWorldOrientation() - -- local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - -- local transform = Game.GetPlayer():GetWorldTransform() - -- transform:SetPosition(objpos) - -- transform:SetOrientationEuler(angle) - -- grabbedTarget = WorldFunctionalTests.SpawnEntity("base\\items\\interactive\\dining_accessories\\int_dining_accessories_001__bar_asset_h_sponge.ent", transform, '') - end - Cron.After(0.7,function() - if (grabbedTarget ~= nil) then - targetPos = grabbedTarget:GetWorldPosition() - targetAngle = Vector4.ToRotation(grabbedTarget:GetWorldForward()) - objectDist = Vector4.Distance(targetPos, playerPos) - phi = math.atan2(playerAngle.y, playerAngle.x) - targetDeltaPos = Vector4.new(((objectDist * math.cos(phi)) + playerPos.x), ((objectDist * math.sin(phi)) + playerPos.y), (objectDist * math.sin(playerAngle.z) + playerPos.z), targetPos.w) - targetDeltaPos = Delta(targetDeltaPos, targetPos) - logme(3,grabbedTarget, "grabbed.") - grabbed = true - else - logme(3,"No target!") - end - end) - end - end - if(action.name == "select_item") then - if(#currentItemSpawned > 0 )then - for i = 1, #currentItemSpawned do - local mitems = currentItemSpawned[i] - if(mitems.Id == action.value) then - selectedItem = nil - selectedItem = mitems - if(selectedItem.entityId ~= nil and Game.FindEntityByID(selectedItem.entityId) ~=nil and Game.FindEntityByID(selectedItem.entityId):IsA('gameObject') == true)then - grabbedTarget = Game.FindEntityByID(selectedItem.entityId) - enabled = true - id = true - if (grabbedTarget ~= nil) then - targetPos = grabbedTarget:GetWorldPosition() - targetAngle = Vector4.ToRotation(grabbedTarget:GetWorldForward()) - objectDist = Vector4.Distance(targetPos, playerPos) - phi = math.atan2(playerAngle.y, playerAngle.x) - targetDeltaPos = Vector4.new(((objectDist * math.cos(phi)) + playerPos.x), ((objectDist * math.sin(phi)) + playerPos.y), (objectDist * math.sin(playerAngle.z) + playerPos.z), targetPos.w) - targetDeltaPos = Delta(targetDeltaPos, targetPos) - logme(3,grabbedTarget, "grabbed.") - grabbed = true - else - logme(3,"No target!") - end - end - end - end - end - end - if(action.name == "unselect_item") then - selectedItem = nil - grabbedTarget = nil - grabbed = false - objPush = false - objPull = false - enabled = false - id = false - end - if(action.name == "move_select_item_to_player_position") then - if selectedItem ~= nil then - local objpos = Game.GetPlayer():GetWorldPosition() - local qat = Game.GetPlayer():GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - updateItemPosition(selectedItem, objpos, angle, true) - end - end - if(action.name == "move_selected_item_Z") then - if selectedItem ~= nil then - local entity = Game.FindEntityByID(selectedItem.entityId) - if(entity ~= nil) then - local objpos = entity:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - objpos.z = objpos.z + action.value - local qat = entity:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - updateItemPosition(selectedItem, objpos, angle, true) - end - end - end - if(action.name == "move_selected_item_X") then - if selectedItem ~= nil then - local entity = Game.FindEntityByID(selectedItem.entityId) - if(entity ~= nil) then - local objpos = entity:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - objpos.x = objpos.x + action.value - local qat = entity:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - updateItemPosition(selectedItem, objpos, angle, true) - end - end - end - if(action.name == "move_selected_item_Y") then - if selectedItem ~= nil then - local entity = Game.FindEntityByID(selectedItem.entityId) - if(entity ~= nil) then - local objpos = entity:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - objpos.y = objpos.y + action.value - local qat = entity:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - updateItemPosition(selectedItem, objpos, angle, true) - end - end - end - if(action.name == "yaw_selected_item") then - if selectedItem ~= nil then - local entity = Game.FindEntityByID(selectedItem.entityId) - if(entity ~= nil) then - local objpos = entity:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - local qat = entity:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - angle.yaw = angle.yaw + action.value - updateItemPosition(selectedItem, objpos, angle, true) - end - end - end - if(action.name == "roll_selected_item") then - if selectedItem ~= nil then - local entity = Game.FindEntityByID(selectedItem.entityId) - if(entity ~= nil) then - local objpos = entity:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - local qat = entity:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - angle.roll = angle.roll + action.value - updateItemPosition(selectedItem, objpos, angle, true) - end - end - end - if(action.name == "pitch_selected_item") then - if selectedItem ~= nil then - local entity = Game.FindEntityByID(selectedItem.entityId) - if(entity ~= nil) then - local objpos = entity:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - local qat = entity:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - angle.pitch = angle.pitch + action.value - updateItemPosition(selectedItem, objpos, angle, true) - end - end - end - if(action.name == "selected_item_remove") then - if selectedItem ~= nil then - local entity = Game.FindEntityByID(selectedItem.entityId) - if(entity ~= nil) then - for i =1, #currentSave.arrayPlayerItems do - local mitem = currentSave.arrayPlayerItems[i] - if(mitem.Tag == selectedItem.Tag) then - Game.FindEntityByID(selectedItem.entityId):GetEntity():Destroy() - logme(3,"toto") - updatePlayerItemsQuantity(mitem,1) - deleteHousing(selectedItem.Id) - local index = getItemEntityIndexFromManager(selectedItem.entityId) - --despawnItem(selectedItem.Id) - table.remove(currentItemSpawned,index) - Cron.After(1, function() - selectedItem = nil - end) - end - end - else - logme(3,"nope") - end - end - end - if(action.name == "spawn_buyed_item") then - if action.tag ~= nil then - local pos = Game.GetPlayer():GetWorldPosition() - local angles = GetSingleton('Quaternion'):ToEulerAngles(Game.GetPlayer():GetWorldOrientation()) - local spawnedItem = {} - local mitems = getPlayerItemsbyTag(action.tag) - if(currentHouse ~= nil and mitems ~= nil and mitems.Quantity > 0 and (string.match(tostring(mitems.Tag), "AMM_Props.") == nil or (string.match(tostring(mitems.Tag), "AMM_Props.") ~= nil and AMM ~= nil) ) ) then - spawnedItem.Tag = mitems.Tag - spawnedItem.HouseTag = currentHouse.tag - spawnedItem.ItemPath = mitems.Path - spawnedItem.X = pos.x - spawnedItem.Y = pos.y - spawnedItem.Z = pos.z - spawnedItem.Yaw = angles.yaw - spawnedItem.Pitch = angles.pitch - spawnedItem.Roll = angles.roll - spawnedItem.Title = mitems.Title - spawnedItem.fromTemplate = false - saveHousing(spawnedItem) - local housing = getHousing(spawnedItem.Tag,spawnedItem.X,spawnedItem.Y,spawnedItem.Z) - spawnedItem.Id = housing.Id - updatePlayerItemsQuantity(mitems,-1) - spawnedItem.entityId = spawnItem(spawnedItem, pos, angles) - local entity = Game.FindEntityByID(spawnedItem.entityId) - local components = checkForValidComponents(entity) - if components then - local visualScale = checkDefaultScale(components) - spawnedItem.defaultScale = { - x = visualScale.x * 100, - y = visualScale.x * 100, - z = visualScale.x * 100, - } - spawnedItem.scale = { - x = visualScale.x * 100, - y = visualScale.y * 100, - z = visualScale.z * 100, - } - end - table.insert(currentItemSpawned,spawnedItem) - selectedItem = spawnedItem - end - end - end - if(action.name == "despawn_placed_item") then - if action.tag ~= nil then - local pos = Game.GetPlayer():GetWorldPosition() - local angles = GetSingleton('Quaternion'):ToEulerAngles(Game.GetPlayer():GetWorldOrientation()) - local spawnedItem = {} - if(currentHouse ~= nil)then - local entity = getItemByHouseTagandTagFromManager(action.tag,currentHouse.tag) - if(entity ~= nil) then - for i =1, #currentSave.arrayPlayerItems do - local mitem = currentSave.arrayPlayerItems[i] - if(mitem.Tag == entity.Tag) then - local housingitem = getHousing(entity.Tag,entity.X,entity.Y,entity.Z) - despawnItem(entity.entityId) - deleteHousing(housingitem.Id) - updatePlayerItemsQuantity(mitem,1) - end - end - else - logme(3,"nope") - end - end - end - end - if(action.name == "current_place_clear_all_item") then - - if(currentHouse ~=nil) then - if(#currentItemSpawned > 0) then - - - for i=1,#currentItemSpawned do - - deleteHousing(currentItemSpawned[i].Id) - - - end - - despawnItemFromHouse() - - end - end - - end - if(action.name == "scale_selected_item") then - if selectedItem ~= nil then - local entity = Game.FindEntityByID(selectedItem.entityId) - if(entity ~= nil) then - local values = Vector3.new(action.x, action.y, action.z) - setItemScale(entity, values) - end - end - end - - - - if(action.name == "current_place_apply_template") then - - currentHouseApplyTemplate(action.tag,action.x,action.y,action.z) - - end - - if(action.name == "current_place_clear_all_template") then - currentHouseClearAllTemplate() - - end - - - if(action.name == "current_place_clear_template") then - - - currentHouseClearTemplate(action.tag) - - end - - end - - if gangregion then - if(action.name == "gang_affinity") then - local score = getScoreKey("Affinity",action.value) - if(score == nil) then - score = 0 - setScore("Affinity",action.value,score) - end - score = score + action.score - setScore("Affinity",action.value,score) - end - if(action.name == "add_gang_district_score") then - local score = getVariableKeyWithDefault(action.faction,action.district,0) - setVariable(action.faction,action.district,score + action.value) - end - if(action.name == "remove_gang_district_score") then - local score = getVariableKeyWithDefault(action.faction,action.district,0) - setVariable(action.faction,action.district,score - action.value) - end - if(action.name == "set_gang_district_score") then - setVariable(action.faction,action.district,action.value) - end - if(action.name == "gang_affinity_from_current_district_leader") then - local gangs = getGangfromDistrict(currentDistricts2.tag,20) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - local score = getScoreKey("Affinity",gang.tag) - if(score == nil) then - score = 0 - setScore("Affinity",gang.tag,score) - end - score = score + action.score - setScore("Affinity",gang.tag,score) - end - end - if(action.name == "gang_affinity_from_current_district_leader_rival") then - - local gangs = getGangfromDistrict(currentDistricts2.Tag,20) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - local rivalindex = math.random(1,#gang.rivals) - gang = getFactionByTag(gang.rivals[rivalindex]) - local score = getScoreKey("Affinity",gang.tag) - if(score == nil) then - score = 0 - setScore("Affinity",gang.tag,score) - end - score = score + action.score - setScore("Affinity",gang.tag,score) - end - end - if(action.name == "gang_affinity_from_current_subdistrict_leader") then - if #currentDistricts2.districtLabels > 0 then - for i, test in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - local gangs = getGangfromDistrict(test,20) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - local score = getScoreKey(gang.tag,"Score") - if(score == nil) then - score = 0 - setScore("Affinity",gang.tag,score) - end - score = score + action.score - setScore("Affinity",gang.tag,score) - break - end - end - end - end - end - if(action.name == "gang_affinity_from_current_subdistrict_leader_rival") then - if #currentDistricts2.districtLabels > 0 then - for i, test in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - local gangs = getGangfromDistrict(test,20) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - local rivalindex = math.random(1,#gang.rivals) - gang = getFactionByTag(gang.rivals[rivalindex]) - local score = getScoreKey("Affinity",gang.tag) - if(score == nil) then - score = 0 - setScore("Affinity",gang.tag,score) - end - score = score + action.score - setScore("Affinity",gang.tag,score) - break - end - end - end - end - end - - - if(action.name == "add_gang_currentdistrict_score") then - if currentDistricts2 ~= nil then - - local score = getVariableKeyWithDefault(action.faction,currentDistricts2.Tag,0) - setVariable(action.faction,currentDistricts2.Tag, score + action.value) - - end - end - if(action.name == "remove_gang_currentdistrict_score") then - if currentDistricts2 ~= nil then - local score = getVariableKeyWithDefault(action.faction,currentDistricts2.Tag,0) - setVariable(action.faction,currentDistricts2.Tag, score + action.value) - end - end - if(action.name == "add_leader_currentdistrict_score") then - if currentDistricts2 ~= nil then - local gangs = getGangfromDistrict(currentDistricts2.Tag,20) - if(#gangs > 0) then - - - local score = getVariableKeyWithDefault(gangs[1].tag,currentDistricts2.Tag,0) - setVariable(gangs[1].tag,currentDistricts2.Tag, score + action.value) - end - end - end - if(action.name == "remove_leader_currentdistrict_score") then - if currentDistricts2 ~= nil then - local gangs = getGangfromDistrict(currentDistricts2.Tag,20) - if(#gangs > 0) then - local score = getVariableKeyWithDefault(gangs[1].tag,currentDistricts2.Tag,0) - setVariable(gangs[1].tag,currentDistricts2.Tag, score - action.value) - end - end - end - if(action.name == "add_leader_currentsubdistrict_score") then - if #currentDistricts2.districtLabels > 0 then - for i, test in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - local gangs = getGangfromDistrict(test,20) - if(#gangs > 0) then - - local score = getVariableKeyWithDefault(gangs[1].tag,test,0) - setVariable(gangs[1].tag,test, score + action.value) - break - end - end - end - end - end - if(action.name == "remove_leader_currentsubdistrict_score") then - if #currentDistricts2.districtLabels > 0 then - for i, test in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - local gangs = getGangfromDistrict(test,20) - if(#gangs > 0) then - - local score = getVariableKeyWithDefault(gangs[1].tag,test,0) - setVariable(gangs[1].tag,test, score - action.value) - break - end - end - end - end - end - if(action.name == "set_gang_currentdistrict_score") then - if currentDistricts2 ~= nil then - - setVariable(action.faction,currentDistricts2.Tag, action.value) - end - end - if(action.name == "add_gang_currentsubdistrict_score") then - if #currentDistricts2.districtLabels > 0 then - for i, test in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - local score = getVariableKeyWithDefault(action.faction,test,0) - setVariable(action.faction,test, score + action.value) - break - end - end - end - end - if(action.name == "remove_gang_currentsubdistrict_score") then - if #currentDistricts2.districtLabels > 0 then - for i, test in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - local score = getVariableKeyWithDefault(action.faction,test,0) - setVariable(action.faction,test, score - action.value) - break - end - end - end - end - if(action.name == "set_gang_currentsubdistrict_score") then - if #currentDistricts2.districtLabels > 0 then - for i, test in ipairs(currentDistricts2.districtLabels) do - if i > 1 then - local score = getVariableKeyWithDefault(action.faction,test,0) - setVariable(action.faction,test,action.value) - break - end - end - end - end - if(action.name == "trigger_edit_crew_mode") then - inCrewManager = action.value - end - if(action.name == "set_player_current_gang") then - setVariable("player","current_gang",action.tag) - end - if(action.name == "set_gang_relation") then - - if(action.tag == "player") then - - action.tag = getVariableKey("player","current_gang") - - end - - - if(action.mode == "gang") then - - - if(action.target ~= action.tag) then - - setFactionRelation(action.tag,action.target,action.score) - - end - - end - - if(action.mode == "district_leader" or action.mode == "district_subleader") then - - local gangs = getGangfromDistrict(action.target,20) - if(#gangs > 0) then - - if(gangs[1].tag ~= action.tag) then - - setFactionRelation(action.tag,gangs[1].tag,action.score) - - end - end - - - end - - if(action.mode == "current_district_leader") then - - if currentDistricts2 ~= nil then - local gangs = getGangfromDistrict(currentDistricts2.Tag,20) - if(#gangs > 0) then - setFactionRelation(action.tag,gangs[1].tag,action.score) - - end - end - - end - - if(action.mode == "current_district_subleader") then - if currentDistricts2 ~= nil then - if #currentDistricts2.districtLabels > 0 and #currentDistricts2.districtLabels > 1 then - local gangs = getGangfromDistrict(currentDistricts2.districtLabels[2],20) - if(#gangs > 0) then - setFactionRelation(action.tag,gangs[1].tag,action.score) - - end - end - end - - end - - end - - if(action.name == "add_gang_relation") then - - if(action.tag == "player") then - - action.tag = getVariableKey("player","current_gang") - - end - - - if(action.mode == "gang") then - - - if(action.target ~= action.tag) then - - addFactionRelation(action.tag,action.target,action.score) - - end - - end - - if(action.mode == "district_leader" or action.mode == "district_subleader") then - - local gangs = getGangfromDistrict(action.target,20) - if(#gangs > 0) then - - if(gangs[1].tag ~= action.tag) then - - addFactionRelation(action.tag,gangs[1].tag,action.score) - - end - end - - - end - - if(action.mode == "current_district_leader") then - - if currentDistricts2 ~= nil then - local gangs = getGangfromDistrict(currentDistricts2.Tag,20) - if(#gangs > 0) then - addFactionRelation(action.tag,gangs[1].tag,action.score) - - end - end - - end - - if(action.mode == "current_district_subleader") then - if currentDistricts2 ~= nil then - if #currentDistricts2.districtLabels > 0 and #currentDistricts2.districtLabels > 1 then - local gangs = getGangfromDistrict(currentDistricts2.districtLabels[2],20) - if(#gangs > 0) then - addFactionRelation(action.tag,gangs[1].tag,action.score) - - end - end - end - - end - - end - end - - if miscregion then - if(action.name == "set_fact") then - - Game.GetQuestsSystem():SetFactStr(action.value, action.score) - - end - if(action.name == "refresh_shard_cache") then - local activeData = CodexListSyncData.new() - local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) - if gameshardscompiled == nil then gameshardscompiled = {} end - for i,v in pairs(gameshards) do - if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end - - - end - end - if(action.name == "execute_in_tick") then - - if(#action.action > 0) then - for i,act in ipairs(action.action) do - - executeAction(act,tag,parent,index,source,executortag) - - end - end - - end - if(action.name == "load_interact") then - - if(#loadInteract < 4 and (table_contains(loadInteract,action.tag,false) == false))then - table.insert(loadInteract,action.tag) - - createInteraction(false) - candisplayInteract = true - createInteraction(true) - cycleInteract() - else - if((table_contains(loadInteract,action.tag,false) == false)) then - error("There is already 4 force loaded interact. Limit is reached !") - end - end - end - - if(action.name == "unload_interact") then - if(#loadInteract > 0 and (table_contains(loadInteract,action.tag,false) == true)) then - local indextoremove = nil - for i,v in ipairs(loadInteract) do - - if(v == action.tag) then - - indextoremove = i - - end - - end - - - if(indextoremove ~= nil) then - - table.remove(loadInteract,indextoremove) - - end - - end - candisplayInteract = false - createInteraction(false) - end - - if(action.name == "clean_all_loaded_interact") then - loadInteract = {} - candisplayInteract = false - createInteraction(false) - end - - if(action.name == "buy_item") then - local player = Game.GetPlayer() - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new("Items.money") - local itemid = ItemID.new(tid) - local amount = tonumber(action.price..".000") - if currentHouse ~= nil and currentHouse.coef ~=nil and currentHouse.coef > 0 then - amount = amount * currentHouse.coef - end - if currentStar ~= nil then - amount = amount * 2 - end - local result = ts:RemoveItem(player, itemid, amount) - ------logme(3,"remove money") - local player = Game.GetPlayer() - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new(action.value) - local itemid = ItemID.new(tid) - local result = ts:GiveItem(player, itemid, tonumber(action.amount)) - ------logme(3,"give item") - end - if(action.name == "give_item") then - local player = Game.GetPlayer() - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new(action.value) - local itemid = ItemID.new(tid) - local result = ts:GiveItem(player, itemid, tonumber(action.amount)) - ------logme(3,"give item") - end - if(action.name == "remove_item") then - local player = Game.GetPlayer() - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new(action.value) - local itemid = ItemID.new(tid) - local result = ts:RemoveItem(player, itemid, tonumber(action.amount)) - end - if(action.name == "give_money") then - local player = Game.GetPlayer() - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new("Items.money") - local itemid = ItemID.new(tid) - local amount = tonumber(action.value..".000") - if currentHouse ~= nil and currentHouse.coef ~= nil then - amount = amount * currentHouse.coef - end - local result = ts:GiveItem(player, itemid, amount) - ------logme(3,"give money") - end - if(action.name == "remove_money") then - local player = Game.GetPlayer() - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new("Items.money") - local itemid = ItemID.new(tid) - local amount = tonumber(action.value..".000") - print(amount) - if(action.useplacecoef ~= nil and action.useplacecoef == true) then - if currentHouse ~= nil and currentHouse.coef ~=nil then - amount = amount * currentHouse.coef - end - if currentStar ~= nil then - amount = amount * 2 - end - end - local result = ts:RemoveItem(player, itemid, amount) - logme(3,result) - end - if(action.name == "remove_random_money") then - local player = Game.GetPlayer() - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new("Items.money") - local itemid = ItemID.new(tid) - local amount = math.random(tonumber(action.min..".000"),tonumber(action.max..".000")) - - if currentHouse ~= nil and currentHouse.coef ~=nil then - amount = amount * currentHouse.coef - end - if currentStar ~= nil then - amount = amount * 2 - end - local result = ts:RemoveItem(player, itemid, amount) - --logme(3,result) - --logme(3,"remove money") - end - if(action.name == "clean_custommappin") then - ActivecustomMappin = nil - - - - - mappinManager["selected_mappin"] = nil - end - if(action.name == "clean_activefasttravelpoint") then - ActiveFastTravelMappin = nil - mappinManager["selected_fasttravel_mappin"] = nil - end - - if(action.name == "notify") then - Game.GetPlayer():SetWarningMessage(getLang(action.value)) - end - - if(action.name == "custom_notification") then - - - - - - local message = SimpleScreenMessage.new() - message.message = getLang(action.value) - message.isShown = true - message.duration = 5 - if action.type ~= 0 then - message.type = action.type - end - - local blackboardDefs = Game.GetAllBlackboardDefs() - local blackboardUI = Game.GetBlackboardSystem():Get(blackboardDefs.UI_Notifications) - blackboardUI:SetVariant( - blackboardDefs.UI_Notifications.WarningMessage, - ToVariant(message), - true - ) - - end - - if(action.name == "simple_message") then - local message = SimpleScreenMessage.new() - message.message = getLang(action.value) - message.isShown = true - local blackboardDefs = Game.GetAllBlackboardDefs() - local blackboardUI = Game.GetBlackboardSystem():Get(blackboardDefs.UI_Notifications) - blackboardUI:SetVariant( - blackboardDefs.UI_Notifications.OnscreenMessage, - ToVariant(message), - true - ) - end - - if(action.name == "npcd_finish_notification") then - local ncpd = NCPDJobDoneEvent.new() - ncpd.levelXPAwarded = action.levelXPAwarded - ncpd.streetCredXPAwarded = action.streetCredXPAwarded - Game.GetUISystem():QueueEvent(ncpd) - end - if(action.name == "quest_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end - - local userData = QuestUpdateNotificationViewData.new() - userData.text = getLang(action.desc) - - if(action.type == "new") then - - local questAction = TrackQuestNotificationAction.new() - questAction.eventDispatcher = GameController["JournalNotificationQueue"] - - if(action.quest ~= nil and action.quest ~= "") then - local questentry = gameJournalQuest.new() - questentry.districtID = action.objective - questentry.id = action.quest - questAction.questEntry = questentry - - end - - userData.title = test - userData.canBeMerged = false; - userData.action = questAction - userData.soundEvent = CName("QuestNewPopup") - userData.soundAction = CName("OnOpen") - userData.animation = CName("notification_new_quest_added") - - - - - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_new_quest_added') - notificationData.notificationData = userData - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - - if(action.type == "update") then - - local questAction = TrackQuestNotificationAction.new() - questAction.eventDispatcher = GameController["JournalNotificationQueue"] - - - userData.title = "UI-Notifications-QuestUpdated" - userData.canBeMerged = false; - userData.action = questAction - userData.soundEvent = CName("QuestUpdatePopup") - userData.soundAction = CName("OnOpen") - userData.animation = CName("notification_quest_updated") - - - if(action.quest ~= nil and action.quest ~= "") then - local questentry = gameJournalQuest.new() - questentry.districtID = action.objective - questentry.id = action.quest - - questAction.questEntry = questentry - - end - - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_quest_updated') - notificationData.notificationData = userData - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - - if(action.type == "success") then - - - - - userData.title = "UI-Notifications-QuestCompleted" - userData.canBeMerged = false - userData.soundEvent = CName("QuestSuccessPopup") - userData.soundAction = CName("OnOpen") - userData.animation = CName("notification_quest_completed") - userData.dontRemoveOnRequest = false - - - - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_quest_completed') - notificationData.notificationData = userData - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - - if(action.type == "fail") then - - - userData.title = "LocKey#27566" - userData.canBeMerged = false - userData.soundEvent = CName("QuestFailedPopup") - userData.soundAction = CName("OnOpen") - userData.animation = CName("notification_quest_failed") - userData.dontRemoveOnRequest = false - - - - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_quest_failed') - notificationData.notificationData = userData - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - - end - if(action.name == "shard_notification") then - local test = getLang(action.title) - - - local notificationData = gameuiGenericNotificationData.new() - - local userData = ShardCollectedNotificationViewData.new() - userData.title = GetLocalizedText("UI-Notifications-ShardCollected") .. " " .. test - userData.text = getLang(action.desc) - userData.shardTitle = test - userData.isCrypted = action.iscrypted - userData.entry = nil - - - if(action.shard ~= nil and action.shard ~= "") then - - local shard = getShardByTag(action.shard) - - if(shard ~= nil) then - checkContext(shard) - - userData.title = GetLocalizedText("UI-Notifications-ShardCollected") .. " " .. getLang(shard.title) - userData.text = getLang(shard.description) - userData.shardTitle = getLang(shard.title) - cyberscript.cache["shard"][shard.tag].data.locked = false - userData.isCrypted = shard.crypted - end - end - - - - - local shardOpenAction = OpenShardNotificationAction.new() - shardOpenAction.eventDispatcher = Game.GetUISystem() - - userData.action = shardOpenAction - userData.soundEvent = CName("ShardCollectedPopup") - userData.soundAction = CName("OnLoot") - - - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_shard') - notificationData.notificationData = userData - - - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - if(action.name == "contact_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end - - local notificationData = gameuiGenericNotificationData.new() - - local userData = QuestUpdateNotificationViewData.new() - userData.title = GetLocalizedText("Story-base-gameplay-gui-widgets-notifications-quest_update-_localizationString6") - userData.text = getLang(action.desc) - userData.animation = CName("notification_newContactAdded") - - - - - userData.soundEvent = CName("QuestUpdatePopup") - userData.soundAction = CName("OnOpen") - - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_NewContactAdded') - notificationData.notificationData = userData - - - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - if(action.name == "location_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end - - local userData = QuestUpdateNotificationViewData.new() - userData.title = test - userData.text = getLang(action.desc) - userData.animation = CName("notification_LocationAdded") - userData.soundEvent = CName("ui_phone_sms") - userData.soundAction = CName("OnOpen") - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName("notification_LocationAdded") - notificationData.notificationData = userData - - - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - - if(action.name == "codex_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end - - local userData = QuestUpdateNotificationViewData.new() - userData.title = test - userData.text = getLang(action.desc) - userData.animation = CName("notification_LocationAdded") - userData.soundEvent = CName("ui_phone_sms") - userData.soundAction = CName("OnOpen") - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName("notification_LocationAdded") - notificationData.notificationData = userData - - - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - - if(action.name == "activity_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end - - local userData = QuestUpdateNotificationViewData.new() - userData.title = test - userData.text = getLang(action.desc) - userData.animation = CName("notification_new_activity") - userData.soundEvent = CName("QuestNewPopup") - userData.soundAction = CName("OnOpen") - userData.canBeMerged = false - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName("notification_new_activity") - notificationData.notificationData = userData - - - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - - if(action.name == "authorization_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end - -- local notificationData = gameuiGenericNotificationData.new() - -- local userData = AuthorisationNotificationViewData.new() - -- userData.title = test - -- userData.text = getLang(action.desc) - -- userData.authType = 2; - -- notificationData.time = action.duration - -- notificationData.widgetLibraryItemName = CName("access_granted") - -- notificationData.notificationData = userData - - - -- GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - local notification = AuthorisationNotificationEvent.new(); - notification.type = action.type - - Game.GetPlayer():QueueEvent(notification); - - end - - - - - if(action.name == "hacking_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end - - local userData = QuestUpdateNotificationViewData.new() - userData.title = test - userData.text = getLang(action.desc) - userData.animation = CName("notification_hacking_reward") - userData.soundEvent = CName("QuestNewPopup") - userData.soundAction = CName("OnOpen") - userData.canBeMerged = false - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName("notification_hacking_reward") - notificationData.notificationData = userData - - - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - if(action.name == "phone_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end + if(action.type ~= nil and action.type == "lang") then + text = getLang(action.value) + end + + setVariable(action.variable,action.key,text) + end + + + if(action.name == "concate_variable") then + local var = getVariableKey(action.variable,action.key) + var = var .. action.value + setVariable(action.variable,action.key,var) + end + + + + if(action.name == "operate_score") then + local score = getScoreKey(action.score,action.key) + if(score == nil) then score = 0 end + + if(action.operator == "+") then + score = score + action.value + end + if(action.operator == "-") then + score = score - action.value + end + if(action.operator == "*") then + score = score * action.value + end + if(action.operator == "/") then + score = score / action.value + end + if(action.operator == "positive") then + if(score > 0) then + score = 0 + score + else + score = 0 - score + end + end + if(action.operator == "negative") then + if(score > 0) then + score = 0 - score + else + score = 0 + score + end + end + if(action.operator == "random") then + score = math.random(action.min,action.max) + end + if(action.operator == "floor") then + score = math.floor(score) + end + if(action.operator == "ceil") then + score = math.ceil(score) + end + + + setScore(action.score,action.key,score) + end + + + + + + end + + if houseregion then + if(action.name == "change_house_statut") then + + setScore(action.value,"Statut",action.score) + end + if(action.name == "change_house_score") then + + setScore(action.value,"Score",action.score) + end + + + + if(action.name == "open_placed_item_ui") then + if currentHouse ~= nil then + if(getHouseStatut(currentHouse.tag) == 1) then + PlacedItemsUI() + end + end + end + if(action.name == "open_buyed_item_ui") then + if currentHouse ~= nil then + if(getHouseStatut(currentHouse.tag) == 1) then + + BuyedItemsUI() + end + end + end + if(action.name == "move_looked_item_to_player_position") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local obj = getItemEntityFromManager(entid) + if(obj == nil) then + obj = getItemEntityFromManagerByPlayerLookinAt() + end + if(obj ~= nil) then + local objpos = Game.GetPlayer():GetWorldPosition() + local qat = Game.GetPlayer():GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + updateItemPosition(obj, objpos, angle, true) + end + end + end + if(action.name == "move_looked_item_Z") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local obj = getItemEntityFromManager(entid) + if(obj == nil) then + obj = getItemEntityFromManagerByPlayerLookinAt() + end + if(obj ~= nil) then + local objpos = objLook:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + objpos.z = objpos.z + action.value + local qat = objLook:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + updateItemPosition(obj, objpos, angle, true) + else + logme(3,"null") + end + end + end + if(action.name == "move_looked_item_X") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local obj = getItemEntityFromManager(entid) + if(obj == nil) then + obj = getItemEntityFromManagerByPlayerLookinAt() + end + if(obj ~= nil) then + local objpos = objLook:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + objpos.x = objpos.x + action.value + local qat = objLook:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + updateItemPosition(obj, objpos, angle, true) + end + end + end + if(action.name == "move_looked_item_Y") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local obj = getItemEntityFromManager(entid) + if(obj == nil) then + obj = getItemEntityFromManagerByPlayerLookinAt() + end + if(obj ~= nil) then + local objpos = objLook:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + objpos.y = objpos.y + action.value + local qat = objLook:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + updateItemPosition(obj, objpos, angle, true) + end + end + end + if(action.name == "yaw_looked_item") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local obj = getItemEntityFromManager(entid) + if(obj == nil) then + obj = getItemEntityFromManagerByPlayerLookinAt() + end + if(obj ~= nil) then + local objpos = objLook:GetWorldPosition() + local qat = objLook:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + angle.yaw = angle.yaw + action.value + updateItemPosition(obj, objpos, angle, true) + end + end + end + if(action.name == "roll_looked_item") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local entity = getItemEntityFromManager(entid) + if(entity == nil) then + entity = getItemEntityFromManagerByPlayerLookinAt() + end + if(entity ~= nil) then + local worldpos = entity:GetWorldTransform() + local pos = worldpos.Position:ToVector4(worldpos.Position) + local qat = worldpos:GetOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + angle.roll = angle.roll + action.value + updateItemPosition(obj, pos, angle) + end + end + end + if(action.name == "pitch_looked_item") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local entity = getItemEntityFromManager(entid) + if(entity == nil) then + entity = getItemEntityFromManagerByPlayerLookinAt() + end + if(entity ~= nil) then + local worldpos = entity:GetWorldTransform() + local pos = worldpos.Position:ToVector4(worldpos.Position) + local qat = worldpos:GetOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + angle.roll = angle.roll + action.value + updateItemPosition(obj, pos, angle) + end + end + end + if(action.name == "set_item") then + if grabbedTarget ~= nil then + -- tp:Teleport(grabbedTarget, targetPos, targetAngle) + -- if(safeFindEntityByID(selectedItem.entityId):IsA('gameObject') == false)then + -- grabbedTarget:Destroy() + -- end + updateItemPosition(selectedItem, targetPos, targetAngle,true) + grabbedTarget = nil + grabbed = false + objPush = false + objPull = false + enabled = false + id = false + end + end + if(action.name == "looked_item_remove") then + if objLook ~= nil then + tarName = objLook:ToString() + appName = Game.NameToString(objLook:GetCurrentAppearanceName()) + dipName = objLook:GetDisplayName() + local entid = objLook:GetEntityID() + local entity = getItemEntityFromManager(entid) + if(entity == nil) then + entity = getItemEntityFromManagerByPlayerLookinAt() + end + -- if(entity ~= nil) then + logme(3,entity.Tag) + logme(3,entity.Tag) + logme(3,#currentSave.arrayPlayerItems) + for i =1, #currentSave.arrayPlayerItems do + local mitem = currentSave.arrayPlayerItems[i] + logme(3,mitem.Tag) + if(mitem.Tag == entity.Tag) then + local housingitem = getHousing(entity.Tag,entity.X,entity.Y,entity.Z) + deleteHousing(housingitem.Id) + updatePlayerItemsQuantity(mitem,1) + despawnItem(entid) + end + end + else + logme(3,"nope") + end + end + + if(action.name == "grab_select_item") then + if selectedItem ~= nil then + enabled = true + id = true + grabbedTarget = safeFindEntityByID(selectedItem.entityId) + if(grabbedTarget:IsA('gameObject') == false)then + grabbedTarget = nil + grabbed = false + objPush = false + objPull = false + enabled = false + id = false + --Game.GetPlayer():SetWarningMessage(getLang(action.value)) + -- local objpos = grabbedTarget:GetWorldPosition() + -- local worldpos = Game.GetPlayer():GetWorldTransform() + -- local qat = grabbedTarget:GetWorldOrientation() + -- local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + -- local transform = Game.GetPlayer():GetWorldTransform() + -- transform:SetPosition(objpos) + -- transform:SetOrientationEuler(angle) + -- grabbedTarget = WorldFunctionalTests.SpawnEntity("base\\items\\interactive\\dining_accessories\\int_dining_accessories_001__bar_asset_h_sponge.ent", transform, '') + end + Cron.After(0.7,function() + if (grabbedTarget ~= nil) then + targetPos = grabbedTarget:GetWorldPosition() + targetAngle = Vector4.ToRotation(grabbedTarget:GetWorldForward()) + objectDist = Vector4.Distance(targetPos, playerPos) + phi = math.atan2(playerAngle.y, playerAngle.x) + targetDeltaPos = Vector4.new(((objectDist * math.cos(phi)) + playerPos.x), ((objectDist * math.sin(phi)) + playerPos.y), (objectDist * math.sin(playerAngle.z) + playerPos.z), targetPos.w) + targetDeltaPos = Delta(targetDeltaPos, targetPos) + logme(3,grabbedTarget, "grabbed.") + grabbed = true + else + logme(3,"No target!") + end + end) + end + end + if(action.name == "select_item") then + if(#currentItemSpawned > 0 )then + for i = 1, #currentItemSpawned do + local mitems = currentItemSpawned[i] + if(mitems.Id == action.value) then + selectedItem = nil + selectedItem = mitems + if(selectedItem.entityId ~= nil and safeFindEntityByID(selectedItem.entityId) ~=nil and safeFindEntityByID(selectedItem.entityId):IsA('gameObject') == true)then + grabbedTarget = safeFindEntityByID(selectedItem.entityId) + enabled = true + id = true + if (grabbedTarget ~= nil) then + targetPos = grabbedTarget:GetWorldPosition() + targetAngle = Vector4.ToRotation(grabbedTarget:GetWorldForward()) + objectDist = Vector4.Distance(targetPos, playerPos) + phi = math.atan2(playerAngle.y, playerAngle.x) + targetDeltaPos = Vector4.new(((objectDist * math.cos(phi)) + playerPos.x), ((objectDist * math.sin(phi)) + playerPos.y), (objectDist * math.sin(playerAngle.z) + playerPos.z), targetPos.w) + targetDeltaPos = Delta(targetDeltaPos, targetPos) + logme(3,grabbedTarget, "grabbed.") + grabbed = true + else + logme(3,"No target!") + end + end + end + end + end + end + if(action.name == "unselect_item") then + selectedItem = nil + grabbedTarget = nil + grabbed = false + objPush = false + objPull = false + enabled = false + id = false + end + if(action.name == "move_select_item_to_player_position") then + if selectedItem ~= nil then + local objpos = Game.GetPlayer():GetWorldPosition() + local qat = Game.GetPlayer():GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + updateItemPosition(selectedItem, objpos, angle, true) + end + end + if(action.name == "move_selected_item_Z") then + if selectedItem ~= nil then + local entity = safeFindEntityByID(selectedItem.entityId) + if(entity ~= nil) then + local objpos = entity:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + objpos.z = objpos.z + action.value + local qat = entity:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + updateItemPosition(selectedItem, objpos, angle, true) + end + end + end + if(action.name == "move_selected_item_X") then + if selectedItem ~= nil then + local entity = safeFindEntityByID(selectedItem.entityId) + if(entity ~= nil) then + local objpos = entity:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + objpos.x = objpos.x + action.value + local qat = entity:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + updateItemPosition(selectedItem, objpos, angle, true) + end + end + end + if(action.name == "move_selected_item_Y") then + if selectedItem ~= nil then + local entity = safeFindEntityByID(selectedItem.entityId) + if(entity ~= nil) then + local objpos = entity:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + objpos.y = objpos.y + action.value + local qat = entity:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + updateItemPosition(selectedItem, objpos, angle, true) + end + end + end + if(action.name == "yaw_selected_item") then + if selectedItem ~= nil then + local entity = safeFindEntityByID(selectedItem.entityId) + if(entity ~= nil) then + local objpos = entity:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + local qat = entity:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + angle.yaw = angle.yaw + action.value + updateItemPosition(selectedItem, objpos, angle, true) + end + end + end + if(action.name == "roll_selected_item") then + if selectedItem ~= nil then + local entity = safeFindEntityByID(selectedItem.entityId) + if(entity ~= nil) then + local objpos = entity:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + local qat = entity:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + angle.roll = angle.roll + action.value + updateItemPosition(selectedItem, objpos, angle, true) + end + end + end + if(action.name == "pitch_selected_item") then + if selectedItem ~= nil then + local entity = safeFindEntityByID(selectedItem.entityId) + if(entity ~= nil) then + local objpos = entity:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + local qat = entity:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + angle.pitch = angle.pitch + action.value + updateItemPosition(selectedItem, objpos, angle, true) + end + end + end + if(action.name == "selected_item_remove") then + if selectedItem ~= nil then + local entity = safeFindEntityByID(selectedItem.entityId) + if(entity ~= nil) then + for i =1, #currentSave.arrayPlayerItems do + local mitem = currentSave.arrayPlayerItems[i] + if(mitem.Tag == selectedItem.Tag) then + safeFindEntityByID(selectedItem.entityId):GetEntity():Destroy() + logme(3,"toto") + updatePlayerItemsQuantity(mitem,1) + deleteHousing(selectedItem.Id) + local index = getItemEntityIndexFromManager(selectedItem.entityId) + --despawnItem(selectedItem.Id) + table.remove(currentItemSpawned,index) + Cron.After(1, function() + selectedItem = nil + end) + end + end + else + logme(3,"nope") + end + end + end + if(action.name == "spawn_buyed_item") then + if action.tag ~= nil then + local pos = Game.GetPlayer():GetWorldPosition() + local angles = GetSingleton('Quaternion'):ToEulerAngles(Game.GetPlayer():GetWorldOrientation()) + local spawnedItem = {} + local mitems = getPlayerItemsbyTag(action.tag) + if(currentHouse ~= nil and mitems ~= nil and mitems.Quantity > 0 and (string.match(tostring(mitems.Tag), "AMM_Props.") == nil or (string.match(tostring(mitems.Tag), "AMM_Props.") ~= nil and AMM ~= nil) ) ) then + spawnedItem.Tag = mitems.Tag + spawnedItem.HouseTag = currentHouse.tag + spawnedItem.ItemPath = mitems.Path + spawnedItem.X = pos.x + spawnedItem.Y = pos.y + spawnedItem.Z = pos.z + spawnedItem.Yaw = angles.yaw + spawnedItem.Pitch = angles.pitch + spawnedItem.Roll = angles.roll + spawnedItem.Title = mitems.Title + spawnedItem.fromTemplate = false + saveHousing(spawnedItem) + local housing = getHousing(spawnedItem.Tag,spawnedItem.X,spawnedItem.Y,spawnedItem.Z) + spawnedItem.Id = housing.Id + updatePlayerItemsQuantity(mitems,-1) + spawnedItem.entityId = spawnItem(spawnedItem, pos, angles) + local entity = safeFindEntityByID(spawnedItem.entityId) + local components = checkForValidComponents(entity) + if components then + local visualScale = checkDefaultScale(components) + spawnedItem.defaultScale = { + x = visualScale.x * 100, + y = visualScale.x * 100, + z = visualScale.x * 100, + } + spawnedItem.scale = { + x = visualScale.x * 100, + y = visualScale.y * 100, + z = visualScale.z * 100, + } + end + table.insert(currentItemSpawned,spawnedItem) + selectedItem = spawnedItem + end + end + end + if(action.name == "despawn_placed_item") then + if action.tag ~= nil then + local pos = Game.GetPlayer():GetWorldPosition() + local angles = GetSingleton('Quaternion'):ToEulerAngles(Game.GetPlayer():GetWorldOrientation()) + local spawnedItem = {} + if(currentHouse ~= nil)then + local entity = getItemByHouseTagandTagFromManager(action.tag,currentHouse.tag) + if(entity ~= nil) then + for i =1, #currentSave.arrayPlayerItems do + local mitem = currentSave.arrayPlayerItems[i] + if(mitem.Tag == entity.Tag) then + local housingitem = getHousing(entity.Tag,entity.X,entity.Y,entity.Z) + despawnItem(entity.entityId) + deleteHousing(housingitem.Id) + updatePlayerItemsQuantity(mitem,1) + end + end + else + logme(3,"nope") + end + end + end + end + if(action.name == "current_place_clear_all_item") then + + if(currentHouse ~=nil) then + if(#currentItemSpawned > 0) then + + + for i=1,#currentItemSpawned do + + deleteHousing(currentItemSpawned[i].Id) + + + end + + despawnItemFromHouse() + + end + end + + end + if(action.name == "scale_selected_item") then + if selectedItem ~= nil then + local entity = safeFindEntityByID(selectedItem.entityId) + if(entity ~= nil) then + local values = Vector3.new(action.x, action.y, action.z) + setItemScale(entity, values) + end + end + end + + + + if(action.name == "current_place_apply_template") then + + currentHouseApplyTemplate(action.tag,action.x,action.y,action.z) + + end + + if(action.name == "current_place_clear_all_template") then + currentHouseClearAllTemplate() + + end + + + if(action.name == "current_place_clear_template") then + + + currentHouseClearTemplate(action.tag) + + end + + end + + if gangregion then + if(action.name == "gang_affinity") then + local score = getScoreKey("Affinity",action.value) + if(score == nil) then + score = 0 + setScore("Affinity",action.value,score) + end + score = score + action.score + setScore("Affinity",action.value,score) + end + if(action.name == "add_gang_district_score") then + local score = getVariableKeyWithDefault(action.faction,action.district,0) + setVariable(action.faction,action.district,score + action.value) + end + if(action.name == "remove_gang_district_score") then + local score = getVariableKeyWithDefault(action.faction,action.district,0) + setVariable(action.faction,action.district,score - action.value) + end + if(action.name == "set_gang_district_score") then + setVariable(action.faction,action.district,action.value) + end + if(action.name == "gang_affinity_from_current_district_leader") then + local gangs = getGangfromDistrict(currentDistricts2.tag,20) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + local score = getScoreKey("Affinity",gang.tag) + if(score == nil) then + score = 0 + setScore("Affinity",gang.tag,score) + end + score = score + action.score + setScore("Affinity",gang.tag,score) + end + end + if(action.name == "gang_affinity_from_current_district_leader_rival") then + + local gangs = getGangfromDistrict(currentDistricts2.Tag,20) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + local rivalindex = math.random(1,#gang.rivals) + gang = getFactionByTag(gang.rivals[rivalindex]) + local score = getScoreKey("Affinity",gang.tag) + if(score == nil) then + score = 0 + setScore("Affinity",gang.tag,score) + end + score = score + action.score + setScore("Affinity",gang.tag,score) + end + end + if(action.name == "gang_affinity_from_current_subdistrict_leader") then + if #currentDistricts2.districtLabels > 0 then + for i, test in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + local gangs = getGangfromDistrict(test,20) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + local score = getScoreKey(gang.tag,"Score") + if(score == nil) then + score = 0 + setScore("Affinity",gang.tag,score) + end + score = score + action.score + setScore("Affinity",gang.tag,score) + break + end + end + end + end + end + if(action.name == "gang_affinity_from_current_subdistrict_leader_rival") then + if #currentDistricts2.districtLabels > 0 then + for i, test in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + local gangs = getGangfromDistrict(test,20) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + local rivalindex = math.random(1,#gang.rivals) + gang = getFactionByTag(gang.rivals[rivalindex]) + local score = getScoreKey("Affinity",gang.tag) + if(score == nil) then + score = 0 + setScore("Affinity",gang.tag,score) + end + score = score + action.score + setScore("Affinity",gang.tag,score) + break + end + end + end + end + end + + + if(action.name == "add_gang_currentdistrict_score") then + if currentDistricts2 ~= nil then + + local score = getVariableKeyWithDefault(action.faction,currentDistricts2.Tag,0) + setVariable(action.faction,currentDistricts2.Tag, score + action.value) + + end + end + if(action.name == "remove_gang_currentdistrict_score") then + if currentDistricts2 ~= nil then + local score = getVariableKeyWithDefault(action.faction,currentDistricts2.Tag,0) + setVariable(action.faction,currentDistricts2.Tag, score + action.value) + end + end + if(action.name == "add_leader_currentdistrict_score") then + if currentDistricts2 ~= nil then + local gangs = getGangfromDistrict(currentDistricts2.Tag,20) + if(#gangs > 0) then + + + local score = getVariableKeyWithDefault(gangs[1].tag,currentDistricts2.Tag,0) + setVariable(gangs[1].tag,currentDistricts2.Tag, score + action.value) + end + end + end + if(action.name == "remove_leader_currentdistrict_score") then + if currentDistricts2 ~= nil then + local gangs = getGangfromDistrict(currentDistricts2.Tag,20) + if(#gangs > 0) then + local score = getVariableKeyWithDefault(gangs[1].tag,currentDistricts2.Tag,0) + setVariable(gangs[1].tag,currentDistricts2.Tag, score - action.value) + end + end + end + if(action.name == "add_leader_currentsubdistrict_score") then + if #currentDistricts2.districtLabels > 0 then + for i, test in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + local gangs = getGangfromDistrict(test,20) + if(#gangs > 0) then + + local score = getVariableKeyWithDefault(gangs[1].tag,test,0) + setVariable(gangs[1].tag,test, score + action.value) + break + end + end + end + end + end + if(action.name == "remove_leader_currentsubdistrict_score") then + if #currentDistricts2.districtLabels > 0 then + for i, test in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + local gangs = getGangfromDistrict(test,20) + if(#gangs > 0) then + + local score = getVariableKeyWithDefault(gangs[1].tag,test,0) + setVariable(gangs[1].tag,test, score - action.value) + break + end + end + end + end + end + if(action.name == "set_gang_currentdistrict_score") then + if currentDistricts2 ~= nil then + + setVariable(action.faction,currentDistricts2.Tag, action.value) + end + end + if(action.name == "add_gang_currentsubdistrict_score") then + if #currentDistricts2.districtLabels > 0 then + for i, test in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + local score = getVariableKeyWithDefault(action.faction,test,0) + setVariable(action.faction,test, score + action.value) + break + end + end + end + end + if(action.name == "remove_gang_currentsubdistrict_score") then + if #currentDistricts2.districtLabels > 0 then + for i, test in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + local score = getVariableKeyWithDefault(action.faction,test,0) + setVariable(action.faction,test, score - action.value) + break + end + end + end + end + if(action.name == "set_gang_currentsubdistrict_score") then + if #currentDistricts2.districtLabels > 0 then + for i, test in ipairs(currentDistricts2.districtLabels) do + if i > 1 then + local score = getVariableKeyWithDefault(action.faction,test,0) + setVariable(action.faction,test,action.value) + break + end + end + end + end + if(action.name == "trigger_edit_crew_mode") then + inCrewManager = action.value + end + if(action.name == "set_player_current_gang") then + setVariable("player","current_gang",action.tag) + end + if(action.name == "set_gang_relation") then + + if(action.tag == "player") then + + action.tag = getVariableKey("player","current_gang") + + end + + + if(action.mode == "gang") then + + + if(action.target ~= action.tag) then + + setFactionRelation(action.tag,action.target,action.score) + + end + + end + + if(action.mode == "district_leader" or action.mode == "district_subleader") then + + local gangs = getGangfromDistrict(action.target,20) + if(#gangs > 0) then + + if(gangs[1].tag ~= action.tag) then + + setFactionRelation(action.tag,gangs[1].tag,action.score) + + end + end + + + end + + if(action.mode == "current_district_leader") then + + if currentDistricts2 ~= nil then + local gangs = getGangfromDistrict(currentDistricts2.Tag,20) + if(#gangs > 0) then + setFactionRelation(action.tag,gangs[1].tag,action.score) + + end + end + + end + + if(action.mode == "current_district_subleader") then + if currentDistricts2 ~= nil then + if #currentDistricts2.districtLabels > 0 and #currentDistricts2.districtLabels > 1 then + local gangs = getGangfromDistrict(currentDistricts2.districtLabels[2],20) + if(#gangs > 0) then + setFactionRelation(action.tag,gangs[1].tag,action.score) + + end + end + end + + end + + end + + if(action.name == "add_gang_relation") then + + if(action.tag == "player") then + + action.tag = getVariableKey("player","current_gang") + + end + + + if(action.mode == "gang") then + + + if(action.target ~= action.tag) then + + addFactionRelation(action.tag,action.target,action.score) + + end + + end + + if(action.mode == "district_leader" or action.mode == "district_subleader") then + + local gangs = getGangfromDistrict(action.target,20) + if(#gangs > 0) then + + if(gangs[1].tag ~= action.tag) then + + addFactionRelation(action.tag,gangs[1].tag,action.score) + + end + end + + + end + + if(action.mode == "current_district_leader") then + + if currentDistricts2 ~= nil then + local gangs = getGangfromDistrict(currentDistricts2.Tag,20) + if(#gangs > 0) then + addFactionRelation(action.tag,gangs[1].tag,action.score) + + end + end + + end + + if(action.mode == "current_district_subleader") then + if currentDistricts2 ~= nil then + if #currentDistricts2.districtLabels > 0 and #currentDistricts2.districtLabels > 1 then + local gangs = getGangfromDistrict(currentDistricts2.districtLabels[2],20) + if(#gangs > 0) then + addFactionRelation(action.tag,gangs[1].tag,action.score) + + end + end + end + + end + + end + end + + if miscregion then + if(action.name == "set_fact") then + + Game.GetQuestsSystem():SetFactStr(action.value, action.score) + + end + if(action.name == "refresh_shard_cache") then + local activeData = CodexListSyncData.new() + local gameshards = CodexUtils.GetShardsDataArray(GameInstance.GetJournalManager(), activeData) + if gameshardscompiled == nil then gameshardscompiled = {} end + for i,v in pairs(gameshards) do + if gameshardscompiled[v.data.title] == nil then gameshardscompiled[v.data.title] = true end + + + end + end + if(action.name == "execute_in_tick") then + + if(#action.action > 0) then + for i,act in ipairs(action.action) do + + executeAction(act,tag,parent,index,source,executortag) + + end + end + + end + if(action.name == "load_interact") then + + if(#loadInteract < 4 and (table_contains(loadInteract,action.tag,false) == false))then + table.insert(loadInteract,action.tag) + + createInteraction(false) + candisplayInteract = true + createInteraction(true) + cycleInteract() + else + if((table_contains(loadInteract,action.tag,false) == false)) then + error("There is already 4 force loaded interact. Limit is reached !") + end + end + end + + if(action.name == "unload_interact") then + if(#loadInteract > 0 and (table_contains(loadInteract,action.tag,false) == true)) then + local indextoremove = nil + for i,v in ipairs(loadInteract) do + + if(v == action.tag) then + + indextoremove = i + + end + + end + + + if(indextoremove ~= nil) then + + table.remove(loadInteract,indextoremove) + + end + + end + candisplayInteract = false + createInteraction(false) + end + + if(action.name == "clean_all_loaded_interact") then + loadInteract = {} + candisplayInteract = false + createInteraction(false) + end + + if(action.name == "buy_item") then + local player = Game.GetPlayer() + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new("Items.money") + local itemid = ItemID.new(tid) + local amount = tonumber(action.price..".000") + if currentHouse ~= nil and currentHouse.coef ~=nil and currentHouse.coef > 0 then + amount = amount * currentHouse.coef + end + if currentStar ~= nil then + amount = amount * 2 + end + local result = ts:RemoveItem(player, itemid, amount) + ------logme(3,"remove money") + local player = Game.GetPlayer() + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new(action.value) + local itemid = ItemID.new(tid) + local result = ts:GiveItem(player, itemid, tonumber(action.amount)) + ------logme(3,"give item") + end + if(action.name == "give_item") then + local player = Game.GetPlayer() + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new(action.value) + local itemid = ItemID.new(tid) + local result = ts:GiveItem(player, itemid, tonumber(action.amount)) + ------logme(3,"give item") + end + if(action.name == "remove_item") then + local player = Game.GetPlayer() + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new(action.value) + local itemid = ItemID.new(tid) + local result = ts:RemoveItem(player, itemid, tonumber(action.amount)) + end + if(action.name == "give_money") then + local player = Game.GetPlayer() + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new("Items.money") + local itemid = ItemID.new(tid) + local amount = tonumber(action.value..".000") + if currentHouse ~= nil and currentHouse.coef ~= nil then + amount = amount * currentHouse.coef + end + local result = ts:GiveItem(player, itemid, amount) + ------logme(3,"give money") + end + if(action.name == "remove_money") then + local player = Game.GetPlayer() + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new("Items.money") + local itemid = ItemID.new(tid) + local amount = tonumber(action.value..".000") + print(amount) + if(action.useplacecoef ~= nil and action.useplacecoef == true) then + if currentHouse ~= nil and currentHouse.coef ~=nil then + amount = amount * currentHouse.coef + end + if currentStar ~= nil then + amount = amount * 2 + end + end + local result = ts:RemoveItem(player, itemid, amount) + logme(3,result) + end + if(action.name == "remove_random_money") then + local player = Game.GetPlayer() + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new("Items.money") + local itemid = ItemID.new(tid) + local amount = math.random(tonumber(action.min..".000"),tonumber(action.max..".000")) + + if currentHouse ~= nil and currentHouse.coef ~=nil then + amount = amount * currentHouse.coef + end + if currentStar ~= nil then + amount = amount * 2 + end + local result = ts:RemoveItem(player, itemid, amount) + --logme(3,result) + --logme(3,"remove money") + end + if(action.name == "clean_custommappin") then + ActivecustomMappin = nil + + + + + mappinManager["selected_mappin"] = nil + end + if(action.name == "clean_activefasttravelpoint") then + ActiveFastTravelMappin = nil + mappinManager["selected_fasttravel_mappin"] = nil + end + + if(action.name == "notify") then + Game.GetPlayer():SetWarningMessage(getLang(action.value)) + end + + if(action.name == "custom_notification") then + + + + + + local message = SimpleScreenMessage.new() + message.message = getLang(action.value) + message.isShown = true + message.duration = 5 + if action.type ~= 0 then + message.type = action.type + end + + local blackboardDefs = Game.GetAllBlackboardDefs() + local blackboardUI = Game.GetBlackboardSystem():Get(blackboardDefs.UI_Notifications) + blackboardUI:SetVariant( + blackboardDefs.UI_Notifications.WarningMessage, + ToVariant(message), + true + ) + + end + + if(action.name == "simple_message") then + local message = SimpleScreenMessage.new() + message.message = getLang(action.value) + message.isShown = true + local blackboardDefs = Game.GetAllBlackboardDefs() + local blackboardUI = Game.GetBlackboardSystem():Get(blackboardDefs.UI_Notifications) + blackboardUI:SetVariant( + blackboardDefs.UI_Notifications.OnscreenMessage, + ToVariant(message), + true + ) + end + + if(action.name == "npcd_finish_notification") then + local ncpd = NCPDJobDoneEvent.new() + ncpd.levelXPAwarded = action.levelXPAwarded + ncpd.streetCredXPAwarded = action.streetCredXPAwarded + Game.GetUISystem():QueueEvent(ncpd) + end + if(action.name == "quest_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end + + local userData = QuestUpdateNotificationViewData.new() + userData.text = getLang(action.desc) + + if(action.type == "new") then + + local questAction = TrackQuestNotificationAction.new() + questAction.eventDispatcher = GameController["JournalNotificationQueue"] + + if(action.quest ~= nil and action.quest ~= "") then + local questentry = gameJournalQuest.new() + questentry.districtID = action.objective + questentry.id = action.quest + questAction.questEntry = questentry + + end + + userData.title = test + userData.canBeMerged = false; + userData.action = questAction + userData.soundEvent = CName("QuestNewPopup") + userData.soundAction = CName("OnOpen") + userData.animation = CName("notification_new_quest_added") + + + + + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_new_quest_added') + notificationData.notificationData = userData + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + + if(action.type == "update") then + + local questAction = TrackQuestNotificationAction.new() + questAction.eventDispatcher = GameController["JournalNotificationQueue"] + + + userData.title = "UI-Notifications-QuestUpdated" + userData.canBeMerged = false; + userData.action = questAction + userData.soundEvent = CName("QuestUpdatePopup") + userData.soundAction = CName("OnOpen") + userData.animation = CName("notification_quest_updated") + + + if(action.quest ~= nil and action.quest ~= "") then + local questentry = gameJournalQuest.new() + questentry.districtID = action.objective + questentry.id = action.quest + + questAction.questEntry = questentry + + end + + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_quest_updated') + notificationData.notificationData = userData + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + + if(action.type == "success") then + + + + + userData.title = "UI-Notifications-QuestCompleted" + userData.canBeMerged = false + userData.soundEvent = CName("QuestSuccessPopup") + userData.soundAction = CName("OnOpen") + userData.animation = CName("notification_quest_completed") + userData.dontRemoveOnRequest = false + + + + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_quest_completed') + notificationData.notificationData = userData + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + + if(action.type == "fail") then + + + userData.title = "LocKey#27566" + userData.canBeMerged = false + userData.soundEvent = CName("QuestFailedPopup") + userData.soundAction = CName("OnOpen") + userData.animation = CName("notification_quest_failed") + userData.dontRemoveOnRequest = false + + + + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_quest_failed') + notificationData.notificationData = userData + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + + end + if(action.name == "shard_notification") then + local test = getLang(action.title) + + + local notificationData = gameuiGenericNotificationData.new() + + local userData = ShardCollectedNotificationViewData.new() + userData.title = GetLocalizedText("UI-Notifications-ShardCollected") .. " " .. test + userData.text = getLang(action.desc) + userData.shardTitle = test + userData.isCrypted = action.iscrypted + userData.entry = nil + + + if(action.shard ~= nil and action.shard ~= "") then + + local shard = getShardByTag(action.shard) + + if(shard ~= nil) then + checkContext(shard) + + userData.title = GetLocalizedText("UI-Notifications-ShardCollected") .. " " .. getLang(shard.title) + userData.text = getLang(shard.description) + userData.shardTitle = getLang(shard.title) + cyberscript.cache["shard"][shard.tag].data.locked = false + userData.isCrypted = shard.crypted + end + end + + + + + local shardOpenAction = OpenShardNotificationAction.new() + shardOpenAction.eventDispatcher = Game.GetUISystem() + + userData.action = shardOpenAction + userData.soundEvent = CName("ShardCollectedPopup") + userData.soundAction = CName("OnLoot") + + + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_shard') + notificationData.notificationData = userData + + + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + if(action.name == "contact_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end + + local notificationData = gameuiGenericNotificationData.new() + + local userData = QuestUpdateNotificationViewData.new() + userData.title = GetLocalizedText("Story-base-gameplay-gui-widgets-notifications-quest_update-_localizationString6") + userData.text = getLang(action.desc) + userData.animation = CName("notification_newContactAdded") + + + + + userData.soundEvent = CName("QuestUpdatePopup") + userData.soundAction = CName("OnOpen") + + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_NewContactAdded') + notificationData.notificationData = userData + + + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + if(action.name == "location_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end + + local userData = QuestUpdateNotificationViewData.new() + userData.title = test + userData.text = getLang(action.desc) + userData.animation = CName("notification_LocationAdded") + userData.soundEvent = CName("ui_phone_sms") + userData.soundAction = CName("OnOpen") + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName("notification_LocationAdded") + notificationData.notificationData = userData + + + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + + if(action.name == "codex_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end + + local userData = QuestUpdateNotificationViewData.new() + userData.title = test + userData.text = getLang(action.desc) + userData.animation = CName("notification_LocationAdded") + userData.soundEvent = CName("ui_phone_sms") + userData.soundAction = CName("OnOpen") + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName("notification_LocationAdded") + notificationData.notificationData = userData + + + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + + if(action.name == "activity_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end + + local userData = QuestUpdateNotificationViewData.new() + userData.title = test + userData.text = getLang(action.desc) + userData.animation = CName("notification_new_activity") + userData.soundEvent = CName("QuestNewPopup") + userData.soundAction = CName("OnOpen") + userData.canBeMerged = false + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName("notification_new_activity") + notificationData.notificationData = userData + + + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + + if(action.name == "authorization_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end + -- local notificationData = gameuiGenericNotificationData.new() + -- local userData = AuthorisationNotificationViewData.new() + -- userData.title = test + -- userData.text = getLang(action.desc) + -- userData.authType = 2; + -- notificationData.time = action.duration + -- notificationData.widgetLibraryItemName = CName("access_granted") + -- notificationData.notificationData = userData + + + -- GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + local notification = AuthorisationNotificationEvent.new(); + notification.type = action.type + + Game.GetPlayer():QueueEvent(notification); + + end + + + + + if(action.name == "hacking_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end + + local userData = QuestUpdateNotificationViewData.new() + userData.title = test + userData.text = getLang(action.desc) + userData.animation = CName("notification_hacking_reward") + userData.soundEvent = CName("QuestNewPopup") + userData.soundAction = CName("OnOpen") + userData.canBeMerged = false + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName("notification_hacking_reward") + notificationData.notificationData = userData + + + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + if(action.name == "phone_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end - local openAction = OpenPhoneMessageAction.new() - openAction.eventDispatcher = GameController["JournalNotificationQueue"] - local userData = PhoneMessageNotificationViewData.new() - userData.title = test - userData.SMSText = getLang(action.desc) - userData.action = openAction - userData.animation = CName('notification_phone_MSG') - userData.soundEvent = CName('PhoneSmsPopup') - userData.soundAction = CName('OnOpen') - currentPhoneDialogPopup = gameJournalPhoneMessage.new() - currentPhoneDialogPopup.sender = 1 - currentPhoneDialogPopup.text = getLang(action.desc) - currentPhoneDialogPopup.delay = -9999 - currentPhoneDialogPopup.id = test - local gotsomething = false - if(action.conversation ~= nil and action.conversation ~= "") then - - for k,v in pairs(cyberscript.cache["phone_dialog"]) do - local phoneConversation = v.data - for z=1,#phoneConversation.conversation do - local conversation = phoneConversation.conversation[z] - if(conversation.tag == action.conversation)then - gotsomething = true - - currentPhoneConversation = phoneConversation.conversation[z] - currentPhoneConversation.currentchoices = {} - currentPhoneConversation.loaded = 0 - currentPhoneConversation.speaker = conversation.speaker - phonecounter = -1 - PhoneHotkeyController_UpdateData(GameController["PhoneHotkeyController"]) - - end - end - - end - end - - if(gotsomething == false ) then - - currentPhoneConversation = "cs_nothing" - end - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_message') - notificationData.notificationData = userData - GameController["NewHudPhoneGameController"]:AddNewNotificationData(notificationData) - end - - if(action.name == "phone_news_notification") then - local test = getLang(action.title) - local obj = getEntityFromManager(action.title) - local enti = Game.FindEntityByID(obj.id) - if(action.title == "lookat")then - enti = objLook - end - if(enti ~= nil) then - if(action.title == "current_phone_npc") then - if(currentNPC ~= nil) then - test = currentNPC.Names - end - end - if(action.title == "current_star") then - if(currentStar ~= nil) then - test = currentStar.Names - end - end - end - local openAction = OpenMessengerNotificationAction.new() - openAction.eventDispatcher = GameController["JournalNotificationQueue"] - local userData = PhoneMessageNotificationViewData.new() - userData.title = test - - local text = "Error, connect to keystone for get the latest news !" - - if(#corpoNews > 0) then - local id = math.random(1,#corpoNews) - text = corpoNews[id] - end - userData.SMSText = text - - userData.action = openAction - userData.animation = CName('notification_phone_MSG') - userData.soundEvent = CName('PhoneSmsPopup') - userData.soundAction = CName('OnOpen') - currentPhoneDialogPopup = gameJournalPhoneMessage.new() - currentPhoneDialogPopup.sender = 1 - currentPhoneDialogPopup.text = text - currentPhoneDialogPopup.delay = -9999 - currentPhoneDialogPopup.id = test - - - local phone_news_conv = {} - phone_news_conv.tag = "corpo_news" - phone_news_conv.unlock = false - phone_news_conv.speaker = getLang("see_action_phone_news_speaker") - phone_news_conv.conversation = {} - - local phone_news_conv01 = {} - phone_news_conv01.tag = "corpo_news01" - phone_news_conv01.name = "Latest News" - phone_news_conv01.unlock = false - phone_news_conv01.message = {} - - local phone_news_conv01_msg = {} - phone_news_conv01_msg.tag = "corpo_news01" - phone_news_conv01_msg.text = text - phone_news_conv01_msg.sender = 0 - phone_news_conv01_msg.unlock = true - phone_news_conv01_msg.readed = false - phone_news_conv01_msg.choices = {} - - table.insert(phone_news_conv01.message,phone_news_conv01_msg) - table.insert(phone_news_conv.conversation,phone_news_conv01) - - cyberscript.cache["phone_dialog"]["corpo_news"] = {} - cyberscript.cache["phone_dialog"]["corpo_news"].data = phone_news_conv - cyberscript.cache["phone_dialog"]["corpo_news"].file = "default" - cyberscript.cache["phone_dialog"]["corpo_news"].datapack = "default" - - - - currentPhoneConversation = cyberscript.cache["phone_dialog"]["corpo_news"].data.conversation[1] - currentPhoneConversation.currentchoices = {} - currentPhoneConversation.loaded = 0 - currentPhoneConversation.speaker = cyberscript.cache["phone_dialog"]["corpo_news"].speaker - - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_message') - notificationData.notificationData = userData - GameController["NewHudPhoneGameController"]:AddNewNotificationData(notificationData) - end - - if(action.name == "tutorial_notification") then - - --openInterface = true - if UIPopupsManager.IsReady() then - local notificationData = TutorialPopupData.new() - notificationData.notificationName = CName("base\\gameplay\\gui\\widgets\\notifications\\tutorial.inkwidget") - notificationData.queueName = CName("tutorial") - notificationData.closeAtInput = action.closeatinput - notificationData.pauseGame = action.pausegame - notificationData.position = action.position - notificationData.isModal = action.ismodal - notificationData.margin = inkMargin.new() - notificationData.title = action.title - notificationData.message = action.desc - notificationData.imageId = nil - notificationData.videoType = gameVideoType.Unknown - notificationData.video = nil - notificationData.useCursor = true - notificationData.isBlocking = action.isblocking - - UIPopupsManager.ShowPopup(notificationData) - else - Game.GetPlayer():SetWarningMessage(getLang("see_action_poup_fail")) - end - - end - if(action.name=="next_help")then - if currentHelp ~= nil then - currentHelpIndex =currentHelpIndex+1 - if(currentHelpIndex > #currentHelp.section)then - UIPopupsManager.ClosePopup() - workerTable[currentHelp.tag] = nil - currentHelp = nil - - currentHelpIndex = 1 - end - UIPopupsManager.ClosePopup() - end - end - - if(action.name=="previous_help")then - if currentHelp ~= nil then - currentHelpIndex =currentHelpIndex-1 - - if(currentHelpIndex < 1)then - currentHelpIndex = 1 - end - UIPopupsManager.ClosePopup() - end - - end - if(action.name == "open_help") then - currentHelp = cyberscript.cache["help"][action.tag].data - --openInterface = true - - if currentHelp ~= nil then - if(currentHelpIndex > #currentHelp.section)then - UIPopupsManager.ClosePopup() - workerTable[currentHelp.tag] = nil - currentHelp = nil - currentHelpIndex = 1 - else - - local myHelp = deepcopy(currentHelp) - checkContext(myHelp) - myHelp.action = action - if UIPopupsManager.IsReady() then - local notificationData = TutorialPopupData.new() - notificationData.notificationName = CName("base\\gameplay\\gui\\widgets\\notifications\\tutorial.inkwidget") - notificationData.queueName = CName("tutorial") - notificationData.closeAtInput = action.closeatinput - notificationData.pauseGame = action.pausegame - notificationData.position = action.popupposition - notificationData.isModal = action.ismodal - notificationData.margin = inkMargin.new() - notificationData.title = myHelp.title - local section = nil - if(myHelp.section[myHelp] ~= nil) then - section = deepcopy(myHelp.section[myHelp]) - end + local openAction = OpenPhoneMessageAction.new() + openAction.eventDispatcher = GameController["JournalNotificationQueue"] + local userData = PhoneMessageNotificationViewData.new() + userData.title = test + userData.SMSText = getLang(action.desc) + userData.action = openAction + userData.animation = CName('notification_phone_MSG') + userData.soundEvent = CName('PhoneSmsPopup') + userData.soundAction = CName('OnOpen') + currentPhoneDialogPopup = gameJournalPhoneMessage.new() + currentPhoneDialogPopup.sender = 1 + currentPhoneDialogPopup.text = getLang(action.desc) + currentPhoneDialogPopup.delay = -9999 + currentPhoneDialogPopup.id = test + local gotsomething = false + if(action.conversation ~= nil and action.conversation ~= "") then + + for k,v in pairs(cyberscript.cache["phone_dialog"]) do + local phoneConversation = v.data + for z=1,#phoneConversation.conversation do + local conversation = phoneConversation.conversation[z] + if(conversation.tag == action.conversation)then + gotsomething = true + + currentPhoneConversation = phoneConversation.conversation[z] + currentPhoneConversation.currentchoices = {} + currentPhoneConversation.loaded = 0 + currentPhoneConversation.speaker = conversation.speaker + phonecounter = -1 + PhoneHotkeyController_UpdateData(GameController["PhoneHotkeyController"]) + + end + end + + end + end + + if(gotsomething == false ) then + + currentPhoneConversation = "cs_nothing" + end + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_message') + notificationData.notificationData = userData + GameController["NewHudPhoneGameController"]:AddNewNotificationData(notificationData) + end + + if(action.name == "phone_news_notification") then + local test = getLang(action.title) + local obj = getEntityFromManager(action.title) + local enti = safeFindEntityByID(obj) + if(action.title == "lookat")then + enti = objLook + end + if(enti ~= nil) then + if(action.title == "current_phone_npc") then + if(currentNPC ~= nil) then + test = currentNPC.Names + end + end + if(action.title == "current_star") then + if(currentStar ~= nil) then + test = currentStar.Names + end + end + end + local openAction = OpenMessengerNotificationAction.new() + openAction.eventDispatcher = GameController["JournalNotificationQueue"] + local userData = PhoneMessageNotificationViewData.new() + userData.title = test + + local text = "Error, connect to keystone for get the latest news !" + + if(#corpoNews > 0) then + local id = math.random(1,#corpoNews) + text = corpoNews[id] + end + userData.SMSText = text + + userData.action = openAction + userData.animation = CName('notification_phone_MSG') + userData.soundEvent = CName('PhoneSmsPopup') + userData.soundAction = CName('OnOpen') + currentPhoneDialogPopup = gameJournalPhoneMessage.new() + currentPhoneDialogPopup.sender = 1 + currentPhoneDialogPopup.text = text + currentPhoneDialogPopup.delay = -9999 + currentPhoneDialogPopup.id = test + + + local phone_news_conv = {} + phone_news_conv.tag = "corpo_news" + phone_news_conv.unlock = false + phone_news_conv.speaker = getLang("see_action_phone_news_speaker") + phone_news_conv.conversation = {} + + local phone_news_conv01 = {} + phone_news_conv01.tag = "corpo_news01" + phone_news_conv01.name = "Latest News" + phone_news_conv01.unlock = false + phone_news_conv01.message = {} + + local phone_news_conv01_msg = {} + phone_news_conv01_msg.tag = "corpo_news01" + phone_news_conv01_msg.text = text + phone_news_conv01_msg.sender = 0 + phone_news_conv01_msg.unlock = true + phone_news_conv01_msg.readed = false + phone_news_conv01_msg.choices = {} + + table.insert(phone_news_conv01.message,phone_news_conv01_msg) + table.insert(phone_news_conv.conversation,phone_news_conv01) + + cyberscript.cache["phone_dialog"]["corpo_news"] = {} + cyberscript.cache["phone_dialog"]["corpo_news"].data = phone_news_conv + cyberscript.cache["phone_dialog"]["corpo_news"].file = "default" + cyberscript.cache["phone_dialog"]["corpo_news"].datapack = "default" + + + + currentPhoneConversation = cyberscript.cache["phone_dialog"]["corpo_news"].data.conversation[1] + currentPhoneConversation.currentchoices = {} + currentPhoneConversation.loaded = 0 + currentPhoneConversation.speaker = cyberscript.cache["phone_dialog"]["corpo_news"].speaker + + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_message') + notificationData.notificationData = userData + GameController["NewHudPhoneGameController"]:AddNewNotificationData(notificationData) + end + + if(action.name == "tutorial_notification") then + + --openInterface = true + if UIPopupsManager.IsReady() then + local notificationData = TutorialPopupData.new() + notificationData.notificationName = CName("base\\gameplay\\gui\\widgets\\notifications\\tutorial.inkwidget") + notificationData.queueName = CName("tutorial") + notificationData.closeAtInput = action.closeatinput + notificationData.pauseGame = action.pausegame + notificationData.position = action.position + notificationData.isModal = action.ismodal + notificationData.margin = inkMargin.new() + notificationData.title = action.title + notificationData.message = action.desc + notificationData.imageId = nil + notificationData.videoType = gameVideoType.Unknown + notificationData.video = nil + notificationData.useCursor = true + notificationData.isBlocking = action.isblocking + + UIPopupsManager.ShowPopup(notificationData) + else + Game.GetPlayer():SetWarningMessage(getLang("see_action_poup_fail")) + end + + end + if(action.name=="next_help")then + if currentHelp ~= nil then + currentHelpIndex =currentHelpIndex+1 + if(currentHelpIndex > #currentHelp.section)then + UIPopupsManager.ClosePopup() + workerTable[currentHelp.tag] = nil + currentHelp = nil + + currentHelpIndex = 1 + end + UIPopupsManager.ClosePopup() + end + end + + if(action.name=="previous_help")then + if currentHelp ~= nil then + currentHelpIndex =currentHelpIndex-1 + + if(currentHelpIndex < 1)then + currentHelpIndex = 1 + end + UIPopupsManager.ClosePopup() + end + + end + if(action.name == "open_help") then + currentHelp = cyberscript.cache["help"][action.tag].data + --openInterface = true + + if currentHelp ~= nil then + if(currentHelpIndex > #currentHelp.section)then + UIPopupsManager.ClosePopup() + workerTable[currentHelp.tag] = nil + currentHelp = nil + currentHelpIndex = 1 + else + + local myHelp = deepcopy(currentHelp) + checkContext(myHelp) + myHelp.action = action + if UIPopupsManager.IsReady() then + local notificationData = TutorialPopupData.new() + notificationData.notificationName = CName("base\\gameplay\\gui\\widgets\\notifications\\tutorial.inkwidget") + notificationData.queueName = CName("tutorial") + notificationData.closeAtInput = action.closeatinput + notificationData.pauseGame = action.pausegame + notificationData.position = action.popupposition + notificationData.isModal = action.ismodal + notificationData.margin = inkMargin.new() + notificationData.title = myHelp.title + local section = nil + if(myHelp.section[myHelp] ~= nil) then + section = deepcopy(myHelp.section[myHelp]) + end - checkContext(section) - if(myHelp.section[myHelp].message == nil) then - - notificationData.message = "no data" + checkContext(section) + if(myHelp.section[myHelp].message == nil) then + + notificationData.message = "no data" - else - - notificationData.message = section.message - if(section.action ~=nil and #section.action > 0) then - runActionList(section.action, myHelp.tag.."_"..currentHelpIndex, tag,source,false,executortag) - end - end - notificationData.imageId = nil - notificationData.videoType = gameVideoType.Unknown - notificationData.video = nil - notificationData.useCursor = true - notificationData.isBlocking = action.isblocking - - UIPopupsManager.ShowPopup(notificationData) - else - Game.GetPlayer():SetWarningMessage(getLang("see_action_poup_fail")) - end - end - - else - logme(10,"no help founded with the tag "..action.tag) - end - end - - if(action.name == "hide_tutorial_notification") then - if GameController["TutorialPopupGameController"] ~= nil then - GameController["TutorialPopupGameController"]:GetRootWidget():SetVisible(false) - end - end - - if(action.name == "start_upload_program") then - local evt = UploadProgramProgressEvent.new() - evt.state = EUploadProgramState.STARTED - evt.duration = action.duration - evt.progressBarType = EProgressBarType.UPLOAD - evt.progressBarContext = EProgressBarContext.QuickHack - - evt.statPoolType = gamedataStatPoolType.QuickHackUpload - Game.GetPersistencySystem():QueueEntityEvent(Game.GetPlayer():GetEntityID(), evt) - end - - if(action.name == "end_upload_program") then - local evt = UploadProgramProgressEvent.new() - evt.state = EUploadProgramState.COMPLETED - evt.duration = action.duration - evt.progressBarType = EProgressBarType.UPLOAD - evt.progressBarContext = EProgressBarContext.QuickHack - - evt.statPoolType = gamedataStatPoolType.QuickHackUpload - Game.GetPersistencySystem():QueueEntityEvent(Game.GetPlayer():GetEntityID(), evt) - end - - - if(action.name == "set_metro_time") then - MetroCurrentTime = action.value - end - if(action.name == "trigger_metro_time") then - activeMetroDisplay = action.value - end - if(action.name == "consolelog") then - logme(1,getLang(action.value)) - end - - if(action.name == "log") then - logme(getLang(action.value),action.level) - end - - if(action.name == "shard_window") then - shardUIevent = NotifyShardRead.new() - shardUIevent.text = getLang(action.content) - shardUIevent.title = getLang(action.title) - Game.GetUISystem():QueueEvent(shardUIevent) - end - if(action.name == "add_time") then - local temp = getGameTime() - addGameTime(temp, action.value) - end - if(action.name == "set_time") then - setGameTime(action.hour,action.minute) - end - if(action.name == "add_stat") then - Game.GetStatPoolsSystem():RequestChangingStatPoolValue(Game.GetPlayer():GetEntityID(), action.value, action_score, Game.GetPlayer(), true, false) - end - if(action.name == "add_stat_perc") then - Game.GetStatPoolsSystem():RequestChangingStatPoolValue(Game.GetPlayer():GetEntityID(), action.value, action.score, Game.GetPlayer(), true, true) - end - if(action.name == "mod_stat") then - -- https://nativedb.red4ext.com/gamedataStatType - Game.ModStatPlayer(action.value, action.score) - end - if(action.name == "mod_statpool") then - --https://nativedb.red4ext.com/gamedataStatPoolType - if(action.tag == nil) then + else + + notificationData.message = section.message + if(section.action ~=nil and #section.action > 0) then + runActionList(section.action, myHelp.tag.."_"..currentHelpIndex, tag,source,false,executortag) + end + end + notificationData.imageId = nil + notificationData.videoType = gameVideoType.Unknown + notificationData.video = nil + notificationData.useCursor = true + notificationData.isBlocking = action.isblocking + + UIPopupsManager.ShowPopup(notificationData) + else + Game.GetPlayer():SetWarningMessage(getLang("see_action_poup_fail")) + end + end + + else + logme(10,"no help founded with the tag "..action.tag) + end + end + + if(action.name == "hide_tutorial_notification") then + if GameController["TutorialPopupGameController"] ~= nil then + GameController["TutorialPopupGameController"]:GetRootWidget():SetVisible(false) + end + end + + if(action.name == "start_upload_program") then + local evt = UploadProgramProgressEvent.new() + evt.state = EUploadProgramState.STARTED + evt.duration = action.duration + evt.progressBarType = EProgressBarType.UPLOAD + evt.progressBarContext = EProgressBarContext.QuickHack + + evt.statPoolType = gamedataStatPoolType.QuickHackUpload + Game.GetPersistencySystem():QueueEntityEvent(Game.GetPlayer():GetEntityID(), evt) + end + + if(action.name == "end_upload_program") then + local evt = UploadProgramProgressEvent.new() + evt.state = EUploadProgramState.COMPLETED + evt.duration = action.duration + evt.progressBarType = EProgressBarType.UPLOAD + evt.progressBarContext = EProgressBarContext.QuickHack + + evt.statPoolType = gamedataStatPoolType.QuickHackUpload + Game.GetPersistencySystem():QueueEntityEvent(Game.GetPlayer():GetEntityID(), evt) + end + + + if(action.name == "set_metro_time") then + MetroCurrentTime = action.value + end + if(action.name == "trigger_metro_time") then + activeMetroDisplay = action.value + end + if(action.name == "consolelog") then + logme(1,getLang(action.value)) + end + + if(action.name == "log") then + logme(getLang(action.value),action.level) + end + + if(action.name == "shard_window") then + shardUIevent = NotifyShardRead.new() + shardUIevent.text = getLang(action.content) + shardUIevent.title = getLang(action.title) + Game.GetUISystem():QueueEvent(shardUIevent) + end + if(action.name == "add_time") then + local temp = getGameTime() + addGameTime(temp, action.value) + end + if(action.name == "set_time") then + setGameTime(action.hour,action.minute) + end + if(action.name == "add_stat") then + Game.GetStatPoolsSystem():RequestChangingStatPoolValue(Game.GetPlayer():GetEntityID(), action.value, action_score, Game.GetPlayer(), true, false) + end + if(action.name == "add_stat_perc") then + Game.GetStatPoolsSystem():RequestChangingStatPoolValue(Game.GetPlayer():GetEntityID(), action.value, action.score, Game.GetPlayer(), true, true) + end + if(action.name == "mod_stat") then + -- https://nativedb.red4ext.com/gamedataStatType + Game.ModStatPlayer(action.value, action.score) + end + if(action.name == "mod_statpool") then + --https://nativedb.red4ext.com/gamedataStatPoolType + if(action.tag == nil) then - action.tag = "player" - end - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - Game.GetStatPoolsSystem():RequestSettingStatPoolValue(enti:GetEntityID(), Enum.new('gamedataStatPoolType', action.value), action.score, Game.GetPlayer(), action.perc); - else - error("can't apply mod_statpool to this entity") - end + action.tag = "player" + end + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + + if(enti ~= nil) then + Game.GetStatPoolsSystem():RequestSettingStatPoolValue(enti:GetEntityID(), Enum.new('gamedataStatPoolType', action.value), action.score, Game.GetPlayer(), action.perc); + else + error("can't apply mod_statpool to this entity") + end - - end - if(action.name == "mod_statpool_max") then - --https://nativedb.red4ext.com/gamedataStatPoolType - if(action.tag == nil) then + + end + if(action.name == "mod_statpool_max") then + --https://nativedb.red4ext.com/gamedataStatPoolType + if(action.tag == nil) then - action.tag = "player" - end - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - Game.GetStatPoolsSystem():RequestSettingStatPoolMaxValue(enti:GetEntityID(), Enum.new('gamedataStatPoolType', action.value), Game.GetPlayer()); - else - error("can't apply mod_statpool to this entity") - end + action.tag = "player" + end + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + + if(enti ~= nil) then + Game.GetStatPoolsSystem():RequestSettingStatPoolMaxValue(enti:GetEntityID(), Enum.new('gamedataStatPoolType', action.value), Game.GetPlayer()); + else + error("can't apply mod_statpool to this entity") + end - end - - if(action.name == "set_attribute") then - Game.SetAtt(action.value, action.score) - end - - if(action.name == "give_skill_point") then - Game.GiveDevPoints("Attribute", action.score) - end - - if(action.name == "give_perk_point") then - Game.GiveDevPoints("Primary", action.score) - end - - if(action.name == "toggle_infinite_stamina") then - InfiniteStamina(action.value) - end - - if(action.name == "set_level") then - Game.SetLevel("Level", action.score) - - end - - - - if(action.name == "wanted_level") then - -- local preventionSystem = Game.GetScriptableSystemsContainer():Get("PreventionSystem") - -- preventionSystem:SetHeatStage(action.value) - -- preventionSystem:OnHeatChanged() - -- if(action.value == 0) then - - - -- if preventionSystem:IsChasingPlayer() then - - - -- preventionSystem.systemDisabled = false - -- preventionSystem:WhipeBlinkData() - -- preventionSystem:ChangeAgentsAttitude(EAIAttitude.AIA_Neutral) - -- preventionSystem:WakeUpAllAgents(false) - -- preventionSystem:WhipeHitNPC() - -- preventionSystem:DespawnAllPolice() - -- preventionSystem:RemovePlayerFromSecuritySystemBlacklist() - -- preventionSystem:CancelAllDelayedEvents() - -- preventionSystem.isHidingFromPolice = false - -- preventionSystem.generalPercent = 0 - - -- for _, veh in ipairs(preventionSystem.vehicles) do - -- if preventionSystem:IsVehicleValid(veh) then - -- Game.GetPreventionSpawnSystem():JoinTraffic(veh) - -- end - -- end - - -- local playergroup = Game.GetPlayer():GetAttitudeAgent():GetAttitudeGroup() - -- Game.GetAttitudeSystem():SetAttitudeGroupRelationPersistent("police", playergroup, EAIAttitude.AIA_Neutral) - -- end - -- end - Game.GetScriptableSystemsContainer():Get("PreventionSystem"):OnSetWantedLevel(SetWantedLevel.new({wantedLevel =action.value })) - end - if(action.name == "change_zone") then - if(action.value == "safe") then - - RemoveEffectPlayer("GameplayRestriction.NoCombat") - - ChangeZoneIndicatorSafe() - - end - if(action.value == "neutral") then - Game.ChangeZoneIndicatorPublic() - RemoveEffectPlayer("GameplayRestriction.NoCombat") - end - if(action.value == "hostile") then - Game.ChangeZoneIndicatorDanger() - RemoveEffectPlayer("GameplayRestriction.NoCombat") - end - end - if(action.name == "recording_mode") then - if(action.value == "true") then - Game.t1() - recordingMode = true - end - if(action.value == "false") then - Game.t2() - recordingMode = false - end - end - if(action.name == "fade_in") then - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - nexttemp =nexttemp + action.value - fademessage = getLang(action.message) - action.tick = nexttemp - result = false - end - if(action.name == "fade_out") then - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - nexttemp =nexttemp + action.value - action.tick = nexttemp - result = false - end - if(action.name == "set_timer") then - if(currentTimer == nil) then - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - nexttemp =nexttemp + action.value - currentTimer = {} - currentTimer.time = nexttemp - currentTimer.value = (action.value) - currentTimer.message = action.message - currentTimer.type = action.type - ticktimer = 0 - else - Game.GetPlayer():SetWarningMessage(getLang("see_timer_already")) - end - end - - - - - - if(action.name == "reset_timer") then - currentTimer = nil - - ticktimer = 0 - end - - - if(action.name == "open_stash") then - local stash = getMainStash() - if stash then - local openEvent = NewObject('handle:OpenStash') - openEvent:SetProperties() - stash:OnOpenStash(openEvent) - end - end - if(action.name == "open_door") then - if IsAFakeDoor(objLook) then - objLook:Dispose() - else - local handlePS = objLook:GetDevicePS() - if handlePS:IsLocked() then handlePS:ToggleLockOnDoor() end - if handlePS:IsSealed() then handlePS:ToggleSealOnDoor() end - if handlePS:IsSealed() then handlePS:ToggleSealOnDoor() end - objLook:OpenDoor() - end - end - if(action.name == "set_mappin") then - - if(action.position ~= "on_entity" and action.position ~= "on_group")then - local position = getPositionFromParameter(action) - if(position.x ~= nil)then - registerMappin(position.x,position.y,position.z,action.tag,action.typemap,action.wall,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) - else - error("can't make an mappin to this position") - end - else - if(action.position == "on_entity")then - if(action.position_tag ~= nil)then - local obj = getEntityFromManager(action.position_tag) - local enti = Game.GetPlayer() - if(action.position_tag ~= "player") then - enti = Game.FindEntityByID(obj.id) - end - if(enti ~= nil) then - registerMappintoEntity(enti,action.tag,action.typemap,action.wall,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) - else - error("can't make an mappin to this entity") - end - else - error("can't make an mappin to this entity") - end - end - if(action.position == "on_group")then - local group =getGroupfromManager(action.position_tag) - if group ~= nil then - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local mapTag = action.position_tag.."_"..i - registerMappintoEntity(enti,mapTag,action.typemap,action.wall,action.active,action.mapgroup,action.title,action.desc,action.color,action.icon) - else - error("can't make an mappin to this entity") - end - end - else - error("can't make an mappin to this group") - end - end - end - end - - - - - if(action.name == "edit_mappin") then - - if(action.position ~= "on_entity" and action.position ~= "on_group")then - local position = getPositionFromParameter(action) - if(position.x ~= nil)then - editMappin(position.x,position.y,position.z,action.tag,action.typemap,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) - else - error("can't make an mappin to this position") - end - else - if(action.position == "on_entity")then - if(action.position_tag ~= nil)then - local obj = getEntityFromManager(action.position_tag) - local enti = Game.GetPlayer() - if(action.position_tag ~= "player") then - enti = Game.FindEntityByID(obj.id) - end - if(enti ~= nil) then - editMappin(enti,action.tag,action.typemap,action.wall,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) - setMappinTrackingByTag(tag,enti) - else - error("can't make an mappin to this entity") - end - else - error("can't make an mappin to this entity") - end - end - if(action.position == "on_group")then - local group =getGroupfromManager(action.position_tag) - if group ~= nil then - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local mapTag = action.position_tag.."_"..i - - editMappin(enti,action.mapTag,action.typemap,action.wall,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) - setMappinTrackingByTag(mapTag,enti) - else - error("can't make an mappin to this entity") - end - end - else - error("can't make an mappin to this group") - end - end - end - end - - - - - - - - if(action.name == "delete_map_point" or action.name == "delete_mappin") then - deleteMappinByTag(action.tag) - end - if(action.name == "delete_map_group" or action.name == "delete_mappin_group") then - local maplist = getMappinByGroup(action.mapgroup) - if(#maplist > 0) then - for i = 1,#maplist do - deleteMappinByTag(maplist[i].tag) - end - end - end - if(action.name == "active_map_point" or action.name == "active_mappin") then - activeMappinByTag(action.tag,action.active) - end - if(action.name == "active_map_group" or action.name == "active_mappin_group") then - local maplist = getMappinByGroup(action.mapgroup) - if(#maplist > 0) then - for i = 1,#maplist do - activeMappinByTag(maplist[i].tag,action.active) - end - end - end - if(action.name == "track_mappin") then - local mappin = getMappinByTag(action.tag) - - if(mappin)then - local startHub = StartHubMenuEvent.new() - - local userData = MapMenuUserData.new() - userData.moveTo = Vector3.new(mappin.position.x, mappin.position.y, mappin.position.z) - startHub:SetStartMenu("world_map",nil,userData) - - Game.GetUISystem():QueueEvent(startHub) - Cron.After(1, function() - if GameController["WorldMapMenuGameController"] ~= nil then - - - - - GameController["WorldMapMenuGameController"]:UpdateCustomFilter(gamedataWorldMapFilter.Quest,false) - GameController["WorldMapMenuGameController"]:TrackMappin(mappin.controller) - + end + + if(action.name == "set_attribute") then + Game.SetAtt(action.value, action.score) + end + + if(action.name == "give_skill_point") then + Game.GiveDevPoints("Attribute", action.score) + end + + if(action.name == "give_perk_point") then + Game.GiveDevPoints("Primary", action.score) + end + + if(action.name == "toggle_infinite_stamina") then + InfiniteStamina(action.value) + end + + if(action.name == "set_level") then + Game.SetLevel("Level", action.score) + + end + + + + if(action.name == "wanted_level") then + -- local preventionSystem = Game.GetScriptableSystemsContainer():Get("PreventionSystem") + -- preventionSystem:SetHeatStage(action.value) + -- preventionSystem:OnHeatChanged() + -- if(action.value == 0) then + + + -- if preventionSystem:IsChasingPlayer() then + + + -- preventionSystem.systemDisabled = false + -- preventionSystem:WhipeBlinkData() + -- preventionSystem:ChangeAgentsAttitude(EAIAttitude.AIA_Neutral) + -- preventionSystem:WakeUpAllAgents(false) + -- preventionSystem:WhipeHitNPC() + -- preventionSystem:DespawnAllPolice() + -- preventionSystem:RemovePlayerFromSecuritySystemBlacklist() + -- preventionSystem:CancelAllDelayedEvents() + -- preventionSystem.isHidingFromPolice = false + -- preventionSystem.generalPercent = 0 + + -- for _, veh in ipairs(preventionSystem.vehicles) do + -- if preventionSystem:IsVehicleValid(veh) then + -- Game.GetPreventionSpawnSystem():JoinTraffic(veh) + -- end + -- end + + -- local playergroup = Game.GetPlayer():GetAttitudeAgent():GetAttitudeGroup() + -- Game.GetAttitudeSystem():SetAttitudeGroupRelationPersistent("police", playergroup, EAIAttitude.AIA_Neutral) + -- end + -- end + Game.GetScriptableSystemsContainer():Get("PreventionSystem"):OnSetWantedLevel(SetWantedLevel.new({wantedLevel =action.value })) + end + if(action.name == "change_zone") then + if(action.value == "safe") then + + RemoveEffectPlayer("GameplayRestriction.NoCombat") + + ChangeZoneIndicatorSafe() + + end + if(action.value == "neutral") then + Game.ChangeZoneIndicatorPublic() + RemoveEffectPlayer("GameplayRestriction.NoCombat") + end + if(action.value == "hostile") then + Game.ChangeZoneIndicatorDanger() + RemoveEffectPlayer("GameplayRestriction.NoCombat") + end + end + if(action.name == "recording_mode") then + if(action.value == "true") then + Game.t1() + recordingMode = true + end + if(action.value == "false") then + Game.t2() + recordingMode = false + end + end + if(action.name == "fade_in") then + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + nexttemp =nexttemp + action.value + fademessage = getLang(action.message) + action.tick = nexttemp + result = false + end + if(action.name == "fade_out") then + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + nexttemp =nexttemp + action.value + action.tick = nexttemp + result = false + end + if(action.name == "set_timer") then + if(currentTimer == nil) then + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + nexttemp =nexttemp + action.value + currentTimer = {} + currentTimer.time = nexttemp + currentTimer.value = (action.value) + currentTimer.message = action.message + currentTimer.type = action.type + ticktimer = 0 + else + Game.GetPlayer():SetWarningMessage(getLang("see_timer_already")) + end + end + + + + + + if(action.name == "reset_timer") then + currentTimer = nil + + ticktimer = 0 + end + + + if(action.name == "open_stash") then + local stash = getMainStash() + if stash then + local openEvent = NewObject('handle:OpenStash') + openEvent:SetProperties() + stash:OnOpenStash(openEvent) + end + end + if(action.name == "open_door") then + if IsAFakeDoor(objLook) then + objLook:Dispose() + else + local handlePS = objLook:GetDevicePS() + if handlePS:IsLocked() then handlePS:ToggleLockOnDoor() end + if handlePS:IsSealed() then handlePS:ToggleSealOnDoor() end + if handlePS:IsSealed() then handlePS:ToggleSealOnDoor() end + objLook:OpenDoor() + end + end + if(action.name == "set_mappin") then + + if(action.position ~= "on_entity" and action.position ~= "on_group")then + local position = getPositionFromParameter(action) + if(position.x ~= nil)then + registerMappin(position.x,position.y,position.z,action.tag,action.typemap,action.wall,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) + else + error("can't make an mappin to this position") + end + else + if(action.position == "on_entity")then + if(action.position_tag ~= nil)then + local obj = getEntityFromManager(action.position_tag) + local enti = Game.GetPlayer() + if(action.position_tag ~= "player") then + enti = safeFindEntityByID(obj) + end + if(enti ~= nil) then + registerMappintoEntity(enti,action.tag,action.typemap,action.wall,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) + else + error("can't make an mappin to this entity") + end + else + error("can't make an mappin to this entity") + end + end + if(action.position == "on_group")then + local group =getGroupfromManager(action.position_tag) + if group ~= nil then + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local mapTag = action.position_tag.."_"..i + registerMappintoEntity(enti,mapTag,action.typemap,action.wall,action.active,action.mapgroup,action.title,action.desc,action.color,action.icon) + else + error("can't make an mappin to this entity") + end + end + else + error("can't make an mappin to this group") + end + end + end + end + + + + + if(action.name == "edit_mappin") then + + if(action.position ~= "on_entity" and action.position ~= "on_group")then + local position = getPositionFromParameter(action) + if(position.x ~= nil)then + editMappin(position.x,position.y,position.z,action.tag,action.typemap,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) + else + error("can't make an mappin to this position") + end + else + if(action.position == "on_entity")then + if(action.position_tag ~= nil)then + local obj = getEntityFromManager(action.position_tag) + local enti = Game.GetPlayer() + if(action.position_tag ~= "player") then + enti = safeFindEntityByID(obj) + end + if(enti ~= nil) then + editMappin(enti,action.tag,action.typemap,action.wall,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) + setMappinTrackingByTag(tag,enti) + else + error("can't make an mappin to this entity") + end + else + error("can't make an mappin to this entity") + end + end + if(action.position == "on_group")then + local group =getGroupfromManager(action.position_tag) + if group ~= nil then + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local mapTag = action.position_tag.."_"..i + + editMappin(enti,action.mapTag,action.typemap,action.wall,action.active,action.mapgroup,nil,action.title,action.desc,action.color,action.icon) + setMappinTrackingByTag(mapTag,enti) + else + error("can't make an mappin to this entity") + end + end + else + error("can't make an mappin to this group") + end + end + end + end + + + + + + + + if(action.name == "delete_map_point" or action.name == "delete_mappin") then + deleteMappinByTag(action.tag) + end + if(action.name == "delete_map_group" or action.name == "delete_mappin_group") then + local maplist = getMappinByGroup(action.mapgroup) + if(#maplist > 0) then + for i = 1,#maplist do + deleteMappinByTag(maplist[i].tag) + end + end + end + if(action.name == "active_map_point" or action.name == "active_mappin") then + activeMappinByTag(action.tag,action.active) + end + if(action.name == "active_map_group" or action.name == "active_mappin_group") then + local maplist = getMappinByGroup(action.mapgroup) + if(#maplist > 0) then + for i = 1,#maplist do + activeMappinByTag(maplist[i].tag,action.active) + end + end + end + if(action.name == "track_mappin") then + local mappin = getMappinByTag(action.tag) + + if(mappin)then + local startHub = StartHubMenuEvent.new() + + local userData = MapMenuUserData.new() + userData.moveTo = Vector3.new(mappin.position.x, mappin.position.y, mappin.position.z) + startHub:SetStartMenu("world_map",nil,userData) + + Game.GetUISystem():QueueEvent(startHub) + Cron.After(1, function() + if GameController["WorldMapMenuGameController"] ~= nil then + + + + + GameController["WorldMapMenuGameController"]:UpdateCustomFilter(gamedataWorldMapFilter.Quest,false) + GameController["WorldMapMenuGameController"]:TrackMappin(mappin.controller) + - Cron.After(5, function() - GameController["WorldMapMenuGameController"]:UpdateCustomFilter(gamedataWorldMapFilter.Quest,true) - GameController["WorldMapMenuGameController"]:TrackMappin(mappin.controller) - - Cron.After(2, function() - GameController["WorldMapMenuGameController"]:TrackMappin(mappin.controller) - - - local closeHub = ForceCloseHubMenuEvent.new() - Game.GetUISystem():QueueEvent(closeHub) - - end) - - - end) - - end - end) - end - - end - if(action.name == "untrack_mappin") then - if GameController["WorldMapMenuGameController"] ~= nil and GameController["WorldMapMenuGameController"]:IsA("gameuiWorldMapMenuGameController") then - local mappin = getMappinByTag(action.tag) - if(mappin and mappin.controller ~= nil)then - GameController["WorldMapMenuGameController"]:UntrackMappin() - end - - - end - end - - if(action.name == "set_map_point_position" or action.name == "set_mappin_position") then - setMappinPositionByTag(action.tag,action.x,action.y,action.z) - end - if(action.name == "set_map_group_position" or action.name == "set_mappin_group_position") then - local maplist = getMappinByGroup(action.mapgroup) - if(#maplist > 0) then - for i = 1,#maplist do - setMappinPositionByTag(maplist[i].tag,action.x,action.y,action.z) - end - end - end - if(action.name == "set_map_point_type" or action.name == "set_mappin_type") then - setMappinTypeByTag(action.tag,action.typemap) - end - if(action.name == "set_map_group_type" or action.name == "set_mappin_group_type") then - local maplist = getMappinByGroup(action.mapgroup) - if(#maplist > 0) then - for i = 1,#maplist do - setMappinTypeByTag(maplist[i].tag,action.typemap) - end - end - end - if(action.name == "set_map_point_tracking_to" or action.name == "set_mappin_tracking_to") then - setMappinTrackingByTag(action.tag,action.target) - end - if(action.name == "set_map_group_tracking_to" or action.name == "set_mappin_group_tracking_to") then - local maplist = getMappinByGroup(action.mapgroup) - if(#maplist > 0) then - for i = 1,#maplist do - setMappinTrackingByTag(maplist[i].tag,action.target) - end - end - end - - if(action.name == "loot_item") then - - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - - if(action.target == "lookat" )then - enti = objLook - - end - - if(enti ~= nil) then - - if(#action.value > 1) then - local instructions = {} - - - for i,value in ipairs(action.value) do - - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new(value) - local itemid = ItemID.new(tid) - local result = ts:GiveItem(enti, itemid, 1) - - - table.insert(instructions, DropInstruction.Create(itemid, 1)) - - - -- if (RPGManager.GetItemCategory(itemid) ~= gamedataItemCategory.Part and RPGManager.GetItemCategory(itemid) ~= gamedataItemCategory.Weapon) then - - -- else - -- ----print(RPGManager.GetItemCategory(itemid)) - -- Game.GetLootManager():SpawnItemDrop(enti,itemid,Vector4.new(action.x,action.y,action.z+1,1)) - -- end - - - - - - - - end - - Game.GetLootManager():SpawnItemDropOfManyItems(enti, instructions, "playerDropBag",Vector4.new(action.x,action.y,action.z+1,1)) - - else - - - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new(action.value[1]) - local itemid = ItemID.new(tid) - local result = ts:GiveItem(enti, itemid, 1) - - - - - local instructions = {} - - - if (RPGManager.GetItemCategory(itemid) ~= gamedataItemCategory.Part or RPGManager.GetItemCategory(itemid) ~= gamedataItemCategory.Weapon ) then - table.insert(instructions, DropInstruction.Create(itemid, 1)) - ----print("test"..action.x) - ----print("test"..action.y) - ----print("test"..action.z) - Game.GetLootManager():SpawnItemDropOfManyItems(Game.GetPlayerSystem():GetLocalPlayerControlledGameObject(), instructions, "playerDropBag",Vector4.new(action.x,action.y,action.z,1)) - else - Game.GetLootManager():SpawnItemDrop(enti,itemid,Vector4.new(action.x,action.y,action.z+1,1)) - end - - - - end - end - end - - if(action.name == "save_lock") then - if(action.value == true)then - local request = SaveLockRequest.new() - request.operation = EItemOperationType.ADD - request.reason = 'FastTravel' - GameInstance.QueueScriptableSystemRequest('SaveLocksManager', request) - else - - local request = SaveLockRequest.new() - request.operation = EItemOperationType.REMOVE - request.reason = 'FastTravel' - GameInstance.QueueScriptableSystemRequest('SaveLocksManager', request) - - end - end - - if(action.name == "safe_execution") then - local status, result = pcall(executeAction(action.action,tag,parent,index,source,executortag)) - - - - if status == false then - - if(action.output == true) then - - logme(1,action.name) - logme(1,dump(action)) - logme(1,tostring(result)) - end - - logme(1,getLang("Action execution error") .. result.." Action : "..tostring(JSON:encode_pretty(action))) - - --Game.GetPlayer():SetWarningMessage("CyberScript Trigger error, check the log for more detail") - runActionList(action.failactions, tag, source,false,executortag) - - end - - end - - if(action.name == "change_weather") then - Game.GetWeatherSystem():SetWeather(action.value, action.blendtime, action.priority); - end - - if(action.name == "reset_weather") then - Game.GetWeatherSystem():ResetWeather(action.value);; - end - - if(action.name == "set_tweak") then - TweakDB:SetFlat(action.source, action.value) - end + Cron.After(5, function() + GameController["WorldMapMenuGameController"]:UpdateCustomFilter(gamedataWorldMapFilter.Quest,true) + GameController["WorldMapMenuGameController"]:TrackMappin(mappin.controller) + + Cron.After(2, function() + GameController["WorldMapMenuGameController"]:TrackMappin(mappin.controller) + + + local closeHub = ForceCloseHubMenuEvent.new() + Game.GetUISystem():QueueEvent(closeHub) + + end) + + + end) + + end + end) + end + + end + if(action.name == "untrack_mappin") then + if GameController["WorldMapMenuGameController"] ~= nil and GameController["WorldMapMenuGameController"]:IsA("gameuiWorldMapMenuGameController") then + local mappin = getMappinByTag(action.tag) + if(mappin and mappin.controller ~= nil)then + GameController["WorldMapMenuGameController"]:UntrackMappin() + end + + + end + end + + if(action.name == "set_map_point_position" or action.name == "set_mappin_position") then + setMappinPositionByTag(action.tag,action.x,action.y,action.z) + end + if(action.name == "set_map_group_position" or action.name == "set_mappin_group_position") then + local maplist = getMappinByGroup(action.mapgroup) + if(#maplist > 0) then + for i = 1,#maplist do + setMappinPositionByTag(maplist[i].tag,action.x,action.y,action.z) + end + end + end + if(action.name == "set_map_point_type" or action.name == "set_mappin_type") then + setMappinTypeByTag(action.tag,action.typemap) + end + if(action.name == "set_map_group_type" or action.name == "set_mappin_group_type") then + local maplist = getMappinByGroup(action.mapgroup) + if(#maplist > 0) then + for i = 1,#maplist do + setMappinTypeByTag(maplist[i].tag,action.typemap) + end + end + end + if(action.name == "set_map_point_tracking_to" or action.name == "set_mappin_tracking_to") then + setMappinTrackingByTag(action.tag,action.target) + end + if(action.name == "set_map_group_tracking_to" or action.name == "set_mappin_group_tracking_to") then + local maplist = getMappinByGroup(action.mapgroup) + if(#maplist > 0) then + for i = 1,#maplist do + setMappinTrackingByTag(maplist[i].tag,action.target) + end + end + end + + if(action.name == "loot_item") then + + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + + if(action.target == "lookat" )then + enti = objLook + + end + + if(enti ~= nil) then + + if(#action.value > 1) then + local instructions = {} + + + for i,value in ipairs(action.value) do + + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new(value) + local itemid = ItemID.new(tid) + local result = ts:GiveItem(enti, itemid, 1) + + + table.insert(instructions, DropInstruction.Create(itemid, 1)) + + + -- if (RPGManager.GetItemCategory(itemid) ~= gamedataItemCategory.Part and RPGManager.GetItemCategory(itemid) ~= gamedataItemCategory.Weapon) then + + -- else + -- ----print(RPGManager.GetItemCategory(itemid)) + -- Game.GetLootManager():SpawnItemDrop(enti,itemid,Vector4.new(action.x,action.y,action.z+1,1)) + -- end + + + + + + + + end + + Game.GetLootManager():SpawnItemDropOfManyItems(enti, instructions, "playerDropBag",Vector4.new(action.x,action.y,action.z+1,1)) + + else + + + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new(action.value[1]) + local itemid = ItemID.new(tid) + local result = ts:GiveItem(enti, itemid, 1) + + + + + local instructions = {} + + + if (RPGManager.GetItemCategory(itemid) ~= gamedataItemCategory.Part or RPGManager.GetItemCategory(itemid) ~= gamedataItemCategory.Weapon ) then + table.insert(instructions, DropInstruction.Create(itemid, 1)) + ----print("test"..action.x) + ----print("test"..action.y) + ----print("test"..action.z) + Game.GetLootManager():SpawnItemDropOfManyItems(Game.GetPlayerSystem():GetLocalPlayerControlledGameObject(), instructions, "playerDropBag",Vector4.new(action.x,action.y,action.z,1)) + else + Game.GetLootManager():SpawnItemDrop(enti,itemid,Vector4.new(action.x,action.y,action.z+1,1)) + end + + + + end + end + end + + if(action.name == "save_lock") then + if(action.value == true)then + local request = SaveLockRequest.new() + request.operation = EItemOperationType.ADD + request.reason = 'FastTravel' + GameInstance.QueueScriptableSystemRequest('SaveLocksManager', request) + else + + local request = SaveLockRequest.new() + request.operation = EItemOperationType.REMOVE + request.reason = 'FastTravel' + GameInstance.QueueScriptableSystemRequest('SaveLocksManager', request) + + end + end + + if(action.name == "safe_execution") then + local status, result = pcall(executeAction(action.action,tag,parent,index,source,executortag)) + + + + if status == false then + + if(action.output == true) then + + logme(1,action.name) + logme(1,dump(action)) + logme(1,tostring(result)) + end + + logme(1,getLang("Action execution error") .. result.." Action : "..tostring(JSON:encode_pretty(action))) + + --Game.GetPlayer():SetWarningMessage("CyberScript Trigger error, check the log for more detail") + runActionList(action.failactions, tag, source,false,executortag) + + end + + end + + if(action.name == "change_weather") then + Game.GetWeatherSystem():SetWeather(action.value, action.blendtime, action.priority); + end + + if(action.name == "reset_weather") then + Game.GetWeatherSystem():ResetWeather(action.value);; + end + + if(action.name == "set_tweak") then + TweakDB:SetFlat(action.source, action.value) + end - if(action.name == "set_noupdate_tweak") then - TweakDB:SetFlatNoUpdate(action.source, action.value) - end + if(action.name == "set_noupdate_tweak") then + TweakDB:SetFlatNoUpdate(action.source, action.value) + end - if(action.name == "update_tweak") then - TweakDB:Update(action.source) - end + if(action.name == "update_tweak") then + TweakDB:Update(action.source) + end - if(action.name == "set_by_get_tweak") then - TweakDB:SetFlat(action.source, TweakDB:GetFlat(action.value)) - end + if(action.name == "set_by_get_tweak") then + TweakDB:SetFlat(action.source, TweakDB:GetFlat(action.value)) + end - if(action.name == "set_by_get_noupdate_tweak") then - TweakDB:SetFlatNoUpdate(action.source, TweakDB:GetFlat(action.value)) - end + if(action.name == "set_by_get_noupdate_tweak") then + TweakDB:SetFlatNoUpdate(action.source, TweakDB:GetFlat(action.value)) + end - if(action.name == "clone_tweak") then - TweakDB:CloneRecord(action.source, action.value) - end + if(action.name == "clone_tweak") then + -- B-21 fix: skip if record already exists (avoids log spam) + pcall(function() + if TweakDB:GetRecord(action.source) == nil then + TweakDB:CloneRecord(action.source, action.value) + end + end) + end - if(action.name == "create_tweak") then - TweakDB:CreateRecord(action.source, action.value) - end + if(action.name == "create_tweak") then + -- B-21 fix: skip if record already exists (avoids log spam) + pcall(function() + if TweakDB:GetRecord(action.source) == nil then + TweakDB:CreateRecord(action.source, action.value) + end + end) + end - if(action.name == "delete_tweak") then - TweakDB:DeleteRecord(action.source) - end + if(action.name == "delete_tweak") then + TweakDB:DeleteRecord(action.source) + end - if(action.name == "change_journal_entry_state_by_hash") then - local state = gameJournalEntryState.Undefined - - + if(action.name == "change_journal_entry_state_by_hash") then + local state = gameJournalEntryState.Undefined + + - if(action.state == 1) then - - state = gameJournalEntryState.Inactive - end + if(action.state == 1) then + + state = gameJournalEntryState.Inactive + end - if(action.state == 2) then - - state = gameJournalEntryState.Active - end + if(action.state == 2) then + + state = gameJournalEntryState.Active + end - if(action.state == 3) then - - state = gameJournalEntryState.Succeeded - end + if(action.state == 3) then + + state = gameJournalEntryState.Succeeded + end - if(action.state == 4) then - - state = gameJournalEntryState.Failed - - end - local notify = JournalNotifyOption.DoNotNotify - if(action.notify == true) then - - notify = JournalNotifyOption.Notify - end + if(action.state == 4) then + + state = gameJournalEntryState.Failed + + end + local notify = JournalNotifyOption.DoNotNotify + if(action.notify == true) then + + notify = JournalNotifyOption.Notify + end - Game.GetJournalManager():ChangeEntryStateByHash(tonumber(action.hash), state, notify) - - end + Game.GetJournalManager():ChangeEntryStateByHash(tonumber(action.hash), state, notify) + + end - - - end - - if relationregion then - if(action.name == "dialog") then - --logme(3,"is logme(10,source) - local usedial = SetNextDialog(action.dialog,source,executortag) - -- logme(3,source) - -- logme(3,executortag) - -- logme(3,usedial.desc) - createDialog(usedial) - -- logme(3,source) - -- if(source == "quest") then - -- local dioal = SetNextDialog(action.value,source) - -- if dioal.havequitoption == nil then dioal.havequitoption = true end - -- logme(3,dioal.desc) - -- openQuestDialogWindow = false - -- currentQuestdialog = dioal - -- openQuestDialogWindow = true - -- end - -- if(source == "interact") then - -- local dioal = SetNextDialog(action.value,source) - -- if dioal.havequitoption == nil then dioal.havequitoption = true end - -- logme(3,dioal.desc) - -- openEventDialogWindow = false - -- currentEventDialog = dioal - -- openEventDialogWindow = true - -- end - -- if(source == "phone") then - -- local dioal = SetNextDialog(action.value,source) - -- if dioal.havequitoption == nil then dioal.havequitoption = true end - -- logme(3,dioal.desc) - -- openPhoneDialogWindow = false - -- currentPhoneDialog = dioal - -- openPhoneDialogWindow = true - -- --SetDialogPhoneUI(dioal) - -- ------logme(3,"dialog phone enabled") - -- end - -- if(source == "speak") then - -- local dioal = SetNextDialog(action.value,source) - -- if dioal.havequitoption == nil then dioal.havequitoption = true end - -- logme(3,dioal.desc) - -- openSpeakDialogWindow = false - -- currentSpeakDialog = dioal - -- openSpeakDialogWindow = true - -- end - end - if(action.name == "clean_dialog") then - interactionUI.hideHub() - currentDialogHub = nil - --print(dump((currentDialogHub))) - end - - if(action.name == "inject_dialog") then - --logme(3,"is logme(10,source) - local usedial = SetNextDialog(action.dialog,source,executortag) - if(interactionUI.injectdialog == nil) then interactionUI.injectdialog = {} end - table.insert(interactionUI.injectdialog,usedial) - - - -- logme(3,source) - -- logme(3,executortag) - -- logme(3,usedial.desc) - - -- logme(3,source) - -- if(source == "quest") then - -- local dioal = SetNextDialog(action.value,source) - -- if dioal.havequitoption == nil then dioal.havequitoption = true end - -- logme(3,dioal.desc) - -- openQuestDialogWindow = false - -- currentQuestdialog = dioal - -- openQuestDialogWindow = true - -- end - -- if(source == "interact") then - -- local dioal = SetNextDialog(action.value,source) - -- if dioal.havequitoption == nil then dioal.havequitoption = true end - -- logme(3,dioal.desc) - -- openEventDialogWindow = false - -- currentEventDialog = dioal - -- openEventDialogWindow = true - -- end - -- if(source == "phone") then - -- local dioal = SetNextDialog(action.value,source) - -- if dioal.havequitoption == nil then dioal.havequitoption = true end - -- logme(3,dioal.desc) - -- openPhoneDialogWindow = false - -- currentPhoneDialog = dioal - -- openPhoneDialogWindow = true - -- --SetDialogPhoneUI(dioal) - -- ------logme(3,"dialog phone enabled") - -- end - -- if(source == "speak") then - -- local dioal = SetNextDialog(action.value,source) - -- if dioal.havequitoption == nil then dioal.havequitoption = true end - -- logme(3,dioal.desc) - -- openSpeakDialogWindow = false - -- currentSpeakDialog = dioal - -- openSpeakDialogWindow = true - -- end - end - - - - if(action.name == "speak_npc")then - - - - if(action.speaker == "current_phone_npc") then - - if(currentNPC ~= nil) then - - loadBasicDialog(currentNPC,action.way) - - else - - error("No Current NPC at Phone exist") - end - - - elseif(action.speaker == "current_star") then - - if(currentStar ~= nil) then - - loadBasicDialog(currentStar,action.way) - else - - error("No Current Star exist") - end - - - else - local phoned = findPhonedNPCByName(action.speaker) - if(phoned ~= nil) then - - loadBasicDialog(phoned,action.way) - else - - error("No NPC exist") - end - end - - end - - - - - if(action.name == "speak_to_current_star")then - - - if currentStar ~= nil then - --if string.match(currentStar.Names,targName) then - - - - - - loadBasicDialog(currentStar,"speak") - - - - - else - error("Current Star is not defined") - - end - end - if(action.name == "incoming_call") then - - - - if(GameController["NewHudPhoneGameController"] ~= nil) then - StatusEffectHelper.ApplyStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - GameController["NewHudPhoneGameController"].incomingCallElement.request = GameController["NewHudPhoneGameController"]:AsyncSpawnFromLocal(inkWidgetRef.Get(GameController["NewHudPhoneGameController"].incomingCallElement.slot), GameController["NewHudPhoneGameController"].incomingCallElement.libraryID, GameController["NewHudPhoneGameController"], "OnIncommingCallSpawned"); - - GameController["NewHudPhoneGameController"]:HandleCall() - local audioEvent = SoundPlayEvent.new() - audioEvent.soundName = "ui_phone_incoming_call" - Game.GetPlayer():QueueEvent(audioEvent) - - GameController["NewHudPhoneGameController"]:SetPhoneFunction(EHudPhoneFunction.IncomingCall); - Cron.After(0.2, function() - - local controller = GameController["NewHudPhoneGameController"].incomingCallElement.widget:GetController() - - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.HolocallHolder:SetVisible(true); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.SignalRangeIcon:SetVisible(false); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.WaveformPlaceholder:SetVisible(false); - - - controller.contactNameWidget:SetText(action.caller) - InkImageUtils.RequestSetImage(controller, controller.avatar, "PhoneAvatars."..action.image) - - inkWidgetRef.SetVisible(controller.buttonHint, action.isrejectable); - currentPhoneCall = action - end) - else - error("can't find IncomingCallGameController controller, please call an npc for load one or reload an save") - end - end - - if(action.name == "outcoming_call") then - - - if(GameController["NewHudPhoneGameController"] ~= nil) then - StatusEffectHelper.ApplyStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - - GameController["NewHudPhoneGameController"]:HandleCall() - local audioEvent = SoundPlayEvent.new() - audioEvent.soundName = "ui_phone_initiation_call" - Game.GetPlayer():QueueEvent(audioEvent) - - GameController["NewHudPhoneGameController"]:SetPhoneFunction(EHudPhoneFunction.Holocall); - Cron.After(0.2, function() - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.HolocallHolder:SetVisible(true); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.SignalRangeIcon:SetVisible(false); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.WaveformPlaceholder:SetVisible(false); - - GameController["NewHudPhoneGameController"].holoAudioCallLogicController:Show() - GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowIncomingContact("cyberscript", "cyberscript") - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactName.widget:SetText(getLang(action.caller)) - InkImageUtils.RequestSetImage(GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController, GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactAvatar, "PhoneAvatars."..action.image) - - end) - else - error("can't find IncomingCallGameController controller, please call an npc for load one or reload an save") - end - end - - if(action.name == "show_phone_avatar") then - if(GameController["NewHudPhoneGameController"] ~= nil ) then - - if(GameController["NewHudPhoneGameController"].incomingCallElement.widget ~=nil) then - local controller = GameController["NewHudPhoneGameController"].incomingCallElement.widget:GetController() - - GameController["NewHudPhoneGameController"]:DeactivatePhoneElement(gameuiActivePhoneElement.IncomingCall); - inkCompoundRef.RemoveChild(GameController["NewHudPhoneGameController"].incomingCallElement.slot, GameController["NewHudPhoneGameController"].incomingCallElement.widget); - GameController["NewHudPhoneGameController"].incomingCallElement.widget = nil; - end - local audioEvent = SoundStopEvent.new() - audioEvent.soundName = "ui_phone_incoming_call" - Game.GetPlayer():QueueEvent(audioEvent) - - local audioEvent = SoundStopEvent.new() - audioEvent.soundName = "ui_phone_initiation_call" - Game.GetPlayer():QueueEvent(audioEvent) - local audioEvent = SoundPlayEvent.new() - audioEvent.soundName = "ui_phone_incoming_call_positive" - Game.GetPlayer():QueueEvent(audioEvent) - - - GameController["NewHudPhoneGameController"].holoAudioCallLogicController:Show() - GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowIncomingContact("cyberscript", "cyberscript") - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactName.widget:SetText(getLang(action.caller)) - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController:SetStatusText(getLang(action.desc)); - - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.HolocallHolder:SetVisible(true); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.SignalRangeIcon:SetVisible(false); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.WaveformPlaceholder:SetVisible(false); - InkImageUtils.RequestSetImage(GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController, GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactAvatar, "PhoneAvatars."..action.image) - - - end - - - - end - if(action.name == "show_call_avatar") then - if(GameController["NewHudPhoneGameController"] ~= nil ) then - StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - if(GameController["NewHudPhoneGameController"].incomingCallElement.widget ~=nil) then - local controller = GameController["NewHudPhoneGameController"].incomingCallElement.widget:GetController() - - GameController["NewHudPhoneGameController"]:DeactivatePhoneElement(gameuiActivePhoneElement.IncomingCall); - inkCompoundRef.RemoveChild(GameController["NewHudPhoneGameController"].incomingCallElement.slot, GameController["NewHudPhoneGameController"].incomingCallElement.widget); - GameController["NewHudPhoneGameController"].incomingCallElement.widget = nil; - end - local audioEvent = SoundStopEvent.new() - audioEvent.soundName = "ui_phone_incoming_call" - Game.GetPlayer():QueueEvent(audioEvent) - - local audioEvent = SoundStopEvent.new() - audioEvent.soundName = "ui_phone_initiation_call" - Game.GetPlayer():QueueEvent(audioEvent) - local audioEvent = SoundPlayEvent.new() - audioEvent.soundName = "ui_phone_incoming_call_positive" - Game.GetPlayer():QueueEvent(audioEvent) - - - GameController["NewHudPhoneGameController"].holoAudioCallLogicController:Show() - GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowIncomingContact("cyberscript", "cyberscript") - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactName.widget:SetText(getLang(action.caller)) - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController:SetStatusText(getLang(action.desc)); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.HolocallHolder:SetVisible(false); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.SignalRangeIcon:SetVisible(true); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.WaveformPlaceholder:SetVisible(true); - InkImageUtils.RequestSetImage(GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController, GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactAvatar, "PhoneAvatars."..action.image) - - - end - - - - end - if(action.name == "hide_phone_avatar") then - if(GameController["NewHudPhoneGameController"] ~= nil) then - StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - local audioEvent = SoundStopEvent.new() - audioEvent.soundName = "ui_phone_incoming_call" - Game.GetPlayer():QueueEvent(audioEvent) - - local audioEvent = SoundPlayEvent.new() - audioEvent.soundName = "ui_phone_initiation_call_negative" - Game.GetPlayer():QueueEvent(audioEvent) - if(GameController["NewHudPhoneGameController"].incomingCallElement.widget ~=nil) then - local controller = GameController["NewHudPhoneGameController"].incomingCallElement.widget:GetController() - - GameController["NewHudPhoneGameController"]:DeactivatePhoneElement(gameuiActivePhoneElement.IncomingCall); - inkCompoundRef.RemoveChild(GameController["NewHudPhoneGameController"].incomingCallElement.slot, GameController["NewHudPhoneGameController"].incomingCallElement.widget); - GameController["NewHudPhoneGameController"].incomingCallElement.widget = nil - end - --GameController["NewHudPhoneGameController"].holoAudioCallLogicController:Show() - GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowIncomingContact("cyberscript", "cyberscript"); - GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowEndCallContact("cyberscript", "cyberscript") - - end - - - - end - - if(action.name == "take_call") then - if currentPhoneCall ~= nil then - - StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - - local audioEvent = SoundStopEvent.new() - audioEvent.soundName = "ui_phone_incoming_call" - Game.GetPlayer():QueueEvent(audioEvent) - - runActionList(currentPhoneCall.answer_action,"phone_call","interact",false,"player") - incomingCallGameController:OnInitialize() - currentPhoneCall = nil - StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - end - - - end - - if(action.name == "refuse_call") then - if currentPhoneCall ~= nil then - - StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - phoneAction = true - local audioEvent = SoundStopEvent.new() - audioEvent.soundName = "ui_phone_incoming_call" - Game.GetPlayer():QueueEvent(audioEvent) - - runActionList(currentPhoneCall.rejected_action,"phone_call","interact",false,"player") - incomingCallGameController:OnInitialize() - currentPhoneCall = nil - end - - - end - - if(action.name == "subtitle") then - if(GameController["SubtitlesGameController"] ~= nil) then - --logme(3,"ye") - local linesToShow = {} - --GameController["SubtitlesGameController"]:Cleanup() - local dialogLine = scnDialogLineData.new() - local id = math.random(1,9999) - dialogLine.id = CRUID(id) - dialogLine.text = getLang(action.title) - dialogLine.type = action.type - dialogLine.speaker = Game.GetPlayer() - dialogLine.speakerName = getLang(action.speaker) - local candotext = true - if(action.speaker == "current_phone_npc") then - if(currentNPC ~= nil) then - dialogLine.speakerName = currentNPC.Names - else - candotext = false - end - elseif(action.speaker == "current_star") then - if(currentStar ~= nil) then - dialogLine.speakerName = currentStar.Names - else - candotext = false - end - elseif(action.speaker == "entity") then - local obj = getEntityFromManager(action.speakertag) - dialogLine.speakerName = obj.name - candotext = true - elseif(action.speaker == "mp_player") then - dialogLine.speakerName = myTag - candotext = true - elseif(action.speaker == "mp_looked_player") then - if(multiName == "") then - dialogLine.speakerName = "Player" - else - dialogLine.speakerName = multiName - end - candotext = true - else - dialogLine.speakerName = getLang(action.speaker) - candotext = true - end - - - - - - if(candotext == true) then - dialogLine.isPersistent = true - dialogLine.duration = action.duration - local restry,msg = pcall(function() - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then - GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) - end - - end) - - if(restry == false) then - local inkSystem = Game.GetInkSystem(); - local layers = inkSystem:GetLayers(); - - for i,layer in ipairs(layers) do - for j,controller in ipairs(layer:GetGameControllers()) do - if(GameController[NameToString(controller:GetClassName())] == "SubtitlesGameController") then - GameController["SubtitlesGameController"] = controller - end - - end - end - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then - GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) - end - - end - - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - nexttemp =nexttemp + action.duration - action.tick = nexttemp - result = false - end - else - error("can't find Subtitle controller, please call an npc for load one") - end - end - if(action.name == "news_subtitle") then - if(GameController["SubtitlesGameController"] ~= nil) then - --logme(3,"ye") - local linesToShow = {} - --GameController["SubtitlesGameController"]:Cleanup() - local dialogLine = scnDialogLineData.new() - local id = math.random(1,9999) - dialogLine.id = CRUID(id) - dialogLine.text = getLang(action.title) - dialogLine.type = 5 - dialogLine.speaker = Game.GetPlayer() - dialogLine.speakerName = getLang(action.speaker) - local candotext = true - if(action.speaker == "current_phone_npc") then - if(currentNPC ~= nil) then - dialogLine.speakerName = currentNPC.Names - else - candotext = false - end - elseif(action.speaker == "current_star") then - if(currentStar ~= nil) then - dialogLine.speakerName = currentStar.Names - else - candotext = false - end - elseif(action.speaker == "entity") then - local obj = getEntityFromManager(action.speakertag) - dialogLine.speakerName = obj.name - candotext = true - elseif(action.speaker == "mp_player") then - dialogLine.speakerName = myTag - candotext = true - elseif(action.speaker == "mp_looked_player") then - if(multiName == "") then - dialogLine.speakerName = "Player" - else - dialogLine.speakerName = multiName - end - candotext = true - else - dialogLine.speakerName = getLang(action.speaker) - - if(action.usecorponews == true) then - if(#corpoNews > 0) then - local id = math.random(1,#corpoNews) - dialogLine.text = getLang(corpoNews[id]) - end - end - - - candotext = true - end - if(candotext == true) then - dialogLine.isPersistent = true - dialogLine.duration = action.duration - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then - GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) - end - - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - nexttemp =nexttemp + action.duration - action.tick = nexttemp - result = false - end - else - error("can't find Subtitle controller, please call an npc for load one") - end - end - if(action.name == "random_subtitle") then - if(GameController["SubtitlesGameController"] ~= nil) then - --logme(3,"ye") - local linesToShow = {} - --GameController["SubtitlesGameController"]:Cleanup() - local tago = math.random(1,#action.title) - local dialogLine = scnDialogLineData.new() - local id = math.random(1,9999) - dialogLine.id = CRUID(id) - dialogLine.text = getLang(action.title[tago]) - dialogLine.type = action.type - dialogLine.speaker = Game.GetPlayer() - dialogLine.speakerName = getLang(action.speaker) - local candotext = true - if(action.speaker == "current_phone_npc") then - if(currentNPC ~= nil) then - dialogLine.speakerName = currentNPC.Names - else - candotext = false - end - elseif(action.speaker == "current_star") then - if(currentStar ~= nil) then - dialogLine.speakerName = currentStar.Names - else - candotext = false - end - elseif(action.speaker == "entity") then - local obj = getEntityFromManager(action.speakertag) - dialogLine.speakerName = obj.name - candotext = true - else - dialogLine.speakerName = getLang(action.speaker) - candotext = true - end - if(candotext == true) then - dialogLine.isPersistent = true - dialogLine.duration = action.duration - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then - GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) - end - - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - nexttemp =nexttemp + action.duration - action.tick = nexttemp - result = false - end - else - error("can't find Subtitle controller, please call an npc for load one") - - end - end - if(action.name == "npc_chat") then - if(GameController["ChattersGameController"] ~= nil) then - local linesToShow = {} - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - if(action.target == "lookat")then - enti = objLook - end - if(enti ~= nil) then - - local dialogLine = scnDialogLineData.new() - local id = math.random(1,9999) - dialogLine.id = CRUID(id) - dialogLine.text = getLang(action.title) - dialogLine.type = action.type - local candotext = true - dialogLine.speaker = enti - dialogLine.speakerName = getLang(action.speaker) - if(action.speaker == "current_phone_npc") then - if(currentNPC ~= nil) then - dialogLine.speakerName = currentNPC.Names - else - candotext = false - end - end - if(action.speaker == "current_star") then - if(currentStar ~= nil) then - dialogLine.speakerName = currentStar.Names - else - candotext = false - end - end - if(action.speaker == "entity") then - local obj = getEntityFromManager(action.speakertag) - dialogLine.speakerName = obj.name - candotext = true - end - if(candotext == true) then - dialogLine.isPersistent = true - dialogLine.duration = action.duration - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Overheads"):GetValue() == true) then - GameController["ChattersGameController"]:SpawnDialogLine(dialogLine) - end - - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - nexttemp =nexttemp + action.duration - --logme(3,nexttemp) - action.tick = nexttemp - result = false - end - end - else - error("can't find chat Subtitle controller, please go to see an npc who speak in street or an TV or an Radio for load one") - - end - end - if(action.name == "random_npc_chat") then - if(GameController["ChattersGameController"] ~= nil) then - local linesToShow = {} - local tago = math.random(1,#action.title) - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - if(action.target == "lookat")then - enti = objLook - end - if(enti ~= nil) then - local dialogLine = scnDialogLineData.new() - local id = math.random(1,9999) - dialogLine.id = CRUID(id) - dialogLine.text = getLang(action.title[tago]) - dialogLine.type = action.type - local candotext = true - dialogLine.speaker = enti - dialogLine.speakerName = getLang(action.speaker) - if(action.speaker == "current_phone_npc") then - if(currentNPC ~= nil) then - dialogLine.speakerName = currentNPC.Names - else - candotext = false - end - end - if(action.speaker == "current_star") then - if(currentStar ~= nil) then - dialogLine.speakerName = currentStar.Names - else - candotext = false - end - end - if(action.speaker == "entity") then - local obj = getEntityFromManager(action.speakertag) - dialogLine.speakerName = obj.name - candotext = true - end - if(candotext == true) then - dialogLine.isPersistent = true - dialogLine.duration = action.duration - - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Overheads"):GetValue() == true) then - GameController["ChattersGameController"]:SpawnDialogLine(dialogLine) - end - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - nexttemp =nexttemp + action.duration - --logme(3,nexttemp) - action.tick = nexttemp - result = false - end - end - else - error("can't find chat Subtitle controller, please go to see an npc who speak in street or an TV or an Radio for load one") - end - end - if(action.name == "clean_subtitle") then - if(GameController["SubtitlesGameController"] ~= nil) then - GameController["SubtitlesGameController"]:Cleanup() - GameController["SubtitlesGameController"]:Cleanup() - end - end - if(action.name == "clean_npc_chat") then - if(GameController["ChattersGameController"] ~= nil) then - GameController["ChattersGameController"]:Cleanup() - GameController["ChattersGameController"]:Cleanup() - end - end - if(action.name == "do_random_dialog")then - local tago = math.random(1,#action.dialog) - -- logme(3,action.dialog[tago]) - if( tago ~= nil) then - createDialog(SetNextDialog(action.dialog[tago],source,executortag)) - end - end - if(action.name == "npc_star_affinity") then - if(currentStar ~= nil) then - local score = getScoreKey("Affinity",currentStar.Names) - if(score == nil) then score = 0 end - score = score + action.value - setScore("Affinity",currentStar.Names,score) - end - end - if(action.name == "npc_affinity") then - local score = getScoreKey("Affinity",action.value) - if(score == nil) then score = 0 end - score = score + action.score - setScore("Affinity",action.value,score) - end - if(action.name == "entity_affinity") then - local obj = getEntityFromManager(action.tag) - logme(3,dump((obj))) - local score = getScoreKey("Affinity",obj.name) - if(score == nil) then score = 0 end - score = score + action.score - setScore("Affinity",obj.name,score) - end - if(action.name == "custom_star_message") then - ------logme(3,npcStarSpawn) - if(npcStarSpawn) then - customEventMessage(action.value, currentStar) - end - end - if(action.name == "change_dialog_windows") then - if(action.window == "quest" ) then - if(string.lower(tostring(action.value)) == "true")then - openQuestDialogWindow = true - else - openQuestDialogWindow = false - currentQuestdialog = nil - end - end - if(action.window == "speak" ) then - if(string.lower(tostring(action.value)) == "true")then - openSpeakDialogWindow = true - else - openSpeakDialogWindow = false - currentSpeakDialog = nil - end - end - if(action.window == "phone" ) then - if(string.lower(tostring(action.value)) == "true")then - openPhoneDialogWindow = true - else - openPhoneDialogWindow = false - currentPhoneDialog = nil - end - end - if(action.window == "event" ) then - if(string.lower(tostring(action.value)) == "true")then - openEventDialogWindow = true - else - openEventDialogWindow = false - currentEventDialog = nil - end - end - end - end - - if questregion then - if(action.name == "change_quest_content") then - QuestManager.ChangeQuestContent(action.tag,getLang(action.value)) - end - - if(action.name == "change_quest_title") then - QuestManager.ChangeQuestTitle(action.tag,getLang(action.value)) - end - - if(action.name == "change_objective_content" or action.name == "change_objective_text") then - QuestManager.ChangeObjectiveContent(action.tag,getLang(action.value)) - end - - - if(action.name == "mission") then - setScore(action.value,"Score",0) - - QuestManager.MarkQuestAsActive(action.value) - local objective = QuestManager.GetFirstObjectiveEntry(action.value) - QuestManager.TrackObjective(objective.id) - - TriggerQuest(action.value) - - end - if(action.name == "lock_mission") then - setScore(action.value,"Score",nil) - QuestManager.MarkQuestAsUnVisited(action.value) - end - if(action.name == "lock_objective") then - QuestManager.MarkObjectiveAsUndefined(action.value) - if(QuestManager.IsTrackedObjective(action.value)) then - QuestManager.UntrackObjective() - end - end - if(action.name == "set_objective_state") then - QuestManager.MarkObjectiveAs(action.value,action.state) - end - if(action.name == "unlock_objective") then - QuestManager.MarkObjectiveAsActive(action.value) - end - if(action.name == "inactive_objective") then - QuestManager.MarkObjectiveAsInactive(action.value) - if(QuestManager.IsTrackedObjective(action.value)) then - QuestManager.UntrackObjective() - end - end - if(action.name == "fail_objective") then - QuestManager.MarkObjectiveAsFailed(action.value) - end - if(action.name == "win_objective") then - QuestManager.MarkObjectiveAsComplete(action.value) - end - if(action.name == "track_objective") then - QuestManager.TrackObjective(action.value) - end - if(action.name == "unlock_mission") then - setScore(action.value,"Score",0) - end - if(action.name == "finish_mission") then - if currentQuest ~= nil and currentQuest.tag == action.tag then - canDoEndAction = true - else - if currentQuest ~= nil and currentQuest.tag ~= action.tag then - result = false - end - end - end - if(action.name == "fail_mission") then - if currentQuest ~= nil then - canDoFailActionForce = true - end - end - if(action.name == "reset_mission") then - if getQuestByTag(action.tag) ~= nil then - QuestManager.resetQuestfromJson(action.tag) - end - end - end - - if noderegion then - if(action.name == "draw_custom_3Dmappin_node") then - local node = getNode(action.tag) - if(action.atgameplayposition)then - draw3DCustomMappin(node.gameplay_x,node.gameplay_y,node.gameplay_z) - else - draw3DCustomMappin(node.x,node.y,node.z) - end - end - if(action.name == "set_entity_circuit") then - local circuit = getCircuit(action.circuit) - circuit.reverse = action.reverse - local obj = getEntityFromManager(action.tag) - obj.circuit = circuit - end - if(action.name == "set_entity_node_current") then - local obj = getEntityFromManager(action.tag) - obj.currentNode = getNode(action.data) - end - if(action.name == "set_entity_node_current_auto") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - local positionVec4 = enti:GetWorldPosition() - obj.currentNode = getNodefromPosition(positionVec4.x, positionVec4.y, positionVec4.z, action.range) - end - if(action.name == "set_entity_node_next") then - local obj = getEntityFromManager(action.tag) - if(obj.circuit.reverse == false) then - local nextNodeIndex = getNodeIndexFromCircuit(action.data,obj.circuit.datas) - obj.nextNode = obj.circuit.datas[nextNodeIndex+1] - else - local inversed_circuit = reverseTable(obj.circuit.datas) - local nextNodeIndex = getNodeIndexFromCircuit(action.data,inversed_circuit) - obj.nextNode = inversed_circuit[nextNodeIndex+1] - end - end - if(action.name == "set_entity_node_next_auto") then - local obj = getEntityFromManager(action.tag) - if(obj.circuit.reverse == false) then - local nextNodeIndex = getNodeIndexFromCircuit(obj.currentNode.tag,obj.circuit.datas) - obj.nextNode = getNode(obj.circuit.datas[nextNodeIndex+1]) - else - local inversed_circuit = reverseTable(obj.circuit.datas) - local nextNodeIndex = getNodeIndexFromCircuit(obj.currentNode.tag,inversed_circuit) - obj.nextNode = getNode(inversed_circuit[nextNodeIndex+1]) - end - end - if(action.name == "set_entity_node_path") then - local obj = getEntityFromManager(action.tag) - obj.path = getPath(action.path) - if(obj.path == nil) then - Game.GetPlayer():SetWarningMessage(getLang("see_action_nopath")) - else - obj.path.reverse = obj.circuit.reverse - if(obj.path.reverse == true) then - obj.path.index = #obj.path.locations - obj.path.finish = false - else - track.index = 1 - obj.path.finish = false - end - end - end - if(action.name == "set_entity_node_path_auto") then - local obj = getEntityFromManager(action.tag) - obj.path = getPathBetweenTwoNode(obj.currentNode.tag, obj.nextNode.tag) - if(obj.path == nil) then - Game.GetPlayer():SetWarningMessage(getLang("see_action_nopath")) - else - obj.path.reverse = obj.circuit.reverse - if(obj.path.reverse == true) then - obj.path.index = #obj.path.locations - obj.path.finish = false - else - obj.path.index = 1 - obj.path.finish = false - end - end - end - if(action.name == "run_entity_path") then - local obj = getEntityFromManager(action.tag) - if(obj ~= nil and obj.path ~= nil) then - local actionlist = {} - --logme(3,#actionlist) - --doActionofIndex(actionlist,"interact",listaction,currentindex) - result = false - local path = getEntityFromManager(group.entities[1]).path - if(path.reverse == false) then - for i=1,#path.locations do - local trackpos = obj.path.locations[i] - local nexttrackpos = obj.path.locations[i+1] - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,obj.path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if entityTag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - if(path.recordRotation == true) then - angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) - end - --logme(3,"yaw "..angle.yaw) - local newaction = {} - newaction.name = "teleport_entity_at_position" - newaction.tag = entityTag - newaction.x = direction.x - newaction.y = direction.y - newaction.z = direction.z - newaction.angle = angle - table.insert(actionlist,newaction) - - - if(trackpos.action ~= nil and #trackpos.action > 0) then - - for y=1,#trackpos.action do - - table.insert(actionlist,trackpos.action[y]) - - end - - - end - end - else - obj.path.finish = true - end - end - else - for i= #path.locations, 1,-1 do - if(obj ~= nil) then - local trackpos = obj.path.locations[i] - local nexttrackpos = obj.path.locations[i+1] - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,obj.path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if entityTag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - if(path.recordRotation == true) then - angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) - end - --logme(3,"yaw "..angle.yaw) - local newaction = {} - newaction.name = "teleport_entity_at_position" - newaction.tag = entityTag - newaction.x = direction.x - newaction.y = direction.y - newaction.z = direction.z - newaction.angle = angle - table.insert(actionlist,newaction) - - - if(trackpos.action ~= nil and #trackpos.action > 0) then - - for y=1,#trackpos.action do - - table.insert(actionlist,trackpos.action[y]) - - end - - - end - end - else - obj.path.finish = true - end - end - end - end - -- for i=1,#actionlist do - -- executeAction(actionlist[i],tag,parent,index,source) - -- end - runSubActionList(actionlist, tag.."_run_path", tag,source,false,executortag) - end - end - - if(action.name == "play_path") then - local obj = getEntityFromManager(action.tag) - if(obj ~= nil ) then - local actionlist = {} - --logme(3,#actionlist) - --doActionofIndex(actionlist,"interact",listaction,currentindex) - result = false - local path = getPath(action.path) - if(action.reverse == nil or action.reverse == false) then - path.index = 1 - for i=1,#path.locations do - local trackpos = path.locations[i] - local nexttrackpos = path.locations[i+1] - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if action.tag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - if(path.recordRotation == true) then - angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) - end - --logme(3,"yaw "..angle.yaw) - - local newaction = {} - if(action.isrelative ~= nil and action.isrelative == true) then - newaction.name = "teleport_entity_at_relative_position" - - else - newaction.name = "teleport_entity_at_position" - end - newaction.tag = action.tag - newaction.x = direction.x - newaction.y = direction.y - newaction.z = direction.z - newaction.angle = angle - table.insert(actionlist,newaction) - - if(trackpos.action ~= nil and #trackpos.action > 0) then - - for y=1,#trackpos.action do - - table.insert(actionlist,trackpos.action[y]) - - end - - - end - end - else - obj.path = {} - obj.path.finish = true - end - end - else - path.index = #path.locations - for i= #path.locations, 1,-1 do - if(obj ~= nil) then - local trackpos = path.locations[i] - local nexttrackpos = path.locations[i+1] - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if action.tag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - if(path.recordRotation == true) then - angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) - end - --logme(3,"yaw "..angle.yaw) - local newaction = {} - if(action.isrelative ~= nil and action.isrelative == true) then - newaction.name = "teleport_entity_at_relative_position" - - else - newaction.name = "teleport_entity_at_position" - end - newaction.tag = action.tag - newaction.x = direction.x - newaction.y = direction.y - newaction.z = direction.z - newaction.angle = angle - table.insert(actionlist,newaction) - if(trackpos.action ~= nil and #trackpos.action > 0) then - - for y=1,#trackpos.action do - - table.insert(actionlist,trackpos.action[y]) - - end - - - end - - end - else - obj.path = {} - obj.path.finish = true - end - end - end - end - -- for i=1,#actionlist do - -- executeAction(actionlist[i],tag,parent,index,source) - -- end - spdlog.error(dump(actionlist)) - runSubActionList(actionlist, tag.."_run_path", tag,source,false,executortag) - end - end - - - - if(action.name == "clean_entity_circuit") then - local obj = getEntityFromManager(action.tag) - if(obj ~= nil) then - obj.path = nil - obj.circuit = nil - obj.currentNode = nil - obj.nextNode = nil - end - end - if(action.name == "summon_entity_at_node") then - local node = getNode(action.data) - local isAV = false - if(action.isAV ~= nil) then - isAV = action.isAV - end - chara = action.npc - if(action.atgameplayposition) then - - end - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,action.tag) - end - end - if(action.name == "summon_entity_at_mappin") then - local mappin = getMappinByTag(action.mappin) - local isAV = false - if(action.isAV ~= nil) then - isAV = action.isAV - end - chara = action.npc - if(mappin) then - - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,action.tag) - end - end - end - if(action.name == "teleport_entity_at_node") then - local node = getNode(action.data) - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - local isplayer = false - if(action.tag == "player") then - enti = Game.GetPlayer() - isplayer = true - end - if(enti ~= nil) then - --logme(3,"moveit") - if(action.atgameplayposition) then - teleportTo(enti, Vector4.new( node.gameplay_x+action.offset, node.gameplay_y, node.gameplay_z,1), 1,isplayer) - else - teleportTo(enti, Vector4.new( node.x+action.offset, node.y, node.z,1), 1,isplayer) - end - end - end - if(action.name == "teleport_entity_at_current_node") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - local isplayer = false - if(action.tag == "player") then - enti = Game.GetPlayer() - isplayer = true - end - local position = enti:GetWorldPosition() - local range = 70 - if(action.range ~= nil) then - range = action.range - end - local node = getNodefromPosition(position.x,position.y,position.z,range) - if node ~= nil then - if(enti ~= nil) then - logme(3,"tp to node "..data.name) - if(action.atgameplayposition) then - teleportTo(enti, Vector4.new( node.gameplay_x+action.offset, node.gameplay_y, node.gameplay_z,1), 1,isplayer) - else - teleportTo(enti, Vector4.new( node.x+action.offset, node.y, node.z,1), 1,isplayer) - end - end - end - end - if(action.name == "summon_entity_at_current_node") then - local position = Game.GetPlayer():GetWorldPosition() - local range = 70 - if(action.range ~= nil) then - range = action.range - end - local node = getNodefromPosition(position.x,position.y,position.z,range) - if node ~= nil then - chara = action.npc - local isAV = false - if(action.isAV ~= nil) then - isAV = action.isAV - end - if(action.atgameplayposition) then - - end - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,action.tag) - end - end - end - if(action.name == "set_group_circuit") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - logme(3,entityTag) - logme(3,action.circuit) - local obj = getEntityFromManager(entityTag) - local circuit = getCircuit(action.circuit) - logme(3,dump(circuit)) - logme(3,dump(obj)) - obj.circuit =circuit - logme(3,"set circuit.."..obj.circuit.tag) - logme(3,"action.reverse"..tostring(action.reverse)) - obj.circuit.reverse = action.reverse - end - end - if(action.name == "set_group_node_current") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getTrueEntityFromManager(entityTag) - obj.currentNode = getNode(action.data) - setEntityFromManager(entityTag,obj) - end - end - if(action.name == "set_group_node_current_auto") then - local group =getGroupfromManager(action.tag) - logme(3,"test.."..#group.entities) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getTrueEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - local positionVec4 = enti:GetWorldPosition() - obj.currentNode = getNodefromPosition(positionVec4.x, positionVec4.y, positionVec4.z, action.range) - logme(3,"currentNode "..obj.currentNode.tag) - -- setEntityFromManager(entityTag,obj) - end - end - if(action.name == "set_group_node_next") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - if(obj.circuit.reverse == false ) then - local nextNodeIndex = getNodeIndexFromCircuit(action.data,obj.circuit.datas) - obj.nextNode = obj.circuit.datas[nextNodeIndex+1] - else - local inversed_circuit = reverseTable(obj.circuit.datas) - local nextNodeIndex = getNodeIndexFromCircuit(action.data,inversed_circuit) - obj.nextNode = inversed_circuit[nextNodeIndex+1] - end - end - end - if(action.name == "set_group_node_next_auto") then - local group =getGroupfromManager(action.tag) - logme(3,"test.."..#group.entities) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getTrueEntityFromManager(entityTag) - logme(3,"currentNode "..obj.currentNode.tag) - logme(3,#obj.circuit) - logme(3,tostring(obj.circuit.reverse)) - if(obj.circuit.reverse == false or obj.circuit.reverse == nil) then - local nextNodeIndex = getNodeIndexFromCircuit(obj.currentNode.tag,obj.circuit.datas) - logme(3,"nextNodeIndex "..nextNodeIndex) - obj.nextNode = getNode(obj.circuit.datas[nextNodeIndex+1]) - logme(3,"nextNode "..obj.nextNode.tag) - setEntityFromManager(entityTag,obj) - else - local inversed_circuit = reverseTable(obj.circuit.datas) - local nextNodeIndex = getNodeIndexFromCircuit(obj.currentNode.tag,inversed_circuit) - obj.nextNode = getNode(inversed_circuit[nextNodeIndex+1]) - --setEntityFromManager(entityTag,obj) - end - end - end - if(action.name == "set_group_node_path") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - obj.path = getPath(action.path) - if(obj.path == nil) then - Game.GetPlayer():SetWarningMessage(getLang("see_action_nopath")) - else - obj.path.reverse = obj.circuit.reverse - if(obj.path.reverse == true) then - obj.path.index = #obj.path.locations - obj.path.finish = false - else - track.index = 1 - obj.path.finish = false - end - end - end - end - if(action.name == "set_group_node_path_auto") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - logme(3,obj.currentNode.tag) - logme(3,obj.nextNode.tag) - if(obj.circuit.reverse == true) then - obj.path = getPathBetweenTwoNode(obj.nextNode.tag, obj.currentNode.tag) - else - obj.path = getPathBetweenTwoNode(obj.currentNode.tag, obj.nextNode.tag) - end - if(obj.path == nil) then - Game.GetPlayer():SetWarningMessage(getLang("see_action_nopath")) - else - obj.path.reverse = obj.circuit.reverse - if(obj.path.reverse == true) then - obj.path.index = #obj.path.locations - obj.path.finish = false - else - obj.path.index = 1 - obj.path.finish = false - end - end - end - end - - if(action.name == "run_group_path_cached" or action.name == "run_group_path") then - local group =getGroupfromManager(action.tag) - local actionlist = {} - --logme(3,#actionlist) - --doActionofIndex(actionlist,"interact",listaction,currentindex) - result = false - local path = getEntityFromManager(group.entities[1]).path - if(path.reverse == false) then - for i=1,#path.locations do - for y=1, #group.entities do - local entityTag = group.entities[y] - local obj = getEntityFromManager(entityTag) - if(obj ~= nil) then - local trackpos = obj.path.locations[i] - local nexttrackpos = obj.path.locations[i+1] - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,obj.path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if entityTag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - if(path.recordRotation == true) then - angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) - end - --logme(3,"yaw "..angle.yaw) - local newaction = {} - if(action.isrelative ~= nil and action.isrelative == true) then - newaction.name = "teleport_entity_at_relative_position" - - else - newaction.name = "teleport_entity_at_position" - end - newaction.tag = entityTag - newaction.x = direction.x - newaction.y = direction.y - newaction.z = direction.z - newaction.angle = angle - table.insert(actionlist,newaction) - - if(trackpos.action ~= nil and #trackpos.action > 0) then - - for y=1,#trackpos.action do - - table.insert(actionlist,trackpos.action[y]) - - end - - - end - end - else - obj.path.finish = true - end - end - end - end - else - for i= #path.locations, 1,-1 do - for y=1, #group.entities do - local entityTag = group.entities[y] - local obj = getEntityFromManager(entityTag) - if(obj ~= nil) then - local trackpos = obj.path.locations[i] - local nexttrackpos = obj.path.locations[i+1] - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,obj.path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if entityTag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - if(path.recordRotation == true) then - angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) - end - --logme(3,"yaw "..angle.yaw) - local newaction = {} - if(action.isrelative ~= nil and action.isrelative == true) then - newaction.name = "teleport_entity_at_relative_position" - - else - newaction.name = "teleport_entity_at_position" - end - newaction.tag = entityTag - newaction.x = direction.x - newaction.y = direction.y - newaction.z = direction.z - newaction.angle = angle - table.insert(actionlist,newaction) - - if(trackpos.action ~= nil and #trackpos.action > 0) then - - for y=1,#trackpos.action do - - table.insert(actionlist,trackpos.action[y]) - - end - - - end - end - else - obj.path.finish = true - end - end - end - end - end - -- for i=1,#actionlist do - -- executeAction(actionlist[i],tag,parent,index,source) - -- end - runSubActionList(actionlist, tag.."_run_path", tag,source,false,executortag) - end - - -- end - if(action.name == "play_group_path_cached" or action.name == "play_group_path") then - local group =getGroupfromManager(action.tag) - local actionlist = {} - --logme(3,#actionlist) - --doActionofIndex(actionlist,"interact",listaction,currentindex) - result = false - local path = getPath(action.path) - if(path.reverse == false) then - for i=1,#path.locations do - for y=1, #group.entities do - local entityTag = group.entities[y] - local obj = getEntityFromManager(entityTag) - if(obj ~= nil) then - local trackpos = path.locations[i] - local nexttrackpos = path.locations[i+1] - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if entityTag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - if(path.recordRotation == true) then - angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) - end - --logme(3,"yaw "..angle.yaw) - local newaction = {} - - if(action.isrelative ~= nil and action.isrelative == true) then - newaction.name = "teleport_entity_at_relative_position" - - else - newaction.name = "teleport_entity_at_position" - end - newaction.tag = entityTag - newaction.x = direction.x - newaction.y = direction.y - newaction.z = direction.z - newaction.angle = angle - table.insert(actionlist,newaction) - end - else - obj.path = {} - obj.path.finish = true - end - end - end - end - else - for i= #path.locations, 1,-1 do - for y=1, #group.entities do - local entityTag = group.entities[y] - local obj = getEntityFromManager(entityTag) - if(obj ~= nil) then - local trackpos = path.locations[i] - local nexttrackpos = path.locations[i+1] - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if entityTag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - if(path.recordRotation == true) then - angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) - end - --logme(3,"yaw "..angle.yaw) - local newaction = {} - - if(action.isrelative ~= nil and action.isrelative == true) then - newaction.name = "teleport_entity_at_relative_position" - - else - newaction.name = "teleport_entity_at_position" - end - newaction.tag = entityTag - newaction.x = direction.x - newaction.y = direction.y - newaction.z = direction.z - newaction.angle = angle - table.insert(actionlist,newaction) - end - - else - obj.path = {} - obj.path.finish = true - - end - end - end - end - end - -- for i=1,#actionlist do - -- executeAction(actionlist[i],tag,parent,index,source) - -- end - runSubActionList(actionlist, tag.."_run_path", tag,source,false,executortag) - end - - - - if(action.name == "clean_group_circuit") then - local group =getGroupfromManager(action.tag) - if group ~= nil then - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - if(obj ~= nil) then - obj.path = nil - obj.circuit = nil - obj.currentNode = nil - obj.nextNode = nil - end - end - end - end - if(action.name == "group_look_at_next_path_position") then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - if(obj ~= nil) then - local trackpos = obj.path.locations[obj.path.index] - local nexttrackpos = obj.path.locations[obj.path.index+1] - if obj.path.reverse == true then - nexttrackpos = obj.path.locations[obj.path.index-1] - end - if(nexttrackpos ~= nil) and (trackpos ~= nil) then - logme(3,obj.path.index) - local direction = {} - local separate = 0 - if(action.separate ~= nil and action.separate == true) then - separate = i-1 - end - direction.x = nexttrackpos.x-separate - direction.y = nexttrackpos.y-separate - direction.z = nexttrackpos.z+action.zoffset - direction.w = 1 - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if entityTag == "player" then - isplayer = true - end - local dirVector = diffVector(enti:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - logme(3,"yaw "..angle.yaw) - teleportTo(enti, enti:GetWorldPosition(), angle,isplayer) - end - end - end - end - end - end - - if soundregion then - if(action.name == "play_game_sound" or action.name == "play_game_sound_test") then - local audioEvent = SoundPlayEvent.new() - audioEvent.soundName = action.value - Game.GetPlayer():QueueEvent(audioEvent) - end - if(action.name == "stop_game_sound" or action.name == "stop_game_sound_test") then - local audioEvent = SoundStopEvent.new() - audioEvent.soundName = action.value - Game.GetPlayer():QueueEvent(audioEvent) - end - if(action.name == "play_custom_sound") then - - if(cyberscript.cache["sound"][action.value] ~= nil) then - local path = cyberscript.cache["sound"][action.value].data - - local isradio = false - local needrepeat = false - - if action.isradio ~= nil then isradio = action.isradio end - if action.needrepeat ~= nil then needrepeat = action.needrepeat end - - - - PlaySound(path,isradio,needrepeat) - else - error("No sound founded") - end - end - - if(action.name == "play_custom_sound_with_subtitle") then - - if(cyberscript.cache["sound"][action.value] ~= nil) then - - if(GameController["SubtitlesGameController"] ~= nil) then - --logme(3,"ye") - local linesToShow = {} - --GameController["SubtitlesGameController"]:Cleanup() - local dialogLine = scnDialogLineData.new() - local id = math.random(1,9999) - dialogLine.id = CRUID(id) - dialogLine.text = getLang(cyberscript.cache["sound"][action.value].data.subtitle) - dialogLine.type = action.type - dialogLine.speaker = Game.GetPlayer() - dialogLine.speakerName = getLang(action.speaker) - local candotext = true - if(action.speaker == "current_phone_npc") then - if(currentNPC ~= nil) then - dialogLine.speakerName = currentNPC.Names - else - candotext = false - end - elseif(action.speaker == "current_star") then - if(currentStar ~= nil) then - dialogLine.speakerName = currentStar.Names - else - candotext = false - end - elseif(action.speaker == "entity") then - local obj = getEntityFromManager(action.speakertag) - dialogLine.speakerName = obj.name - candotext = true - elseif(action.speaker == "mp_player") then - dialogLine.speakerName = myTag - candotext = true - elseif(action.speaker == "mp_looked_player") then - if(multiName == "") then - dialogLine.speakerName = "Player" - else - dialogLine.speakerName = multiName - end - candotext = true - else - dialogLine.speakerName = getLang(action.speaker) - candotext = true - end - - local tempsMoyen = calcTimebyLetter( countLetter(dialogLine.text), vitesseParLettre) - + + + end + + if relationregion then + if(action.name == "dialog") then + --logme(3,"is logme(10,source) + local usedial = SetNextDialog(action.dialog,source,executortag) + -- logme(3,source) + -- logme(3,executortag) + -- logme(3,usedial.desc) + createDialog(usedial) + -- logme(3,source) + -- if(source == "quest") then + -- local dioal = SetNextDialog(action.value,source) + -- if dioal.havequitoption == nil then dioal.havequitoption = true end + -- logme(3,dioal.desc) + -- openQuestDialogWindow = false + -- currentQuestdialog = dioal + -- openQuestDialogWindow = true + -- end + -- if(source == "interact") then + -- local dioal = SetNextDialog(action.value,source) + -- if dioal.havequitoption == nil then dioal.havequitoption = true end + -- logme(3,dioal.desc) + -- openEventDialogWindow = false + -- currentEventDialog = dioal + -- openEventDialogWindow = true + -- end + -- if(source == "phone") then + -- local dioal = SetNextDialog(action.value,source) + -- if dioal.havequitoption == nil then dioal.havequitoption = true end + -- logme(3,dioal.desc) + -- openPhoneDialogWindow = false + -- currentPhoneDialog = dioal + -- openPhoneDialogWindow = true + -- --SetDialogPhoneUI(dioal) + -- ------logme(3,"dialog phone enabled") + -- end + -- if(source == "speak") then + -- local dioal = SetNextDialog(action.value,source) + -- if dioal.havequitoption == nil then dioal.havequitoption = true end + -- logme(3,dioal.desc) + -- openSpeakDialogWindow = false + -- currentSpeakDialog = dioal + -- openSpeakDialogWindow = true + -- end + end + if(action.name == "clean_dialog") then + interactionUI.hideHub() + currentDialogHub = nil + --print(dump((currentDialogHub))) + end + + if(action.name == "inject_dialog") then + --logme(3,"is logme(10,source) + local usedial = SetNextDialog(action.dialog,source,executortag) + if(interactionUI.injectdialog == nil) then interactionUI.injectdialog = {} end + table.insert(interactionUI.injectdialog,usedial) + + + -- logme(3,source) + -- logme(3,executortag) + -- logme(3,usedial.desc) + + -- logme(3,source) + -- if(source == "quest") then + -- local dioal = SetNextDialog(action.value,source) + -- if dioal.havequitoption == nil then dioal.havequitoption = true end + -- logme(3,dioal.desc) + -- openQuestDialogWindow = false + -- currentQuestdialog = dioal + -- openQuestDialogWindow = true + -- end + -- if(source == "interact") then + -- local dioal = SetNextDialog(action.value,source) + -- if dioal.havequitoption == nil then dioal.havequitoption = true end + -- logme(3,dioal.desc) + -- openEventDialogWindow = false + -- currentEventDialog = dioal + -- openEventDialogWindow = true + -- end + -- if(source == "phone") then + -- local dioal = SetNextDialog(action.value,source) + -- if dioal.havequitoption == nil then dioal.havequitoption = true end + -- logme(3,dioal.desc) + -- openPhoneDialogWindow = false + -- currentPhoneDialog = dioal + -- openPhoneDialogWindow = true + -- --SetDialogPhoneUI(dioal) + -- ------logme(3,"dialog phone enabled") + -- end + -- if(source == "speak") then + -- local dioal = SetNextDialog(action.value,source) + -- if dioal.havequitoption == nil then dioal.havequitoption = true end + -- logme(3,dioal.desc) + -- openSpeakDialogWindow = false + -- currentSpeakDialog = dioal + -- openSpeakDialogWindow = true + -- end + end + + + + if(action.name == "speak_npc")then + + + + if(action.speaker == "current_phone_npc") then + + if(currentNPC ~= nil) then + + loadBasicDialog(currentNPC,action.way) + + else + + error("No Current NPC at Phone exist") + end + + + elseif(action.speaker == "current_star") then + + if(currentStar ~= nil) then + + loadBasicDialog(currentStar,action.way) + else + + error("No Current Star exist") + end + + + else + local phoned = findPhonedNPCByName(action.speaker) + if(phoned ~= nil) then + + loadBasicDialog(phoned,action.way) + else + + error("No NPC exist") + end + end + + end + + + + + if(action.name == "speak_to_current_star")then + + + if currentStar ~= nil then + --if string.match(currentStar.Names,targName) then + + + + + + loadBasicDialog(currentStar,"speak") + + + + + else + error("Current Star is not defined") + + end + end + if(action.name == "incoming_call") then + + + + if(GameController["NewHudPhoneGameController"] ~= nil) then + StatusEffectHelper.ApplyStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + GameController["NewHudPhoneGameController"].incomingCallElement.request = GameController["NewHudPhoneGameController"]:AsyncSpawnFromLocal(inkWidgetRef.Get(GameController["NewHudPhoneGameController"].incomingCallElement.slot), GameController["NewHudPhoneGameController"].incomingCallElement.libraryID, GameController["NewHudPhoneGameController"], "OnIncommingCallSpawned"); + + GameController["NewHudPhoneGameController"]:HandleCall() + local audioEvent = SoundPlayEvent.new() + audioEvent.soundName = "ui_phone_incoming_call" + Game.GetPlayer():QueueEvent(audioEvent) + + GameController["NewHudPhoneGameController"]:SetPhoneFunction(EHudPhoneFunction.IncomingCall); + Cron.After(0.2, function() + + local controller = GameController["NewHudPhoneGameController"].incomingCallElement.widget:GetController() + + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.HolocallHolder:SetVisible(true); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.SignalRangeIcon:SetVisible(false); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.WaveformPlaceholder:SetVisible(false); + + + controller.contactNameWidget:SetText(action.caller) + InkImageUtils.RequestSetImage(controller, controller.avatar, "PhoneAvatars."..action.image) + + inkWidgetRef.SetVisible(controller.buttonHint, action.isrejectable); + currentPhoneCall = action + end) + else + error("can't find IncomingCallGameController controller, please call an npc for load one or reload an save") + end + end + + if(action.name == "outcoming_call") then + + + if(GameController["NewHudPhoneGameController"] ~= nil) then + StatusEffectHelper.ApplyStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + + GameController["NewHudPhoneGameController"]:HandleCall() + local audioEvent = SoundPlayEvent.new() + audioEvent.soundName = "ui_phone_initiation_call" + Game.GetPlayer():QueueEvent(audioEvent) + + GameController["NewHudPhoneGameController"]:SetPhoneFunction(EHudPhoneFunction.Holocall); + Cron.After(0.2, function() + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.HolocallHolder:SetVisible(true); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.SignalRangeIcon:SetVisible(false); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.WaveformPlaceholder:SetVisible(false); + + GameController["NewHudPhoneGameController"].holoAudioCallLogicController:Show() + GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowIncomingContact("cyberscript", "cyberscript") + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactName.widget:SetText(getLang(action.caller)) + InkImageUtils.RequestSetImage(GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController, GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactAvatar, "PhoneAvatars."..action.image) + + end) + else + error("can't find IncomingCallGameController controller, please call an npc for load one or reload an save") + end + end + + if(action.name == "show_phone_avatar") then + if(GameController["NewHudPhoneGameController"] ~= nil ) then + + if(GameController["NewHudPhoneGameController"].incomingCallElement.widget ~=nil) then + local controller = GameController["NewHudPhoneGameController"].incomingCallElement.widget:GetController() + + GameController["NewHudPhoneGameController"]:DeactivatePhoneElement(gameuiActivePhoneElement.IncomingCall); + inkCompoundRef.RemoveChild(GameController["NewHudPhoneGameController"].incomingCallElement.slot, GameController["NewHudPhoneGameController"].incomingCallElement.widget); + GameController["NewHudPhoneGameController"].incomingCallElement.widget = nil; + end + local audioEvent = SoundStopEvent.new() + audioEvent.soundName = "ui_phone_incoming_call" + Game.GetPlayer():QueueEvent(audioEvent) + + local audioEvent = SoundStopEvent.new() + audioEvent.soundName = "ui_phone_initiation_call" + Game.GetPlayer():QueueEvent(audioEvent) + local audioEvent = SoundPlayEvent.new() + audioEvent.soundName = "ui_phone_incoming_call_positive" + Game.GetPlayer():QueueEvent(audioEvent) + + + GameController["NewHudPhoneGameController"].holoAudioCallLogicController:Show() + GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowIncomingContact("cyberscript", "cyberscript") + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactName.widget:SetText(getLang(action.caller)) + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController:SetStatusText(getLang(action.desc)); + + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.HolocallHolder:SetVisible(true); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.SignalRangeIcon:SetVisible(false); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.WaveformPlaceholder:SetVisible(false); + InkImageUtils.RequestSetImage(GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController, GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactAvatar, "PhoneAvatars."..action.image) + + + end + + + + end + if(action.name == "show_call_avatar") then + if(GameController["NewHudPhoneGameController"] ~= nil ) then + StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + if(GameController["NewHudPhoneGameController"].incomingCallElement.widget ~=nil) then + local controller = GameController["NewHudPhoneGameController"].incomingCallElement.widget:GetController() + + GameController["NewHudPhoneGameController"]:DeactivatePhoneElement(gameuiActivePhoneElement.IncomingCall); + inkCompoundRef.RemoveChild(GameController["NewHudPhoneGameController"].incomingCallElement.slot, GameController["NewHudPhoneGameController"].incomingCallElement.widget); + GameController["NewHudPhoneGameController"].incomingCallElement.widget = nil; + end + local audioEvent = SoundStopEvent.new() + audioEvent.soundName = "ui_phone_incoming_call" + Game.GetPlayer():QueueEvent(audioEvent) + + local audioEvent = SoundStopEvent.new() + audioEvent.soundName = "ui_phone_initiation_call" + Game.GetPlayer():QueueEvent(audioEvent) + local audioEvent = SoundPlayEvent.new() + audioEvent.soundName = "ui_phone_incoming_call_positive" + Game.GetPlayer():QueueEvent(audioEvent) + + + GameController["NewHudPhoneGameController"].holoAudioCallLogicController:Show() + GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowIncomingContact("cyberscript", "cyberscript") + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactName.widget:SetText(getLang(action.caller)) + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController:SetStatusText(getLang(action.desc)); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.HolocallHolder:SetVisible(false); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.SignalRangeIcon:SetVisible(true); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.WaveformPlaceholder:SetVisible(true); + InkImageUtils.RequestSetImage(GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController, GameController["NewHudPhoneGameController"].holoAudioCallLogicController.AvatarController.ContactAvatar, "PhoneAvatars."..action.image) + + + end + + + + end + if(action.name == "hide_phone_avatar") then + if(GameController["NewHudPhoneGameController"] ~= nil) then + StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + local audioEvent = SoundStopEvent.new() + audioEvent.soundName = "ui_phone_incoming_call" + Game.GetPlayer():QueueEvent(audioEvent) + + local audioEvent = SoundPlayEvent.new() + audioEvent.soundName = "ui_phone_initiation_call_negative" + Game.GetPlayer():QueueEvent(audioEvent) + if(GameController["NewHudPhoneGameController"].incomingCallElement.widget ~=nil) then + local controller = GameController["NewHudPhoneGameController"].incomingCallElement.widget:GetController() + + GameController["NewHudPhoneGameController"]:DeactivatePhoneElement(gameuiActivePhoneElement.IncomingCall); + inkCompoundRef.RemoveChild(GameController["NewHudPhoneGameController"].incomingCallElement.slot, GameController["NewHudPhoneGameController"].incomingCallElement.widget); + GameController["NewHudPhoneGameController"].incomingCallElement.widget = nil + end + --GameController["NewHudPhoneGameController"].holoAudioCallLogicController:Show() + GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowIncomingContact("cyberscript", "cyberscript"); + GameController["NewHudPhoneGameController"].holoAudioCallLogicController:ShowEndCallContact("cyberscript", "cyberscript") + + end + + + + end + + if(action.name == "take_call") then + if currentPhoneCall ~= nil then + + StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + + local audioEvent = SoundStopEvent.new() + audioEvent.soundName = "ui_phone_incoming_call" + Game.GetPlayer():QueueEvent(audioEvent) + + runActionList(currentPhoneCall.answer_action,"phone_call","interact",false,"player") + incomingCallGameController:OnInitialize() + currentPhoneCall = nil + StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + end + + + end + + if(action.name == "refuse_call") then + if currentPhoneCall ~= nil then + + StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + phoneAction = true + local audioEvent = SoundStopEvent.new() + audioEvent.soundName = "ui_phone_incoming_call" + Game.GetPlayer():QueueEvent(audioEvent) + + runActionList(currentPhoneCall.rejected_action,"phone_call","interact",false,"player") + incomingCallGameController:OnInitialize() + currentPhoneCall = nil + end + + + end + + if(action.name == "subtitle") then + if(GameController["SubtitlesGameController"] ~= nil) then + --logme(3,"ye") + local linesToShow = {} + --GameController["SubtitlesGameController"]:Cleanup() + local dialogLine = scnDialogLineData.new() + local id = math.random(1,9999) + dialogLine.id = CRUID(id) + dialogLine.text = getLang(action.title) + dialogLine.type = action.type + dialogLine.speaker = Game.GetPlayer() + dialogLine.speakerName = getLang(action.speaker) + local candotext = true + if(action.speaker == "current_phone_npc") then + if(currentNPC ~= nil) then + dialogLine.speakerName = currentNPC.Names + else + candotext = false + end + elseif(action.speaker == "current_star") then + if(currentStar ~= nil) then + dialogLine.speakerName = currentStar.Names + else + candotext = false + end + elseif(action.speaker == "entity") then + local obj = getEntityFromManager(action.speakertag) + dialogLine.speakerName = obj.name + candotext = true + elseif(action.speaker == "mp_player") then + dialogLine.speakerName = myTag + candotext = true + elseif(action.speaker == "mp_looked_player") then + if(multiName == "") then + dialogLine.speakerName = "Player" + else + dialogLine.speakerName = multiName + end + candotext = true + else + dialogLine.speakerName = getLang(action.speaker) + candotext = true + end + + + + + + if(candotext == true) then + dialogLine.isPersistent = true + dialogLine.duration = action.duration + local restry,msg = pcall(function() + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then + GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) + end + + end) + + if(restry == false) then + local inkSystem = Game.GetInkSystem(); + local layers = inkSystem:GetLayers(); + + for i,layer in ipairs(layers) do + for j,controller in ipairs(layer:GetGameControllers()) do + if(GameController[NameToString(controller:GetClassName())] == "SubtitlesGameController") then + GameController["SubtitlesGameController"] = controller + end + + end + end + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then + GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) + end + + end + + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + nexttemp =nexttemp + action.duration + action.tick = nexttemp + result = false + end + else + error("can't find Subtitle controller, please call an npc for load one") + end + end + if(action.name == "news_subtitle") then + if(GameController["SubtitlesGameController"] ~= nil) then + --logme(3,"ye") + local linesToShow = {} + --GameController["SubtitlesGameController"]:Cleanup() + local dialogLine = scnDialogLineData.new() + local id = math.random(1,9999) + dialogLine.id = CRUID(id) + dialogLine.text = getLang(action.title) + dialogLine.type = 5 + dialogLine.speaker = Game.GetPlayer() + dialogLine.speakerName = getLang(action.speaker) + local candotext = true + if(action.speaker == "current_phone_npc") then + if(currentNPC ~= nil) then + dialogLine.speakerName = currentNPC.Names + else + candotext = false + end + elseif(action.speaker == "current_star") then + if(currentStar ~= nil) then + dialogLine.speakerName = currentStar.Names + else + candotext = false + end + elseif(action.speaker == "entity") then + local obj = getEntityFromManager(action.speakertag) + dialogLine.speakerName = obj.name + candotext = true + elseif(action.speaker == "mp_player") then + dialogLine.speakerName = myTag + candotext = true + elseif(action.speaker == "mp_looked_player") then + if(multiName == "") then + dialogLine.speakerName = "Player" + else + dialogLine.speakerName = multiName + end + candotext = true + else + dialogLine.speakerName = getLang(action.speaker) + + if(action.usecorponews == true) then + if(#corpoNews > 0) then + local id = math.random(1,#corpoNews) + dialogLine.text = getLang(corpoNews[id]) + end + end + + + candotext = true + end + if(candotext == true) then + dialogLine.isPersistent = true + dialogLine.duration = action.duration + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then + GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) + end + + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + nexttemp =nexttemp + action.duration + action.tick = nexttemp + result = false + end + else + error("can't find Subtitle controller, please call an npc for load one") + end + end + if(action.name == "random_subtitle") then + if(GameController["SubtitlesGameController"] ~= nil) then + --logme(3,"ye") + local linesToShow = {} + --GameController["SubtitlesGameController"]:Cleanup() + local tago = math.random(1,#action.title) + local dialogLine = scnDialogLineData.new() + local id = math.random(1,9999) + dialogLine.id = CRUID(id) + dialogLine.text = getLang(action.title[tago]) + dialogLine.type = action.type + dialogLine.speaker = Game.GetPlayer() + dialogLine.speakerName = getLang(action.speaker) + local candotext = true + if(action.speaker == "current_phone_npc") then + if(currentNPC ~= nil) then + dialogLine.speakerName = currentNPC.Names + else + candotext = false + end + elseif(action.speaker == "current_star") then + if(currentStar ~= nil) then + dialogLine.speakerName = currentStar.Names + else + candotext = false + end + elseif(action.speaker == "entity") then + local obj = getEntityFromManager(action.speakertag) + dialogLine.speakerName = obj.name + candotext = true + else + dialogLine.speakerName = getLang(action.speaker) + candotext = true + end + if(candotext == true) then + dialogLine.isPersistent = true + dialogLine.duration = action.duration + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then + GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) + end + + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + nexttemp =nexttemp + action.duration + action.tick = nexttemp + result = false + end + else + error("can't find Subtitle controller, please call an npc for load one") + + end + end + if(action.name == "npc_chat") then + if(GameController["ChattersGameController"] ~= nil) then + local linesToShow = {} + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + if(action.target == "lookat")then + enti = objLook + end + if(enti ~= nil) then + + local dialogLine = scnDialogLineData.new() + local id = math.random(1,9999) + dialogLine.id = CRUID(id) + dialogLine.text = getLang(action.title) + dialogLine.type = action.type + local candotext = true + dialogLine.speaker = enti + dialogLine.speakerName = getLang(action.speaker) + if(action.speaker == "current_phone_npc") then + if(currentNPC ~= nil) then + dialogLine.speakerName = currentNPC.Names + else + candotext = false + end + end + if(action.speaker == "current_star") then + if(currentStar ~= nil) then + dialogLine.speakerName = currentStar.Names + else + candotext = false + end + end + if(action.speaker == "entity") then + local obj = getEntityFromManager(action.speakertag) + dialogLine.speakerName = obj.name + candotext = true + end + if(candotext == true) then + dialogLine.isPersistent = true + dialogLine.duration = action.duration + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Overheads"):GetValue() == true) then + GameController["ChattersGameController"]:SpawnDialogLine(dialogLine) + end + + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + nexttemp =nexttemp + action.duration + --logme(3,nexttemp) + action.tick = nexttemp + result = false + end + end + else + error("can't find chat Subtitle controller, please go to see an npc who speak in street or an TV or an Radio for load one") + + end + end + if(action.name == "random_npc_chat") then + if(GameController["ChattersGameController"] ~= nil) then + local linesToShow = {} + local tago = math.random(1,#action.title) + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + if(action.target == "lookat")then + enti = objLook + end + if(enti ~= nil) then + local dialogLine = scnDialogLineData.new() + local id = math.random(1,9999) + dialogLine.id = CRUID(id) + dialogLine.text = getLang(action.title[tago]) + dialogLine.type = action.type + local candotext = true + dialogLine.speaker = enti + dialogLine.speakerName = getLang(action.speaker) + if(action.speaker == "current_phone_npc") then + if(currentNPC ~= nil) then + dialogLine.speakerName = currentNPC.Names + else + candotext = false + end + end + if(action.speaker == "current_star") then + if(currentStar ~= nil) then + dialogLine.speakerName = currentStar.Names + else + candotext = false + end + end + if(action.speaker == "entity") then + local obj = getEntityFromManager(action.speakertag) + dialogLine.speakerName = obj.name + candotext = true + end + if(candotext == true) then + dialogLine.isPersistent = true + dialogLine.duration = action.duration + + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Overheads"):GetValue() == true) then + GameController["ChattersGameController"]:SpawnDialogLine(dialogLine) + end + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + nexttemp =nexttemp + action.duration + --logme(3,nexttemp) + action.tick = nexttemp + result = false + end + end + else + error("can't find chat Subtitle controller, please go to see an npc who speak in street or an TV or an Radio for load one") + end + end + if(action.name == "clean_subtitle") then + if(GameController["SubtitlesGameController"] ~= nil) then + GameController["SubtitlesGameController"]:Cleanup() + GameController["SubtitlesGameController"]:Cleanup() + end + end + if(action.name == "clean_npc_chat") then + if(GameController["ChattersGameController"] ~= nil) then + GameController["ChattersGameController"]:Cleanup() + GameController["ChattersGameController"]:Cleanup() + end + end + if(action.name == "do_random_dialog")then + local tago = math.random(1,#action.dialog) + -- logme(3,action.dialog[tago]) + if( tago ~= nil) then + createDialog(SetNextDialog(action.dialog[tago],source,executortag)) + end + end + if(action.name == "npc_star_affinity") then + if(currentStar ~= nil) then + local score = getScoreKey("Affinity",currentStar.Names) + if(score == nil) then score = 0 end + score = score + action.value + setScore("Affinity",currentStar.Names,score) + end + end + if(action.name == "npc_affinity") then + local score = getScoreKey("Affinity",action.value) + if(score == nil) then score = 0 end + score = score + action.score + setScore("Affinity",action.value,score) + end + if(action.name == "entity_affinity") then + local obj = getEntityFromManager(action.tag) + logme(3,dump((obj))) + local score = getScoreKey("Affinity",obj.name) + if(score == nil) then score = 0 end + score = score + action.score + setScore("Affinity",obj.name,score) + end + if(action.name == "custom_star_message") then + ------logme(3,npcStarSpawn) + if(npcStarSpawn) then + customEventMessage(action.value, currentStar) + end + end + if(action.name == "change_dialog_windows") then + if(action.window == "quest" ) then + if(string.lower(tostring(action.value)) == "true")then + openQuestDialogWindow = true + else + openQuestDialogWindow = false + currentQuestdialog = nil + end + end + if(action.window == "speak" ) then + if(string.lower(tostring(action.value)) == "true")then + openSpeakDialogWindow = true + else + openSpeakDialogWindow = false + currentSpeakDialog = nil + end + end + if(action.window == "phone" ) then + if(string.lower(tostring(action.value)) == "true")then + openPhoneDialogWindow = true + else + openPhoneDialogWindow = false + currentPhoneDialog = nil + end + end + if(action.window == "event" ) then + if(string.lower(tostring(action.value)) == "true")then + openEventDialogWindow = true + else + openEventDialogWindow = false + currentEventDialog = nil + end + end + end + end + + if questregion then + if(action.name == "change_quest_content") then + QuestManager.ChangeQuestContent(action.tag,getLang(action.value)) + end + + if(action.name == "change_quest_title") then + QuestManager.ChangeQuestTitle(action.tag,getLang(action.value)) + end + + if(action.name == "change_objective_content" or action.name == "change_objective_text") then + QuestManager.ChangeObjectiveContent(action.tag,getLang(action.value)) + end + + + if(action.name == "mission") then + setScore(action.value,"Score",0) + + QuestManager.MarkQuestAsActive(action.value) + local objective = QuestManager.GetFirstObjectiveEntry(action.value) + QuestManager.TrackObjective(objective.id) + + TriggerQuest(action.value) + + end + if(action.name == "lock_mission") then + setScore(action.value,"Score",nil) + QuestManager.MarkQuestAsUnVisited(action.value) + end + if(action.name == "lock_objective") then + QuestManager.MarkObjectiveAsUndefined(action.value) + if(QuestManager.IsTrackedObjective(action.value)) then + QuestManager.UntrackObjective() + end + end + if(action.name == "set_objective_state") then + QuestManager.MarkObjectiveAs(action.value,action.state) + end + if(action.name == "unlock_objective") then + QuestManager.MarkObjectiveAsActive(action.value) + end + if(action.name == "inactive_objective") then + QuestManager.MarkObjectiveAsInactive(action.value) + if(QuestManager.IsTrackedObjective(action.value)) then + QuestManager.UntrackObjective() + end + end + if(action.name == "fail_objective") then + QuestManager.MarkObjectiveAsFailed(action.value) + end + if(action.name == "win_objective") then + QuestManager.MarkObjectiveAsComplete(action.value) + end + if(action.name == "track_objective") then + QuestManager.TrackObjective(action.value) + end + if(action.name == "unlock_mission") then + setScore(action.value,"Score",0) + end + if(action.name == "finish_mission") then + if currentQuest ~= nil and currentQuest.tag == action.tag then + canDoEndAction = true + else + if currentQuest ~= nil and currentQuest.tag ~= action.tag then + result = false + end + end + end + if(action.name == "fail_mission") then + if currentQuest ~= nil then + canDoFailActionForce = true + end + end + if(action.name == "reset_mission") then + if getQuestByTag(action.tag) ~= nil then + QuestManager.resetQuestfromJson(action.tag) + end + end + end + + if noderegion then + if(action.name == "draw_custom_3Dmappin_node") then + local node = getNode(action.tag) + if(action.atgameplayposition)then + draw3DCustomMappin(node.gameplay_x,node.gameplay_y,node.gameplay_z) + else + draw3DCustomMappin(node.x,node.y,node.z) + end + end + if(action.name == "set_entity_circuit") then + local circuit = getCircuit(action.circuit) + circuit.reverse = action.reverse + local obj = getEntityFromManager(action.tag) + obj.circuit = circuit + end + if(action.name == "set_entity_node_current") then + local obj = getEntityFromManager(action.tag) + obj.currentNode = getNode(action.data) + end + if(action.name == "set_entity_node_current_auto") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + local positionVec4 = enti:GetWorldPosition() + obj.currentNode = getNodefromPosition(positionVec4.x, positionVec4.y, positionVec4.z, action.range) + end + if(action.name == "set_entity_node_next") then + local obj = getEntityFromManager(action.tag) + if(obj.circuit.reverse == false) then + local nextNodeIndex = getNodeIndexFromCircuit(action.data,obj.circuit.datas) + obj.nextNode = obj.circuit.datas[nextNodeIndex+1] + else + local inversed_circuit = reverseTable(obj.circuit.datas) + local nextNodeIndex = getNodeIndexFromCircuit(action.data,inversed_circuit) + obj.nextNode = inversed_circuit[nextNodeIndex+1] + end + end + if(action.name == "set_entity_node_next_auto") then + local obj = getEntityFromManager(action.tag) + if(obj.circuit.reverse == false) then + local nextNodeIndex = getNodeIndexFromCircuit(obj.currentNode.tag,obj.circuit.datas) + obj.nextNode = getNode(obj.circuit.datas[nextNodeIndex+1]) + else + local inversed_circuit = reverseTable(obj.circuit.datas) + local nextNodeIndex = getNodeIndexFromCircuit(obj.currentNode.tag,inversed_circuit) + obj.nextNode = getNode(inversed_circuit[nextNodeIndex+1]) + end + end + if(action.name == "set_entity_node_path") then + local obj = getEntityFromManager(action.tag) + obj.path = getPath(action.path) + if(obj.path == nil) then + Game.GetPlayer():SetWarningMessage(getLang("see_action_nopath")) + else + obj.path.reverse = obj.circuit.reverse + if(obj.path.reverse == true) then + obj.path.index = #obj.path.locations + obj.path.finish = false + else + track.index = 1 + obj.path.finish = false + end + end + end + if(action.name == "set_entity_node_path_auto") then + local obj = getEntityFromManager(action.tag) + obj.path = getPathBetweenTwoNode(obj.currentNode.tag, obj.nextNode.tag) + if(obj.path == nil) then + Game.GetPlayer():SetWarningMessage(getLang("see_action_nopath")) + else + obj.path.reverse = obj.circuit.reverse + if(obj.path.reverse == true) then + obj.path.index = #obj.path.locations + obj.path.finish = false + else + obj.path.index = 1 + obj.path.finish = false + end + end + end + if(action.name == "run_entity_path") then + local obj = getEntityFromManager(action.tag) + if(obj ~= nil and obj.path ~= nil) then + local actionlist = {} + --logme(3,#actionlist) + --doActionofIndex(actionlist,"interact",listaction,currentindex) + result = false + local path = getEntityFromManager((group and group.entities or {})[1]).path + if(path.reverse == false) then + for i=1,#path.locations do + local trackpos = obj.path.locations[i] + local nexttrackpos = obj.path.locations[i+1] + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,obj.path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if entityTag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + if(path.recordRotation == true) then + angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) + end + --logme(3,"yaw "..angle.yaw) + local newaction = {} + newaction.name = "teleport_entity_at_position" + newaction.tag = entityTag + newaction.x = direction.x + newaction.y = direction.y + newaction.z = direction.z + newaction.angle = angle + table.insert(actionlist,newaction) + + + if(trackpos.action ~= nil and #trackpos.action > 0) then + + for y=1,#trackpos.action do + + table.insert(actionlist,trackpos.action[y]) + + end + + + end + end + else + obj.path.finish = true + end + end + else + for i= #path.locations, 1,-1 do + if(obj ~= nil) then + local trackpos = obj.path.locations[i] + local nexttrackpos = obj.path.locations[i+1] + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,obj.path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if entityTag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + if(path.recordRotation == true) then + angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) + end + --logme(3,"yaw "..angle.yaw) + local newaction = {} + newaction.name = "teleport_entity_at_position" + newaction.tag = entityTag + newaction.x = direction.x + newaction.y = direction.y + newaction.z = direction.z + newaction.angle = angle + table.insert(actionlist,newaction) + + + if(trackpos.action ~= nil and #trackpos.action > 0) then + + for y=1,#trackpos.action do + + table.insert(actionlist,trackpos.action[y]) + + end + + + end + end + else + obj.path.finish = true + end + end + end + end + -- for i=1,#actionlist do + -- executeAction(actionlist[i],tag,parent,index,source) + -- end + runSubActionList(actionlist, tag.."_run_path", tag,source,false,executortag) + end + end + + if(action.name == "play_path") then + local obj = getEntityFromManager(action.tag) + if(obj ~= nil ) then + local actionlist = {} + --logme(3,#actionlist) + --doActionofIndex(actionlist,"interact",listaction,currentindex) + result = false + local path = getPath(action.path) + if(action.reverse == nil or action.reverse == false) then + path.index = 1 + for i=1,#path.locations do + local trackpos = path.locations[i] + local nexttrackpos = path.locations[i+1] + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if action.tag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + if(path.recordRotation == true) then + angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) + end + --logme(3,"yaw "..angle.yaw) + + local newaction = {} + if(action.isrelative ~= nil and action.isrelative == true) then + newaction.name = "teleport_entity_at_relative_position" + + else + newaction.name = "teleport_entity_at_position" + end + newaction.tag = action.tag + newaction.x = direction.x + newaction.y = direction.y + newaction.z = direction.z + newaction.angle = angle + table.insert(actionlist,newaction) + + if(trackpos.action ~= nil and #trackpos.action > 0) then + + for y=1,#trackpos.action do + + table.insert(actionlist,trackpos.action[y]) + + end + + + end + end + else + obj.path = {} + obj.path.finish = true + end + end + else + path.index = #path.locations + for i= #path.locations, 1,-1 do + if(obj ~= nil) then + local trackpos = path.locations[i] + local nexttrackpos = path.locations[i+1] + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if action.tag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + if(path.recordRotation == true) then + angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) + end + --logme(3,"yaw "..angle.yaw) + local newaction = {} + if(action.isrelative ~= nil and action.isrelative == true) then + newaction.name = "teleport_entity_at_relative_position" + + else + newaction.name = "teleport_entity_at_position" + end + newaction.tag = action.tag + newaction.x = direction.x + newaction.y = direction.y + newaction.z = direction.z + newaction.angle = angle + table.insert(actionlist,newaction) + if(trackpos.action ~= nil and #trackpos.action > 0) then + + for y=1,#trackpos.action do + + table.insert(actionlist,trackpos.action[y]) + + end + + + end + + end + else + obj.path = {} + obj.path.finish = true + end + end + end + end + -- for i=1,#actionlist do + -- executeAction(actionlist[i],tag,parent,index,source) + -- end + spdlog.error(dump(actionlist)) + runSubActionList(actionlist, tag.."_run_path", tag,source,false,executortag) + end + end + + + + if(action.name == "clean_entity_circuit") then + local obj = getEntityFromManager(action.tag) + if(obj ~= nil) then + obj.path = nil + obj.circuit = nil + obj.currentNode = nil + obj.nextNode = nil + end + end + if(action.name == "summon_entity_at_node") then + local node = getNode(action.data) + local isAV = false + if(action.isAV ~= nil) then + isAV = action.isAV + end + chara = action.npc + if(action.atgameplayposition) then + + end + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,action.tag) + end + end + if(action.name == "summon_entity_at_mappin") then + local mappin = getMappinByTag(action.mappin) + local isAV = false + if(action.isAV ~= nil) then + isAV = action.isAV + end + chara = action.npc + if(mappin) then + + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,action.tag) + end + end + end + if(action.name == "teleport_entity_at_node") then + local node = getNode(action.data) + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + local isplayer = false + if(action.tag == "player") then + enti = Game.GetPlayer() + isplayer = true + end + if(enti ~= nil) then + --logme(3,"moveit") + if(action.atgameplayposition) then + teleportTo(enti, Vector4.new( node.gameplay_x+action.offset, node.gameplay_y, node.gameplay_z,1), 1,isplayer) + else + teleportTo(enti, Vector4.new( node.x+action.offset, node.y, node.z,1), 1,isplayer) + end + end + end + if(action.name == "teleport_entity_at_current_node") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + local isplayer = false + if(action.tag == "player") then + enti = Game.GetPlayer() + isplayer = true + end + local position = enti:GetWorldPosition() + local range = 70 + if(action.range ~= nil) then + range = action.range + end + local node = getNodefromPosition(position.x,position.y,position.z,range) + if node ~= nil then + if(enti ~= nil) then + logme(3,"tp to node "..data.name) + if(action.atgameplayposition) then + teleportTo(enti, Vector4.new( node.gameplay_x+action.offset, node.gameplay_y, node.gameplay_z,1), 1,isplayer) + else + teleportTo(enti, Vector4.new( node.x+action.offset, node.y, node.z,1), 1,isplayer) + end + end + end + end + if(action.name == "summon_entity_at_current_node") then + local position = Game.GetPlayer():GetWorldPosition() + local range = 70 + if(action.range ~= nil) then + range = action.range + end + local node = getNodefromPosition(position.x,position.y,position.z,range) + if node ~= nil then + chara = action.npc + local isAV = false + if(action.isAV ~= nil) then + isAV = action.isAV + end + if(action.atgameplayposition) then + + end + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,action.tag) + end + end + end + if(action.name == "set_group_circuit") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + logme(3,entityTag) + logme(3,action.circuit) + local obj = getEntityFromManager(entityTag) + local circuit = getCircuit(action.circuit) + logme(3,dump(circuit)) + logme(3,dump(obj)) + obj.circuit =circuit + logme(3,"set circuit.."..obj.circuit.tag) + logme(3,"action.reverse"..tostring(action.reverse)) + obj.circuit.reverse = action.reverse + end + end + if(action.name == "set_group_node_current") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getTrueEntityFromManager(entityTag) + obj.currentNode = getNode(action.data) + setEntityFromManager(entityTag,obj) + end + end + if(action.name == "set_group_node_current_auto") then + local group =getGroupfromManager(action.tag) + logme(3,"test.."..#(group and (group and group.entities or {}) or {})) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getTrueEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + local positionVec4 = enti:GetWorldPosition() + obj.currentNode = getNodefromPosition(positionVec4.x, positionVec4.y, positionVec4.z, action.range) + logme(3,"currentNode "..obj.currentNode.tag) + -- setEntityFromManager(entityTag,obj) + end + end + if(action.name == "set_group_node_next") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + if(obj.circuit.reverse == false ) then + local nextNodeIndex = getNodeIndexFromCircuit(action.data,obj.circuit.datas) + obj.nextNode = obj.circuit.datas[nextNodeIndex+1] + else + local inversed_circuit = reverseTable(obj.circuit.datas) + local nextNodeIndex = getNodeIndexFromCircuit(action.data,inversed_circuit) + obj.nextNode = inversed_circuit[nextNodeIndex+1] + end + end + end + if(action.name == "set_group_node_next_auto") then + local group =getGroupfromManager(action.tag) + logme(3,"test.."..#(group and (group and group.entities or {}) or {})) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getTrueEntityFromManager(entityTag) + logme(3,"currentNode "..obj.currentNode.tag) + logme(3,#obj.circuit) + logme(3,tostring(obj.circuit.reverse)) + if(obj.circuit.reverse == false or obj.circuit.reverse == nil) then + local nextNodeIndex = getNodeIndexFromCircuit(obj.currentNode.tag,obj.circuit.datas) + logme(3,"nextNodeIndex "..nextNodeIndex) + obj.nextNode = getNode(obj.circuit.datas[nextNodeIndex+1]) + logme(3,"nextNode "..obj.nextNode.tag) + setEntityFromManager(entityTag,obj) + else + local inversed_circuit = reverseTable(obj.circuit.datas) + local nextNodeIndex = getNodeIndexFromCircuit(obj.currentNode.tag,inversed_circuit) + obj.nextNode = getNode(inversed_circuit[nextNodeIndex+1]) + --setEntityFromManager(entityTag,obj) + end + end + end + if(action.name == "set_group_node_path") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + obj.path = getPath(action.path) + if(obj.path == nil) then + Game.GetPlayer():SetWarningMessage(getLang("see_action_nopath")) + else + obj.path.reverse = obj.circuit.reverse + if(obj.path.reverse == true) then + obj.path.index = #obj.path.locations + obj.path.finish = false + else + track.index = 1 + obj.path.finish = false + end + end + end + end + if(action.name == "set_group_node_path_auto") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + logme(3,obj.currentNode.tag) + logme(3,obj.nextNode.tag) + if(obj.circuit.reverse == true) then + obj.path = getPathBetweenTwoNode(obj.nextNode.tag, obj.currentNode.tag) + else + obj.path = getPathBetweenTwoNode(obj.currentNode.tag, obj.nextNode.tag) + end + if(obj.path == nil) then + Game.GetPlayer():SetWarningMessage(getLang("see_action_nopath")) + else + obj.path.reverse = obj.circuit.reverse + if(obj.path.reverse == true) then + obj.path.index = #obj.path.locations + obj.path.finish = false + else + obj.path.index = 1 + obj.path.finish = false + end + end + end + end + + if(action.name == "run_group_path_cached" or action.name == "run_group_path") then + local group =getGroupfromManager(action.tag) + local actionlist = {} + --logme(3,#actionlist) + --doActionofIndex(actionlist,"interact",listaction,currentindex) + result = false + local path = getEntityFromManager((group and group.entities or {})[1]).path + if(path.reverse == false) then + for i=1,#path.locations do + for y=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[y] + local obj = getEntityFromManager(entityTag) + if(obj ~= nil) then + local trackpos = obj.path.locations[i] + local nexttrackpos = obj.path.locations[i+1] + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,obj.path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if entityTag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + if(path.recordRotation == true) then + angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) + end + --logme(3,"yaw "..angle.yaw) + local newaction = {} + if(action.isrelative ~= nil and action.isrelative == true) then + newaction.name = "teleport_entity_at_relative_position" + + else + newaction.name = "teleport_entity_at_position" + end + newaction.tag = entityTag + newaction.x = direction.x + newaction.y = direction.y + newaction.z = direction.z + newaction.angle = angle + table.insert(actionlist,newaction) + + if(trackpos.action ~= nil and #trackpos.action > 0) then + + for y=1,#trackpos.action do + + table.insert(actionlist,trackpos.action[y]) + + end + + + end + end + else + obj.path.finish = true + end + end + end + end + else + for i= #path.locations, 1,-1 do + for y=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[y] + local obj = getEntityFromManager(entityTag) + if(obj ~= nil) then + local trackpos = obj.path.locations[i] + local nexttrackpos = obj.path.locations[i+1] + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,obj.path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if entityTag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + if(path.recordRotation == true) then + angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) + end + --logme(3,"yaw "..angle.yaw) + local newaction = {} + if(action.isrelative ~= nil and action.isrelative == true) then + newaction.name = "teleport_entity_at_relative_position" + + else + newaction.name = "teleport_entity_at_position" + end + newaction.tag = entityTag + newaction.x = direction.x + newaction.y = direction.y + newaction.z = direction.z + newaction.angle = angle + table.insert(actionlist,newaction) + + if(trackpos.action ~= nil and #trackpos.action > 0) then + + for y=1,#trackpos.action do + + table.insert(actionlist,trackpos.action[y]) + + end + + + end + end + else + obj.path.finish = true + end + end + end + end + end + -- for i=1,#actionlist do + -- executeAction(actionlist[i],tag,parent,index,source) + -- end + runSubActionList(actionlist, tag.."_run_path", tag,source,false,executortag) + end + + -- end + if(action.name == "play_group_path_cached" or action.name == "play_group_path") then + local group =getGroupfromManager(action.tag) + local actionlist = {} + --logme(3,#actionlist) + --doActionofIndex(actionlist,"interact",listaction,currentindex) + result = false + local path = getPath(action.path) + if(path.reverse == false) then + for i=1,#path.locations do + for y=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[y] + local obj = getEntityFromManager(entityTag) + if(obj ~= nil) then + local trackpos = path.locations[i] + local nexttrackpos = path.locations[i+1] + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if entityTag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + if(path.recordRotation == true) then + angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) + end + --logme(3,"yaw "..angle.yaw) + local newaction = {} + + if(action.isrelative ~= nil and action.isrelative == true) then + newaction.name = "teleport_entity_at_relative_position" + + else + newaction.name = "teleport_entity_at_position" + end + newaction.tag = entityTag + newaction.x = direction.x + newaction.y = direction.y + newaction.z = direction.z + newaction.angle = angle + table.insert(actionlist,newaction) + end + else + obj.path = {} + obj.path.finish = true + end + end + end + end + else + for i= #path.locations, 1,-1 do + for y=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[y] + local obj = getEntityFromManager(entityTag) + if(obj ~= nil) then + local trackpos = path.locations[i] + local nexttrackpos = path.locations[i+1] + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if entityTag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + if(path.recordRotation == true) then + angle = EulerAngles.new(trackpos.roll, trackpos.pitch, nexttrackpos.yaw) + end + --logme(3,"yaw "..angle.yaw) + local newaction = {} + + if(action.isrelative ~= nil and action.isrelative == true) then + newaction.name = "teleport_entity_at_relative_position" + + else + newaction.name = "teleport_entity_at_position" + end + newaction.tag = entityTag + newaction.x = direction.x + newaction.y = direction.y + newaction.z = direction.z + newaction.angle = angle + table.insert(actionlist,newaction) + end + + else + obj.path = {} + obj.path.finish = true + + end + end + end + end + end + -- for i=1,#actionlist do + -- executeAction(actionlist[i],tag,parent,index,source) + -- end + runSubActionList(actionlist, tag.."_run_path", tag,source,false,executortag) + end + + + + if(action.name == "clean_group_circuit") then + local group =getGroupfromManager(action.tag) + if group ~= nil then + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + if(obj ~= nil) then + obj.path = nil + obj.circuit = nil + obj.currentNode = nil + obj.nextNode = nil + end + end + end + end + if(action.name == "group_look_at_next_path_position") then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + if(obj ~= nil) then + local trackpos = obj.path.locations[obj.path.index] + local nexttrackpos = obj.path.locations[obj.path.index+1] + if obj.path.reverse == true then + nexttrackpos = obj.path.locations[obj.path.index-1] + end + if(nexttrackpos ~= nil) and (trackpos ~= nil) then + logme(3,obj.path.index) + local direction = {} + local separate = 0 + if(action.separate ~= nil and action.separate == true) then + separate = i-1 + end + direction.x = nexttrackpos.x-separate + direction.y = nexttrackpos.y-separate + direction.z = nexttrackpos.z+action.zoffset + direction.w = 1 + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if entityTag == "player" then + isplayer = true + end + local dirVector = diffVector(enti:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + logme(3,"yaw "..angle.yaw) + teleportTo(enti, enti:GetWorldPosition(), angle,isplayer) + end + end + end + end + end + end + + if soundregion then + if(action.name == "play_game_sound" or action.name == "play_game_sound_test") then + local audioEvent = SoundPlayEvent.new() + audioEvent.soundName = action.value + Game.GetPlayer():QueueEvent(audioEvent) + end + if(action.name == "stop_game_sound" or action.name == "stop_game_sound_test") then + local audioEvent = SoundStopEvent.new() + audioEvent.soundName = action.value + Game.GetPlayer():QueueEvent(audioEvent) + end + if(action.name == "play_custom_sound") then + + if(cyberscript.cache["sound"][action.value] ~= nil) then + local path = cyberscript.cache["sound"][action.value].data + + local isradio = false + local needrepeat = false + + if action.isradio ~= nil then isradio = action.isradio end + if action.needrepeat ~= nil then needrepeat = action.needrepeat end + + + + PlaySound(path,isradio,needrepeat) + else + error("No sound founded") + end + end + + if(action.name == "play_custom_sound_with_subtitle") then + + if(cyberscript.cache["sound"][action.value] ~= nil) then + + if(GameController["SubtitlesGameController"] ~= nil) then + --logme(3,"ye") + local linesToShow = {} + --GameController["SubtitlesGameController"]:Cleanup() + local dialogLine = scnDialogLineData.new() + local id = math.random(1,9999) + dialogLine.id = CRUID(id) + dialogLine.text = getLang(cyberscript.cache["sound"][action.value].data.subtitle) + dialogLine.type = action.type + dialogLine.speaker = Game.GetPlayer() + dialogLine.speakerName = getLang(action.speaker) + local candotext = true + if(action.speaker == "current_phone_npc") then + if(currentNPC ~= nil) then + dialogLine.speakerName = currentNPC.Names + else + candotext = false + end + elseif(action.speaker == "current_star") then + if(currentStar ~= nil) then + dialogLine.speakerName = currentStar.Names + else + candotext = false + end + elseif(action.speaker == "entity") then + local obj = getEntityFromManager(action.speakertag) + dialogLine.speakerName = obj.name + candotext = true + elseif(action.speaker == "mp_player") then + dialogLine.speakerName = myTag + candotext = true + elseif(action.speaker == "mp_looked_player") then + if(multiName == "") then + dialogLine.speakerName = "Player" + else + dialogLine.speakerName = multiName + end + candotext = true + else + dialogLine.speakerName = getLang(action.speaker) + candotext = true + end + + local tempsMoyen = calcTimebyLetter( countLetter(dialogLine.text), vitesseParLettre) + - - - - if(candotext == true) then - dialogLine.isPersistent = true - dialogLine.duration = math.ceil(tempsMoyen) - - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then - GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) - end - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp + + + + if(candotext == true) then + dialogLine.isPersistent = true + dialogLine.duration = math.ceil(tempsMoyen) + + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then + GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) + end + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp - - + + - nexttemp =nexttemp + math.ceil(tempsMoyen) - action.tick = nexttemp - - local path = cyberscript.cache["sound"][action.value].data - - local isradio = false - local needrepeat = false - - if action.isradio ~= nil then isradio = action.isradio end - if action.needrepeat ~= nil then needrepeat = action.needrepeat end - - - if(action.target == nil or action.target == "player") then - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - else - local obj = getEntityFromManager(action.target) - if(obj ~= nil) then - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - - local actionb = deepcopy(cyberscript.actiontemplate["fake_lips_sync"]) - actionb.duration = math.floor(tempsMoyen) - actionb.tag = action.target - local actionlist = {} - actionlist[1] = actionb - runActionList(actionlist, "fake_lips_sync_async_action_"..tostring(math.random(1,987987)), "see",false,nil) - PlaySoundAtEntity(path,isradio,needrepeat,action.target,tempsMoyen,action.volume) - else - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - end - else - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - end - end - result = false - end - else - error("can't find Subtitle controller, please call an npc for load one") - end - - - else - error("No sound founded") - end - end - - if(action.name == "play_random_custom_sound_with_subtitle") then - local tago = math.random(1,#action.value) - local tag = action.value[tago] - if(cyberscript.cache["sound"][tag] ~= nil) then - - if(GameController["SubtitlesGameController"] ~= nil) then - --logme(3,"ye") - local linesToShow = {} - --GameController["SubtitlesGameController"]:Cleanup() - local dialogLine = scnDialogLineData.new() - local id = math.random(1,9999) - dialogLine.id = CRUID(id) - dialogLine.text = getLang(cyberscript.cache["sound"][tag].data.subtitle) - dialogLine.type = action.type - dialogLine.speaker = Game.GetPlayer() - dialogLine.speakerName = getLang(action.speaker) - local candotext = true - if(action.speaker == "current_phone_npc") then - if(currentNPC ~= nil) then - dialogLine.speakerName = currentNPC.Names - else - candotext = false - end - elseif(action.speaker == "current_star") then - if(currentStar ~= nil) then - dialogLine.speakerName = currentStar.Names - else - candotext = false - end - elseif(action.speaker == "entity") then - local obj = getEntityFromManager(action.speakertag) - dialogLine.speakerName = obj.name - candotext = true - elseif(action.speaker == "mp_player") then - dialogLine.speakerName = myTag - candotext = true - elseif(action.speaker == "mp_looked_player") then - if(multiName == "") then - dialogLine.speakerName = "Player" - else - dialogLine.speakerName = multiName - end - candotext = true - else - dialogLine.speakerName = getLang(action.speaker) - candotext = true - end - - - local tempsMoyen = calcTimebyLetter(countLetter(dialogLine.text), vitesseParLettre) - - - - - if(candotext == true) then - dialogLine.isPersistent = true - dialogLine.duration = math.ceil(tempsMoyen) - - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then - GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) - end - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp + nexttemp =nexttemp + math.ceil(tempsMoyen) + action.tick = nexttemp + + local path = cyberscript.cache["sound"][action.value].data + + local isradio = false + local needrepeat = false + + if action.isradio ~= nil then isradio = action.isradio end + if action.needrepeat ~= nil then needrepeat = action.needrepeat end + + + if(action.target == nil or action.target == "player") then + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + else + local obj = getEntityFromManager(action.target) + if(obj ~= nil) then + local enti = safeFindEntityByID(obj) + + if(enti ~= nil) then + + local actionb = deepcopy(cyberscript.actiontemplate["fake_lips_sync"]) + actionb.duration = math.floor(tempsMoyen) + actionb.tag = action.target + local actionlist = {} + actionlist[1] = actionb + runActionList(actionlist, "fake_lips_sync_async_action_"..tostring(math.random(1,987987)), "see",false,nil) + PlaySoundAtEntity(path,isradio,needrepeat,action.target,tempsMoyen,action.volume) + else + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + end + else + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + end + end + result = false + end + else + error("can't find Subtitle controller, please call an npc for load one") + end + + + else + error("No sound founded") + end + end + + if(action.name == "play_random_custom_sound_with_subtitle") then + local tago = math.random(1,#action.value) + local tag = action.value[tago] + if(cyberscript.cache["sound"][tag] ~= nil) then + + if(GameController["SubtitlesGameController"] ~= nil) then + --logme(3,"ye") + local linesToShow = {} + --GameController["SubtitlesGameController"]:Cleanup() + local dialogLine = scnDialogLineData.new() + local id = math.random(1,9999) + dialogLine.id = CRUID(id) + dialogLine.text = getLang(cyberscript.cache["sound"][tag].data.subtitle) + dialogLine.type = action.type + dialogLine.speaker = Game.GetPlayer() + dialogLine.speakerName = getLang(action.speaker) + local candotext = true + if(action.speaker == "current_phone_npc") then + if(currentNPC ~= nil) then + dialogLine.speakerName = currentNPC.Names + else + candotext = false + end + elseif(action.speaker == "current_star") then + if(currentStar ~= nil) then + dialogLine.speakerName = currentStar.Names + else + candotext = false + end + elseif(action.speaker == "entity") then + local obj = getEntityFromManager(action.speakertag) + dialogLine.speakerName = obj.name + candotext = true + elseif(action.speaker == "mp_player") then + dialogLine.speakerName = myTag + candotext = true + elseif(action.speaker == "mp_looked_player") then + if(multiName == "") then + dialogLine.speakerName = "Player" + else + dialogLine.speakerName = multiName + end + candotext = true + else + dialogLine.speakerName = getLang(action.speaker) + candotext = true + end + + + local tempsMoyen = calcTimebyLetter(countLetter(dialogLine.text), vitesseParLettre) + + + + + if(candotext == true) then + dialogLine.isPersistent = true + dialogLine.duration = math.ceil(tempsMoyen) + + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Cinematic"):GetValue() == true) then + GameController["SubtitlesGameController"]:SpawnDialogLine(dialogLine) + end + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp - + - nexttemp =nexttemp + math.ceil(tempsMoyen) - action.tick = nexttemp - - local path = cyberscript.cache["sound"][tag].data - - local isradio = false - local needrepeat = false - - if action.isradio ~= nil then isradio = action.isradio end - if action.needrepeat ~= nil then needrepeat = action.needrepeat end - - - - if(action.target == nil or action.target == "player") then - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - else - local obj = getEntityFromManager(action.target) - if(obj ~= nil) then - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - - local actionb = deepcopy(cyberscript.actiontemplate["fake_lips_sync"]) - actionb.duration = math.floor(tempsMoyen) - actionb.tag = action.target - local actionlist = {} - actionlist[1] = actionb - runActionList(actionlist, "fake_lips_sync_async_action_"..tostring(math.random(1,987987)), "see",false,nil) - PlaySoundAtEntity(path,isradio,needrepeat,enti,tempsMoyen,action.volume) - else - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - end - else - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - end - end - - result = false - end - else - error("can't find Subtitle controller, please call an npc for load one") - end - - - else - error("No sound founded for "..tag) - end - end - - if(action.name == "play_custom_sound_at_entity") then - - if(cyberscript.cache["sound"][action.value] ~= nil) then - local path = cyberscript.cache["sound"][action.value].data - - local isradio = false - local needrepeat = false - - if action.isradio ~= nil then isradio = action.isradio end - if action.needrepeat ~= nil then needrepeat = action.needrepeat end - - - - PlaySoundAtEntity(path,isradio,needrepeat,action.tag) - else - error("No sound founded") - end - end - - if(action.name == "stop_custom_sound") then - local path = cyberscript.cache["sound"][action.value].data - Stop(path) - end - if(action.name == "setGameVolume") then - SetSoundSettingValue(action.value, action.score) - end - if(action.name == "change_radio_index") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - ps.activeStation = action.value - enti:PlayGivenStation() - - end - end - - if(action.name == "change_tv_index") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - - enti:SelectChannel(action.value) - - end - end - - if(action.name == "device_turn_on") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - - enti:TurnOnDevice() - - end - end - - if(action.name == "device_turn_off") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - - enti:TurnOffDevice() - - end - end - - - if(action.name == "device_glitch_on") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - - enti:StartGlitching(action.value, 1) - - end - end - - - if(action.name == "device_stop_using") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - - enti:StopUsing() - end - end - - if(action.name == "device_start_using") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - - enti:StartUsing() - end - end - - if(action.name == "device_glitch_off") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local ps = enti:GetDevicePS() - - enti:StopGlitching() - - end - end - - if(action.name == "play_custom_sound_with_subtitle_as_chat") then - if(cyberscript.cache["sound"][action.value] ~= nil) then - - if(GameController["ChattersGameController"] ~= nil) then - local linesToShow = {} - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - if(action.target == "lookat")then - enti = objLook - end - if(enti ~= nil) then - local dialogLine = scnDialogLineData.new() - local id = math.random(1,9999) - dialogLine.id = CRUID(id) - dialogLine.text =getLang(cyberscript.cache["sound"][action.value].data.subtitle) - dialogLine.type = action.type - local candotext = true - dialogLine.speaker = enti - dialogLine.speakerName = getLang(action.speaker) - if(action.speaker == "current_phone_npc") then - if(currentNPC ~= nil) then - dialogLine.speakerName = currentNPC.Names - else - candotext = false - end - end - if(action.speaker == "current_star") then - if(currentStar ~= nil) then - dialogLine.speakerName = currentStar.Names - else - candotext = false - end - end - if(action.speaker == "entity") then - local obj = getEntityFromManager(action.speakertag) - dialogLine.speakerName = obj.name - candotext = true - end - - local tempsMoyen = calcTimebyLetter(countLetter(dialogLine.text), vitesseParLettre) - - if(candotext == true) then - dialogLine.isPersistent = false - dialogLine.duration = math.ceil(tempsMoyen) - - if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Overheads"):GetValue() == true) then - GameController["ChattersGameController"]:SpawnDialogLine(dialogLine) - end - local temp = os.time(os.date("!*t"))+0 - local nexttemp = temp - - - nexttemp =nexttemp + math.ceil(tempsMoyen) - action.tick = nexttemp - - local path = cyberscript.cache["sound"][action.value].data - - local isradio = false - local needrepeat = false - - if action.isradio ~= nil then isradio = action.isradio end - if action.needrepeat ~= nil then needrepeat = action.needrepeat end - - - - if(action.target == nil or action.target == "player") then - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - else - local obj = getEntityFromManager(action.target) - if(obj ~= nil) then - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - - local actionb = deepcopy(cyberscript.actiontemplate["fake_lips_sync"]) - actionb.duration = math.floor(tempsMoyen) - actionb.tag = action.target - local actionlist = {} - actionlist[1] = actionb - runActionList(actionlist, "fake_lips_sync_async_action_"..tostring(math.random(1,987987)), "see",false,nil) - PlaySoundAtEntity(path,isradio,needrepeat,action.target,tempsMoyen,action.volume) else - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - end - else - PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) - end - end - - result = false - end - end - else - error("can't find chat Subtitle controller, please go to see an npc who speak in street or an TV or an Radio for load one") - - end - - - else - error("No sound founded") - end - - - end - - end - - if entityregion then - if(action.name == "spawn_npc") then - local chara = "" - if(action.amount == nil) then - action.amount = 1 - end - if(action.amount == 0) then - action.amount = math.random(1,6) - end - for i=1,action.amount do - - - - if(action.source == "from_list") then - local indexchara = math.random(1,#action.source_list) - chara = action.source_list[indexchara] - end - if(action.source == "npc") then - chara = action.source_tag - end - if(action.source == "custom_npc") then - local npc = getCustomNPCbyTag(action.tag) - if(npc ~= nil) then - chara = npc.tweakDB - npc.spawnforced=true - - - npc.isspawn=true - npc.init=false - end - end - if(action.source == "current_star") then - if(currentStar ~= nil) then - chara = currentStar.TweakIDs - else - error("No Current Star defined, can't spawn !") - end - end - if(action.source == "current_phoned_npc") then - if(currentNPC ~= nil) then - chara = currentNPC.TweakIDs - else - error("No Current Phoned NPC defined, can't spawn !") - end - end - if(action.source == "faction") then - local gang = getFactionByTag(action.source_tag) - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - if(action.source_use_vip == true) then - if(#gang.vip > 0) then - local viptable = getVIPfromfactionbyscore(gang.tag) - if(#viptable > 0) then - local index = math.random(1,#viptable) - - chara = viptable[index] - else - - error("No VIP NPC for this faction") - end - end - else - --spdlog.error(dump(gang)) - if(gang.spawnable_npc ~= nil and #gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - chara = gang.spawnable_npc[index] - - else - - error("No Spawnable NPC for this faction") - end - end - end - if(action.source == "faction_random_list") then - local indexchara = math.random(1,#action.source_list) - - local gang = getFactionByTag(action.source_list[indexchara]) - - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - if(action.source_use_vip == true) then - if(#gang.vip > 0) then - local viptable = getVIPfromfactionbyscore(gang.tag) - if(#viptable > 0) then - local index = math.random(1,#viptable) - - chara = viptable[index] - else - - error("No VIP NPC for this faction") - end - end - else - --spdlog.error(dump(gang)) - if(gang.spawnable_npc ~= nil and #gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - chara = gang.spawnable_npc[index] - - else - - error("No Spawnable NPC for this faction") - end - end - end - if(action.source == "district_leader" or action.source == "subdistrict_leader") then - local gangs = getGangfromDistrict(action.source_tag,20) - logme(3,dump(gangs)) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - if(action.source_use_vip == true) then - if(#gang.vip > 0) then - local viptable = getVIPfromfactionbyscore(gang.tag) - if(#viptable > 0) then - local index = math.random(1,#viptable) - - chara = viptable[index] - end - end - else - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - chara = gang.spawnable_npc[index] - end - end - end - end - if(action.source == "current_district_leader") then - - local gangs = getGangfromDistrict(currentDistricts2.Tag,0) - - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - - if(action.source_use_vip == true) then - if(#gang.vip > 0) then - local viptable = getVIPfromfactionbyscore(gang.tag) - if(#viptable > 0) then - local index = math.random(1,#viptable) - - chara = viptable[index] - end - end - else - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - chara = gang.spawnable_npc[index] - end - end - end - end - if(action.source == "current_subdistrict_leader") then - local gangs = {} - for j, test in ipairs(currentDistricts2.districtLabels) do - if j > 1 then - gangs = getGangfromDistrict(test,20) - if(#gangs > 0) then - break - end - end - end - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - if(action.source_use_rival == true) then - gang = getFactionByTag(gang.rivals[1]) - end - if(action.source_use_vip == true) then - if(#gang.vip > 0) then - local viptable = getVIPfromfactionbyscore(gang.tag) - if(#viptable > 0) then - local index = math.random(1,#viptable) - - chara = viptable[index] - end - end - else - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - chara = gang.spawnable_npc[index] - end - end - end - end - if(action.source == "district_rival" or action.source == "subdistrict_rival") then - - if(action.source_gang == "player") then - - action.source_gang = getVariableKey("player","current_gang") - - end - - local gangs = getGangRivalfromDistrict(action.source_gang,action.source_tag,20) - - - - if(#gangs > 0) then - - - local gang = getFactionByTag(gangs[1].tag) - - if(action.source_use_vip == true) then - if(#gang.vip > 0) then - local viptable = getVIPfromfactionbyscore(gang.tag) - if(#viptable > 0) then - local index = math.random(1,#viptable) - - chara = viptable[index] - end - end - else - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - chara = gang.spawnable_npc[index] - end - end - end - end - if(action.source == "current_district_rival") then - - if(action.source_gang == "player") then - - action.source_gang = getVariableKey("player","current_gang") - - end - - local gangs = getGangRivalfromDistrict(action.source_gang,currentDistricts2.Tag,20) - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - - if(action.source_use_vip == true) then - if(#gang.vip > 0) then - local viptable = getVIPfromfactionbyscore(gang.tag) - if(#viptable > 0) then - local index = math.random(1,#viptable) - - chara = viptable[index] - end - end - else - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - chara = gang.spawnable_npc[index] - end - end - end - end - - if(action.source == "current_subdistrict_rival") then - - if(action.source_gang == "player") then - - action.source_gang = getVariableKey("player","current_gang") - - end - - local gangs = {} - for j, test in ipairs(currentDistricts2.districtLabels) do - if j > 1 then - gangs = getGangRivalfromDistrict(action.source_gang,test,20) - if(#gangs > 0) then - break - end - end - end - if(#gangs > 0) then - local gang = getFactionByTag(gangs[1].tag) - - if(action.source_use_vip == true) then - if(#gang.vip > 0) then - local viptable = getVIPfromfactionbyscore(gang.tag) - if(#viptable > 0) then - local index = math.random(1,#viptable) - - chara = viptable[index] - end - end - else - if(#gang.spawnable_npc > 0) then - local index = math.random(1,#gang.spawnable_npc) - chara = gang.spawnable_npc[index] - end - end - end - end - - - local tag = action.tag - if(action.amount > 1) then - tag = action.tag.."_"..i - end - - - local position = {} - local position = getPositionFromParameter(action) - - if(chara ~= "" and chara ~= nil and position.x ~= nil) then - + nexttemp =nexttemp + math.ceil(tempsMoyen) + action.tick = nexttemp + + local path = cyberscript.cache["sound"][tag].data + + local isradio = false + local needrepeat = false + + if action.isradio ~= nil then isradio = action.isradio end + if action.needrepeat ~= nil then needrepeat = action.needrepeat end + + + + if(action.target == nil or action.target == "player") then + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + else + local obj = getEntityFromManager(action.target) + if(obj ~= nil) then + local enti = safeFindEntityByID(obj) + + if(enti ~= nil) then + + local actionb = deepcopy(cyberscript.actiontemplate["fake_lips_sync"]) + actionb.duration = math.floor(tempsMoyen) + actionb.tag = action.target + local actionlist = {} + actionlist[1] = actionb + runActionList(actionlist, "fake_lips_sync_async_action_"..tostring(math.random(1,987987)), "see",false,nil) + PlaySoundAtEntity(path,isradio,needrepeat,enti,tempsMoyen,action.volume) + else + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + end + else + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + end + end + + result = false + end + else + error("can't find Subtitle controller, please call an npc for load one") + end + + + else + error("No sound founded for "..tag) + end + end + + if(action.name == "play_custom_sound_at_entity") then + + if(cyberscript.cache["sound"][action.value] ~= nil) then + local path = cyberscript.cache["sound"][action.value].data + + local isradio = false + local needrepeat = false + + if action.isradio ~= nil then isradio = action.isradio end + if action.needrepeat ~= nil then needrepeat = action.needrepeat end + + + + PlaySoundAtEntity(path,isradio,needrepeat,action.tag) + else + error("No sound founded") + end + end + + if(action.name == "stop_custom_sound") then + local path = cyberscript.cache["sound"][action.value].data + Stop(path) + end + if(action.name == "setGameVolume") then + SetSoundSettingValue(action.value, action.score) + end + if(action.name == "change_radio_index") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local ps = enti:GetDevicePS() + ps.activeStation = action.value + enti:PlayGivenStation() + + end + end + + if(action.name == "change_tv_index") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local ps = enti:GetDevicePS() + + enti:SelectChannel(action.value) + + end + end + + if(action.name == "device_turn_on") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local ps = enti:GetDevicePS() + + enti:TurnOnDevice() + + end + end + + if(action.name == "device_turn_off") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local ps = enti:GetDevicePS() + + enti:TurnOffDevice() + + end + end + + + if(action.name == "device_glitch_on") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local ps = enti:GetDevicePS() + + enti:StartGlitching(action.value, 1) + + end + end + + + if(action.name == "device_stop_using") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local ps = enti:GetDevicePS() + + enti:StopUsing() + end + end + + if(action.name == "device_start_using") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local ps = enti:GetDevicePS() + + enti:StartUsing() + end + end + + if(action.name == "device_glitch_off") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local ps = enti:GetDevicePS() + + enti:StopGlitching() + + end + end + + if(action.name == "play_custom_sound_with_subtitle_as_chat") then + if(cyberscript.cache["sound"][action.value] ~= nil) then + + if(GameController["ChattersGameController"] ~= nil) then + local linesToShow = {} + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + if(action.target == "lookat")then + enti = objLook + end + if(enti ~= nil) then + local dialogLine = scnDialogLineData.new() + local id = math.random(1,9999) + dialogLine.id = CRUID(id) + dialogLine.text =getLang(cyberscript.cache["sound"][action.value].data.subtitle) + dialogLine.type = action.type + local candotext = true + dialogLine.speaker = enti + dialogLine.speakerName = getLang(action.speaker) + if(action.speaker == "current_phone_npc") then + if(currentNPC ~= nil) then + dialogLine.speakerName = currentNPC.Names + else + candotext = false + end + end + if(action.speaker == "current_star") then + if(currentStar ~= nil) then + dialogLine.speakerName = currentStar.Names + else + candotext = false + end + end + if(action.speaker == "entity") then + local obj = getEntityFromManager(action.speakertag) + dialogLine.speakerName = obj.name + candotext = true + end + + local tempsMoyen = calcTimebyLetter(countLetter(dialogLine.text), vitesseParLettre) + + if(candotext == true) then + dialogLine.isPersistent = false + dialogLine.duration = math.ceil(tempsMoyen) + + if(Game.GetSettingsSystem():GetVar("/accessibility/subtitles", "Overheads"):GetValue() == true) then + GameController["ChattersGameController"]:SpawnDialogLine(dialogLine) + end + local temp = os.time(os.date("!*t"))+0 + local nexttemp = temp + + + nexttemp =nexttemp + math.ceil(tempsMoyen) + action.tick = nexttemp + + local path = cyberscript.cache["sound"][action.value].data + + local isradio = false + local needrepeat = false + + if action.isradio ~= nil then isradio = action.isradio end + if action.needrepeat ~= nil then needrepeat = action.needrepeat end + + + + if(action.target == nil or action.target == "player") then + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + else + local obj = getEntityFromManager(action.target) + if(obj ~= nil) then + local enti = safeFindEntityByID(obj) + + if(enti ~= nil) then + + local actionb = deepcopy(cyberscript.actiontemplate["fake_lips_sync"]) + actionb.duration = math.floor(tempsMoyen) + actionb.tag = action.target + local actionlist = {} + actionlist[1] = actionb + runActionList(actionlist, "fake_lips_sync_async_action_"..tostring(math.random(1,987987)), "see",false,nil) + PlaySoundAtEntity(path,isradio,needrepeat,action.target,tempsMoyen,action.volume) else + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + end + else + PlaySound(path,isradio,needrepeat,nil,tempsMoyen,action.volume) + end + end + + result = false + end + end + else + error("can't find chat Subtitle controller, please go to see an npc who speak in street or an TV or an Radio for load one") + + end + + + else + error("No sound founded") + end + + + end + + end + + if entityregion then + if(action.name == "spawn_npc") then + local chara = "" + if(action.amount == nil) then + action.amount = 1 + end + if(action.amount == 0) then + action.amount = math.random(1,6) + end + for i=1,action.amount do + + + + if(action.source == "from_list") then + local indexchara = math.random(1,#action.source_list) + chara = action.source_list[indexchara] + end + if(action.source == "npc") then + chara = action.source_tag + end + if(action.source == "custom_npc") then + local npc = getCustomNPCbyTag(action.tag) + if(npc ~= nil) then + chara = npc.tweakDB + npc.spawnforced=true + + + npc.isspawn=true + npc.init=false + end + end + if(action.source == "current_star") then + if(currentStar ~= nil) then + chara = currentStar.TweakIDs + else + error("No Current Star defined, can't spawn !") + end + end + if(action.source == "current_phoned_npc") then + if(currentNPC ~= nil) then + chara = currentNPC.TweakIDs + else + error("No Current Phoned NPC defined, can't spawn !") + end + end + if(action.source == "faction") then + local gang = getFactionByTag(action.source_tag) + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + if(action.source_use_vip == true) then + if(#gang.vip > 0) then + local viptable = getVIPfromfactionbyscore(gang.tag) + if(#viptable > 0) then + local index = math.random(1,#viptable) + + chara = viptable[index] + else + + error("No VIP NPC for this faction") + end + end + else + --spdlog.error(dump(gang)) + if(gang.spawnable_npc ~= nil and #gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + chara = gang.spawnable_npc[index] + + else + + error("No Spawnable NPC for this faction") + end + end + end + if(action.source == "faction_random_list") then + local indexchara = math.random(1,#action.source_list) + + local gang = getFactionByTag(action.source_list[indexchara]) + + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + if(action.source_use_vip == true) then + if(#gang.vip > 0) then + local viptable = getVIPfromfactionbyscore(gang.tag) + if(#viptable > 0) then + local index = math.random(1,#viptable) + + chara = viptable[index] + else + + error("No VIP NPC for this faction") + end + end + else + --spdlog.error(dump(gang)) + if(gang.spawnable_npc ~= nil and #gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + chara = gang.spawnable_npc[index] + + else + + error("No Spawnable NPC for this faction") + end + end + end + if(action.source == "district_leader" or action.source == "subdistrict_leader") then + local gangs = getGangfromDistrict(action.source_tag,20) + logme(3,dump(gangs)) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + if(action.source_use_vip == true) then + if(#gang.vip > 0) then + local viptable = getVIPfromfactionbyscore(gang.tag) + if(#viptable > 0) then + local index = math.random(1,#viptable) + + chara = viptable[index] + end + end + else + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + chara = gang.spawnable_npc[index] + end + end + end + end + if(action.source == "current_district_leader") then + + local gangs = getGangfromDistrict(currentDistricts2.Tag,0) + + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + + if(action.source_use_vip == true) then + if(#gang.vip > 0) then + local viptable = getVIPfromfactionbyscore(gang.tag) + if(#viptable > 0) then + local index = math.random(1,#viptable) + + chara = viptable[index] + end + end + else + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + chara = gang.spawnable_npc[index] + end + end + end + end + if(action.source == "current_subdistrict_leader") then + local gangs = {} + for j, test in ipairs(currentDistricts2.districtLabels) do + if j > 1 then + gangs = getGangfromDistrict(test,20) + if(#gangs > 0) then + break + end + end + end + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + if(action.source_use_rival == true) then + gang = getFactionByTag(gang.rivals[1]) + end + if(action.source_use_vip == true) then + if(#gang.vip > 0) then + local viptable = getVIPfromfactionbyscore(gang.tag) + if(#viptable > 0) then + local index = math.random(1,#viptable) + + chara = viptable[index] + end + end + else + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + chara = gang.spawnable_npc[index] + end + end + end + end + if(action.source == "district_rival" or action.source == "subdistrict_rival") then + + if(action.source_gang == "player") then + + action.source_gang = getVariableKey("player","current_gang") + + end + + local gangs = getGangRivalfromDistrict(action.source_gang,action.source_tag,20) + + + + if(#gangs > 0) then + + + local gang = getFactionByTag(gangs[1].tag) + + if(action.source_use_vip == true) then + if(#gang.vip > 0) then + local viptable = getVIPfromfactionbyscore(gang.tag) + if(#viptable > 0) then + local index = math.random(1,#viptable) + + chara = viptable[index] + end + end + else + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + chara = gang.spawnable_npc[index] + end + end + end + end + if(action.source == "current_district_rival") then + + if(action.source_gang == "player") then + + action.source_gang = getVariableKey("player","current_gang") + + end + + local gangs = getGangRivalfromDistrict(action.source_gang,currentDistricts2.Tag,20) + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + + if(action.source_use_vip == true) then + if(#gang.vip > 0) then + local viptable = getVIPfromfactionbyscore(gang.tag) + if(#viptable > 0) then + local index = math.random(1,#viptable) + + chara = viptable[index] + end + end + else + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + chara = gang.spawnable_npc[index] + end + end + end + end + + if(action.source == "current_subdistrict_rival") then + + if(action.source_gang == "player") then + + action.source_gang = getVariableKey("player","current_gang") + + end + + local gangs = {} + for j, test in ipairs(currentDistricts2.districtLabels) do + if j > 1 then + gangs = getGangRivalfromDistrict(action.source_gang,test,20) + if(#gangs > 0) then + break + end + end + end + if(#gangs > 0) then + local gang = getFactionByTag(gangs[1].tag) + + if(action.source_use_vip == true) then + if(#gang.vip > 0) then + local viptable = getVIPfromfactionbyscore(gang.tag) + if(#viptable > 0) then + local index = math.random(1,#viptable) + + chara = viptable[index] + end + end + else + if(#gang.spawnable_npc > 0) then + local index = math.random(1,#gang.spawnable_npc) + chara = gang.spawnable_npc[index] + end + end + end + end + + + local tag = action.tag + if(action.amount > 1) then + tag = action.tag.."_"..i + end + + + local position = {} + local position = getPositionFromParameter(action) + + if(chara ~= "" and chara ~= nil and position.x ~= nil) then + - if(action.amount > 1) then - if(action.amountoffsetx ~= nil and action.amountoffsetx ~= 0) then - position.x = position.x + (i * action.amountoffsetx) - else - position.x = position.x + (i * 0.5) - end + if(action.amount > 1) then + if(action.amountoffsetx ~= nil and action.amountoffsetx ~= 0) then + position.x = position.x + (i * action.amountoffsetx) + else + position.x = position.x + (i * 0.5) + end - if(action.amountoffsety ~= nil and action.amountoffsety ~= 0) then - - position.y = position.y + (i * action.amountoffsety) - - end - end - local rot = EulerAngles.new(0,0,0) - if(action.yaw ~= nil) then - - - rot.roll = action.roll - rot.pitch = action.pitch - rot.yaw = action.yaw - - end + if(action.amountoffsety ~= nil and action.amountoffsety ~= 0) then + + position.y = position.y + (i * action.amountoffsety) + + end + end + local rot = EulerAngles.new(0,0,0) + if(action.yaw ~= nil) then + + + rot.roll = action.roll + rot.pitch = action.pitch + rot.yaw = action.yaw + + end - spawnNPC(chara,action.appearance, tag, position.x, position.y ,position.z,action.spawnlevel,action.use_police_prevention_system,false,action.scriptlevel,action.useEntpath,rot,action.despawntimer,action.usecodeware,action.persiststate,action.persistspawn,action.alwaysspawned,action.spawninview,action.dontregister,action.npcname,action.isboss) - if(action.group ~= nil and action.group ~= "") then - - if(cyberscript.GroupManager[action.group] == nil and action.create_group_if_not_exist == true) then - local group = {} - group.tag = action.group - group.entities = {} - cyberscript.GroupManager[action.group] = group - logme(3,"group created") - - end - if(cyberscript.GroupManager[action.group] ~= nil) then - table.insert(cyberscript.GroupManager[action.group].entities,tag) - else - error("group with tag : "..action.group.." doesn't exist") - end - end - else - error("bad character or position. character tweak : "..chara.." position : "..dump(position)) - end - end - end - if(action.name == "despawn_lookat") then - if(objLook ~= nil) then - local enti = getEntityFromManagerById(objLook:GetEntityID()) - if(enti ~= nil)then - logme(3,"yahoo") - despawnEntity(enti.tag) - - end - end - end - if(action.name == "despawnAll") then - despawnAll() - end - if(action.name == "teleport_player") then - --Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Vector4.new( action.x, action.y, action.z,1) , 1) - TeleportPlayerToPosition(action.x,action.y,action.z) - end - if(action.name == "set_component_hidden") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local components = enti:GetComponents(); - for i,component in ipairs(components) do - if(NameToString(component:GetName()) == action.value) then - component:TemporaryHide(action.hide) - end - end - - end - end - - if(action.name == "set_current_star") then - if(currentNPC ~= nil) then - - currentStar = currentNPC - currentNPC = nil - - else - - error("No current Phoned NPC ") - end - end - if(action.name == "clone_entity") then - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - local postp = enti:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - - worldpos:SetOrientation(worldpos, enti:GetWorldOrientation()) - - - local npcSpec = DynamicEntitySpec.new() - npcSpec.recordID = enti:GetRecordID() - npcSpec.appearanceName = Game.NameToString(enti:GetCurrentAppearanceName()) - npcSpec.position = postp - npcSpec.orientation = enti:GetWorldOrientation() - npcSpec.persistState = action.persiststate - npcSpec.persistSpawn = action.persistspawn - npcSpec.alwaysSpawned = action.alwaysspawned - npcSpec.spawnInView = action.spawninview - - CName.add("CyberScript") - CName.add("CyberScript.NPC") - CName.add("CyberScript.NPC."..action.tag) - - npcSpec.tags = {"CyberScript","CyberScript.NPC","CyberScript.NPC."..action.tag} - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..action.tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.NPC."..action.tag) end - - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..action.tag) == false) then - - NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) - - if(NPC ~= nil) then - local entity = {} - entity.id = NPC - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+action.despawntimer - entity.tag = action.tag - entity.spawnlocation = postp - entity.isitem = false - entity.tweak ="" - entity.isprevention = false - entity.iscodeware = true - entity.persistState = false - entity.persistSpawn = false - entity.alwaysSpawned = false - entity.spawnInView = true - entity.scriptlevel = 0 - entity.name = entity.tag - - - - - cyberscript.EntityManager[action.tag]=entity - cyberscript.EntityManager["last_spawned"].tag=action.tag - - if(action.deleteoriginal == true) then - - enti:Dispose() - cyberscript.EntityManager[action.target]=nil - end - -- Cron.After(0.5, function() - - - -- if isprevention == true then - -- local postp = Vector4.new( x, y, z,1) - -- teleportTo(Game.FindEntityByID(NPC), postp, 1,false) - -- end - - - - - -- end) - end - - - - - end - - - end - end - - - if(action.name == "replace_entity") then - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - local postp = enti:GetWorldPosition() - local worldpos = Game.GetPlayer():GetWorldTransform() - - worldpos:SetOrientation(worldpos, enti:GetWorldOrientation()) - - - local npcSpec = DynamicEntitySpec.new() - npcSpec.recordID = action.source_tag - npcSpec.appearanceName = action.appearance - npcSpec.position = postp - npcSpec.orientation = enti:GetWorldOrientation() - npcSpec.persistState = action.persiststate - npcSpec.persistSpawn = action.persistspawn - npcSpec.alwaysSpawned = action.alwaysspawned - npcSpec.spawnInView = action.spawninview - - CName.add("CyberScript") - CName.add("CyberScript.NPC") - CName.add("CyberScript.NPC."..action.tag) - - npcSpec.tags = {"CyberScript","CyberScript.NPC","CyberScript.NPC."..action.tag} - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..action.tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.NPC."..action.tag) end - - if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..action.tag) == false) then - - NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) - - if(NPC ~= nil) then - local entity = {} - entity.id = NPC - entity.spawntimespan = os.time(os.date("!*t"))+0 - entity.despawntimespan = os.time(os.date("!*t"))+action.despawntimer - entity.tag = action.tag - entity.spawnlocation = postp - entity.isitem = false - entity.tweak ="" - entity.isprevention = false - entity.iscodeware = true - entity.persistState = false - entity.persistSpawn = false - entity.alwaysSpawned = false - entity.spawnInView = true - entity.scriptlevel = 0 - entity.name = entity.tag - - - - - cyberscript.EntityManager[action.tag]=entity - cyberscript.EntityManager["last_spawned"].tag=action.tag - - if(action.deleteoriginal == true) then - - enti:Dispose() - cyberscript.EntityManager[action.target]=nil - end - -- Cron.After(0.5, function() - - - -- if isprevention == true then - -- local postp = Vector4.new( x, y, z,1) - -- teleportTo(Game.FindEntityByID(NPC), postp, 1,false) - -- end - - - - - -- end) - end - - else - - - end - - - end - end - - if(action.name == "change_entity_tag") then - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local entity = deepcopy(obj) - entity.id = enti:GetEntityID() - entity.tag = action.tag - cyberscript.EntityManager[action.tag]=entity - cyberscript.EntityManager[action.target]=nil - end - end - - - if(action.name == "push_force_entity") then - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - playerCamPos = Matrix.GetTranslation(Game.GetPlayer():GetFPPCameraComponent():GetLocalToWorld()); - playerCamFwd = Matrix.GetDirectionVector(Game.GetPlayer():GetFPPCameraComponent():GetLocalToWorld()); - playerCamPos_Vector = playerCamPos; - triggerOrigin = Vector4.Normalize(playerCamFwd); - totalPP = Vector4.Normalize(playerCamFwd); - triggerOrigin.x = playerCamPos_Vector.x + triggerOrigin.x * 0.10; - triggerOrigin.y = playerCamPos_Vector.y + triggerOrigin.y * 0.10; - triggerOrigin.z = playerCamPos_Vector.z+ triggerOrigin.z * 0.10 ; - triggerOrigin.w = playerCamPos_Vector.w + triggerOrigin.w * 0.10; - - totalPP.x = totalPP.x * action.x; - totalPP.y = totalPP.y * action.y; - totalPP.z = totalPP.z * action.z; - - - enti.npcRagdollComponent.isEnabled = true - enti:QueueEvent(CreateForceRagdollEvent("None")); - GameInstance.GetDelaySystem():DelayEvent(enti,CreateRagdollApplyImpulseEvent(triggerOrigin, totalPP, 900000000.00), 0.10, false); - end - end + spawnNPC(chara,action.appearance, tag, position.x, position.y ,position.z,action.spawnlevel,action.use_police_prevention_system,false,action.scriptlevel,action.useEntpath,rot,action.despawntimer,action.usecodeware,action.persiststate,action.persistspawn,action.alwaysspawned,action.spawninview,action.dontregister,action.npcname,action.isboss) + if(action.group ~= nil and action.group ~= "") then + + if(cyberscript.GroupManager[action.group] == nil and action.create_group_if_not_exist == true) then + local group = {} + group.tag = action.group + group.entities = {} + cyberscript.GroupManager[action.group] = group + logme(3,"group created") + + end + if(cyberscript.GroupManager[action.group] ~= nil) then + table.insert(cyberscript.GroupManager[action.group].entities,tag) + else + -- B-23 fix: don't error() — log and skip. Aborting the whole action list on a missing group is too harsh. + logme(2, "[Cyberscript] spawn_npc: group with tag '" .. tostring(action.group) .. "' doesn't exist; skipping group assignment") + end + end + else + -- B-23 fix: don't error() — log and skip. The mod's JSON referenced an invalid character tweak or position; skip this single spawn instead of crashing the whole script. + logme(1, "[Cyberscript] spawn_npc: bad character or position. character tweak: " .. tostring(chara) .. " position: " .. tostring(position and dump(position) or "nil")) + end + end + end + if(action.name == "despawn_lookat") then + if(objLook ~= nil) then + local enti = getEntityFromManagerById(objLook:GetEntityID()) + if(enti ~= nil)then + logme(3,"yahoo") + despawnEntity(enti.tag) + + end + end + end + if(action.name == "despawnAll") then + despawnAll() + end + if(action.name == "teleport_player") then + --Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Vector4.new( action.x, action.y, action.z,1) , 1) + TeleportPlayerToPosition(action.x,action.y,action.z) + end + if(action.name == "set_component_hidden") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local components = enti:GetComponents(); + for i,component in ipairs(components) do + if(NameToString(component:GetName()) == action.value) then + component:TemporaryHide(action.hide) + end + end + + end + end + + if(action.name == "set_current_star") then + if(currentNPC ~= nil) then + + currentStar = currentNPC + currentNPC = nil + + else + + error("No current Phoned NPC ") + end + end + if(action.name == "clone_entity") then + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + local postp = enti:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + + worldpos:SetOrientation(worldpos, enti:GetWorldOrientation()) + + + local npcSpec = DynamicEntitySpec.new() + npcSpec.recordID = enti:GetRecordID() + npcSpec.appearanceName = Game.NameToString(enti:GetCurrentAppearanceName()) + npcSpec.position = postp + npcSpec.orientation = enti:GetWorldOrientation() + npcSpec.persistState = action.persiststate + npcSpec.persistSpawn = action.persistspawn + npcSpec.alwaysSpawned = action.alwaysspawned + npcSpec.spawnInView = action.spawninview + + CName.add("CyberScript") + CName.add("CyberScript.NPC") + CName.add("CyberScript.NPC."..action.tag) + + npcSpec.tags = {"CyberScript","CyberScript.NPC","CyberScript.NPC."..action.tag} + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..action.tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.NPC."..action.tag) end + + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..action.tag) == false) then + + NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) + + if(NPC ~= nil) then + local entity = {} + entity.id = NPC + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+action.despawntimer + entity.tag = action.tag + entity.spawnlocation = postp + entity.isitem = false + entity.tweak ="" + entity.isprevention = false + entity.iscodeware = true + entity.persistState = false + entity.persistSpawn = false + entity.alwaysSpawned = false + entity.spawnInView = true + entity.scriptlevel = 0 + entity.name = entity.tag + + + + + cyberscript.EntityManager[action.tag]=entity + cyberscript.EntityManager["last_spawned"].tag=action.tag + + if(action.deleteoriginal == true) then + + enti:Dispose() + cyberscript.EntityManager[action.target]=nil + end + -- Cron.After(0.5, function() + + + -- if isprevention == true then + -- local postp = Vector4.new( x, y, z,1) + -- teleportTo(safeFindEntityByID(NPC), postp, 1,false) + -- end + + + + + -- end) + end + + + + + end + + + end + end + + + if(action.name == "replace_entity") then + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + local postp = enti:GetWorldPosition() + local worldpos = Game.GetPlayer():GetWorldTransform() + + worldpos:SetOrientation(worldpos, enti:GetWorldOrientation()) + + + local npcSpec = DynamicEntitySpec.new() + npcSpec.recordID = action.source_tag + npcSpec.appearanceName = action.appearance + npcSpec.position = postp + npcSpec.orientation = enti:GetWorldOrientation() + npcSpec.persistState = action.persiststate + npcSpec.persistSpawn = action.persistspawn + npcSpec.alwaysSpawned = action.alwaysspawned + npcSpec.spawnInView = action.spawninview + + CName.add("CyberScript") + CName.add("CyberScript.NPC") + CName.add("CyberScript.NPC."..action.tag) + + npcSpec.tags = {"CyberScript","CyberScript.NPC","CyberScript.NPC."..action.tag} + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..action.tag) == true) then Game.GetDynamicEntitySystem():DeleteTagged("CyberScript.NPC."..action.tag) end + + if(Game.GetDynamicEntitySystem():IsPopulated("CyberScript.NPC."..action.tag) == false) then + + NPC = Game.GetDynamicEntitySystem():CreateEntity(npcSpec) + + if(NPC ~= nil) then + local entity = {} + entity.id = NPC + entity.spawntimespan = os.time(os.date("!*t"))+0 + entity.despawntimespan = os.time(os.date("!*t"))+action.despawntimer + entity.tag = action.tag + entity.spawnlocation = postp + entity.isitem = false + entity.tweak ="" + entity.isprevention = false + entity.iscodeware = true + entity.persistState = false + entity.persistSpawn = false + entity.alwaysSpawned = false + entity.spawnInView = true + entity.scriptlevel = 0 + entity.name = entity.tag + + + + + cyberscript.EntityManager[action.tag]=entity + cyberscript.EntityManager["last_spawned"].tag=action.tag + + if(action.deleteoriginal == true) then + + enti:Dispose() + cyberscript.EntityManager[action.target]=nil + end + -- Cron.After(0.5, function() + + + -- if isprevention == true then + -- local postp = Vector4.new( x, y, z,1) + -- teleportTo(safeFindEntityByID(NPC), postp, 1,false) + -- end + + + + + -- end) + end + + else + + + end + + + end + end + + if(action.name == "change_entity_tag") then + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local entity = deepcopy(obj) + entity.id = enti:GetEntityID() + entity.tag = action.tag + cyberscript.EntityManager[action.tag]=entity + cyberscript.EntityManager[action.target]=nil + end + end + + + if(action.name == "push_force_entity") then + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + playerCamPos = Matrix.GetTranslation(Game.GetPlayer():GetFPPCameraComponent():GetLocalToWorld()); + playerCamFwd = Matrix.GetDirectionVector(Game.GetPlayer():GetFPPCameraComponent():GetLocalToWorld()); + playerCamPos_Vector = playerCamPos; + triggerOrigin = Vector4.Normalize(playerCamFwd); + totalPP = Vector4.Normalize(playerCamFwd); + triggerOrigin.x = playerCamPos_Vector.x + triggerOrigin.x * 0.10; + triggerOrigin.y = playerCamPos_Vector.y + triggerOrigin.y * 0.10; + triggerOrigin.z = playerCamPos_Vector.z+ triggerOrigin.z * 0.10 ; + triggerOrigin.w = playerCamPos_Vector.w + triggerOrigin.w * 0.10; + + totalPP.x = totalPP.x * action.x; + totalPP.y = totalPP.y * action.y; + totalPP.z = totalPP.z * action.z; + + + enti.npcRagdollComponent.isEnabled = true + enti:QueueEvent(CreateForceRagdollEvent("None")); + GameInstance.GetDelaySystem():DelayEvent(enti,CreateRagdollApplyImpulseEvent(triggerOrigin, totalPP, 900000000.00), 0.10, false); + end + end - if(action.name == "player_blackwall_hand_anim") then - local player = Game.GetPlayer() - if StatusEffectSystem.ObjectHasStatusEffect(player, "GameplayRestriction.BodyCarryingWoundedSoldier") then - isCarryingWounded = true - end - if not isCarryingWounded then - Game.SetAnimWrapperWeight(Game.GetPlayer(), 'carry_woundedSoldier', 1.0) - forcedCarryingWounded = true - end - handAnim = player:GetBlackboard():GetInt(GetAllBlackboardDefs().BlackwallDeathAnim.handGestureAnimNumber) - if handAnim < 0 or handAnim == 5 then - handAnim = 0 - end - adHocAnimEvent = AdHocAnimationEvent.new() - adHocAnimEvent.animationIndex = handAnim - adHocAnimEvent.useBothHands = true - adHocAnimEvent.unequipWeapon = true - player:QueueEvent(adHocAnimEvent) - player:GetBlackboard():SetInt(GetAllBlackboardDefs().BlackwallDeathAnim.handGestureAnimNumber, handAnim + 1) - Cron.After(1, { tick = 1 }, function() - if forcedCarryingWounded then - Game.SetAnimWrapperWeight(Game.GetPlayer(), 'carry_woundedSoldier', 0.0) - forcedCarryingWounded = false - end - end) - end + if(action.name == "player_blackwall_hand_anim") then + local player = Game.GetPlayer() + if StatusEffectSystem.ObjectHasStatusEffect(player, "GameplayRestriction.BodyCarryingWoundedSoldier") then + isCarryingWounded = true + end + if not isCarryingWounded then + Game.SetAnimWrapperWeight(Game.GetPlayer(), 'carry_woundedSoldier', 1.0) + forcedCarryingWounded = true + end + handAnim = player:GetBlackboard():GetInt(GetAllBlackboardDefs().BlackwallDeathAnim.handGestureAnimNumber) + if handAnim < 0 or handAnim == 5 then + handAnim = 0 + end + adHocAnimEvent = AdHocAnimationEvent.new() + adHocAnimEvent.animationIndex = handAnim + adHocAnimEvent.useBothHands = true + adHocAnimEvent.unequipWeapon = true + player:QueueEvent(adHocAnimEvent) + player:GetBlackboard():SetInt(GetAllBlackboardDefs().BlackwallDeathAnim.handGestureAnimNumber, handAnim + 1) + Cron.After(1, { tick = 1 }, function() + if forcedCarryingWounded then + Game.SetAnimWrapperWeight(Game.GetPlayer(), 'carry_woundedSoldier', 0.0) + forcedCarryingWounded = false + end + end) + end - if(action.name == "pull_force_entity") then - local obj = getEntityFromManager(action.target) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - playerCamPos = Matrix.GetTranslation(Game.GetPlayer():GetFPPCameraComponent():GetLocalToWorld()); - playerCamFwd = Matrix.GetDirectionVector(Game.GetPlayer():GetFPPCameraComponent():GetLocalToWorld()); - playerCamPos_Vector = playerCamPos; - triggerOrigin = Vector4.Normalize(playerCamFwd); - totalPP = Vector4.Normalize(playerCamFwd); - triggerOrigin.x = playerCamPos_Vector.x + triggerOrigin.x * 0.10; - triggerOrigin.y = playerCamPos_Vector.y + triggerOrigin.y * 0.10; - triggerOrigin.z = playerCamPos_Vector.z + triggerOrigin.z * 0.10; - triggerOrigin.w = playerCamPos_Vector.w + triggerOrigin.w * 0.10; - - totalPP.x = totalPP.x * action.x *-1; - totalPP.y = totalPP.y * action.y *-1; - totalPP.z = totalPP.z * action.z *-1; - - - enti.npcRagdollComponent.isEnabled = true - enti:QueueEvent(CreateForceRagdollEvent("None")); - GameInstance.GetDelaySystem():DelayEvent(enti,CreateRagdollApplyImpulseEvent(triggerOrigin, totalPP, 900000000.00), 0.10, false); - end - end - - - - if(action.name == "register_entity_you_look_at") then - if(objLook ~= nil) then - local entity = getEntityFromManager(action.tag) - if (entity.id == nil) then - local entity = {} - entity.id = objLook:GetEntityID() - entity.tag = action.tag - entity.tweak = "None" - entity.iscompanion = false - cyberscript.EntityManager[action.tag]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,action.tag) - end - else - Game.GetPlayer():SetWarningMessage("An entity with this tag already exist.") - end - end - end - - if(action.name == "register_entity_by_hash") then - - player = Game.GetPlayer() - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects - searchQuery.maxDistance = action.range - success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) - - - - local goodEntity = false - - for i, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - - - - - - - if(action.value == tostring(newent:GetEntityID().hash))then - local entity = {} - entity.id = newent:GetEntityID() - entity.tag = action.tag - entity.tweak = "None" - entity.iscompanion = false - cyberscript.EntityManager[action.tag]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,action.tag) - end - end - - - - - - - - - - end - end - - if(action.name == "register_entity_by_filter") then - - player = Game.GetPlayer() - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects - - searchQuery.maxDistance = action.range - success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) - - - - local goodEntity = false - - for i, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - - - - - - - if((action.value ~= "isnpc" or (action.value == "isnpc" and newent:IsA("NPCPuppet"))) and - string.match(newent:ToString(), action.value) or - - string.match( Game.NameToString(newent:GetCurrentAppearanceName()), action.value) or string.match(newent:GetDisplayName(), action.value))then - local entity = {} - entity.id = newent:GetEntityID() - entity.tag = action.tag - entity.tweak = "None" - entity.iscompanion = false - cyberscript.EntityManager[action.tag]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,action.tag) - end - end - - - - - - - - - - end - end - - if(action.name == "register_entities_around_you") then - - player = Game.GetPlayer() - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects - searchQuery.maxDistance = action.range - success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) - local startindex = 0 - local goodEntity = false - local limitactive = 0 - for i, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - - - - if(action.limit == nil or limitactive <= action.limit ) then - - if #action.filter > 0 then - for i,filter in ipairs(action.filter) do - - if( (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and - string.match(newent:ToString(), filter) or - string.match( Game.NameToString(newent:GetCurrentAppearanceName()), filter) or - string.match(newent:GetDisplayName(), filter) or - filter == tostring(newent:GetEntityID().hash) - - and (filter ~= "vehicle" or (filter == "vehicle" and newent:IsVehicle())) - )then - local entity = {} - entity.id = newent:GetEntityID() - - local canadd = true - - for k,v in pairs(cyberscript.EntityManager) do - - if(v.id == entity.id) then - print("delete k") - cyberscript.EntityManager[k] = nil - end - - end - - if(action.prefix == nil) then action.prefix = "entity" end - - if(action.startindex == nil) then startindex = newent:GetEntityID().hash end - if(action.startindex ~= nil) then startindex = action.startindex + i - 1 end - entity.tag = action.prefix..tostring(action.startindex) - entity.tweak = "None" - entity.iscompanion = false - if(canadd) then - limitactive = limitactive + 1 - cyberscript.EntityManager[entity.tag]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) - end - end - end - end - else - - local entity = {} - entity.id = newent:GetEntityID() - - local canadd = true - - for k,v in pairs(cyberscript.EntityManager) do - - if(v.id == entity.id) then - - cyberscript.EntityManager[k] = nil - - end - - end - - if(action.prefix == nil) then action.prefix = "entity_" end - startindex = 0 - if(action.startindex == nil) then startindex = newent:GetEntityID().hash end - if(action.startindex ~= nil) then startindex = action.startindex + i - 1 end - entity.tag = action.prefix..tostring(startindex) - entity.tweak = "None" - entity.iscompanion = false - - if(canadd) then - - cyberscript.EntityManager[entity.tag]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) - end - end - end - - end - - - - - - - - end - - - end - - if(action.name == "register_enemy_around_you") then - - player = Game.GetPlayer() - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_EnemyNPC;"]() -- Search ALL objects - searchQuery.maxDistance = action.range - success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) - - local goodEntity = false - - for i, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - - - - - if(action.limit == nil or i <= action.limit ) then - - if #action.filter > 0 then - for i,filter in ipairs(action.filter) do - - if(string.match(newent:ToString(), filter) or string.match( Game.NameToString(newent:GetCurrentAppearanceName()), filter) or string.match(newent:GetDisplayName(), filter) or filter == tostring(newent:GetEntityID().hash))then - local entity = {} - entity.id = newent:GetEntityID() - - local canadd = true - - for k,v in pairs(cyberscript.EntityManager) do - - if(v.id == entity.id) then - - cyberscript.EntityManager[k] = nil - - end - - end - - if(action.prefix == nil) then action.prefix = "entity" end - startindex = 0 - if(action.startindex == nil) then startindex = newent:GetEntityID().hash end - if(action.startindex ~= nil) then startindex = action.startindex + i - 1 end - entity.tag = action.prefix..tostring(startindex) - entity.tweak = "None" - entity.iscompanion = false - if(canadd) then - - cyberscript.EntityManager[entity.tag]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) - end - end - end - end - else - - local entity = {} - entity.id = newent:GetEntityID() - - local canadd = true - - for k,v in pairs(cyberscript.EntityManager) do - - if(v.id == entity.id) then - - cyberscript.EntityManager[k] = nil - - end - - end - - if(action.prefix == nil) then action.prefix = "entity_" end - startindex = 0 - if(action.startindex == nil) then startindex = newent:GetEntityID().hash end - if(action.startindex ~= nil) then startindex = action.startindex + i - 1 end - entity.tag = action.prefix..tostring(startindex) - entity.tweak = "None" - entity.iscompanion = false - - if(canadd) then - - cyberscript.EntityManager[entity.tag]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) - end - end - end - - end - - - - - - - - end - - - end - - - if(action.name == "register_entities_around_entity") then - - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects - searchQuery.maxDistance = action.range - success, parts = targetingSystem:GetTargetParts(enti, searchQuery) - - - - local goodEntity = false - - for i, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - - - - - - - if #action.filter > 0 then - for i,filter in ipairs(action.filter) do - - if( (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and - string.match(newent:ToString(), filter) or - - string.match( Game.NameToString(newent:GetCurrentAppearanceName()), filter) or - string.match(newent:GetDisplayName(), filter) or - filter == tostring(newent:GetEntityID().hash))then - local entity = {} - entity.id = newent:GetEntityID() - - local canadd = true - - for k,v in pairs(cyberscript.EntityManager) do - - if(v.id == entity.id) then - - canadd = false - --print("NOK1") - end - - end - - entity.tag = "entity_"..tostring(newent:GetEntityID().hash) - entity.tweak = "None" - entity.iscompanion = false - if(canadd) then - - cyberscript.EntityManager["entity_"..tostring(newent:GetEntityID().hash)]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,"entity_"..tostring(newent:GetEntityID().hash)) - end - end - end - end - else - - local entity = {} - entity.id = newent:GetEntityID() - - local canadd = true - - for k,v in pairs(cyberscript.EntityManager) do - - if(v.id == entity.id) then - - canadd = false - - end - - end - - entity.tag = "entity_"..tostring(newent:GetEntityID().hash) - entity.tweak = "None" - entity.iscompanion = false - if(candd) then - cyberscript.EntityManager["entity_"..tostring(newent:GetEntityID().hash)]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,"entity_"..tostring(newent:GetEntityID().hash)) - end - end - end - - - - - - - - - - end - - end - end - - - if(action.name == "register_last_killed_entity") then - if(lastTargetKilled ~= nil) then - local entity = getEntityFromManager(action.tag) - if (entity.id == nil) then - local entity = {} - entity.id = lastTargetKilled:GetEntityID() - entity.tag = action.tag - entity.tweak = "None" - entity.iscompanion = false - cyberscript.EntityManager[action.tag]=entity - if(action.group ~= nil and action.group ~= "") then - - table.insert(cyberscript.GroupManager[action.group].entities,action.tag) - end - lastTargetKilled = nil - else - Game.GetPlayer():SetWarningMessage("An entity with this tag already exist.") - end - else - error("No killed entity fonded") - end - end - - if(action.name == "destroy_entity_you_look_at") then - if(objLook ~= nil) then - objLook:Dispose() - end - end - - if(action.name == "reset_last_killed_entity") then - if(lastTargetKilled ~= nil) then - lastTargetKilled = nil - end - end - - if(action.name == "register_entity_you_look_at_in_group") then - if(objLook ~= nil) then - local tag = "entity_"..math.random(0,999) - local entity = getEntityFromManager(tag) - if (entity.id == nil) then - local entity = {} - entity.id = objLook:GetEntityID() - entity.tag = tag - entity.tweak = "None" - entity.iscompanion = false - - cyberscript.EntityManager[tag]=entity - table.insert(cyberscript.GroupManager[action.group].entities,tag) - else - Game.GetPlayer():SetWarningMessage("An entity with this tag already exist.") - end - end - end - if(action.name == "kill_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - enti:OnDied() - -- local sp = GetSingleton("ScriptedPuppet") - -- sp.Kill(enti,false,false) - end - end - - - - - if(action.name == "ressurect_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - local sp = GetSingleton("ScriptedPuppet") - sp:SendResurrectEvent(enti) - enti:OnResurrected() - enti:QueueEvent(CreateDisableRagdollEvent("DisableRagdollTask")) - - end - - end - - - - if(action.name == "set_entity_highlight") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - obj.isquest = action.value - enti:MarkAsQuest(obj.isquest) - end - - end - if(action.name == "bound_entity_to_entity") then - - if(arrayBoundedEntity[action.tag] == nil) then - - arrayBoundedEntity[action.tag] = {} - arrayBoundedEntity[action.tag].anchor=action.entity - arrayBoundedEntity[action.tag].x = action.x - arrayBoundedEntity[action.tag].y = action.y - arrayBoundedEntity[action.tag].z = action.z - arrayBoundedEntity[action.tag].yaw = action.yaw - arrayBoundedEntity[action.tag].pitch = action.pitch - arrayBoundedEntity[action.tag].roll = action.roll - arrayBoundedEntity[action.tag].copyrotation = action.copyrotation - arrayBoundedEntity[action.tag].isitem = action.isitem - arrayBoundedEntity[action.tag].lastposition = {} - arrayBoundedEntity[action.tag].lastposition.x = 0 - arrayBoundedEntity[action.tag].lastposition.y = 0 - arrayBoundedEntity[action.tag].lastposition.z = 0 - - - arrayBoundedEntity[action.tag].lastorientation = {} - arrayBoundedEntity[action.tag].lastorientation.yaw = 0 - arrayBoundedEntity[action.tag].lastorientation.pitch = 0 - arrayBoundedEntity[action.tag].lastorientation.roll = 0 - end - - end - - if(action.name == "unbound_entity") then - - if(arrayBoundedEntity[action.tag] ~= nil) then - - arrayBoundedEntity[action.tag] = nil - - end - - end - - if(action.name == "despawn_entity") then - - despawnEntity(action.tag) - if(action.tag == "current_star") then - currentStar = nil - end - end - if(action.name == "unregister_entity") then - cyberscript.EntityManager[action.tag]=nil - end - - if(action.name == "change_stance_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - changeStance(enti,action.value) - end - end - - if(action.name == "kill_group") then - local group =getGroupfromManager(action.tag) - if(group ~= nil) then - for i,v in ipairs(group.entities) do - local entityTag = v - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - enti:OnDied() - - end - end - end - end - - if(action.name == "move") then - - if(action.group == true ) then - local actionlist = {} - - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - local newaction = deepcopy(action) - newaction.group = false - newaction.tag = entityTag - newaction.x = newaction.x+(0.1*i) - table.insert(actionlist,newaction) - - local waitaction = deepcopy(cyberscript.actiontemplate["wait_second"]) - waitaction.value = 1 - table.insert(actionlist,waitaction) - - - end - - end - logme(1,dump(actionlist[1])) - runActionList(actionlist, tag.."_move_grosssup"..tostring(math.random(1,987987)), "see",false,"",false) - else - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - local position = getPositionFromParameter(action) - - if(position.x ~= nil) then - - local v2 = nil - - if(action.moveV2 == true) then - v2 = {} - v2.quat= GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(action.roll, action.pitch, action.yaw)) - v2.ignoreNav = action.ignorenavigation - v2.stoponobstacle = action.stoponobstacle - v2.distance = action.distance - v2.distancetolerance = action.distancetolerance - v2.outofway=action.outofway - - - end - - - MoveTo(enti, position, 1, action.move,v2) - - - - end - - - - - end - end - end - - if(action.name == "teleport") then - - if(action.group == true ) then - local group =getGroupfromManager(action.tag) - for i=1, #group.entities do - local entityTag = group.entities[i] - local obj = getEntityFromManager(entityTag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - - local position = getPositionFromParameter(action) - - if(position.x ~= nil) then - - local v2 = nil - - local rot = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) - - if(action.yaw) ~= nil then - - rot = EulerAngles.new(action.roll, action.pitch, action.yaw) - - end - - teleportTo(enti, position, rot,(action.tag == "player")) - - - - end - - - - - end - end - else - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local isplayer = false - if action.tag == "player" then - isplayer = true - end - - local position = getPositionFromParameter(action) - - if(position.x ~= nil) then - - - local rot = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) - if(action.yaw) ~= nil then - - rot = EulerAngles.new(action.roll, action.pitch, action.yaw) - - end - teleportTo(enti, position, rot,isplayer) - - - - end - - - - - end - end - end - - - if(action.name == "entity_hold_position") then - local enti = nil - local obj = nil - if(action.tag =="lookat") then - enti = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - else - obj = getEntityFromManager(action.tag) - enti = Game.FindEntityByID(obj.id) - end - local stealth = false - if(action.stealth == nil) then - local state = Game.GetPlayer():GetPlayerStateMachineBlackboard():GetInt(Game.GetAllBlackboardDefs().PlayerStateMachine.Combat) - if(state == 3) then - stealth = true - end - else - stealth = action.stealth - end - if(enti ~= nil) then - if(enti:IsVehicle() ~= true) then - InterruptBehavior(enti) - HoldPosition(enti, action.timer, stealth) - end - end - end - - if(action.name == "entity_stop_movement") then - local enti = nil - local obj = nil - - obj = getEntityFromManager(action.tag) - enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - InterruptBehavior(enti) - - - end - end - - if(action.name == "rotate_entity_to_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local enti2 = Game.GetPlayer() - if(action.entity ~= "player") then - local obj2 = getEntityFromManager(action.entity) - enti2 = Game.FindEntityByID(obj2.id) - end - RotateTo(enti, enti2) - end - end - if(action.name == "rotate_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - RotateEntityTo(enti, action.pitch, action.yaw, action.roll) - end - end + if(action.name == "pull_force_entity") then + local obj = getEntityFromManager(action.target) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + playerCamPos = Matrix.GetTranslation(Game.GetPlayer():GetFPPCameraComponent():GetLocalToWorld()); + playerCamFwd = Matrix.GetDirectionVector(Game.GetPlayer():GetFPPCameraComponent():GetLocalToWorld()); + playerCamPos_Vector = playerCamPos; + triggerOrigin = Vector4.Normalize(playerCamFwd); + totalPP = Vector4.Normalize(playerCamFwd); + triggerOrigin.x = playerCamPos_Vector.x + triggerOrigin.x * 0.10; + triggerOrigin.y = playerCamPos_Vector.y + triggerOrigin.y * 0.10; + triggerOrigin.z = playerCamPos_Vector.z + triggerOrigin.z * 0.10; + triggerOrigin.w = playerCamPos_Vector.w + triggerOrigin.w * 0.10; + + totalPP.x = totalPP.x * action.x *-1; + totalPP.y = totalPP.y * action.y *-1; + totalPP.z = totalPP.z * action.z *-1; + + + enti.npcRagdollComponent.isEnabled = true + enti:QueueEvent(CreateForceRagdollEvent("None")); + GameInstance.GetDelaySystem():DelayEvent(enti,CreateRagdollApplyImpulseEvent(triggerOrigin, totalPP, 900000000.00), 0.10, false); + end + end + + + + if(action.name == "register_entity_you_look_at") then + if(objLook ~= nil) then + local entity = getEntityFromManager(action.tag) + if (entity.id == nil) then + local entity = {} + entity.id = objLook:GetEntityID() + entity.tag = action.tag + entity.tweak = "None" + entity.iscompanion = false + cyberscript.EntityManager[action.tag]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,action.tag) + end + else + Game.GetPlayer():SetWarningMessage("An entity with this tag already exist.") + end + end + end + + if(action.name == "register_entity_by_hash") then + + player = Game.GetPlayer() + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects + searchQuery.maxDistance = action.range + success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) + + + + local goodEntity = false + + for i, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + + + + + + + if(action.value == tostring(newent:GetEntityID().hash))then + local entity = {} + entity.id = newent:GetEntityID() + entity.tag = action.tag + entity.tweak = "None" + entity.iscompanion = false + cyberscript.EntityManager[action.tag]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,action.tag) + end + end + + + + + + + + + + end + end + + if(action.name == "register_entity_by_filter") then + + player = Game.GetPlayer() + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects + + searchQuery.maxDistance = action.range + success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) + + + + local goodEntity = false + + for i, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + + + + + + + if((action.value ~= "isnpc" or (action.value == "isnpc" and newent:IsA("NPCPuppet"))) and + string.match(newent:ToString(), action.value) or + + string.match( Game.NameToString(newent:GetCurrentAppearanceName()), action.value) or string.match(newent:GetDisplayName(), action.value))then + local entity = {} + entity.id = newent:GetEntityID() + entity.tag = action.tag + entity.tweak = "None" + entity.iscompanion = false + cyberscript.EntityManager[action.tag]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,action.tag) + end + end + + + + + + + + + + end + end + + if(action.name == "register_entities_around_you") then + + player = Game.GetPlayer() + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects + searchQuery.maxDistance = action.range + success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) + local startindex = 0 + local goodEntity = false + local limitactive = 0 + for i, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + + + + if(action.limit == nil or limitactive <= action.limit ) then + + if #action.filter > 0 then + for i,filter in ipairs(action.filter) do + + if( (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and + string.match(newent:ToString(), filter) or + string.match( Game.NameToString(newent:GetCurrentAppearanceName()), filter) or + string.match(newent:GetDisplayName(), filter) or + filter == tostring(newent:GetEntityID().hash) + + and (filter ~= "vehicle" or (filter == "vehicle" and newent:IsVehicle())) + )then + local entity = {} + entity.id = newent:GetEntityID() + + local canadd = true + + for k,v in pairs(cyberscript.EntityManager) do + + if(v.id == entity.id) then + print("delete k") + cyberscript.EntityManager[k] = nil + end + + end + + if(action.prefix == nil) then action.prefix = "entity" end + + if(action.startindex == nil) then startindex = newent:GetEntityID().hash end + if(action.startindex ~= nil) then startindex = action.startindex + i - 1 end + entity.tag = action.prefix..tostring(action.startindex) + entity.tweak = "None" + entity.iscompanion = false + if(canadd) then + limitactive = limitactive + 1 + cyberscript.EntityManager[entity.tag]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) + end + end + end + end + else + + local entity = {} + entity.id = newent:GetEntityID() + + local canadd = true + + for k,v in pairs(cyberscript.EntityManager) do + + if(v.id == entity.id) then + + cyberscript.EntityManager[k] = nil + + end + + end + + if(action.prefix == nil) then action.prefix = "entity_" end + startindex = 0 + if(action.startindex == nil) then startindex = newent:GetEntityID().hash end + if(action.startindex ~= nil) then startindex = action.startindex + i - 1 end + entity.tag = action.prefix..tostring(startindex) + entity.tweak = "None" + entity.iscompanion = false + + if(canadd) then + + cyberscript.EntityManager[entity.tag]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) + end + end + end + + end + + + + + + + + end + + + end + + if(action.name == "register_enemy_around_you") then + + player = Game.GetPlayer() + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_EnemyNPC;"]() -- Search ALL objects + searchQuery.maxDistance = action.range + success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) + + local goodEntity = false + + for i, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + + + + + if(action.limit == nil or i <= action.limit ) then + + if #action.filter > 0 then + for i,filter in ipairs(action.filter) do + + if(string.match(newent:ToString(), filter) or string.match( Game.NameToString(newent:GetCurrentAppearanceName()), filter) or string.match(newent:GetDisplayName(), filter) or filter == tostring(newent:GetEntityID().hash))then + local entity = {} + entity.id = newent:GetEntityID() + + local canadd = true + + for k,v in pairs(cyberscript.EntityManager) do + + if(v.id == entity.id) then + + cyberscript.EntityManager[k] = nil + + end + + end + + if(action.prefix == nil) then action.prefix = "entity" end + startindex = 0 + if(action.startindex == nil) then startindex = newent:GetEntityID().hash end + if(action.startindex ~= nil) then startindex = action.startindex + i - 1 end + entity.tag = action.prefix..tostring(startindex) + entity.tweak = "None" + entity.iscompanion = false + if(canadd) then + + cyberscript.EntityManager[entity.tag]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) + end + end + end + end + else + + local entity = {} + entity.id = newent:GetEntityID() + + local canadd = true + + for k,v in pairs(cyberscript.EntityManager) do + + if(v.id == entity.id) then + + cyberscript.EntityManager[k] = nil + + end + + end + + if(action.prefix == nil) then action.prefix = "entity_" end + startindex = 0 + if(action.startindex == nil) then startindex = newent:GetEntityID().hash end + if(action.startindex ~= nil) then startindex = action.startindex + i - 1 end + entity.tag = action.prefix..tostring(startindex) + entity.tweak = "None" + entity.iscompanion = false + + if(canadd) then + + cyberscript.EntityManager[entity.tag]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) + end + end + end + + end + + + + + + + + end + + + end + + + if(action.name == "register_entities_around_entity") then + + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects + searchQuery.maxDistance = action.range + success, parts = targetingSystem:GetTargetParts(enti, searchQuery) + + + + local goodEntity = false + + for i, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + + + + + + + if #action.filter > 0 then + for i,filter in ipairs(action.filter) do + + if( (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and + string.match(newent:ToString(), filter) or + + string.match( Game.NameToString(newent:GetCurrentAppearanceName()), filter) or + string.match(newent:GetDisplayName(), filter) or + filter == tostring(newent:GetEntityID().hash))then + local entity = {} + entity.id = newent:GetEntityID() + + local canadd = true + + for k,v in pairs(cyberscript.EntityManager) do + + if(v.id == entity.id) then + + canadd = false + --print("NOK1") + end + + end + + entity.tag = "entity_"..tostring(newent:GetEntityID().hash) + entity.tweak = "None" + entity.iscompanion = false + if(canadd) then + + cyberscript.EntityManager["entity_"..tostring(newent:GetEntityID().hash)]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,"entity_"..tostring(newent:GetEntityID().hash)) + end + end + end + end + else + + local entity = {} + entity.id = newent:GetEntityID() + + local canadd = true + + for k,v in pairs(cyberscript.EntityManager) do + + if(v.id == entity.id) then + + canadd = false + + end + + end + + entity.tag = "entity_"..tostring(newent:GetEntityID().hash) + entity.tweak = "None" + entity.iscompanion = false + if(candd) then + cyberscript.EntityManager["entity_"..tostring(newent:GetEntityID().hash)]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,"entity_"..tostring(newent:GetEntityID().hash)) + end + end + end + + + + + + + + + + end + + end + end + + + if(action.name == "register_last_killed_entity") then + if(lastTargetKilled ~= nil) then + local entity = getEntityFromManager(action.tag) + if (entity.id == nil) then + local entity = {} + entity.id = lastTargetKilled:GetEntityID() + entity.tag = action.tag + entity.tweak = "None" + entity.iscompanion = false + cyberscript.EntityManager[action.tag]=entity + if(action.group ~= nil and action.group ~= "") then + + table.insert(cyberscript.GroupManager[action.group].entities,action.tag) + end + lastTargetKilled = nil + else + Game.GetPlayer():SetWarningMessage("An entity with this tag already exist.") + end + else + error("No killed entity fonded") + end + end + + if(action.name == "destroy_entity_you_look_at") then + if(objLook ~= nil) then + objLook:Dispose() + end + end + + if(action.name == "reset_last_killed_entity") then + if(lastTargetKilled ~= nil) then + lastTargetKilled = nil + end + end + + if(action.name == "register_entity_you_look_at_in_group") then + if(objLook ~= nil) then + local tag = "entity_"..math.random(0,999) + local entity = getEntityFromManager(tag) + if (entity.id == nil) then + local entity = {} + entity.id = objLook:GetEntityID() + entity.tag = tag + entity.tweak = "None" + entity.iscompanion = false + + cyberscript.EntityManager[tag]=entity + table.insert(cyberscript.GroupManager[action.group].entities,tag) + else + Game.GetPlayer():SetWarningMessage("An entity with this tag already exist.") + end + end + end + if(action.name == "kill_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + enti:OnDied() + -- local sp = GetSingleton("ScriptedPuppet") + -- sp.Kill(enti,false,false) + end + end + + + + + if(action.name == "ressurect_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + local sp = GetSingleton("ScriptedPuppet") + sp:SendResurrectEvent(enti) + enti:OnResurrected() + enti:QueueEvent(CreateDisableRagdollEvent("DisableRagdollTask")) + + end + + end + + + + if(action.name == "set_entity_highlight") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + obj.isquest = action.value + enti:MarkAsQuest(obj.isquest) + end + + end + if(action.name == "bound_entity_to_entity") then + + if(arrayBoundedEntity[action.tag] == nil) then + + arrayBoundedEntity[action.tag] = {} + arrayBoundedEntity[action.tag].anchor=action.entity + arrayBoundedEntity[action.tag].x = action.x + arrayBoundedEntity[action.tag].y = action.y + arrayBoundedEntity[action.tag].z = action.z + arrayBoundedEntity[action.tag].yaw = action.yaw + arrayBoundedEntity[action.tag].pitch = action.pitch + arrayBoundedEntity[action.tag].roll = action.roll + arrayBoundedEntity[action.tag].copyrotation = action.copyrotation + arrayBoundedEntity[action.tag].isitem = action.isitem + arrayBoundedEntity[action.tag].lastposition = {} + arrayBoundedEntity[action.tag].lastposition.x = 0 + arrayBoundedEntity[action.tag].lastposition.y = 0 + arrayBoundedEntity[action.tag].lastposition.z = 0 + + + arrayBoundedEntity[action.tag].lastorientation = {} + arrayBoundedEntity[action.tag].lastorientation.yaw = 0 + arrayBoundedEntity[action.tag].lastorientation.pitch = 0 + arrayBoundedEntity[action.tag].lastorientation.roll = 0 + end + + end + + if(action.name == "unbound_entity") then + + if(arrayBoundedEntity[action.tag] ~= nil) then + + arrayBoundedEntity[action.tag] = nil + + end + + end + + if(action.name == "despawn_entity") then + + despawnEntity(action.tag) + if(action.tag == "current_star") then + currentStar = nil + end + end + if(action.name == "unregister_entity") then + cyberscript.EntityManager[action.tag]=nil + end + + if(action.name == "change_stance_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + changeStance(enti,action.value) + end + end + + if(action.name == "kill_group") then + local group =getGroupfromManager(action.tag) + if(group ~= nil) then + for i,v in ipairs((group and group.entities or {})) do + local entityTag = v + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + enti:OnDied() + + end + end + end + end + + if(action.name == "move") then + + if(action.group == true ) then + local actionlist = {} + + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + local newaction = deepcopy(action) + newaction.group = false + newaction.tag = entityTag + newaction.x = newaction.x+(0.1*i) + table.insert(actionlist,newaction) + + local waitaction = deepcopy(cyberscript.actiontemplate["wait_second"]) + waitaction.value = 1 + table.insert(actionlist,waitaction) + + + end + + end + logme(1,dump(actionlist[1])) + runActionList(actionlist, tag.."_move_grosssup"..tostring(math.random(1,987987)), "see",false,"",false) + else + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + local position = getPositionFromParameter(action) + + if(position.x ~= nil) then + + local v2 = nil + + if(action.moveV2 == true) then + v2 = {} + v2.quat= GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(action.roll, action.pitch, action.yaw)) + v2.ignoreNav = action.ignorenavigation + v2.stoponobstacle = action.stoponobstacle + v2.distance = action.distance + v2.distancetolerance = action.distancetolerance + v2.outofway=action.outofway + + + end + + + MoveTo(enti, position, 1, action.move,v2) + + + + end + + + + + end + end + end + + if(action.name == "teleport") then + + if(action.group == true ) then + local group =getGroupfromManager(action.tag) + for i=1, #(group and (group and group.entities or {}) or {}) do + local entityTag = (group and group.entities or {})[i] + local obj = getEntityFromManager(entityTag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + + local position = getPositionFromParameter(action) + + if(position.x ~= nil) then + + local v2 = nil + + local rot = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) + + if(action.yaw) ~= nil then + + rot = EulerAngles.new(action.roll, action.pitch, action.yaw) + + end + + teleportTo(enti, position, rot,(action.tag == "player")) + + + + end + + + + + end + end + else + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local isplayer = false + if action.tag == "player" then + isplayer = true + end + + local position = getPositionFromParameter(action) + + if(position.x ~= nil) then + + + local rot = GetSingleton('Quaternion'):ToEulerAngles(enti:GetWorldOrientation()) + if(action.yaw) ~= nil then + + rot = EulerAngles.new(action.roll, action.pitch, action.yaw) + + end + teleportTo(enti, position, rot,isplayer) + + + + end + + + + + end + end + end + + + if(action.name == "entity_hold_position") then + local enti = nil + local obj = nil + if(action.tag =="lookat") then + enti = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + else + obj = getEntityFromManager(action.tag) + enti = safeFindEntityByID(obj) + end + local stealth = false + if(action.stealth == nil) then + local state = Game.GetPlayer():GetPlayerStateMachineBlackboard():GetInt(Game.GetAllBlackboardDefs().PlayerStateMachine.Combat) + if(state == 3) then + stealth = true + end + else + stealth = action.stealth + end + if(enti ~= nil) then + if(enti:IsVehicle() ~= true) then + InterruptBehavior(enti) + HoldPosition(enti, action.timer, stealth) + end + end + end + + if(action.name == "entity_stop_movement") then + local enti = nil + local obj = nil + + obj = getEntityFromManager(action.tag) + enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + InterruptBehavior(enti) + + + end + end + + if(action.name == "rotate_entity_to_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local enti2 = Game.GetPlayer() + if(action.entity ~= "player") then + local obj2 = getEntityFromManager(action.entity) + enti2 = safeFindEntityByID(obj2.id) + end + RotateTo(enti, enti2) + end + end + if(action.name == "rotate_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + RotateEntityTo(enti, action.pitch, action.yaw, action.roll) + end + end - if(action.name == "rotate_entity_relative") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then + if(action.name == "rotate_entity_relative") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then - local qat = enti:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - local obj = {} - print(dump((angle))) - obj.yaw = angle.yaw + action.yaw - obj.pitch = angle.pitch + action.pitch - obj.roll = angle.roll + action.roll - - print(dump((obj))) + local qat = enti:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + local obj = {} + print(dump((angle))) + obj.yaw = angle.yaw + action.yaw + obj.pitch = angle.pitch + action.pitch + obj.roll = angle.roll + action.roll + + print(dump((obj))) - RotateEntityTo(enti, obj.pitch, obj.yaw, obj.roll) - end - end - - if(action.name == "rotate_entity_to_position") then - action.output = true - local position = getPositionFromParameter(action) - - if(position.x ~= nil) then - - - entityLookAtDirection(action.tag,position.x, position.y, position.z) - end - end - - if(action.name == "rotate_entity_npc_to_position") then - action.output = true - local position = getPositionFromParameter(action) - - if(position.x ~= nil) then - - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - RotateToXYZ(enti, position.x,position.y,position.z) - end - end - end - - if(action.name == "choose_target") then - if(objLook ~= nil) then - selectTarget = objLook:GetEntityID() - end - end - if(action.name == "reset_target") then - selectTarget = nil - end - if(action.name == "follow_entity_to_entity") then - local enti = nil - if(action.tag =="lookat") then - enti = objLook - else - local obj = getEntityFromManager(action.tag) - enti = Game.FindEntityByID(obj.id) - end - local stealth = false - if(enti ~= nil) then - local enti2 = Game.GetPlayer() - if(action.stealth == nil) then - local state = Game.GetPlayer():GetPlayerStateMachineBlackboard():GetInt(Game.GetAllBlackboardDefs().PlayerStateMachine.Combat) - if(state == 3) then - stealth = true - end - else - stealth = action.stealth - end - if(action.entity ~= "player") then - if(action.entity =="lookat") then - local id = enti:GetEntityID() - Cron.After(5, function(id) - enti = Game.FindEntityByID(id) - enti2 = objLook - if(enti2 ~= nil) then - FollowEntity(enti, enti2, action.move, stealth) - end - end) - else - local obj2 = getEntityFromManager(action.entity) - enti2 = Game.FindEntityByID(obj2.id) - FollowEntity(enti, enti2, action.move, stealth) - end - if(action.entity =="target") then - enti2 = Game.FindEntityByID(selectTarget) - FollowEntity(enti, enti2, action.move, stealth) - end - else - FollowEntity(enti, enti2, action.move, stealth) - end - end - end - - if(action.name == "teleport_entity_to_entity_relative") then - local isplayer = false - if action.tag == "player" then - isplayer = true - end - - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - local positionVec4 = Game.GetPlayer():GetWorldPosition() - - local obj2 = getEntityFromManager(action.entity) - local enti2 = Game.FindEntityByID(obj2.id) - if(enti2 ~= nil) then - positionVec4 = enti2:GetWorldPosition() - - positionVec4.x = positionVec4.x + action.x - positionVec4.y = positionVec4.y + action.y - positionVec4.z = positionVec4.z + action.z - - local rot = GetSingleton('Quaternion'):ToEulerAngles(enti2:GetWorldOrientation()) - - teleportTo(enti, positionVec4, rot,isplayer) - else - error("no entity for "..action.entity) - end - else - error("no entity for "..action.tag) - end - end - if(action.name == "teleport_entity_at_position") then - local isplayer = false - if action.tag == "player" then - isplayer = true - end - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local angle = 1 - if(action.angle ~= nil) then - angle = action.angle - end - if(action.collision ~= nil and action.collision == true) then - local filters = { - 'Static', -- Buildings, Concrete Roads, Crates, etc. - 'Terrain' - } - local from = enti:GetWorldPosition() - local to = Vector4.new( - action.x , - action.y , - action.z, - 1 - ) - local collision = false - for _, filter in ipairs(filters) do - local success, result = Game.GetSpatialQueriesSystem():SyncRaycastByCollisionGroup(from, to, filter, false, false) - if success then - collision = true - logme(1,"collision"..filter) - end - end - if(collision == false) then - teleportTo(enti, Vector4.new( action.x, action.y, action.z,1), angle,isplayer) - else - if(action.pathfinding ~= nil and action.pathfinding == true) then - local newpath = giveGoodPath(from,to,action.axis) - teleportTo(enti, newpath, angle,isplayer) - end - end - else - --logme(3,"angle.yaw = "..angle.yaw) - teleportTo(enti, Vector4.new( action.x, action.y, action.z,1), angle,isplayer) - end - end - end - if(action.name == "teleport_entity_at_relative_position") then - local isplayer = false - if action.tag == "player" then - isplayer = true - end - - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local angle = 1 - if(action.angle ~= nil) then - angle = action.angle - end - local positionVec4 = enti:GetWorldPosition() - positionVec4.x = positionVec4.x + action.x - positionVec4.y = positionVec4.y + action.y - positionVec4.z = positionVec4.z + action.z - teleportTo(enti, Vector4.new( positionVec4.x, positionVec4.y, positionVec4.z,1), angle,isplayer) - end - end - if(action.name == "teleport_player_at_relative_position") then - local playerpos = Game.GetPlayer():GetWorldPosition() - TeleportPlayerToPosition(playerpos.x+action.x,playerpos.y+action.y,playerpos.z+action.z) - end - - - - if(action.name == "entity_stop_fight") then - InterruptCombat(action.tag) - end - if(action.name == "switch_primary_secondary_weapon_entity") then - local enti = nil - local obj = nil - if(action.tag =="lookat") then - enti = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - else - obj = getEntityFromManager(action.tag) - enti = Game.FindEntityByID(obj.id) - end - if(enti ~= nil and enti:HasPrimaryOrSecondaryEquipment()) then - if obj.usePrimary == nil or true then - EquipPrimaryWeaponCommand(objlook, false) - EquipSecondaryWeaponCommand(objlook, true) - obj.usePrimary = false - else - EquipSecondaryWeaponCommand(objlook, false) - EquipPrimaryWeaponCommand(objlook, true) - obj.usePrimary = true - end - end - end - if(action.name == "equip_weapon_entity_from_current_player") then - local enti = nil - local obj = nil - if(action.tag =="lookat") then - enti = objLook - obj = getEntityFromManagerById(objLook:GetEntityID()) - else - obj = getEntityFromManager(action.tag) - enti = Game.FindEntityByID(obj.id) - end - if(enti ~= nil and enti:HasPrimaryOrSecondaryEquipment()) then - local es = Game.GetScriptableSystemsContainer():Get(CName.new("EquipmentSystem")) - local weapon = es:GetActiveWeaponObject(Game.GetPlayer(), 39) - local weaponTDBID = weapon:GetItemID().tdbid - EquipGivenWeapon(enti, weaponTDBID, true) - end - end - - if(action.name == "equip_item_on_slot") then - local enti = nil - local obj = nil - obj = getEntityFromManager(action.tag) - enti = Game.FindEntityByID(obj.id) - if(enti ~= nil ) then - - if(action.tag =="player") then - Game.AddToInventory(action.item,1) - Game.GetTransactionSystem():AddItemToSlot(Game.GetPlayer(), TweakDBID.new("AttachmentSlots."..action.slot), ItemID.FromTDBID(TweakDBID.new(action.item))) - else - EquipGivenWeapon(enti, TweakDBID.new(action.item), true, "AttachmentSlots."..action.slot) - end - - - end - end - - - if(action.name == "unequip_item_on_slot") then - local enti = nil - local obj = nil - obj = getEntityFromManager(action.tag) - enti = Game.FindEntityByID(obj.id) - if(enti ~= nil ) then - - if(action.tag =="player") then - Game.AddToInventory(action.item,1) - Game.GetTransactionSystem():RemoveItemFromSlot(Game.GetPlayer(), TweakDBID.new("AttachmentSlots."..action.slot), false,false,false) - else - UnEquipSlot(enti, true, "AttachmentSlots."..action.slot) - end - - - end - end - - - if(action.name == "equip_item") then - - equipItem(action.value) - - end - - if(action.name == "equip_transmog_item") then - - equipVisualItem(action.value) - - end - - if(action.name == "clear_transmog_slot") then - - clearVisualarea(action.value) - - end - - if(action.name == "unequip_item") then - - unequipItem(action.value) - - end - - if(action.name == "set_player_attribute") then - - setPlayerAttributes(action.value, action.score) - - end - - if(action.name == "set_player_skill") then - - setPlayerSkill(action.value, action.score) - - end - - if(action.name == "set_player_skill_progression") then - - setPlayerSkillProgression(action.value, action.score) - - end - - if(action.name == "set_player_perk") then - - setPlayerPerk(action.value, action.score) - - end - - - - if(action.name == "attitude_entity_against_entity") then + RotateEntityTo(enti, obj.pitch, obj.yaw, obj.roll) + end + end + + if(action.name == "rotate_entity_to_position") then + action.output = true + local position = getPositionFromParameter(action) + + if(position.x ~= nil) then + + + entityLookAtDirection(action.tag,position.x, position.y, position.z) + end + end + + if(action.name == "rotate_entity_npc_to_position") then + action.output = true + local position = getPositionFromParameter(action) + + if(position.x ~= nil) then + + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + RotateToXYZ(enti, position.x,position.y,position.z) + end + end + end + + if(action.name == "choose_target") then + if(objLook ~= nil) then + selectTarget = objLook:GetEntityID() + end + end + if(action.name == "reset_target") then + selectTarget = nil + end + if(action.name == "follow_entity_to_entity") then + local enti = nil + if(action.tag =="lookat") then + enti = objLook + else + local obj = getEntityFromManager(action.tag) + enti = safeFindEntityByID(obj) + end + local stealth = false + if(enti ~= nil) then + local enti2 = Game.GetPlayer() + if(action.stealth == nil) then + local state = Game.GetPlayer():GetPlayerStateMachineBlackboard():GetInt(Game.GetAllBlackboardDefs().PlayerStateMachine.Combat) + if(state == 3) then + stealth = true + end + else + stealth = action.stealth + end + if(action.entity ~= "player") then + if(action.entity =="lookat") then + local id = enti:GetEntityID() + Cron.After(5, function(id) + enti = safeFindEntityByID(id) + enti2 = objLook + if(enti2 ~= nil) then + FollowEntity(enti, enti2, action.move, stealth) + end + end) + else + local obj2 = getEntityFromManager(action.entity) + enti2 = safeFindEntityByID(obj2.id) + FollowEntity(enti, enti2, action.move, stealth) + end + if(action.entity =="target") then + enti2 = safeFindEntityByID(selectTarget) + FollowEntity(enti, enti2, action.move, stealth) + end + else + FollowEntity(enti, enti2, action.move, stealth) + end + end + end + + if(action.name == "teleport_entity_to_entity_relative") then + local isplayer = false + if action.tag == "player" then + isplayer = true + end + + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + + if(enti ~= nil) then + local positionVec4 = Game.GetPlayer():GetWorldPosition() + + local obj2 = getEntityFromManager(action.entity) + local enti2 = safeFindEntityByID(obj2.id) + if(enti2 ~= nil) then + positionVec4 = enti2:GetWorldPosition() + + positionVec4.x = positionVec4.x + action.x + positionVec4.y = positionVec4.y + action.y + positionVec4.z = positionVec4.z + action.z + + local rot = GetSingleton('Quaternion'):ToEulerAngles(enti2:GetWorldOrientation()) + + teleportTo(enti, positionVec4, rot,isplayer) + else + error("no entity for "..action.entity) + end + else + error("no entity for "..action.tag) + end + end + if(action.name == "teleport_entity_at_position") then + local isplayer = false + if action.tag == "player" then + isplayer = true + end + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local angle = 1 + if(action.angle ~= nil) then + angle = action.angle + end + if(action.collision ~= nil and action.collision == true) then + local filters = { + 'Static', -- Buildings, Concrete Roads, Crates, etc. + 'Terrain' + } + local from = enti:GetWorldPosition() + local to = Vector4.new( + action.x , + action.y , + action.z, + 1 + ) + local collision = false + for _, filter in ipairs(filters) do + local success, result = Game.GetSpatialQueriesSystem():SyncRaycastByCollisionGroup(from, to, filter, false, false) + if success then + collision = true + logme(1,"collision"..filter) + end + end + if(collision == false) then + teleportTo(enti, Vector4.new( action.x, action.y, action.z,1), angle,isplayer) + else + if(action.pathfinding ~= nil and action.pathfinding == true) then + local newpath = giveGoodPath(from,to,action.axis) + teleportTo(enti, newpath, angle,isplayer) + end + end + else + --logme(3,"angle.yaw = "..angle.yaw) + teleportTo(enti, Vector4.new( action.x, action.y, action.z,1), angle,isplayer) + end + end + end + if(action.name == "teleport_entity_at_relative_position") then + local isplayer = false + if action.tag == "player" then + isplayer = true + end + + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local angle = 1 + if(action.angle ~= nil) then + angle = action.angle + end + local positionVec4 = enti:GetWorldPosition() + positionVec4.x = positionVec4.x + action.x + positionVec4.y = positionVec4.y + action.y + positionVec4.z = positionVec4.z + action.z + teleportTo(enti, Vector4.new( positionVec4.x, positionVec4.y, positionVec4.z,1), angle,isplayer) + end + end + if(action.name == "teleport_player_at_relative_position") then + local playerpos = Game.GetPlayer():GetWorldPosition() + TeleportPlayerToPosition(playerpos.x+action.x,playerpos.y+action.y,playerpos.z+action.z) + end + + + + if(action.name == "entity_stop_fight") then + InterruptCombat(action.tag) + end + if(action.name == "switch_primary_secondary_weapon_entity") then + local enti = nil + local obj = nil + if(action.tag =="lookat") then + enti = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + else + obj = getEntityFromManager(action.tag) + enti = safeFindEntityByID(obj) + end + if(enti ~= nil and enti:HasPrimaryOrSecondaryEquipment()) then + if obj.usePrimary == nil or true then + EquipPrimaryWeaponCommand(objlook, false) + EquipSecondaryWeaponCommand(objlook, true) + obj.usePrimary = false + else + EquipSecondaryWeaponCommand(objlook, false) + EquipPrimaryWeaponCommand(objlook, true) + obj.usePrimary = true + end + end + end + if(action.name == "equip_weapon_entity_from_current_player") then + local enti = nil + local obj = nil + if(action.tag =="lookat") then + enti = objLook + obj = getEntityFromManagerById(objLook:GetEntityID()) + else + obj = getEntityFromManager(action.tag) + enti = safeFindEntityByID(obj) + end + if(enti ~= nil and enti:HasPrimaryOrSecondaryEquipment()) then + local es = Game.GetScriptableSystemsContainer():Get(CName.new("EquipmentSystem")) + local weapon = es:GetActiveWeaponObject(Game.GetPlayer(), 39) + local weaponTDBID = weapon:GetItemID().tdbid + EquipGivenWeapon(enti, weaponTDBID, true) + end + end + + if(action.name == "equip_item_on_slot") then + local enti = nil + local obj = nil + obj = getEntityFromManager(action.tag) + enti = safeFindEntityByID(obj) + if(enti ~= nil ) then + + if(action.tag =="player") then + Game.AddToInventory(action.item,1) + Game.GetTransactionSystem():AddItemToSlot(Game.GetPlayer(), TweakDBID.new("AttachmentSlots."..action.slot), ItemID.FromTDBID(TweakDBID.new(action.item))) + else + EquipGivenWeapon(enti, TweakDBID.new(action.item), true, "AttachmentSlots."..action.slot) + end + + + end + end + + + if(action.name == "unequip_item_on_slot") then + local enti = nil + local obj = nil + obj = getEntityFromManager(action.tag) + enti = safeFindEntityByID(obj) + if(enti ~= nil ) then + + if(action.tag =="player") then + Game.AddToInventory(action.item,1) + Game.GetTransactionSystem():RemoveItemFromSlot(Game.GetPlayer(), TweakDBID.new("AttachmentSlots."..action.slot), false,false,false) + else + UnEquipSlot(enti, true, "AttachmentSlots."..action.slot) + end + + + end + end + + + if(action.name == "equip_item") then + + equipItem(action.value) + + end + + if(action.name == "equip_transmog_item") then + + equipVisualItem(action.value) + + end + + if(action.name == "clear_transmog_slot") then + + clearVisualarea(action.value) + + end + + if(action.name == "unequip_item") then + + unequipItem(action.value) + + end + + if(action.name == "set_player_attribute") then + + setPlayerAttributes(action.value, action.score) + + end + + if(action.name == "set_player_skill") then + + setPlayerSkill(action.value, action.score) + + end + + if(action.name == "set_player_skill_progression") then + + setPlayerSkillProgression(action.value, action.score) + + end + + if(action.name == "set_player_perk") then + + setPlayerPerk(action.value, action.score) + + end + + + + if(action.name == "attitude_entity_against_entity") then - local obj = getEntityFromManager(action.tag) - checkAttitudeCounter(obj) - resetFollower(action.tag) - Cron.After(0.5, function() - if action.attitude == "hostile" then - setAggressiveAgainst(action.tag, action.entity) - end - if action.attitude == "passive" then - setPassiveAgainst(action.tag, action.entity) - end - if action.attitude == "companion" then - setFollower(action.tag) - end - if action.attitude == "friendly" then - setFriendAgainst(action.tag, action.entity) - end - if action.attitude == "psycho" then - setPsycho(action.tag, action.entity) - end + local obj = getEntityFromManager(action.tag) + checkAttitudeCounter(obj) + resetFollower(action.tag) + Cron.After(0.5, function() + if action.attitude == "hostile" then + setAggressiveAgainst(action.tag, action.entity) + end + if action.attitude == "passive" then + setPassiveAgainst(action.tag, action.entity) + end + if action.attitude == "companion" then + setFollower(action.tag) + end + if action.attitude == "friendly" then + setFriendAgainst(action.tag, action.entity) + end + if action.attitude == "psycho" then + setPsycho(action.tag, action.entity) + end - - end) - end - - if(action.name == "set_relation_between_attitude") then - - - local EAIAttitude = Enum.new("EAIAttitude", "AIA_Hostile") - - - if action.relation == "passive" then - EAIAttitude =Enum.new("EAIAttitude", "AIA_Neutral") - end - if action.relation == "friendly" then - EAIAttitude =Enum.new("EAIAttitude", "AIA_Friendly") - end - - - setAttitudeAgainstAttitude(action.attitude,action.target, EAIAttitude) - end - - if(action.name == "set_relation_from_faction_to_attitude") then - - local faction = getFactionByTag(action.tag) - - - if(faction ~= nil and faction.attitude_group ~= nil and #faction.attitude_group > 0) then - - for i,attitude in ipairs(faction.attitude_group) do - - local EAIAttitude = Enum.new("EAIAttitude", "AIA_Hostile") - - - if action.relation == "passive" then - EAIAttitude =Enum.new("EAIAttitude", "AIA_Neutral") - end - if action.relation == "friendly" then - EAIAttitude =Enum.new("EAIAttitude", "AIA_Friendly") - end - - setAttitudeAgainstAttitude(attitude,action.target, EAIAttitude) - end - end - - end - - if(action.name == "set_relation_from_faction_to_faction") then - - local faction = getFactionByTag(action.tag) - - local factiontarget = getFactionByTag(action.target) - - - if(faction ~= nil and faction.attitude_group ~= nil and #faction.attitude_group > 0) and (factiontarget ~= nil and factiontarget.attitude_group ~= nil and #factiontarget.attitude_group > 0) then - - for i,attitude01 in ipairs(faction.attitude_group) do - - for i,attitude02 in ipairs(factiontarget.attitude_group) do - - - - local EAIAttitude = Enum.new("EAIAttitude", "AIA_Hostile") - - - if action.relation == "passive" then - EAIAttitude =Enum.new("EAIAttitude", "AIA_Neutral") - end - if action.relation == "friendly" then - EAIAttitude =Enum.new("EAIAttitude", "AIA_Friendly") - end - - setAttitudeAgainstAttitude(attitude01,attitude02, EAIAttitude) - - if action.target == getVariableKey("player","current_gang") and action.apply_player == true then - - Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(attitude01), CName.new("player"), EAIAttitude) - - end - - - - end - end - - - - - end - - end - - - if(action.name == "update_faction_relation_attitude") then - - for key01,gang01 in pairs(cyberscript.cache["faction"]) do - - for key02,gang02 in pairs(cyberscript.cache["faction"]) do - - local relation = getFactionRelation(gang01.data.tag,gang02.data.tag) - - if(relation == nil or relation == 0) then - - if(gang01.data ~= nil and gang01.data.attitude_group ~= nil and #gang01.data.attitude_group > 0) and (gang02.data ~= nil and gang02.data.attitude_group ~= nil and #gang02.data.attitude_group > 0) then - - for i,attitude01 in ipairs(gang01.data.attitude_group) do - - for i,attitude02 in ipairs(gang02.data.attitude_group) do - - - - local EAIAttitude = Enum.new("EAIAttitude", "AIA_Neutral") - setAttitudeAgainstAttitude(attitude01,attitude02, EAIAttitude) - - if key02 == getVariableKey("player","current_gang") and action.apply_player == true then - - Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(attitude01), CName.new("player"), EAIAttitude) - - - end - end - end - end - - - end - - if(relation ~= nil and relation > 0) then - - if(gang01.data ~= nil and gang01.data.attitude_group ~= nil and #gang01.data.attitude_group > 0) and (gang02.data ~= nil and gang02.data.attitude_group ~= nil and #gang02.data.attitude_group > 0) then - - for i,attitude01 in ipairs(gang01.data.attitude_group) do - - for i,attitude02 in ipairs(gang02.data.attitude_group) do - - - - local EAIAttitude = Enum.new("EAIAttitude", "AIA_Friendly") - setAttitudeAgainstAttitude(attitude01,attitude02, EAIAttitude) - - if key02 == getVariableKey("player","current_gang") and action.apply_player == true then - - Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(attitude01), CName.new("player"), EAIAttitude) - - - end - end - end - end - - - end - - if(relation ~= nil and relation < 0) then - - if(gang01.data ~= nil and gang01.data.attitude_group ~= nil and #gang01.data.attitude_group > 0) and (gang02.data ~= nil and gang02.data.attitude_group ~= nil and #gang02.data.attitude_group > 0) then - - for i,attitude01 in ipairs(gang01.data.attitude_group) do - - for i,attitude02 in ipairs(gang02.data.attitude_group) do - - - - local EAIAttitude = Enum.new("EAIAttitude", "AIA_Hostile") - setAttitudeAgainstAttitude(attitude01,attitude02, EAIAttitude) - - - if key02 == getVariableKey("player","current_gang") and action.apply_player == true then - - Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(attitude01), CName.new("player"), EAIAttitude) - - - end - - end - end - end - - - end - - - end - - end - - end - - - - - if(action.name == "play_entity_voice") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - talk(enti,action.voice) - end - end - if(action.name == "toggle_immortal_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - if(action.tag == "player") then - if (action.immortal == true) then - - Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Invulnerable", CName.new("SecondHeart")) - if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then - local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - if veh then - Game.GetGodModeSystem():AddGodMode(veh:GetEntityID(), "Invulnerable", CName.new("Default")) - end - end - else - local hasSecondHeart = false - local ssc = Game.GetScriptableSystemsContainer() - local es = ssc:Get(CName.new('EquipmentSystem')) - local espd = es:GetPlayerData(Game.GetPlayer()) - espd['GetItemInEquipSlot2'] = espd['GetItemInEquipSlot;gamedataEquipmentAreaInt32'] - for i=0,2 do - if espd:GetItemInEquipSlot2("CardiovascularSystemCW", i).tdbid.hash == 3619482064 then - hasSecondHeart = true - end - end - if hasSecondHeart then - Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Immortal", CName.new("SecondHeart")) - else - Game.GetGodModeSystem():DisableOverride(Game.GetPlayer():GetEntityID(), CName.new("SecondHeart")) - end - if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then - local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - if veh then - Game.GetGodModeSystem():ClearGodMode(veh:GetEntityID(), CName.new("Default")) - end - end - - end - else - ToggleImmortal(enti, action.immortal) - end - end - - - - end - - if(action.name == "toggle_infinite_stamina") then - InfiniteStamina(action.value) - - end - if(action.name == "toggle_infinite_ammo") then - if(action.value == true) then - Game.GetInventoryManager().AddEquipmentStateFlag(Game.GetInventoryManager(),gameEEquipmentManagerState.InfiniteAmmo) - local player = Game.GetPlayer() - local activeWeapon = GameObject.GetActiveWeapon(player) - -- The gist behind this is: - -- Reload the weapon in 0 seconds, end the reload - GameObject.GetActiveWeapon(player).StartReload(activeWeapon,0) - GameObject.GetActiveWeapon(player).StopReload(activeWeapon,gameweaponReloadStatus.Standard) - else - Game.GetInventoryManager().RemoveEquipmentStateFlag(Game.GetInventoryManager(),gameEEquipmentManagerState.InfiniteAmmo) - local player = Game.GetPlayer() - local activeWeapon = GameObject.GetActiveWeapon(player) - -- The gist behind this is: - -- Reload the weapon in 0 seconds, end the reload - GameObject.GetActiveWeapon(player).StartReload(activeWeapon,0) - GameObject.GetActiveWeapon(player).StopReload(activeWeapon,gameweaponReloadStatus.Standard) - end - - end - if(action.name == "play_entity_facial") then - - - local reaction = getExpression(action.value) - - makeFacial(action.tag,reaction) - - end - if(action.name == "fake_lips_sync") then - - local actionlist = {} - local possibility = {} - local val = 30 - - local actionb = deepcopy(cyberscript.actiontemplate["play_entity_facial"]) - actionb.value = "Surprise" - actionb.tag = action.tag - table.insert(actionlist,actionb) - - local actionb = deepcopy(cyberscript.actiontemplate["wait_tick"]) - actionb.value = val - table.insert(actionlist,actionb) - - - for i=1, (action.duration*1) do - - if(i%2==0) then - possibility = {"Terrified","Fear","Surprise"} - val = 40 - else - - - possibility = {"Terrified","Fear","Surprise"} - val = 60 - - - - end - local actionb = deepcopy(cyberscript.actiontemplate["play_entity_facial"]) - actionb.value = possibility[math.random(1,#possibility)] - actionb.tag = action.tag - table.insert(actionlist,actionb) - - local actionb = deepcopy(cyberscript.actiontemplate["wait_tick"]) - actionb.value = val - table.insert(actionlist,actionb) - - end - - local actionb = deepcopy(cyberscript.actiontemplate["reset_entity_facial"]) - actionb.tag = action.tag - table.insert(actionlist,actionb) - - if(action.parallele ~= false)then - - - - runActionList(actionlist, "fake_lips_sync_async_action_"..tostring(math.random(1,987987)), "see",false,nil) - - else - - runSubActionList(actionlist, tag.."_fake_lips_sync_async_action_"..tostring(math.random(1,987987)) ,parent,source,false,exector) - result=false - end - - end - if(action.name == "reset_entity_facial") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - resetFacial(enti) - end - end - if(action.name == "look_at_entity_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - if(action.entity == "player") then - lookAtPlayer(enti) - else - lookAtEntity(enti,action.entity,action.duration) - end - end - end - if(action.name == "reset_lookat_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - resetLookAt(enti) - end - end - if(action.name == "player_look_at_entity") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - --print("tt") - local post = enti:GetWorldPosition() - playerLookAtDirection(post.x, post.y, post.z) - - end - end - if(action.name == "player_look_at_position") then - playerLookAtDirection(action.x, action.y,action.z) - - end - if(action.name == "player_look_at_rotation") then - Game.GetPlayer():GetFPPCameraComponent().pitchMin = pitch - 0.01 -- Use pitchMin/Max to set pitch, needs to have a small difference between Min and Max - Game.GetPlayer():GetFPPCameraComponent().pitchMax = pitch - Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Game.GetPlayer():GetWorldPosition() , EulerAngles.new(action.roll,action.pitch,action.yaw)) -- Set yaw when teleporting - end - if(action.name == "player_move_head_to_position") then - - local player = Game.GetPlayer() - - local direction = {} - direction.x = action.x - direction.y = action.y - direction.z = action.z - direction.w = 1 - - local dirVector = diffVector(player:GetWorldPosition(), direction) - local angle = GetSingleton('Vector4'):ToRotation(dirVector) - - local pitch = angle.pitch - local yaw = angle.yaw - - local oldangle = GetSingleton('Vector4'):ToRotation(player:GetWorldPosition()) - - local how = angle.yaw -oldangle.yaw - logme(10,how) - local actionlist = {} - for i=1,0-how do - local newaction = {} - newaction.name = "player_look_at_rotation" - - newaction.roll = angle.roll - newaction.pitch = angle.pitch - newaction.yaw = oldangle.yaw+i - table.insert(actionlist,newaction) - - local newaction = {} - newaction.name = "wait_second" - - newaction.value = 0.1 - table.insert(actionlist,newaction) - - end - runSubActionList(actionlist, tag.."_forlist", tag,source,false,executortag) - end - if(action.name == "player_look_at_forward") then - local position = getForwardPosition(Game.GetPlayer(),5) - playerLookAtDirection(position.x, position.y,position.z) - Game.GetPlayer():GetFPPCameraComponent().pitchMin = pitch - 0.01 -- Use pitchMin/Max to set pitch, needs to have a small difference between Min and Max - Game.GetPlayer():GetFPPCameraComponent().pitchMax = pitch - Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Game.GetPlayer():GetWorldPosition() , EulerAngles.new(0,0,yaw)) -- Set yaw when teleporting - end - if(action.name == "rotate_player_camera") then - --EulerAngles.new(ROLL,PITCH, YAW) - --https://en.wikipedia.org/wiki/Aircraft_principal_axes#/media/File:Yaw_Axis_Corrected.svg - Game.GetPlayer():GetFPPCameraComponent():SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(90, 0, 0))) - end - if(action.name == "player_look_at_unlock") then - freezeCamera = false - end - if(action.name == "set_entity_appearance") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - --logme(3,"go") - - setAppearance(enti,action.appearance) - end - end - if(action.name == "swap_character") then - swapEntity(action.target,action.swap) - end - if(action.name == "swap_character_current_star") then - if(currentStar ~= nil) then - swapEntity(action.target,currentStar.TweakIDs) - end - end - if(action.name == "change_character_preset") then - changePreset(action.target,action.preset) - end - if(action.name == "freeze_player") then - local blackboardDefs = Game.GetAllBlackboardDefs() - local blackboardPSM = Game.GetBlackboardSystem():GetLocalInstanced(Game.GetPlayer():GetEntityID(), blackboardDefs.PlayerStateMachine) - local test = blackboardPSM:GetInt(blackboardDefs.PlayerStateMachine.SceneTier) - blackboardPSM:SetInt(blackboardDefs.PlayerStateMachine.SceneTier, 5, true) -- GameplayTier.Tier5_Cinematic - times = Game.GetTimeSystem() - times:SetIgnoreTimeDilationOnLocalPlayerZero(false) - Game.GetTimeSystem():SetTimeDilation("cyberscript", 0.0000000000001) - end - if(action.name == "unfreeze_player") then - local blackboardDefs = Game.GetAllBlackboardDefs() - local blackboardPSM = Game.GetBlackboardSystem():GetLocalInstanced(Game.GetPlayer():GetEntityID(), blackboardDefs.PlayerStateMachine) - blackboardPSM:SetInt(blackboardDefs.PlayerStateMachine.SceneTier, 1, true) -- GameplayTier.Tier1_FullGameplay - Game.GetTimeSystem():SetTimeDilation("cyberscript", 0) - end - if(action.name == "apply_effect") then - if(action.tag == "player") then - ApplyEffectOnPlayer(action.value) - else - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - - StatusEffectHelper.ApplyStatusEffectForTimeWindow(enti, TweakDBID.new(action.value),obj.id, 0,1000) - end - end - if(action.name == "remove_effect") then - if(action.tag == "player") then - RemoveEffectPlayer(action.value) - else - local obj = getEntityFromManager(action.tag) - Game.RemoveStatusEffect(obj.id,TweakDBID.new(action.value)) - end - end - if(action.name == "set_timedilationforplayer") then - TimeDilationHelper.SetTimeDilationOnPlayer(Game.GetPlayer(), "see_engine", action.value, 99999, "", ""); - end + + end) + end + + if(action.name == "set_relation_between_attitude") then + + + local EAIAttitude = Enum.new("EAIAttitude", "AIA_Hostile") + + + if action.relation == "passive" then + EAIAttitude =Enum.new("EAIAttitude", "AIA_Neutral") + end + if action.relation == "friendly" then + EAIAttitude =Enum.new("EAIAttitude", "AIA_Friendly") + end + + + setAttitudeAgainstAttitude(action.attitude,action.target, EAIAttitude) + end + + if(action.name == "set_relation_from_faction_to_attitude") then + + local faction = getFactionByTag(action.tag) + + + if(faction ~= nil and faction.attitude_group ~= nil and #faction.attitude_group > 0) then + + for i,attitude in ipairs(faction.attitude_group) do + + local EAIAttitude = Enum.new("EAIAttitude", "AIA_Hostile") + + + if action.relation == "passive" then + EAIAttitude =Enum.new("EAIAttitude", "AIA_Neutral") + end + if action.relation == "friendly" then + EAIAttitude =Enum.new("EAIAttitude", "AIA_Friendly") + end + + setAttitudeAgainstAttitude(attitude,action.target, EAIAttitude) + end + end + + end + + if(action.name == "set_relation_from_faction_to_faction") then + + local faction = getFactionByTag(action.tag) + + local factiontarget = getFactionByTag(action.target) + + + if(faction ~= nil and faction.attitude_group ~= nil and #faction.attitude_group > 0) and (factiontarget ~= nil and factiontarget.attitude_group ~= nil and #factiontarget.attitude_group > 0) then + + for i,attitude01 in ipairs(faction.attitude_group) do + + for i,attitude02 in ipairs(factiontarget.attitude_group) do + + + + local EAIAttitude = Enum.new("EAIAttitude", "AIA_Hostile") + + + if action.relation == "passive" then + EAIAttitude =Enum.new("EAIAttitude", "AIA_Neutral") + end + if action.relation == "friendly" then + EAIAttitude =Enum.new("EAIAttitude", "AIA_Friendly") + end + + setAttitudeAgainstAttitude(attitude01,attitude02, EAIAttitude) + + if action.target == getVariableKey("player","current_gang") and action.apply_player == true then + + Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(attitude01), CName.new("player"), EAIAttitude) + + end + + + + end + end + + + + + end + + end + + + if(action.name == "update_faction_relation_attitude") then + + for key01,gang01 in pairs(cyberscript.cache["faction"]) do + + for key02,gang02 in pairs(cyberscript.cache["faction"]) do + + local relation = getFactionRelation(gang01.data.tag,gang02.data.tag) + + if(relation == nil or relation == 0) then + + if(gang01.data ~= nil and gang01.data.attitude_group ~= nil and #gang01.data.attitude_group > 0) and (gang02.data ~= nil and gang02.data.attitude_group ~= nil and #gang02.data.attitude_group > 0) then + + for i,attitude01 in ipairs(gang01.data.attitude_group) do + + for i,attitude02 in ipairs(gang02.data.attitude_group) do + + + + local EAIAttitude = Enum.new("EAIAttitude", "AIA_Neutral") + setAttitudeAgainstAttitude(attitude01,attitude02, EAIAttitude) + + if key02 == getVariableKey("player","current_gang") and action.apply_player == true then + + Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(attitude01), CName.new("player"), EAIAttitude) + + + end + end + end + end + + + end + + if(relation ~= nil and relation > 0) then + + if(gang01.data ~= nil and gang01.data.attitude_group ~= nil and #gang01.data.attitude_group > 0) and (gang02.data ~= nil and gang02.data.attitude_group ~= nil and #gang02.data.attitude_group > 0) then + + for i,attitude01 in ipairs(gang01.data.attitude_group) do + + for i,attitude02 in ipairs(gang02.data.attitude_group) do + + + + local EAIAttitude = Enum.new("EAIAttitude", "AIA_Friendly") + setAttitudeAgainstAttitude(attitude01,attitude02, EAIAttitude) + + if key02 == getVariableKey("player","current_gang") and action.apply_player == true then + + Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(attitude01), CName.new("player"), EAIAttitude) + + + end + end + end + end + + + end + + if(relation ~= nil and relation < 0) then + + if(gang01.data ~= nil and gang01.data.attitude_group ~= nil and #gang01.data.attitude_group > 0) and (gang02.data ~= nil and gang02.data.attitude_group ~= nil and #gang02.data.attitude_group > 0) then + + for i,attitude01 in ipairs(gang01.data.attitude_group) do + + for i,attitude02 in ipairs(gang02.data.attitude_group) do + + + + local EAIAttitude = Enum.new("EAIAttitude", "AIA_Hostile") + setAttitudeAgainstAttitude(attitude01,attitude02, EAIAttitude) + + + if key02 == getVariableKey("player","current_gang") and action.apply_player == true then + + Game.GetAttitudeSystem():SetAttitudeRelation(CName.new(attitude01), CName.new("player"), EAIAttitude) + + + end + + end + end + end + + + end + + + end + + end + + end + + + + + if(action.name == "play_entity_voice") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + talk(enti,action.voice) + end + end + if(action.name == "toggle_immortal_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + if(action.tag == "player") then + if (action.immortal == true) then + + Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Invulnerable", CName.new("SecondHeart")) + if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then + local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + if veh then + Game.GetGodModeSystem():AddGodMode(veh:GetEntityID(), "Invulnerable", CName.new("Default")) + end + end + else + local hasSecondHeart = false + local ssc = Game.GetScriptableSystemsContainer() + local es = ssc:Get(CName.new('EquipmentSystem')) + local espd = es:GetPlayerData(Game.GetPlayer()) + espd['GetItemInEquipSlot2'] = espd['GetItemInEquipSlot;gamedataEquipmentAreaInt32'] + for i=0,2 do + if espd:GetItemInEquipSlot2("CardiovascularSystemCW", i).tdbid.hash == 3619482064 then + hasSecondHeart = true + end + end + if hasSecondHeart then + Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Immortal", CName.new("SecondHeart")) + else + Game.GetGodModeSystem():DisableOverride(Game.GetPlayer():GetEntityID(), CName.new("SecondHeart")) + end + if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then + local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + if veh then + Game.GetGodModeSystem():ClearGodMode(veh:GetEntityID(), CName.new("Default")) + end + end + + end + else + ToggleImmortal(enti, action.immortal) + end + end + + + + end + + if(action.name == "toggle_infinite_stamina") then + InfiniteStamina(action.value) + + end + if(action.name == "toggle_infinite_ammo") then + if(action.value == true) then + Game.GetInventoryManager().AddEquipmentStateFlag(Game.GetInventoryManager(),gameEEquipmentManagerState.InfiniteAmmo) + local player = Game.GetPlayer() + local activeWeapon = GameObject.GetActiveWeapon(player) + -- The gist behind this is: + -- Reload the weapon in 0 seconds, end the reload + GameObject.GetActiveWeapon(player).StartReload(activeWeapon,0) + GameObject.GetActiveWeapon(player).StopReload(activeWeapon,gameweaponReloadStatus.Standard) + else + Game.GetInventoryManager().RemoveEquipmentStateFlag(Game.GetInventoryManager(),gameEEquipmentManagerState.InfiniteAmmo) + local player = Game.GetPlayer() + local activeWeapon = GameObject.GetActiveWeapon(player) + -- The gist behind this is: + -- Reload the weapon in 0 seconds, end the reload + GameObject.GetActiveWeapon(player).StartReload(activeWeapon,0) + GameObject.GetActiveWeapon(player).StopReload(activeWeapon,gameweaponReloadStatus.Standard) + end + + end + if(action.name == "play_entity_facial") then + + + local reaction = getExpression(action.value) + + makeFacial(action.tag,reaction) + + end + if(action.name == "fake_lips_sync") then + + local actionlist = {} + local possibility = {} + local val = 30 + + local actionb = deepcopy(cyberscript.actiontemplate["play_entity_facial"]) + actionb.value = "Surprise" + actionb.tag = action.tag + table.insert(actionlist,actionb) + + local actionb = deepcopy(cyberscript.actiontemplate["wait_tick"]) + actionb.value = val + table.insert(actionlist,actionb) + + + for i=1, (action.duration*1) do + + if(i%2==0) then + possibility = {"Terrified","Fear","Surprise"} + val = 40 + else + + + possibility = {"Terrified","Fear","Surprise"} + val = 60 + + + + end + local actionb = deepcopy(cyberscript.actiontemplate["play_entity_facial"]) + actionb.value = possibility[math.random(1,#possibility)] + actionb.tag = action.tag + table.insert(actionlist,actionb) + + local actionb = deepcopy(cyberscript.actiontemplate["wait_tick"]) + actionb.value = val + table.insert(actionlist,actionb) + + end + + local actionb = deepcopy(cyberscript.actiontemplate["reset_entity_facial"]) + actionb.tag = action.tag + table.insert(actionlist,actionb) + + if(action.parallele ~= false)then + + + + runActionList(actionlist, "fake_lips_sync_async_action_"..tostring(math.random(1,987987)), "see",false,nil) + + else + + runSubActionList(actionlist, tag.."_fake_lips_sync_async_action_"..tostring(math.random(1,987987)) ,parent,source,false,exector) + result=false + end + + end + if(action.name == "reset_entity_facial") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + resetFacial(enti) + end + end + if(action.name == "look_at_entity_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + if(action.entity == "player") then + lookAtPlayer(enti) + else + lookAtEntity(enti,action.entity,action.duration) + end + end + end + if(action.name == "reset_lookat_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + resetLookAt(enti) + end + end + if(action.name == "player_look_at_entity") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + --print("tt") + local post = enti:GetWorldPosition() + playerLookAtDirection(post.x, post.y, post.z) + -- B-10 fix: optional continuous tracking. The original + -- implementation only snapped the camera once, so users + -- reported player_look_at_entity as "broken" when the + -- target moved (GH #12). If action.track == true and + -- action.duration > 0, repeatedly re-aim at the entity + -- for the requested duration. Default behavior (no + -- track) is unchanged for backward compatibility. + if action.track == true and action.duration and action.duration > 0 then + local trackTag = "player_look_at_entity_track_" .. tostring(action.tag) + Cron.Every(0.1, { done = false }, function(c) + if c.done then return end + local ent = getEntityFromManager(action.tag) + local liveEntity = ent and safeFindEntityByID(ent.id) + if liveEntity then + local p = liveEntity:GetWorldPosition() + playerLookAtDirection(p.x, p.y, p.z) + else + c.done = true + end + end) + Cron.After(action.duration, function() + -- stop the tracking loop on the next tick + Cron.Every(0.1, { stop = true }, function(c) + if c.stop then + -- Cron has no native cancel; flag is checked + -- by the tracker above on its next run. The + -- tracker will self-stop when entity is gone. + end + end) + end) + end + end + end + if(action.name == "player_look_at_position") then + playerLookAtDirection(action.x, action.y,action.z) + + end + -- B-10 fix: alias `player_look_at_xyz` -> `player_look_at_position`. + -- The wiki documents `player_look_at_xyz` but the implementation + -- only had `player_look_at_position`, so JSON actions using the + -- documented name silently did nothing (GH #12). Additive alias, + -- no behavior change for existing actions. + if(action.name == "player_look_at_xyz") then + playerLookAtDirection(action.x, action.y, action.z) + end + if(action.name == "player_look_at_rotation") then + Game.GetPlayer():GetFPPCameraComponent().pitchMin = pitch - 0.01 -- Use pitchMin/Max to set pitch, needs to have a small difference between Min and Max + Game.GetPlayer():GetFPPCameraComponent().pitchMax = pitch + Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Game.GetPlayer():GetWorldPosition() , EulerAngles.new(action.roll,action.pitch,action.yaw)) -- Set yaw when teleporting + end + if(action.name == "player_move_head_to_position") then + + local player = Game.GetPlayer() + + local direction = {} + direction.x = action.x + direction.y = action.y + direction.z = action.z + direction.w = 1 + + local dirVector = diffVector(player:GetWorldPosition(), direction) + local angle = GetSingleton('Vector4'):ToRotation(dirVector) + + local pitch = angle.pitch + local yaw = angle.yaw + + local oldangle = GetSingleton('Vector4'):ToRotation(player:GetWorldPosition()) + + local how = angle.yaw -oldangle.yaw + logme(10,how) + local actionlist = {} + for i=1,0-how do + local newaction = {} + newaction.name = "player_look_at_rotation" + + newaction.roll = angle.roll + newaction.pitch = angle.pitch + newaction.yaw = oldangle.yaw+i + table.insert(actionlist,newaction) + + local newaction = {} + newaction.name = "wait_second" + + newaction.value = 0.1 + table.insert(actionlist,newaction) + + end + runSubActionList(actionlist, tag.."_forlist", tag,source,false,executortag) + end + if(action.name == "player_look_at_forward") then + local position = getForwardPosition(Game.GetPlayer(),5) + playerLookAtDirection(position.x, position.y,position.z) + Game.GetPlayer():GetFPPCameraComponent().pitchMin = pitch - 0.01 -- Use pitchMin/Max to set pitch, needs to have a small difference between Min and Max + Game.GetPlayer():GetFPPCameraComponent().pitchMax = pitch + Game.GetTeleportationFacility():Teleport(Game.GetPlayer(), Game.GetPlayer():GetWorldPosition() , EulerAngles.new(0,0,yaw)) -- Set yaw when teleporting + end + if(action.name == "rotate_player_camera") then + --EulerAngles.new(ROLL,PITCH, YAW) + --https://en.wikipedia.org/wiki/Aircraft_principal_axes#/media/File:Yaw_Axis_Corrected.svg + Game.GetPlayer():GetFPPCameraComponent():SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(90, 0, 0))) + end + -- B-10 fix: alias `player_rotate` -> `rotate_player_camera`. + -- The wiki documents `player_rotate` but the implementation only + -- had `rotate_player_camera`, so JSON actions using the documented + -- name silently did nothing (GH #12). Additive alias, no behavior + -- change for existing actions. + if(action.name == "player_rotate") then + Game.GetPlayer():GetFPPCameraComponent():SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(90, 0, 0))) + end + if(action.name == "player_look_at_unlock") then + freezeCamera = false + end + if(action.name == "set_entity_appearance") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + --logme(3,"go") + + setAppearance(enti,action.appearance) + end + end + if(action.name == "swap_character") then + swapEntity(action.target,action.swap) + end + if(action.name == "swap_character_current_star") then + if(currentStar ~= nil) then + swapEntity(action.target,currentStar.TweakIDs) + end + end + if(action.name == "change_character_preset") then + changePreset(action.target,action.preset) + end + if(action.name == "freeze_player") then + local blackboardDefs = Game.GetAllBlackboardDefs() + local blackboardPSM = Game.GetBlackboardSystem():GetLocalInstanced(Game.GetPlayer():GetEntityID(), blackboardDefs.PlayerStateMachine) + local test = blackboardPSM:GetInt(blackboardDefs.PlayerStateMachine.SceneTier) + blackboardPSM:SetInt(blackboardDefs.PlayerStateMachine.SceneTier, 5, true) -- GameplayTier.Tier5_Cinematic + times = Game.GetTimeSystem() + times:SetIgnoreTimeDilationOnLocalPlayerZero(false) + Game.GetTimeSystem():SetTimeDilation("cyberscript", 0.0000000000001) + end + if(action.name == "unfreeze_player") then + local blackboardDefs = Game.GetAllBlackboardDefs() + local blackboardPSM = Game.GetBlackboardSystem():GetLocalInstanced(Game.GetPlayer():GetEntityID(), blackboardDefs.PlayerStateMachine) + blackboardPSM:SetInt(blackboardDefs.PlayerStateMachine.SceneTier, 1, true) -- GameplayTier.Tier1_FullGameplay + -- B-08 fix: SetTimeDilation("cyberscript", 0) PAUSES time (0 = no + -- time advance), it does NOT unfreeze. The original code therefore + -- left the in-game clock stuck after any freeze_player action, + -- which users reported as "in-game time stops after weather/time + -- change" (GH #10) because freeze_player is commonly used by + -- scripted weather/time events. Use UnsetTimeDilation to actually + -- remove the dilation and restore normal time flow. + Game.GetTimeSystem():UnsetTimeDilation("cyberscript") + end + if(action.name == "apply_effect") then + if(action.tag == "player") then + ApplyEffectOnPlayer(action.value) + else + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + + StatusEffectHelper.ApplyStatusEffectForTimeWindow(enti, TweakDBID.new(action.value),obj.id, 0,1000) + end + end + if(action.name == "remove_effect") then + if(action.tag == "player") then + RemoveEffectPlayer(action.value) + else + local obj = getEntityFromManager(action.tag) + Game.RemoveStatusEffect(obj.id,TweakDBID.new(action.value)) + end + end + if(action.name == "set_timedilationforplayer") then + TimeDilationHelper.SetTimeDilationOnPlayer(Game.GetPlayer(), "see_engine", action.value, 99999, "", ""); + end - if(action.name == "unset_timedilationforplayer") then - TimeDilationHelper.UnSetTimeDilationOnPlayer(Game.GetPlayer(),"see_engine"); - end - - if(action.name == "ignore_timedilatationforplayer") then - Game.GetTimeSystem():SetIgnoreTimeDilationOnLocalPlayerZero(action.value) - end - - - - if(action.name == "set_timedilation") then - - Game.GetTimeSystem():SetTimeDilation("cyberscript", action.value); - end - if(action.name == "unset_timedilation") then - - Game.GetTimeSystem():UnsetTimeDilation("cyberscript"); - Game.GetTimeSystem():SetIgnoreTimeDilationOnLocalPlayerZero(false) - end + if(action.name == "unset_timedilationforplayer") then + TimeDilationHelper.UnSetTimeDilationOnPlayer(Game.GetPlayer(),"see_engine"); + end + + if(action.name == "ignore_timedilatationforplayer") then + Game.GetTimeSystem():SetIgnoreTimeDilationOnLocalPlayerZero(action.value) + end + + + + if(action.name == "set_timedilation") then + + Game.GetTimeSystem():SetTimeDilation("cyberscript", action.value); + end + if(action.name == "unset_timedilation") then + + Game.GetTimeSystem():UnsetTimeDilation("cyberscript"); + Game.GetTimeSystem():SetIgnoreTimeDilationOnLocalPlayerZero(false) + end - if(action.name == "set_timedilation_for_entity") then - - local obj = getEntityFromManager(action.tag) - if(obj ~= nil ) then - local enti = Game.FindEntityByID(obj.id) - - if enti ~= nil then - - TimeDilationHelper.SetIndividualTimeDilation(enti, "see_engine", action.value, 99999, "", ""); - - end - end - end - if(action.name == "unset_timedilation_for_entity") then - - local obj = getEntityFromManager(action.tag) - if(obj ~= nil ) then - local enti = Game.FindEntityByID(obj.id) - - if enti ~= nil then - - TimeDilationHelper.UnsetIndividualTimeDilation(enti); - - end - end - end + if(action.name == "set_timedilation_for_entity") then + + local obj = getEntityFromManager(action.tag) + if(obj ~= nil ) then + local enti = safeFindEntityByID(obj) + + if enti ~= nil then + + TimeDilationHelper.SetIndividualTimeDilation(enti, "see_engine", action.value, 99999, "", ""); + + end + end + end + if(action.name == "unset_timedilation_for_entity") then + + local obj = getEntityFromManager(action.tag) + if(obj ~= nil ) then + local enti = safeFindEntityByID(obj) + + if enti ~= nil then + + TimeDilationHelper.UnsetIndividualTimeDilation(enti); + + end + end + end - if(action.name == "change_camera_position") then - local fppComp = Game.GetPlayer():GetFPPCameraComponent() - fppComp:SetLocalPosition(Vector4:new(action.x, action.y, action.z, 1.0)) - end - if(action.name == "change_camera_rotation") then - local fppComp = Game.GetPlayer():GetFPPCameraComponent() - fppComp:SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(action.roll, action.pitch, action.yaw))) - end - if(action.name == "add_camera_position") then - local fppComp = Game.GetPlayer():GetFPPCameraComponent() - local pos = fppComp:GetLocalPosition() - pos.x = pos.x + action.x - pos.y = pos.y + action.y - pos.x = pos.z + action.z - fppComp:SetLocalPosition(Vector4:new(pos.x, pos.y, pos.z, 1.0)) - end - if(action.name == "add_camera_rotation") then - local fppComp = Game.GetPlayer():GetFPPCameraComponent() - local pos = fppComp:GetLocalOrientation() - local rot = GetSingleton('Quaternion'):ToEulerAngles(pos) - rot.yaw = rot.yaw + action.yaw - rot.pitch = rot.pitch + action.pitch - rot.roll = rot.roll + action.roll - fppComp:SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(rot.roll, rot.pitch, rot.yaw))) - end - if(action.name == "reset_camera") then - local fppComp = Game.GetPlayer():GetFPPCameraComponent() - fppComp:SetLocalPosition(Vector4:new(0, 0, 0, 1.0)) - fppComp:SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(0, 0, 0))) - end - if(action.name == "execute_at_script_level") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - if(obj.scriptlevel == nil or obj.scriptlevel <= action.scriptlevel) then - - runSubActionList(action.action, tag.."_execute_at_level", tag,source,false,obj.tag) - - end - end - - end - - if(action.name == "set_script_level") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - obj.scriptlevel = action.scriptlevel - - end - - end - - if(action.name == "player_toggle_invisible") then - PlayerToggleInvisible(action.value) - end - - if(action.name == "player_toggle_v_component_visibility") then - toggleVBodyComponent(action.value) - end - - if(action.name == "spawn_item") then - local chara = "" - if(action.amount == nil) then - action.amount = 1 - end - if(action.amount == 0) then - action.amount = math.random(1,6) - end - for i=1,action.amount do - - - chara = action.path - - - - local tag = action.tag - if(action.amount > 1) then - tag = action.tag.."_"..i - end - local position = getPositionFromParameter(action) - if(chara ~= "" and chara ~= nil and position.x ~= nil) then - - local spawnedItem = {} - - spawnedItem.Tag = tag - spawnedItem.HouseTag = "" - spawnedItem.ItemPath = chara - spawnedItem.X = position.x - spawnedItem.Y = position.y - spawnedItem.Z = position.z - - spawnedItem.Yaw = action.yaw - spawnedItem.Pitch = action.pitch - spawnedItem.Roll = action.roll - spawnedItem.Title = chara - - local angles = EulerAngles.new(spawnedItem.Yaw,spawnedItem.Pitch,spawnedItem.Roll) - local posVec4 = Vector4.new(position.x, position.y, position.z,1) - spawnedItem.entityId = spawnItem(spawnedItem, posVec4, angles) - local entity = Game.FindEntityByID(spawnedItem.entityId) - local components = checkForValidComponents(entity) - if components then - local visualScale = checkDefaultScale(components) - spawnedItem.defaultScale = { - x = visualScale.x * 100, - y = visualScale.x * 100, - z = visualScale.x * 100, - } - spawnedItem.scale = { - x = visualScale.x * 100, - y = visualScale.y * 100, - z = visualScale.z * 100, - } - end - if(action.isentity == nil or action.isentity == false) then - - - - table.insert(currentItemSpawned,spawnedItem) - - else - - local entity = {} - entity.id = spawnedItem.entityId - entity.tag = tag - entity.tweak = chara - entity.isprevention = false - entity.scriptlevel = 0 - - entity.isMP = false - entity.name = tag - cyberscript.EntityManager[tag]=entity - - - end - - - logme(10,"spawn item. item tweak : "..chara.." position : "..dump(spawnedItem)) - spdlog.error("spawn item. item tweak : "..chara.." position : "..dump(spawnedItem)) - else - error("bad item or position. item tweak : "..chara.." position : "..dump(position)) - end - end - end - - if(action.name == "despawn_item") then - for i=1,#currentItemSpawned do - if(currentItemSpawned[i].Tag == action.tag) then - despawnItem(currentItemSpawned[i].entityId) - end - - end - end - - if(action.name == "set_entity_stat") then - --https://nativedb.red4ext.com/gamedataStatType - --https://nativedb.red4ext.com/gameStatModifierType - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - - if(enti ~= nil) then - - - - local newMod = gameConstantStatModifierData.new() - newMod.statType = Enum.new('gamedataStatType', action.stat) - newMod.modifierType = Enum.new('gameStatModifierType', action.modifierType) - newMod.value = action.value - - Game.GetStatsSystem():AddModifier(obj.id,newmod) - end - end - - - - if(action.name == "for_entity_around_you") then - - player = Game.GetPlayer() - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects - searchQuery.maxDistance = action.range - success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) - - cyberscript.GroupManager["temp_around_group"] = {} - cyberscript.GroupManager["temp_around_group"].tag = "temp_around_group" - cyberscript.GroupManager["temp_around_group"].entities = {} - - local counter = 0 - local max = 9999 - if(action.limit ~= nil and action.limit ~= 0) then max = action.limit end - - for _, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - - - - local goodEntity = false - - if(action.filter ~= nil and #action.filter > 0) then - - - local entName = newent:ToString() - local entAppName = Game.NameToString(newent:GetCurrentAppearanceName()) - local entDispName = newent:GetDisplayName() - - if(entName ~= nil and entAppName ~= nil)then - for i,filter in ipairs(action.filter) do - - if(goodEntity == false and (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and - string.match(entName, filter) or - - string.match(entAppName, filter) or string.match(entDispName, filter))then - goodEntity = true - end - end - end - - - - else - - goodEntity = true - - end - - - local tag = "scripted_around_"..math.random(0,9999) - - local obj2 = getEntityFromManagerById(newent:GetEntityID(),true) - - - if (cyberscript.EntityManager[tag] == nil and goodEntity == true and counter <= max) then - - local entity = {} - if(obj2.id == nil) then - - - print(#parts) - print(newent:GetDisplayName()) - - entity.id = newent:GetEntityID() - entity.tag = tag - entity.tweak = "None" - entity.iscompanion = false - - cyberscript.EntityManager[tag]=entity + if(action.name == "change_camera_position") then + local fppComp = Game.GetPlayer():GetFPPCameraComponent() + fppComp:SetLocalPosition(Vector4:new(action.x, action.y, action.z, 1.0)) + end + if(action.name == "change_camera_rotation") then + local fppComp = Game.GetPlayer():GetFPPCameraComponent() + fppComp:SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(action.roll, action.pitch, action.yaw))) + end + if(action.name == "add_camera_position") then + local fppComp = Game.GetPlayer():GetFPPCameraComponent() + local pos = fppComp:GetLocalPosition() + pos.x = pos.x + action.x + pos.y = pos.y + action.y + pos.x = pos.z + action.z + fppComp:SetLocalPosition(Vector4:new(pos.x, pos.y, pos.z, 1.0)) + end + if(action.name == "add_camera_rotation") then + local fppComp = Game.GetPlayer():GetFPPCameraComponent() + local pos = fppComp:GetLocalOrientation() + local rot = GetSingleton('Quaternion'):ToEulerAngles(pos) + rot.yaw = rot.yaw + action.yaw + rot.pitch = rot.pitch + action.pitch + rot.roll = rot.roll + action.roll + fppComp:SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(rot.roll, rot.pitch, rot.yaw))) + end + if(action.name == "reset_camera") then + local fppComp = Game.GetPlayer():GetFPPCameraComponent() + fppComp:SetLocalPosition(Vector4:new(0, 0, 0, 1.0)) + fppComp:SetLocalOrientation(GetSingleton('EulerAngles'):ToQuat(EulerAngles.new(0, 0, 0))) + end + if(action.name == "execute_at_script_level") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + if(obj.scriptlevel == nil or obj.scriptlevel <= action.scriptlevel) then + + runSubActionList(action.action, tag.."_execute_at_level", tag,source,false,obj.tag) + + end + end + + end + + if(action.name == "set_script_level") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + obj.scriptlevel = action.scriptlevel + + end + + end + + if(action.name == "player_toggle_invisible") then + PlayerToggleInvisible(action.value) + end + + if(action.name == "player_toggle_v_component_visibility") then + toggleVBodyComponent(action.value) + end + + if(action.name == "spawn_item") then + local chara = "" + if(action.amount == nil) then + action.amount = 1 + end + if(action.amount == 0) then + action.amount = math.random(1,6) + end + for i=1,action.amount do + + + chara = action.path + + + + local tag = action.tag + if(action.amount > 1) then + tag = action.tag.."_"..i + end + local position = getPositionFromParameter(action) + if(chara ~= "" and chara ~= nil and position.x ~= nil) then + + local spawnedItem = {} + + spawnedItem.Tag = tag + spawnedItem.HouseTag = "" + spawnedItem.ItemPath = chara + spawnedItem.X = position.x + spawnedItem.Y = position.y + spawnedItem.Z = position.z + + spawnedItem.Yaw = action.yaw + spawnedItem.Pitch = action.pitch + spawnedItem.Roll = action.roll + spawnedItem.Title = chara + + local angles = EulerAngles.new(spawnedItem.Yaw,spawnedItem.Pitch,spawnedItem.Roll) + local posVec4 = Vector4.new(position.x, position.y, position.z,1) + spawnedItem.entityId = spawnItem(spawnedItem, posVec4, angles) + local entity = safeFindEntityByID(spawnedItem.entityId) + local components = checkForValidComponents(entity) + if components then + local visualScale = checkDefaultScale(components) + spawnedItem.defaultScale = { + x = visualScale.x * 100, + y = visualScale.x * 100, + z = visualScale.x * 100, + } + spawnedItem.scale = { + x = visualScale.x * 100, + y = visualScale.y * 100, + z = visualScale.z * 100, + } + end + if(action.isentity == nil or action.isentity == false) then + + + + table.insert(currentItemSpawned,spawnedItem) + + else + + local entity = {} + entity.id = spawnedItem.entityId + entity.tag = tag + entity.tweak = chara + entity.isprevention = false + entity.scriptlevel = 0 + + entity.isMP = false + entity.name = tag + cyberscript.EntityManager[tag]=entity + + + end + + + logme(10,"spawn item. item tweak : "..chara.." position : "..dump(spawnedItem)) + spdlog.error("spawn item. item tweak : "..chara.." position : "..dump(spawnedItem)) + else + error("bad item or position. item tweak : "..chara.." position : "..dump(position)) + end + end + end + + if(action.name == "despawn_item") then + for i=1,#currentItemSpawned do + if(currentItemSpawned[i].Tag == action.tag) then + despawnItem(currentItemSpawned[i].entityId) + end + + end + end + + if(action.name == "set_entity_stat") then + --https://nativedb.red4ext.com/gamedataStatType + --https://nativedb.red4ext.com/gameStatModifierType + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + + if(enti ~= nil) then + + + + local newMod = gameConstantStatModifierData.new() + newMod.statType = Enum.new('gamedataStatType', action.stat) + newMod.modifierType = Enum.new('gameStatModifierType', action.modifierType) + newMod.value = action.value + + Game.GetStatsSystem():AddModifier(obj.id,newmod) + end + end + + + + if(action.name == "for_entity_around_you") then + + player = Game.GetPlayer() + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_ALL;"]() -- Search ALL objects + searchQuery.maxDistance = action.range + success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) + + cyberscript.GroupManager["temp_around_group"] = {} + cyberscript.GroupManager["temp_around_group"].tag = "temp_around_group" + cyberscript.GroupManager["temp_around_group"].entities = {} + + local counter = 0 + local max = 9999 + if(action.limit ~= nil and action.limit ~= 0) then max = action.limit end + + for _, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + + + + local goodEntity = false + + if(action.filter ~= nil and #action.filter > 0) then + + + local entName = newent:ToString() + local entAppName = Game.NameToString(newent:GetCurrentAppearanceName()) + local entDispName = newent:GetDisplayName() + + if(entName ~= nil and entAppName ~= nil)then + for i,filter in ipairs(action.filter) do + + if(goodEntity == false and (filter ~= "isnpc" or (filter == "isnpc" and newent:IsA("NPCPuppet"))) and + string.match(entName, filter) or + + string.match(entAppName, filter) or string.match(entDispName, filter))then + goodEntity = true + end + end + end + + + + else + + goodEntity = true + + end + + + local tag = "scripted_around_"..math.random(0,9999) + + local obj2 = getEntityFromManagerById(newent:GetEntityID(),true) + + + if (cyberscript.EntityManager[tag] == nil and goodEntity == true and counter <= max) then + + local entity = {} + if(obj2.id == nil) then + + + print(#parts) + print(newent:GetDisplayName()) + + entity.id = newent:GetEntityID() + entity.tag = tag + entity.tweak = "None" + entity.iscompanion = false + + cyberscript.EntityManager[tag]=entity - if(obj2.id ~= nil) then -- means it exist already in manager - - cyberscript.EntityManager[tag].tag = obj2.tag - entity.tag = obj2.tag - end + if(obj2.id ~= nil) then -- means it exist already in manager + + cyberscript.EntityManager[tag].tag = obj2.tag + entity.tag = obj2.tag + end - else - - entity.tag = obj2.tag + else + + entity.tag = obj2.tag - - end - - + + end + + - if(action.group == nil or action.group == "") then - - - table.insert(cyberscript.GroupManager["temp_around_group"].entities,entity.tag) - - - - else - - if(cyberscript.GroupManager[action.group] ~= nil) then - table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) - else - - error("no group founded") - - end - - end - - - if(#action.action > 0) then - runActionList(action.action, tag.."_forentitylist", parent,source,false,entity.tag) end - - - end + if(action.group == nil or action.group == "") then + + + table.insert(cyberscript.GroupManager["temp_around_group"].entities,entity.tag) + + + + else + + if(cyberscript.GroupManager[action.group] ~= nil) then + table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) + else + + error("no group founded") + + end + + end + + + if(#action.action > 0) then + runActionList(action.action, tag.."_forentitylist", parent,source,false,entity.tag) end + + + end - counter = counter +1 - - - - end - end - - - if(action.name == "for_enemy_around_you") then - - player = Game.GetPlayer() - targetingSystem = Game.GetTargetingSystem() - parts = {} - local success= false - searchQuery = Game["TSQ_EnemyNPC;"]() -- Search ALL objects - searchQuery.maxDistance = action.range - success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) - - cyberscript.GroupManager["temp_enemy_around_group"] = {} - cyberscript.GroupManager["temp_enemy_around_group"].tag = "temp_enemy_around_group" - cyberscript.GroupManager["temp_enemy_around_group"].entities = {} - print(#parts) - local counter = 0 - local max = 9999 - if(action.limit ~= nil and action.limit ~= 0) then max = action.limit end - - for _, v in ipairs(parts) do - local newent = v:GetComponent(v):GetEntity() - local goodEntity = false - - if(action.filter ~= nil and #action.filter > 0) then - - - local entName = newent:ToString() - local entAppName = Game.NameToString(newent:GetCurrentAppearanceName()) - local entDispName = newent:GetDisplayName() - - if(entName ~= nil and entAppName ~= nil)then - for i,filter in ipairs(action.filter) do - - if(goodEntity == false and string.match(entName, filter) or string.match(entAppName, filter) or string.match(entDispName, filter))then - goodEntity = true - end - end - end - - - - else - - goodEntity = true - - end - - - local tag = "scripted_enemy_around_"..math.random(0,9999) - local obj2 = getEntityFromManagerById(newent:GetEntityID(),true) - + counter = counter +1 + + + + end + end + + + if(action.name == "for_enemy_around_you") then + + player = Game.GetPlayer() + targetingSystem = Game.GetTargetingSystem() + parts = {} + local success= false + searchQuery = Game["TSQ_EnemyNPC;"]() -- Search ALL objects + searchQuery.maxDistance = action.range + success, parts = targetingSystem:GetTargetParts(Game.GetPlayer(), searchQuery) + + cyberscript.GroupManager["temp_enemy_around_group"] = {} + cyberscript.GroupManager["temp_enemy_around_group"].tag = "temp_enemy_around_group" + cyberscript.GroupManager["temp_enemy_around_group"].entities = {} + print(#parts) + local counter = 0 + local max = 9999 + if(action.limit ~= nil and action.limit ~= 0) then max = action.limit end + + for _, v in ipairs(parts) do + local newent = v:GetComponent(v):GetEntity() + local goodEntity = false + + if(action.filter ~= nil and #action.filter > 0) then + + + local entName = newent:ToString() + local entAppName = Game.NameToString(newent:GetCurrentAppearanceName()) + local entDispName = newent:GetDisplayName() + + if(entName ~= nil and entAppName ~= nil)then + for i,filter in ipairs(action.filter) do + + if(goodEntity == false and string.match(entName, filter) or string.match(entAppName, filter) or string.match(entDispName, filter))then + goodEntity = true + end + end + end + + + + else + + goodEntity = true + + end + + + local tag = "scripted_enemy_around_"..math.random(0,9999) + local obj2 = getEntityFromManagerById(newent:GetEntityID(),true) + - if (cyberscript.EntityManager[tag] == nil and goodEntity == true and counter <= max) then - - local entity = {} - if(obj2.id == nil) then - - - print(#parts) - print(newent:GetDisplayName()) - - entity.id = newent:GetEntityID() - entity.tag = tag - entity.tweak = "None" - entity.iscompanion = false - - cyberscript.EntityManager[tag]=entity + if (cyberscript.EntityManager[tag] == nil and goodEntity == true and counter <= max) then + + local entity = {} + if(obj2.id == nil) then + + + print(#parts) + print(newent:GetDisplayName()) + + entity.id = newent:GetEntityID() + entity.tag = tag + entity.tweak = "None" + entity.iscompanion = false + + cyberscript.EntityManager[tag]=entity - if(obj2.id ~= nil) then -- means it exist already in manager - - cyberscript.EntityManager[tag].tag = obj2.tag - entity.tag = obj2.tag - end + if(obj2.id ~= nil) then -- means it exist already in manager + + cyberscript.EntityManager[tag].tag = obj2.tag + entity.tag = obj2.tag + end - else - - entity.tag = obj2.tag + else + + entity.tag = obj2.tag - - end - - + + end + + - if(action.group == nil or action.group == "") then - - - table.insert(cyberscript.GroupManager["temp_around_group"].entities,entity.tag) - - - - else - - if(cyberscript.GroupManager[action.group] ~= nil) then - table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) - else - - error("no group founded") - - end - - end - - - if(#action.action > 0) then - runActionList(action.action, tag.."_forentitylist", parent,source,false,entity.tag) end - end - counter = counter +1 - - - end - - - end - - end - - if scannerregion then - - if(action.name == "set_scannerdata") then - - - - ScannerInfoManager[action.tag] = {} - ScannerInfoManager[action.tag].primaryname = getLang(action.primaryname) - ScannerInfoManager[action.tag].secondaryname = getLang(action.secondaryname) - ScannerInfoManager[action.tag].level = action.level - ScannerInfoManager[action.tag].rarity = action.rarity - ScannerInfoManager[action.tag].faction = action.faction - ScannerInfoManager[action.tag].networkstate = "" - ScannerInfoManager[action.tag].text = getLang("cyberscript_scanner_"..action.text) - -- ----print(action.text) - ScannerInfoManager[action.tag].attitude = action.attitude - - if(action.bounty ~= nil) then - ScannerInfoManager[action.tag].bounty = action.bounty - ScannerInfoManager[action.tag].bounty.issuedby = getLang(action.bounty.issuedby) - end - - - - - - - end - if(action.name == "give_reward_from_scannerdata") then - if(ScannerInfoManager[action.tag] ~= nil and ScannerInfoManager[action.tag].bounty ~= nil) then - - local player = Game.GetPlayer() - local ts = Game.GetTransactionSystem() - local tid = TweakDBID.new("Items.money") - local itemid = ItemID.new(tid) - local amount = tonumber(ScannerInfoManager[action.tag].bounty.reward) - - local result = ts:GiveItem(player, itemid, amount) - - Game.GetStatPoolsSystem():RequestChangingStatPoolValue(Game.GetPlayer():GetEntityID(), 948, ScannerInfoManager[action.tag].bounty.streetreward, Game.GetPlayer(), true, false) - - - - end - - end - - if(action.name == "edit_scannerdata") then - - - if( - action.prop == "primaryname" - or action.prop == "secondaryname" - or action.prop == "text" - or action.prop == "level" - or action.prop == "rarity" - or action.prop == "faction" - or action.prop == "attitude" - ) then - - if('string' == type(action.value)) then - - ScannerInfoManager[action.tag][action.prop] = getLang(action.value) - else - - - - - ScannerInfoManager[action.tag][action.prop] = action.value - end - - end - - - if( - action.prop == "danger" - or action.prop == "reward" - or action.prop == "streetreward" - or action.prop == "issuedby" - ) then - - if(ScannerInfoManager[action.tag].bounty == nil) then - ScannerInfoManager[action.tag].bounty = {} - ScannerInfoManager[action.tag].bounty.danger = 0 - ScannerInfoManager[action.tag].bounty.reward = 0 - ScannerInfoManager[action.tag].bounty.streetreward = 0 - ScannerInfoManager[action.tag].bounty.issuedby = "Unknown" - ScannerInfoManager[action.tag]["bounty"]["transgressions"] = {} - ScannerInfoManager[action.tag]["bounty"]["customtransgressions"] = {} - - end - - if('string' == type(action.value)) then - - ScannerInfoManager[action.tag]["bounty"][action.prop] = getLang(action.value) - else - - if(action.prop == "reward" or action.prop == "streetreward" ) then - if(action.operator == "+") then - ScannerInfoManager[action.tag]["bounty"][action.prop] = ScannerInfoManager[action.tag]["bounty"][action.prop] + action.value - end - if(action.operator == "-") then - ScannerInfoManager[action.tag]["bounty"][action.prop] = ScannerInfoManager[action.tag]["bounty"][action.prop] - action.value - end - if(action.operator == "*") then - ScannerInfoManager[action.tag]["bounty"][action.prop] = ScannerInfoManager[action.tag]["bounty"][action.prop] * action.value - end - if(action.operator == "/") then - ScannerInfoManager[action.tag]["bounty"][action.prop] = ScannerInfoManager[action.tag]["bounty"][action.prop] / action.value - end - if(action.operator == "positive") then - if(ScannerInfoManager[action.tag]["bounty"][action.prop] > 0) then - ScannerInfoManager[action.tag]["bounty"][action.prop] = 0 + ScannerInfoManager[action.tag]["bounty"][action.prop] - else - ScannerInfoManager[action.tag]["bounty"][action.prop] = 0 - ScannerInfoManager[action.tag]["bounty"][action.prop] - end - end - if(action.operator == "negative") then - if(ScannerInfoManager[action.tag]["bounty"][action.prop] > 0) then - ScannerInfoManager[action.tag]["bounty"][action.prop] = 0 - ScannerInfoManager[action.tag]["bounty"][action.prop] - else - ScannerInfoManager[action.tag]["bounty"][action.prop] = 0 + ScannerInfoManager[action.tag]["bounty"][action.prop] - end - end - if(action.operator == "random") then - ScannerInfoManager[action.tag]["bounty"][action.prop] = math.random(action.min,action.max) - end - - if(action.operator == "" or action.operator == "=" or action.operator == nil) then - ScannerInfoManager[action.tag]["bounty"][action.prop] = action.value - end - else - ScannerInfoManager[action.tag]["bounty"][action.prop] = action.value - end - - - end - - - end - - if( - action.prop == "transgressions" - or action.prop == "customtransgressions" - - ) then - - if(ScannerInfoManager[action.tag].bounty == nil) then - ScannerInfoManager[action.tag].bounty = {} - ScannerInfoManager[action.tag].bounty.danger = 0 - ScannerInfoManager[action.tag].bounty.reward = 0 - ScannerInfoManager[action.tag].bounty.streetreward = 0 - ScannerInfoManager[action.tag].bounty.issuedby = "Unknown" - ScannerInfoManager[action.tag]["bounty"]["transgressions"] = {} - ScannerInfoManager[action.tag]["bounty"]["customtransgressions"] = {} - - end - - - - ScannerInfoManager[action.tag]["bounty"][action.prop] = action.value - - - - end - - - - - - - - end - - if(action.name == "delete_scannerdata") then - - - ScannerInfoManager[action.tag] = nil - - - - - - end - - - end - - if animationregion then - if action.name == "play_anim_entity" then - - local angle = nil - - if(action.yaw ~= nil and action.roll ~= nil and action.pitch ~= nil ) then - - angle = {} - angle.yaw = action.yaw - angle.roll = action.pitch - angle.roll = action.pitch - - - end - - - spawnCustomAnimationWorkspot(action.tag,[[base\cyberscript\entity\workspot_anim.ent]],action.anim,"cyberscript_workspot_base",action.isinstant,action.unlockcamera,angle) - end - - if action.name == "play_custom_anim_entity" then - - local angle = nil - - if((action.angle == true or action.angle == nil) and action.yaw ~= nil and action.roll ~= nil and action.pitch ~= nil ) then - - angle = {} - angle.yaw = action.yaw - angle.pitch = action.pitch - angle.roll = action.roll - - - end - - spawnCustomAnimationWorkspot(action.tag,action.ent,action.anim,action.workspot,action.isinstant,action.unlockcamera,angle) - end - - if action.name == "pause_entity_anim" then - - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil and obj.animation ~= nil) then - - TimeDilationHelper.SetIndividualTimeDilation(enti, "see_engine", 0.0000000000001, 99999, "", ""); - - - - end - end - - if action.name == "resume_entity_anim" then - - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil and obj.animation ~= nil and obj.workspot_name ~= nil) then - - - TimeDilationHelper.UnsetIndividualTimeDilation(enti); - - local angle = nil - local anims = obj.animation - local workspot_name = obj.workspot_name - local workspot_ent = obj.workspot_ent - if((action.angle == true or action.angle == nil) and action.yaw ~= nil and action.roll ~= nil and action.pitch ~= nil ) then - - angle = {} - angle.yaw = action.yaw - angle.pitch = action.pitch - angle.roll = action.roll - - - end - - spawnCustomAnimationWorkspot(action.tag,workspot_ent,anims,workspot_name,true,true,angle) - - end - end - - if action.name == "change_anim_entity" then - - - - changeWorkSpotAnims(action.tag,action.anim,action.isinstant) - end + if(action.group == nil or action.group == "") then + + + table.insert(cyberscript.GroupManager["temp_around_group"].entities,entity.tag) + + + + else + + if(cyberscript.GroupManager[action.group] ~= nil) then + table.insert(cyberscript.GroupManager[action.group].entities,entity.tag) + else + + error("no group founded") + + end + + end + + + if(#action.action > 0) then + runActionList(action.action, tag.."_forentitylist", parent,source,false,entity.tag) end + end + counter = counter +1 + + + end + + + end + + end + + if scannerregion then + + if(action.name == "set_scannerdata") then + + + + ScannerInfoManager[action.tag] = {} + ScannerInfoManager[action.tag].primaryname = getLang(action.primaryname) + ScannerInfoManager[action.tag].secondaryname = getLang(action.secondaryname) + ScannerInfoManager[action.tag].level = action.level + ScannerInfoManager[action.tag].rarity = action.rarity + ScannerInfoManager[action.tag].faction = action.faction + ScannerInfoManager[action.tag].networkstate = "" + ScannerInfoManager[action.tag].text = getLang("cyberscript_scanner_"..action.text) + -- ----print(action.text) + ScannerInfoManager[action.tag].attitude = action.attitude + + if(action.bounty ~= nil) then + ScannerInfoManager[action.tag].bounty = action.bounty + ScannerInfoManager[action.tag].bounty.issuedby = getLang(action.bounty.issuedby) + end + + + + + + + end + if(action.name == "give_reward_from_scannerdata") then + if(ScannerInfoManager[action.tag] ~= nil and ScannerInfoManager[action.tag].bounty ~= nil) then + + local player = Game.GetPlayer() + local ts = Game.GetTransactionSystem() + local tid = TweakDBID.new("Items.money") + local itemid = ItemID.new(tid) + local amount = tonumber(ScannerInfoManager[action.tag].bounty.reward) + + local result = ts:GiveItem(player, itemid, amount) + + Game.GetStatPoolsSystem():RequestChangingStatPoolValue(Game.GetPlayer():GetEntityID(), 948, ScannerInfoManager[action.tag].bounty.streetreward, Game.GetPlayer(), true, false) + + + + end + + end + + if(action.name == "edit_scannerdata") then + + + if( + action.prop == "primaryname" + or action.prop == "secondaryname" + or action.prop == "text" + or action.prop == "level" + or action.prop == "rarity" + or action.prop == "faction" + or action.prop == "attitude" + ) then + + if('string' == type(action.value)) then + + ScannerInfoManager[action.tag][action.prop] = getLang(action.value) + else + + + + + ScannerInfoManager[action.tag][action.prop] = action.value + end + + end + + + if( + action.prop == "danger" + or action.prop == "reward" + or action.prop == "streetreward" + or action.prop == "issuedby" + ) then + + if(ScannerInfoManager[action.tag].bounty == nil) then + ScannerInfoManager[action.tag].bounty = {} + ScannerInfoManager[action.tag].bounty.danger = 0 + ScannerInfoManager[action.tag].bounty.reward = 0 + ScannerInfoManager[action.tag].bounty.streetreward = 0 + ScannerInfoManager[action.tag].bounty.issuedby = "Unknown" + ScannerInfoManager[action.tag]["bounty"]["transgressions"] = {} + ScannerInfoManager[action.tag]["bounty"]["customtransgressions"] = {} + + end + + if('string' == type(action.value)) then + + ScannerInfoManager[action.tag]["bounty"][action.prop] = getLang(action.value) + else + + if(action.prop == "reward" or action.prop == "streetreward" ) then + if(action.operator == "+") then + ScannerInfoManager[action.tag]["bounty"][action.prop] = ScannerInfoManager[action.tag]["bounty"][action.prop] + action.value + end + if(action.operator == "-") then + ScannerInfoManager[action.tag]["bounty"][action.prop] = ScannerInfoManager[action.tag]["bounty"][action.prop] - action.value + end + if(action.operator == "*") then + ScannerInfoManager[action.tag]["bounty"][action.prop] = ScannerInfoManager[action.tag]["bounty"][action.prop] * action.value + end + if(action.operator == "/") then + ScannerInfoManager[action.tag]["bounty"][action.prop] = ScannerInfoManager[action.tag]["bounty"][action.prop] / action.value + end + if(action.operator == "positive") then + if(ScannerInfoManager[action.tag]["bounty"][action.prop] > 0) then + ScannerInfoManager[action.tag]["bounty"][action.prop] = 0 + ScannerInfoManager[action.tag]["bounty"][action.prop] + else + ScannerInfoManager[action.tag]["bounty"][action.prop] = 0 - ScannerInfoManager[action.tag]["bounty"][action.prop] + end + end + if(action.operator == "negative") then + if(ScannerInfoManager[action.tag]["bounty"][action.prop] > 0) then + ScannerInfoManager[action.tag]["bounty"][action.prop] = 0 - ScannerInfoManager[action.tag]["bounty"][action.prop] + else + ScannerInfoManager[action.tag]["bounty"][action.prop] = 0 + ScannerInfoManager[action.tag]["bounty"][action.prop] + end + end + if(action.operator == "random") then + ScannerInfoManager[action.tag]["bounty"][action.prop] = math.random(action.min,action.max) + end + + if(action.operator == "" or action.operator == "=" or action.operator == nil) then + ScannerInfoManager[action.tag]["bounty"][action.prop] = action.value + end + else + ScannerInfoManager[action.tag]["bounty"][action.prop] = action.value + end + + + end + + + end + + if( + action.prop == "transgressions" + or action.prop == "customtransgressions" + + ) then + + if(ScannerInfoManager[action.tag].bounty == nil) then + ScannerInfoManager[action.tag].bounty = {} + ScannerInfoManager[action.tag].bounty.danger = 0 + ScannerInfoManager[action.tag].bounty.reward = 0 + ScannerInfoManager[action.tag].bounty.streetreward = 0 + ScannerInfoManager[action.tag].bounty.issuedby = "Unknown" + ScannerInfoManager[action.tag]["bounty"]["transgressions"] = {} + ScannerInfoManager[action.tag]["bounty"]["customtransgressions"] = {} + + end + + + + ScannerInfoManager[action.tag]["bounty"][action.prop] = action.value + + + + end + + + + + + + + end + + if(action.name == "delete_scannerdata") then + + + ScannerInfoManager[action.tag] = nil + + + + + + end + + + end + + if animationregion then + if action.name == "play_anim_entity" then + + local angle = nil + + if(action.yaw ~= nil and action.roll ~= nil and action.pitch ~= nil ) then + + angle = {} + angle.yaw = action.yaw + angle.roll = action.pitch + angle.roll = action.pitch + + + end + + + spawnCustomAnimationWorkspot(action.tag,[[base\cyberscript\entity\workspot_anim.ent]],action.anim,"cyberscript_workspot_base",action.isinstant,action.unlockcamera,angle) + end + + if action.name == "play_custom_anim_entity" then + + local angle = nil + + if((action.angle == true or action.angle == nil) and action.yaw ~= nil and action.roll ~= nil and action.pitch ~= nil ) then + + angle = {} + angle.yaw = action.yaw + angle.pitch = action.pitch + angle.roll = action.roll + + + end + + spawnCustomAnimationWorkspot(action.tag,action.ent,action.anim,action.workspot,action.isinstant,action.unlockcamera,angle) + end + + if action.name == "pause_entity_anim" then + + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil and obj.animation ~= nil) then + + TimeDilationHelper.SetIndividualTimeDilation(enti, "see_engine", 0.0000000000001, 99999, "", ""); + + + + end + end + + if action.name == "resume_entity_anim" then + + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil and obj.animation ~= nil and obj.workspot_name ~= nil) then + + + TimeDilationHelper.UnsetIndividualTimeDilation(enti); + + local angle = nil + local anims = obj.animation + local workspot_name = obj.workspot_name + local workspot_ent = obj.workspot_ent + if((action.angle == true or action.angle == nil) and action.yaw ~= nil and action.roll ~= nil and action.pitch ~= nil ) then + + angle = {} + angle.yaw = action.yaw + angle.pitch = action.pitch + angle.roll = action.roll + + + end + + spawnCustomAnimationWorkspot(action.tag,workspot_ent,anims,workspot_name,true,true,angle) + + end + end + + if action.name == "change_anim_entity" then + + + + changeWorkSpotAnims(action.tag,action.anim,action.isinstant) + end - if action.name == "play_several_anim_entity" then - - local actiontemp = {} - for i,anim in ipairs(action.anims) do - local changewk = false - checkContext(anim) - if(animpack.anims[i-1]~= nil) then - - if - (action.anims[i-1].workspot ~= nil and action.anims[i-1].workspot ~= anim.workspot) or - (cyberscript.EntityManager[entitytag].workspot_name ~= nil and cyberscript.EntityManager[entitytag].workspot_name ~= anim.workspot) - then - changewk = true - print( anim.anim.." changewk") - end + if action.name == "play_several_anim_entity" then + + local actiontemp = {} + for i,anim in ipairs(action.anims) do + local changewk = false + checkContext(anim) + if(animpack.anims[i-1]~= nil) then + + if + (action.anims[i-1].workspot ~= nil and action.anims[i-1].workspot ~= anim.workspot) or + (cyberscript.EntityManager[entitytag].workspot_name ~= nil and cyberscript.EntityManager[entitytag].workspot_name ~= anim.workspot) + then + changewk = true + print( anim.anim.." changewk") + end - end - - if(changewk == true) then - local wkmyaction = deepcopy(cyberscript.actiontemplate["change_play_anim_entity_workspot"],nil) - wkmyaction.workspottag = action.tag.."_workspot" - wkmyaction.workspot = anim.workspot - wkmyaction.unlockcamera = anim.unlockcamera or false - table.insert(actiontemp,wkmyaction) + end + + if(changewk == true) then + local wkmyaction = deepcopy(cyberscript.actiontemplate["change_play_anim_entity_workspot"],nil) + wkmyaction.workspottag = action.tag.."_workspot" + wkmyaction.workspot = anim.workspot + wkmyaction.unlockcamera = anim.unlockcamera or false + table.insert(actiontemp,wkmyaction) - local wkmyaction = deepcopy(cyberscript.actiontemplate["wait_tick"],nil) - wkmyaction.value =30 - table.insert(actiontemp,wkmyaction) - - end + local wkmyaction = deepcopy(cyberscript.actiontemplate["wait_tick"],nil) + wkmyaction.value =30 + table.insert(actiontemp,wkmyaction) + + end - local myaction = deepcopy(cyberscript.actiontemplate["change_anim_entity"],nil) - myaction.tag = action.tag - myaction.anim = anim.anim - myaction.isinstant = anim.isinstant - - table.insert(actiontemp,myaction) + local myaction = deepcopy(cyberscript.actiontemplate["change_anim_entity"],nil) + myaction.tag = action.tag + myaction.anim = anim.anim + myaction.isinstant = anim.isinstant + + table.insert(actiontemp,myaction) - local myaction = deepcopy(cyberscript.actiontemplate["wait_tick"],nil) - myaction.value =anim.timer - table.insert(actiontemp,myaction) - - - end - - - + local myaction = deepcopy(cyberscript.actiontemplate["wait_tick"],nil) + myaction.value =anim.timer + table.insert(actiontemp,myaction) + + + end + + + - if(action.parallele == nil or action.parallele == false)then - - - runSubActionList(actiontemp,tag.."play_several_anim_entity",tag, source,false,executortag,false) - result=false - else - - runActionList(actiontemp,"play_several_anim_entity"..action.tag, source,false,executortag,false) - - - end + if(action.parallele == nil or action.parallele == false)then + + + runSubActionList(actiontemp,tag.."play_several_anim_entity",tag, source,false,executortag,false) + result=false + else + + runActionList(actiontemp,"play_several_anim_entity"..action.tag, source,false,executortag,false) + + + end - - end + + end - if action.name == "play_animpack_entity" then - print( "play_animpack_entity") - if(cyberscript.cache["animpack"][action.packtag] ~= nil) then - local animpack = cyberscript.cache["animpack"][action.packtag].data + if action.name == "play_animpack_entity" then + print( "play_animpack_entity") + if(cyberscript.cache["animpack"][action.packtag] ~= nil) then + local animpack = cyberscript.cache["animpack"][action.packtag].data - local actiontemp = {} - for i,anim in ipairs(animpack.anims) do - local changewk = false - checkContext(anim) - if(animpack.anims[i-1]~= nil) then - - if - (animpack.anims[i-1].workspot ~= nil and animpack.anims[i-1].workspot ~= anim.workspot) or - (cyberscript.EntityManager[action.tag].workspot_name ~= nil and cyberscript.EntityManager[action.tag].workspot_name ~= anim.workspot) - then - changewk = true - print( anim.anim.." changewk") - end + local actiontemp = {} + for i,anim in ipairs(animpack.anims) do + local changewk = false + checkContext(anim) + if(animpack.anims[i-1]~= nil) then + + if + (animpack.anims[i-1].workspot ~= nil and animpack.anims[i-1].workspot ~= anim.workspot) or + (cyberscript.EntityManager[action.tag].workspot_name ~= nil and cyberscript.EntityManager[action.tag].workspot_name ~= anim.workspot) + then + changewk = true + print( anim.anim.." changewk") + end - end - + end + - + - if(changewk == true) then - local wkmyaction = deepcopy(cyberscript.actiontemplate["change_play_anim_entity_workspot"],nil) - wkmyaction.workspottag = action.tag.."_workspot" - wkmyaction.workspot = anim.workspot - wkmyaction.unlockcamera = anim.unlockcamera or false - table.insert(actiontemp,wkmyaction) + if(changewk == true) then + local wkmyaction = deepcopy(cyberscript.actiontemplate["change_play_anim_entity_workspot"],nil) + wkmyaction.workspottag = action.tag.."_workspot" + wkmyaction.workspot = anim.workspot + wkmyaction.unlockcamera = anim.unlockcamera or false + table.insert(actiontemp,wkmyaction) - local wkmyaction = deepcopy(cyberscript.actiontemplate["wait_tick"],nil) - wkmyaction.value =30 - table.insert(actiontemp,wkmyaction) - - end + local wkmyaction = deepcopy(cyberscript.actiontemplate["wait_tick"],nil) + wkmyaction.value =30 + table.insert(actiontemp,wkmyaction) + + end - - local myaction = deepcopy(cyberscript.actiontemplate["change_anim_entity"],nil) - myaction.tag = action.tag - myaction.anim = anim.anim - myaction.isinstant = anim.isinstant - - - table.insert(actiontemp,myaction) + + local myaction = deepcopy(cyberscript.actiontemplate["change_anim_entity"],nil) + myaction.tag = action.tag + myaction.anim = anim.anim + myaction.isinstant = anim.isinstant + + + table.insert(actiontemp,myaction) - local myaction = deepcopy(cyberscript.actiontemplate["wait_tick"],nil) - myaction.value =anim.timer - table.insert(actiontemp,myaction) - - - end - if(action.parallele == nil or action.parallele == false)then - - runSubActionList(actiontemp,tag.."play_animpack_entity",tag, source,false,executortag,false) - - result=false - else - - runActionList(actiontemp,"play_animpack_entity"..action.tag.."_"..action.packtag, source,false,executortag,false) - - - end - - - end - end - - if action.name == "change_anim_entity_workspot" then - - - changeWorkSpot(action.tag,action.workspottag,action.workspot,action.unlockcamera) - - - end + local myaction = deepcopy(cyberscript.actiontemplate["wait_tick"],nil) + myaction.value =anim.timer + table.insert(actiontemp,myaction) + + + end + if(action.parallele == nil or action.parallele == false)then + + runSubActionList(actiontemp,tag.."play_animpack_entity",tag, source,false,executortag,false) + + result=false + else + + runActionList(actiontemp,"play_animpack_entity"..action.tag.."_"..action.packtag, source,false,executortag,false) + + + end + + + end + end + + if action.name == "change_anim_entity_workspot" then + + + changeWorkSpot(action.tag,action.workspottag,action.workspot,action.unlockcamera) + + + end - if action.name == "change_play_anim_entity_workspot" then - - - changeWorkSpot(action.tag,action.workspottag,action.workspot,action.unlockcamera) - changeWorkSpotAnims(action.tag,action.anim,action.isinstant) - - end - - if action.name == "stop_anim_entity" then - - - - stopWorkSpotAnims(action.tag) - end - - - if action.name == "enter_in_workspot" then - - - enterInWorkspot(action.tag,action.workspottag,action.workspot,action.unlockcamera) - - end - - if action.name == "play_in_workspot" then - - playAnimInWorkspot(action.tag,action.anim,action.isinstant) - - end - - if action.name == "stop_in_workspot" then - - stopWorkSpotAnims(action.tag) - - end - end - - if logicregion then - if(action.name == "if") then - checkIf(action,tag,source,executortag) - result = false - end - if(action.name == "lightif") then - local trigger = action.trigger - if(checkTrigger(trigger)) then - for i=1,#action.if_action do - local actiontodo = action.if_action[i] - executeAction(actiontodo,tag,parent,index,source,executortag) - end - else - for i=1,#action.else_action do - local actiontodo = action.else_action[i] - actiontodo(actiontodo,tag,parent,index,source,executortag) - end - end - end - if(action.name == "for") then - local actionlist = {} - if(action.amount > 0) then - for i=1,action.amount do - for y=1, #action.action do - table.insert(actionlist,action.action[y]) - end - end - - --logme(3,#actionlist) - --doActionofIndex(actionlist,"interact",listaction,currentindex) - runSubActionList(actionlist, tag.."_forlist", tag,source,false,executortag) - result = false - end - end - if(action.name == "clean_thread") then - workerTable[action.tag] = nil - end - if(action.name == "wait") then - local temp = getGameTime() - local nexttemp = temp - nexttemp.min = nexttemp.min + action.value - if(nexttemp.min > 60) then - nexttemp.min = nexttemp.min-60 - nexttemp.hour = nexttemp.hour+1 - end - if(nexttemp.hour == 25)then - nexttemp.hour = 1 - end - if(nexttemp.hour == 0)then - nexttemp.hour = 24 - end - nexttemp.hour = nexttemp.hour - action.hour = nexttemp.hour - action.min = nexttemp.min - result = false - end - if(action.name == "wait_second") then - local temp = os.time(os.date("!*t"))+0 - --logme(3,temp) - local nexttemp = temp - --logme(3,math.ceil((action.value*60))) - nexttemp =nexttemp + math.ceil(action.value) - --logme(3,nexttemp) - action.tick = nexttemp - result = false - end - if(action.name == "wait_tick") then - local temp = tick - --logme(3,temp) - local nexttemp = temp - --logme(3,math.ceil((action.value*60))) - nexttemp =nexttemp + action.value - --logme(3,nexttemp) - action.tick = nexttemp - result = false - end - if(action.name == "wait_for_trigger") then - result = false - end - if(action.name == "wait_for_framework") then - - result = false - end - if(action.name == "wait_for_ai_answer") then - - result = false - end - if(action.name == "wait_for_target") then - result = false - end - if(action.name == "wait_for_selection") then - enableEntitySelection = true - entitySelectionIsVehicule = action.isvehicule - selectionSlot = action.slot - result = false - end - if(action.name == "clean_selection") then - if(action.slot == 1) then - local obj = getEntityFromManager("selection") - obj.id = nil - end - if(action.slot == 2) then - local obj = getEntityFromManager("selection2") - obj.id = nil - end - if(action.slot == 3) then - local obj = getEntityFromManager("selection3") - obj.id = nil - end - if(action.slot == 4) then - local obj = getEntityFromManager("selection4") - obj.id = nil - end - if(action.slot == 5) then - local obj = getEntityFromManager("selection5") - obj.id = nil - end - end - if(action.name == "clean_all_selection") then - local obj = getEntityFromManager("selection") - obj.id = nil - obj = getEntityFromManager("selection2") - obj.id = nil - obj = getEntityFromManager("selection3") - obj.id = nil - obj = getEntityFromManager("selection4") - obj.id = nil - obj = getEntityFromManager("selection5") - obj.id = nil - end - if(action.name == "do_random_event")then - local tago = math.random(1,#action.events) - local boj = cyberscript.cache["event"][action.events[tago]] - if( boj ~= nil) then - local event = boj.data - if(action.bypass ~= nil and action.bypass == true) then - logme(3,"Doing event : "..event.name) - if(action.parallele == nil or action.parallele == false)then - runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,executortag) - result=false - else - runActionList(event.action, action.value, tag,source,false,executortag) - end - else - local trigger = event.trigger - if(checkTriggerRequirement(event.requirement,trigger))then - --logme(3,"check for "..data2.name) - logme(3,"Doing event : "..event.name) - if(action.parallele == nil or action.parallele == false)then - runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,executortag) - result=false - else - runActionList(event.action, action.value, tag,source,false,executortag) - end - else - logme(3,"can't do event : "..event.name) - end - end - end - - end - if(action.name == "while_one") then - result = false - end - if(action.name == "do_event") then - local boj = cyberscript.cache["event"][action.value] - logme(3,action.value) - if( boj ~= nil) then - local event = boj.data - - - if(action.bypass ~= nil and action.bypass == true) then - logme(3,"Doing event : "..event.name) - if(action.parallele == nil or action.parallele == false)then - runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,executortag) - result=false - else - runActionList(event.action, action.value, tag,source,false,executortag) - end - - else - local trigger = event.trigger - if(checkTriggerRequirement(event.requirement,trigger))then - --logme(3,"check for "..data2.name) - logme(3,"Doing event : "..event.name) - if(action.parallele == nil or action.parallele == false)then - runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,executortag) - result=false - else - runActionList(event.action, action.value, tag,source,false,executortag) - end - else - logme(3,"can't do event : "..event.name) - end - end - - end - - end - if(action.name == "do_function") then - local boj = cyberscript.cache["functions"][action.value] - if( boj ~= nil) then - local event = boj.data - if( boj ~= nil) then - local exector = executortag - local bypassmenu = false - if action.bypassmenu ~= nil then bypassmenu = action.bypassmenu end - if(action.applyto ~= nil and action.applyto ~= "")then - exector = action.applyto - end - - if(action.repeats == nil or action.repeats < 2) then - if(action.parallele == nil or action.parallele == false)then - - - runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,exector,bypassmenu) - - result=false - else - runActionList(event.action,action.value,source,false,exector,bypassmenu) - - - end - else - - local actionlist = {} - - for i=1,action.repeats do - for y=1, #event.action do - table.insert(actionlist,event.action[y]) - end - end - - - if(action.parallele == nil or action.parallele == false)then - - runSubActionList(actionlist, tag.."_event_"..action.value, tag,source,false,exector,bypassmenu) - - result=false - else - - runActionList(actionlist,action.value,source,false,exector,bypassmenu) - - - end - - - end - end - - end - - end - - if(action.name == "goto") then - local index = workerTable[tag]["index"] - local list = workerTable[tag]["action"] - local parent = workerTable[tag]["parent"] - local pending = workerTable[tag]["pending"] - - if(list[index].parent == true) then - logme(3,"Go to"..action.index.." of "..parent) - workerTable[parent]["index"] = action.index-1 - workerTable[tag]["index"] = workerTable[tag]["index"]+1 - workerTable[parent]["pending"] = false - tag = parent - else - logme(3,"Go to"..action.index.." of "..tag) - workerTable[tag]["index"] = action.index - end - end - - - if(action.name == "goto_alias") then - - local index = workerTable[tag]["index"] - local list = workerTable[tag]["action"] - local parent = workerTable[tag]["parent"] - local pending = workerTable[tag]["pending"] - - - for i,v in ipairs(list) do - - if(action.tag == v.alias) then - - if(list[index].parent == true) then - logme(3,"Go to"..i.." of "..parent.."(alias :"..v.tag..")") - workerTable[parent]["index"] = i-1 - workerTable[tag]["index"] = workerTable[tag]["index"]+1 - workerTable[parent]["pending"] = false - tag = parent - else - logme(3,"Go to"..i.." of "..tag.."(alias :"..v.tag..")") - workerTable[tag]["index"] = i - end - - end - - end - - end - - if(action.name == "do_random_function")then - local tago = math.random(1,#action.funcs) - logme(1,action.funcs[tago]) - local boj = cyberscript.cache["functions"][action.funcs[tago]] - if( boj ~= nil) then - - - local exector = executortag - - - if(action.applyto ~= nil and action.applyto ~= "")then - exector = action.applyto - end - - if(action.parallele == nil or action.parallele == false)then - runSubActionList(boj.data.action, tag.."_event_"..tago,parent,source,false,exector) - result=false - else - runActionList(boj.data.action,tago,source,false,exector) - end - end - - end - - - if(action.name == "subscribe_event_to_direct_execution") then - local boj = cyberscript.cache["event"][action.tag] - - if( boj ~= nil) then - local event = boj.data - local trigger = event.trigger - if(checkTriggerRequirement(event.requirement,trigger))then - local obj = {} - obj.actionlist = event.action - obj.tag = event.tag - obj.after = action.after - - - directWorkerTable[action.tag] = obj - end - - end - - - - - - end - - if(action.name == "subscribe_actionlist_to_direct_execution") then - local obj = {} - obj.actionlist = action.action - obj.tag = action.tag - obj.after = action.after - directWorkerTable[action.tag] = obj - - end - - if(action.name == "subscribe_function_to_direct_execution") then - local boj = cyberscript.cache["functions"][action.tag] - - if( boj ~= nil) then - local functio = boj.data - - local obj = {} - obj.actionlist = functio.action - obj.tag = event.tag - obj.after = action.after - - - directWorkerTable[action.tag] = obj - - - end - - - - - - end - - if(action.name == "unsubscribe_from_direct_execution") then - - directWorkerTable[action.tag] = nil - - end - - if(action.name == "subscribe_actionlist_to_direct_action") then - local obj = {} - obj.actionlist = action.action - obj.tag = action.tag - obj.after = action.after - directActionsWorkerTable[action.tag] = obj - - end - - - - - if(action.name == "subscribe_event_to_direct_action") then - local boj = cyberscript.cache["event"][action.tag] - - if( boj ~= nil) then - local event = boj.data - local trigger = event.trigger - if(checkTriggerRequirement(event.requirement,trigger))then - local obj = {} - obj.actionlist = event.action - obj.tag = event.tag - obj.after = action.after - - - directActionsWorkerTable[action.tag] = obj - end - - end - - - - - - end - - if(action.name == "subscribe_function_to_direct_action") then - local boj = cyberscript.cache["functions"][action.tag] - - if( boj ~= nil) then - local functio = boj.data - - local obj = {} - obj.actionlist = functio.action - obj.tag = event.tag - - - - directActionsWorkerTable[action.tag] = obj - - - end - - - - - - end - - if(action.name == "unsubscribe_from_direct_action") then - - directActionsWorkerTable[action.tag] = nil - - end - - if(action.name == "register_garage_spawn_position") then - - - cyberscript.PositionManager[action.tag] = {} - cyberscript.PositionManager[action.tag].pending = true - - local vehicleSystem = Game.GetVehicleSystem() - - local garageVehicleId = GetSingleton('vehicleGarageVehicleID'):Resolve("Vehicle.v_standard2_archer_hella_player") - - - - vehicleSystem:TogglePlayerActiveVehicle(garageVehicleId, 'Car', true) - - vehicleSystem:SpawnPlayerVehicle('Car') - - - Cron.After(0.3,function() - - Game.GetVehicleSystem():DespawnPlayerVehicle(garageVehicleId) - cyberscript.EntityManager["called_garage"] = nil - - local inkSystem = Game.GetInkSystem(); - local layers = inkSystem:GetLayers(); + if action.name == "change_play_anim_entity_workspot" then + + + changeWorkSpot(action.tag,action.workspottag,action.workspot,action.unlockcamera) + changeWorkSpotAnims(action.tag,action.anim,action.isinstant) + + end + + if action.name == "stop_anim_entity" then + + + + stopWorkSpotAnims(action.tag) + end + + + if action.name == "enter_in_workspot" then + + + enterInWorkspot(action.tag,action.workspottag,action.workspot,action.unlockcamera) + + end + + if action.name == "play_in_workspot" then + + playAnimInWorkspot(action.tag,action.anim,action.isinstant) + + end + + if action.name == "stop_in_workspot" then + + stopWorkSpotAnims(action.tag) + + end + end + + if logicregion then + if(action.name == "if") then + checkIf(action,tag,source,executortag) + result = false + end + if(action.name == "lightif") then + local trigger = action.trigger + if(checkTrigger(trigger)) then + for i=1,#action.if_action do + local actiontodo = action.if_action[i] + executeAction(actiontodo,tag,parent,index,source,executortag) + end + else + for i=1,#action.else_action do + local actiontodo = action.else_action[i] + actiontodo(actiontodo,tag,parent,index,source,executortag) + end + end + end + if(action.name == "for") then + local actionlist = {} + if(action.amount > 0) then + for i=1,action.amount do + for y=1, #action.action do + table.insert(actionlist,action.action[y]) + end + end + + --logme(3,#actionlist) + --doActionofIndex(actionlist,"interact",listaction,currentindex) + runSubActionList(actionlist, tag.."_forlist", tag,source,false,executortag) + result = false + end + end + if(action.name == "clean_thread") then + workerTable[action.tag] = nil + end + if(action.name == "wait") then + local temp = getGameTime() + local nexttemp = temp + nexttemp.min = nexttemp.min + action.value + if(nexttemp.min > 60) then + nexttemp.min = nexttemp.min-60 + nexttemp.hour = nexttemp.hour+1 + end + if(nexttemp.hour == 25)then + nexttemp.hour = 1 + end + if(nexttemp.hour == 0)then + nexttemp.hour = 24 + end + nexttemp.hour = nexttemp.hour + action.hour = nexttemp.hour + action.min = nexttemp.min + result = false + end + if(action.name == "wait_second") then + local temp = os.time(os.date("!*t"))+0 + --logme(3,temp) + local nexttemp = temp + --logme(3,math.ceil((action.value*60))) + nexttemp =nexttemp + math.ceil(action.value) + --logme(3,nexttemp) + action.tick = nexttemp + result = false + end + if(action.name == "wait_tick") then + local temp = tick + --logme(3,temp) + local nexttemp = temp + --logme(3,math.ceil((action.value*60))) + nexttemp =nexttemp + action.value + --logme(3,nexttemp) + action.tick = nexttemp + result = false + end + if(action.name == "wait_for_trigger") then + result = false + end + if(action.name == "wait_for_framework") then + + result = false + end + if(action.name == "wait_for_ai_answer") then + + result = false + end + if(action.name == "wait_for_target") then + result = false + end + if(action.name == "wait_for_selection") then + enableEntitySelection = true + entitySelectionIsVehicule = action.isvehicule + selectionSlot = action.slot + result = false + end + if(action.name == "clean_selection") then + if(action.slot == 1) then + local obj = getEntityFromManager("selection") + obj.id = nil + end + if(action.slot == 2) then + local obj = getEntityFromManager("selection2") + obj.id = nil + end + if(action.slot == 3) then + local obj = getEntityFromManager("selection3") + obj.id = nil + end + if(action.slot == 4) then + local obj = getEntityFromManager("selection4") + obj.id = nil + end + if(action.slot == 5) then + local obj = getEntityFromManager("selection5") + obj.id = nil + end + end + if(action.name == "clean_all_selection") then + local obj = getEntityFromManager("selection") + obj.id = nil + obj = getEntityFromManager("selection2") + obj.id = nil + obj = getEntityFromManager("selection3") + obj.id = nil + obj = getEntityFromManager("selection4") + obj.id = nil + obj = getEntityFromManager("selection5") + obj.id = nil + end + if(action.name == "do_random_event")then + local tago = math.random(1,#action.events) + local boj = cyberscript.cache["event"][action.events[tago]] + if( boj ~= nil) then + local event = boj.data + if(action.bypass ~= nil and action.bypass == true) then + logme(3,"Doing event : "..event.name) + if(action.parallele == nil or action.parallele == false)then + runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,executortag) + result=false + else + runActionList(event.action, action.value, tag,source,false,executortag) + end + else + local trigger = event.trigger + if(checkTriggerRequirement(event.requirement,trigger))then + --logme(3,"check for "..data2.name) + logme(3,"Doing event : "..event.name) + if(action.parallele == nil or action.parallele == false)then + runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,executortag) + result=false + else + runActionList(event.action, action.value, tag,source,false,executortag) + end + else + logme(3,"can't do event : "..event.name) + end + end + end + + end + if(action.name == "while_one") then + result = false + end + if(action.name == "do_event") then + local boj = cyberscript.cache["event"][action.value] + logme(3,action.value) + if( boj ~= nil) then + local event = boj.data + + + if(action.bypass ~= nil and action.bypass == true) then + logme(3,"Doing event : "..event.name) + if(action.parallele == nil or action.parallele == false)then + runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,executortag) + result=false + else + runActionList(event.action, action.value, tag,source,false,executortag) + end + + else + local trigger = event.trigger + if(checkTriggerRequirement(event.requirement,trigger))then + --logme(3,"check for "..data2.name) + logme(3,"Doing event : "..event.name) + if(action.parallele == nil or action.parallele == false)then + runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,executortag) + result=false + else + runActionList(event.action, action.value, tag,source,false,executortag) + end + else + logme(3,"can't do event : "..event.name) + end + end + + end + + end + if(action.name == "do_function") then + local boj = cyberscript.cache["functions"][action.value] + if( boj ~= nil) then + local event = boj.data + if( boj ~= nil) then + local exector = executortag + local bypassmenu = false + if action.bypassmenu ~= nil then bypassmenu = action.bypassmenu end + if(action.applyto ~= nil and action.applyto ~= "")then + exector = action.applyto + end + + if(action.repeats == nil or action.repeats < 2) then + if(action.parallele == nil or action.parallele == false)then + + + runSubActionList(event.action, tag.."_event_"..action.value, tag,source,false,exector,bypassmenu) + + result=false + else + runActionList(event.action,action.value,source,false,exector,bypassmenu) + + + end + else + + local actionlist = {} + + for i=1,action.repeats do + for y=1, #event.action do + table.insert(actionlist,event.action[y]) + end + end + + + if(action.parallele == nil or action.parallele == false)then + + runSubActionList(actionlist, tag.."_event_"..action.value, tag,source,false,exector,bypassmenu) + + result=false + else + + runActionList(actionlist,action.value,source,false,exector,bypassmenu) + + + end + + + end + end + + end + + end + + if(action.name == "goto") then + local index = workerTable[tag]["index"] + local list = workerTable[tag]["action"] + local parent = workerTable[tag]["parent"] + local pending = workerTable[tag]["pending"] + + if(list[index].parent == true) then + logme(3,"Go to"..action.index.." of "..parent) + workerTable[parent]["index"] = action.index-1 + workerTable[tag]["index"] = workerTable[tag]["index"]+1 + workerTable[parent]["pending"] = false + tag = parent + else + logme(3,"Go to"..action.index.." of "..tag) + workerTable[tag]["index"] = action.index + end + end + + + if(action.name == "goto_alias") then + + local index = workerTable[tag]["index"] + local list = workerTable[tag]["action"] + local parent = workerTable[tag]["parent"] + local pending = workerTable[tag]["pending"] + + + for i,v in ipairs(list) do + + if(action.tag == v.alias) then + + if(list[index].parent == true) then + logme(3,"Go to"..i.." of "..parent.."(alias :"..v.tag..")") + workerTable[parent]["index"] = i-1 + workerTable[tag]["index"] = workerTable[tag]["index"]+1 + workerTable[parent]["pending"] = false + tag = parent + else + logme(3,"Go to"..i.." of "..tag.."(alias :"..v.tag..")") + workerTable[tag]["index"] = i + end + + end + + end + + end + + if(action.name == "do_random_function")then + local tago = math.random(1,#action.funcs) + logme(1,action.funcs[tago]) + local boj = cyberscript.cache["functions"][action.funcs[tago]] + if( boj ~= nil) then + + + local exector = executortag + + + if(action.applyto ~= nil and action.applyto ~= "")then + exector = action.applyto + end + + if(action.parallele == nil or action.parallele == false)then + runSubActionList(boj.data.action, tag.."_event_"..tago,parent,source,false,exector) + result=false + else + runActionList(boj.data.action,tago,source,false,exector) + end + end + + end + + + if(action.name == "subscribe_event_to_direct_execution") then + local boj = cyberscript.cache["event"][action.tag] + + if( boj ~= nil) then + local event = boj.data + local trigger = event.trigger + if(checkTriggerRequirement(event.requirement,trigger))then + local obj = {} + obj.actionlist = event.action + obj.tag = event.tag + obj.after = action.after + + + directWorkerTable[action.tag] = obj + end + + end + + + + + + end + + if(action.name == "subscribe_actionlist_to_direct_execution") then + local obj = {} + obj.actionlist = action.action + obj.tag = action.tag + obj.after = action.after + directWorkerTable[action.tag] = obj + + end + + if(action.name == "subscribe_function_to_direct_execution") then + local boj = cyberscript.cache["functions"][action.tag] + + if( boj ~= nil) then + local functio = boj.data + + local obj = {} + obj.actionlist = functio.action + obj.tag = event.tag + obj.after = action.after + + + directWorkerTable[action.tag] = obj + + + end + + + + + + end + + if(action.name == "unsubscribe_from_direct_execution") then + + directWorkerTable[action.tag] = nil + + end + + if(action.name == "subscribe_actionlist_to_direct_action") then + local obj = {} + obj.actionlist = action.action + obj.tag = action.tag + obj.after = action.after + directActionsWorkerTable[action.tag] = obj + + end + + + + + if(action.name == "subscribe_event_to_direct_action") then + local boj = cyberscript.cache["event"][action.tag] + + if( boj ~= nil) then + local event = boj.data + local trigger = event.trigger + if(checkTriggerRequirement(event.requirement,trigger))then + local obj = {} + obj.actionlist = event.action + obj.tag = event.tag + obj.after = action.after + + + directActionsWorkerTable[action.tag] = obj + end + + end + + + + + + end + + if(action.name == "subscribe_function_to_direct_action") then + local boj = cyberscript.cache["functions"][action.tag] + + if( boj ~= nil) then + local functio = boj.data + + local obj = {} + obj.actionlist = functio.action + obj.tag = event.tag + + + + directActionsWorkerTable[action.tag] = obj + + + end + + + + + + end + + if(action.name == "unsubscribe_from_direct_action") then + + directActionsWorkerTable[action.tag] = nil + + end + + if(action.name == "register_garage_spawn_position") then + + + cyberscript.PositionManager[action.tag] = {} + cyberscript.PositionManager[action.tag].pending = true + + local vehicleSystem = Game.GetVehicleSystem() + + local garageVehicleId = GetSingleton('vehicleGarageVehicleID'):Resolve("Vehicle.v_standard2_archer_hella_player") + + + + vehicleSystem:TogglePlayerActiveVehicle(garageVehicleId, 'Car', true) + + vehicleSystem:SpawnPlayerVehicle('Car') + + + Cron.After(0.3,function() + + Game.GetVehicleSystem():DespawnPlayerVehicle(garageVehicleId) + cyberscript.EntityManager["called_garage"] = nil + + local inkSystem = Game.GetInkSystem(); + local layers = inkSystem:GetLayers(); - for i,layer in ipairs(layers) do - for j,controller in ipairs(layer:GetGameControllers()) do - - if(NameToString(controller:GetClassName()) == "VehicleSummonWidgetGameController") then - GameController[NameToString(controller:GetClassName())] = controller - - end - - end - end - - GameController["VehicleSummonWidgetGameController"].rootWidget:SetVisible(false) - ----print(dump(cyberscript.PositionManager[action.tag])) + for i,layer in ipairs(layers) do + for j,controller in ipairs(layer:GetGameControllers()) do + + if(NameToString(controller:GetClassName()) == "VehicleSummonWidgetGameController") then + GameController[NameToString(controller:GetClassName())] = controller + + end + + end + end + + GameController["VehicleSummonWidgetGameController"].rootWidget:SetVisible(false) + ----print(dump(cyberscript.PositionManager[action.tag])) - end) - - end - - - - - - if(action.name == "register_position") then - - local position = {} - local position = getPositionFromParameter(action) - cyberscript.PositionManager[action.tag] = {} - cyberscript.PositionManager[action.tag].x = position.x - cyberscript.PositionManager[action.tag].y = position.y - cyberscript.PositionManager[action.tag].z = position.z - cyberscript.PositionManager[action.tag].pending = false - - - end - - if(action.name == "delete_position") then - - - cyberscript.PositionManager[action.tag] = nil - - end - - end - - if uiregion then - if(action.name == "show_texture") then - local frame = {} - frame.texture = ImGui.LoadTexture(getTextureByTag(action.tag)) - frame.tag = action.tag - frame.size = {} - frame.size.x = action.sizeX - frame.size.y = action.sizeY - frame.position = {} - frame.position.x = action.positionX - frame.position.y = action.positionY - frame.bgcolor = action.bgcolor - frame.bgopacity = action.bgopacity - frame.bordercolor = action.bordercolor - frame.borderopacity = action.borderopacity - frame.title = action.title - frame.titlecolor = action.titlecolor - - frame.titleopacity = 0 - - if(action.showtitle == true) then - frame.titleopacity = 1 - end - - currentLoadedTexture[action.tag] = frame - end - if(action.name == "hide_texture") then - currentLoadedTexture[action.tag] = nil - end - if(action.name == "set_scroll_speed") then - ScrollSpeed = action.value - end - if(action.name == "reset_scroll_speed") then - ScrollSpeed = 0.002 - end - if(action.name == "update_mod_setting") then - updateUserSetting(action.tag,action.value) - end - if(action.name == "setup_gang_player_affinity") then - GangAffinityCalculator() - end - if(action.name == "setup_gang_rival_affinity") then - initGangRelation() - end - if(action.name == "setup_gang_district_affinity") then - initGangDistrictScore() - end - if(action.name == "open_interface") then - currentInterface = cyberscript.cache["interfaces"][action.tag].data - --logme(3,dump(currentInterface)) - if(currentInterface ~= nil) then - --openInterface = true - if UIPopupsManager.IsReady() then - local notificationData = ShardReadPopupData.new() - notificationData.notificationName = 'base\\gameplay\\gui\\widgets\\notifications\\shard_notification.inkwidget' - notificationData.queueName = 'modal_popup' - notificationData.isBlocking = true - notificationData.useCursor = true - UIPopupsManager.ShowPopup(notificationData) - else - Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") - end - else - Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") - end - end - - - if(action.name == "open_shard") then - - local shard = cyberscript.cache["shard"][action.tag] - - if(shard ~= nil) then shard = cyberscript.cache["shard"][action.tag].data end - - if(shard ~= nil) then - - checkContext(shard) - Activatedshard(shard) - - end - end - - if(action.name == "spawn_inkwidget_entity") then - - spawnWidgetEnt(action.tag, action.x, action.y ,action.z) - - end - - - if(action.name == "apply_interface_to_inkwidget_entity") then - - if(cyberscript.EntityManager[action.entity] ~= nil and cyberscript.cache["interfaces"][action.tag] ~= nil) then - - cyberscript.EntityManager[action.entity].interface = action.tag - cyberscript.EntityManager[action.entity].widget :RemoveAllChildren() - makeCustomInterface(cyberscript.EntityManager[action.entity].widget,cyberscript.cache["interfaces"][action.tag].data) - - else - ----print("no apply") - -- ----print(tostring(GameDump(displayHUD[action.parent]))) - -- ----print(tostring(dump(cyberscript.cache["interfaces"][action.tag]))) - - end - end - - if(action.name == "clear_interface_to_inkwidget_entity") then - - if(cyberscript.EntityManager[action.tag] ~= nil) then - - cyberscript.EntityManager[action.tag].interface = nil - cyberscript.EntityManager[action.tag].widget :RemoveAllChildren() - else - ----print("no apply") - -- ----print(tostring(GameDump(displayHUD[action.parent]))) - -- ----print(tostring(dump(cyberscript.cache["interfaces"][action.tag]))) - - end - end - - if(action.name == "apply_interface_to_hud") then - - if(displayHUD[action.parent] ~= nil and cyberscript.cache["interfaces"][action.tag] ~= nil) then - - makeCustomInterface(displayHUD[action.parent],cyberscript.cache["interfaces"][action.tag].data) - - else - ----print("no apply") - -- ----print(tostring(GameDump(displayHUD[action.parent]))) - -- ----print(tostring(dump(cyberscript.cache["interfaces"][action.tag]))) - - end - end - - - if(action.name == "clear_interface") then - - if(currentInterfaceWidget[action.tag] ~= nil and currentInterfaceWidget[action.tag].parent ~= nil) then - - - currentInterfaceWidget[action.tag].parent:RemoveChildByName(currentInterfaceWidget[action.tag].controls[1].tag) - currentInterfaceWidget[action.tag] = nil - - - end - end - - if(action.name == "start_effect" or action.name == "start_effect_test") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - GameObjectEffectHelper.StartEffectEvent(enti, action.value) - end - end - if(action.name == "stop_effect" or action.name == "stop_effect_test") then - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - GameObjectEffectHelper.StopEffectEvent(enti, action.value) - GameObjectEffectHelper.BreakEffectLoopEvent(enti, action.value) - end - end - - if(action.name == "effect_tester") then - - local actionlist = {} - for i=1,#listFX do - - - - local actiond = {} - actiond.name = "start_effect" - actiond.value = listFX[i] - actiond.tag = action.tag - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "simple_message" - actiond.value = listFX[i] - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "wait_second" - actiond.value = 2 - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "stop_effect" - actiond.value = listFX[i] - actiond.tag = action.tag - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "wait_second" - actiond.value = 2 - - table.insert(actionlist,actiond) - - - end - - runSubActionList(actionlist, tag.."_effect_tester", tag,source,false,executortag) - end - - if(action.name == "effect_player_tester") then - - local actionlist = {} - for i=1,#transistionFX do - - - - local actiond = {} - actiond.name = "start_effect" - actiond.value = transistionFX[i] - actiond.tag = action.tag - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "simple_message" - actiond.value = transistionFX[i] - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "wait_second" - actiond.value = 2 - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "stop_effect" - actiond.value = transistionFX[i] - actiond.tag = action.tag - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "wait_second" - actiond.value = 2 - - table.insert(actionlist,actiond) - - - end - - runSubActionList(actionlist, tag.."_effect_tester", tag,source,false,executortag) - end - - if(action.name == "effect_npc_tester") then - - local actionlist = {} - for i=1,#npcFX do - - - - local actiond = {} - actiond.name = "start_effect" - actiond.value = npcFX[i] - actiond.tag = action.tag - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "simple_message" - actiond.value = npcFX[i] - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "wait_second" - actiond.value = 2 - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "stop_effect" - actiond.value = npcFX[i] - actiond.tag = action.tag - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "wait_second" - actiond.value = 2 - - table.insert(actionlist,actiond) - - - end - - runSubActionList(actionlist, tag.."_effect_tester", tag,source,false,executortag) - end - - if(action.name == "effect_car_tester") then - - local actionlist = {} - for i=1,#carFX do - - - - local actiond = {} - actiond.name = "start_effect" - actiond.value = carFX[i] - actiond.tag = action.tag - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "simple_message" - actiond.value = carFX[i] - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "wait_second" - actiond.value = 2 - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "stop_effect" - actiond.value = carFX[i] - actiond.tag = action.tag - - table.insert(actionlist,actiond) - - actiond = {} - actiond.name = "wait_second" - actiond.value = 2 - - table.insert(actionlist,actiond) - - - end - - runSubActionList(actionlist, tag.."_effect_tester", tag,source,false,executortag) - end - - if(action.name == "change_interface_label_text") then - - if(currentInterfaceWidget ~= nil) then - currentInterfaceWidget[action.tag].ink:SetText(action.value) - end - end - if(action.name == "change_interface_cart") then - if(currentInterfaceWidget ~= nil) then - currentInterfaceWidget[action.tag].ink:SetText("Cart Total : "..CartPrice) - end - end - if(action.name == "open_radio") then - if GameController["PopupsManager"] then - openRadio() - else - Game.GetPlayer():SetWarningMessage("Open and close radio from vehicule before or reload an save to call the popup.") - end - end - if(action.name == "set_datapack_group") then - - for i = 1, #currentInteractGroup do - if(action.value == currentInteractGroup[i]) then - currentInteractGroupIndex = i - end - end - end - if(action.name == "set_datapack_group_index") then - - - currentInteractGroupIndex = action.value - end - - if(action.name == "set_selected_item") then - Keystone_currentSelectedItem = action.value - setVariable("Keystone_currentSelectedItem","title", action.value) - end - if(action.name == "set_selected_keystone_datapack") then - - for k,v in ipairs(arrayDatapack3) do - - if v.tag == action.value then - - Keystone_currentSelectedDatapack = v - ----print("select datapack") - end - - end - - - setVariable("Keystone_currentSelectedDatapack","name",Keystone_currentSelectedDatapack.name) - local desctab = splitByChunk(Keystone_currentSelectedDatapack.desc, 75) - local descc = "" - - for y=1,#desctab do - - - descc = descc.."\n"..desctab[y] - end - - - - setVariable("Keystone_currentSelectedDatapack","desc",descc) - - setVariable("Keystone_currentSelectedDatapack","tag",Keystone_currentSelectedDatapack.tag) - - setVariable("Keystone_currentSelectedDatapack","author",Keystone_currentSelectedDatapack.author) - - setVariable("Keystone_currentSelectedDatapack","file",Keystone_currentSelectedDatapack.file) - - setVariable("Keystone_currentSelectedDatapack","version",Keystone_currentSelectedDatapack.version) - - setVariable("Keystone_currentSelectedDatapack","data",Keystone_currentSelectedDatapack.data) - - local localversion = CurrentDownloadedVersion(Keystone_currentSelectedDatapack.tag) - local serverversion = GetDatapackOnlineVersion(Keystone_currentSelectedDatapack.tag) - - setVariable("Keystone_currentSelectedDatapack","serverversion",serverversion) - - setVariable("Keystone_currentSelectedDatapack","localversion",localversion) - - setVariable("Keystone_currentSelectedDatapack","isessential",tostring(#Keystone_currentSelectedDatapack.flags > 0 and table_contains(Keystone_currentSelectedDatapack.flags,"essential",false) == true and table_contains(Keystone_currentSelectedDatapack.flags,"debug",false) == false)) - - setVariable("Keystone_currentSelectedDatapack","isdownloaded",tostring(isDatapackDownloaded(Keystone_currentSelectedDatapack.tag))) - - setVariable("Keystone_currentSelectedDatapack","canbedownload",tostring(DatapackChecker(Keystone_currentSelectedDatapack) == true)) - - setVariable("Keystone_currentSelectedDatapack","needupdate",tostring((localversion~=serverversion and checkVersionNumber(localversion,serverversion) == true))) - - - end - - if(action.name == "refreshBrowser") then - CurrentAddress = action.address - - - if(LastBrowserSubaddress == nil) then LastBrowserSubaddress = "home" end - - - if(action.subaddress == "previous")then --go back to previous - - BrowserCybserscript = LastBrowserSubaddress - - else - - if(action.subaddress ~= "refresh")then --go back to previous - - - - if(BrowserCybserscript ~= action.subaddress) then --case of refresh - - LastBrowserSubaddress = BrowserCybserscript - - end - - BrowserCybserscript = action.subaddress - end - - end - - - - - - GameController["BrowserController"]:LoadWebPage(action.address) - end - - - - if(action.name == "open_datapack_group_ui" or action.name == "open_datapack_group_ui2") then - - ActivatedGroup2() - end - if(action.name == "open_menu") then - local startHub = StartHubMenuEvent.new() - startHub:SetStartMenu(action.value) - Game.GetUISystem():QueueEvent(startHub) - end + end) + + end + + + + + + if(action.name == "register_position") then + + local position = {} + local position = getPositionFromParameter(action) + cyberscript.PositionManager[action.tag] = {} + cyberscript.PositionManager[action.tag].x = position.x + cyberscript.PositionManager[action.tag].y = position.y + cyberscript.PositionManager[action.tag].z = position.z + cyberscript.PositionManager[action.tag].pending = false + + + end + + if(action.name == "delete_position") then + + + cyberscript.PositionManager[action.tag] = nil + + end + + end + + if uiregion then + if(action.name == "show_texture") then + local frame = {} + frame.texture = ImGui.LoadTexture(getTextureByTag(action.tag)) + frame.tag = action.tag + frame.size = {} + frame.size.x = action.sizeX + frame.size.y = action.sizeY + frame.position = {} + frame.position.x = action.positionX + frame.position.y = action.positionY + frame.bgcolor = action.bgcolor + frame.bgopacity = action.bgopacity + frame.bordercolor = action.bordercolor + frame.borderopacity = action.borderopacity + frame.title = action.title + frame.titlecolor = action.titlecolor + + frame.titleopacity = 0 + + if(action.showtitle == true) then + frame.titleopacity = 1 + end + + currentLoadedTexture[action.tag] = frame + end + if(action.name == "hide_texture") then + currentLoadedTexture[action.tag] = nil + end + if(action.name == "set_scroll_speed") then + ScrollSpeed = action.value + end + if(action.name == "reset_scroll_speed") then + ScrollSpeed = 0.002 + end + if(action.name == "update_mod_setting") then + updateUserSetting(action.tag,action.value) + end + if(action.name == "setup_gang_player_affinity") then + GangAffinityCalculator() + end + if(action.name == "setup_gang_rival_affinity") then + initGangRelation() + end + if(action.name == "setup_gang_district_affinity") then + initGangDistrictScore() + end + if(action.name == "open_interface") then + currentInterface = cyberscript.cache["interfaces"][action.tag].data + --logme(3,dump(currentInterface)) + if(currentInterface ~= nil) then + --openInterface = true + if UIPopupsManager.IsReady() then + local notificationData = ShardReadPopupData.new() + notificationData.notificationName = 'base\\gameplay\\gui\\widgets\\notifications\\shard_notification.inkwidget' + notificationData.queueName = 'modal_popup' + notificationData.isBlocking = true + notificationData.useCursor = true + UIPopupsManager.ShowPopup(notificationData) + else + Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") + end + else + Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") + end + end + + + if(action.name == "open_shard") then + + local shard = cyberscript.cache["shard"][action.tag] + + if(shard ~= nil) then shard = cyberscript.cache["shard"][action.tag].data end + + if(shard ~= nil) then + + checkContext(shard) + Activatedshard(shard) + + end + end + + if(action.name == "spawn_inkwidget_entity") then + + spawnWidgetEnt(action.tag, action.x, action.y ,action.z) + + end + + + if(action.name == "apply_interface_to_inkwidget_entity") then + + if(cyberscript.EntityManager[action.entity] ~= nil and cyberscript.cache["interfaces"][action.tag] ~= nil) then + + cyberscript.EntityManager[action.entity].interface = action.tag + cyberscript.EntityManager[action.entity].widget :RemoveAllChildren() + makeCustomInterface(cyberscript.EntityManager[action.entity].widget,cyberscript.cache["interfaces"][action.tag].data) + + else + ----print("no apply") + -- ----print(tostring(GameDump(displayHUD[action.parent]))) + -- ----print(tostring(dump(cyberscript.cache["interfaces"][action.tag]))) + + end + end + + if(action.name == "clear_interface_to_inkwidget_entity") then + + if(cyberscript.EntityManager[action.tag] ~= nil) then + + cyberscript.EntityManager[action.tag].interface = nil + cyberscript.EntityManager[action.tag].widget :RemoveAllChildren() + else + ----print("no apply") + -- ----print(tostring(GameDump(displayHUD[action.parent]))) + -- ----print(tostring(dump(cyberscript.cache["interfaces"][action.tag]))) + + end + end + + if(action.name == "apply_interface_to_hud") then + + if(displayHUD[action.parent] ~= nil and cyberscript.cache["interfaces"][action.tag] ~= nil) then + + makeCustomInterface(displayHUD[action.parent],cyberscript.cache["interfaces"][action.tag].data) + + else + ----print("no apply") + -- ----print(tostring(GameDump(displayHUD[action.parent]))) + -- ----print(tostring(dump(cyberscript.cache["interfaces"][action.tag]))) + + end + end + + + if(action.name == "clear_interface") then + + if(currentInterfaceWidget[action.tag] ~= nil and currentInterfaceWidget[action.tag].parent ~= nil) then + + + currentInterfaceWidget[action.tag].parent:RemoveChildByName(currentInterfaceWidget[action.tag].controls[1].tag) + currentInterfaceWidget[action.tag] = nil + + + end + end + + if(action.name == "start_effect" or action.name == "start_effect_test") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + GameObjectEffectHelper.StartEffectEvent(enti, action.value) + end + end + if(action.name == "stop_effect" or action.name == "stop_effect_test") then + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + GameObjectEffectHelper.StopEffectEvent(enti, action.value) + GameObjectEffectHelper.BreakEffectLoopEvent(enti, action.value) + end + end + + if(action.name == "effect_tester") then + + local actionlist = {} + for i=1,#listFX do + + + + local actiond = {} + actiond.name = "start_effect" + actiond.value = listFX[i] + actiond.tag = action.tag + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "simple_message" + actiond.value = listFX[i] + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "wait_second" + actiond.value = 2 + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "stop_effect" + actiond.value = listFX[i] + actiond.tag = action.tag + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "wait_second" + actiond.value = 2 + + table.insert(actionlist,actiond) + + + end + + runSubActionList(actionlist, tag.."_effect_tester", tag,source,false,executortag) + end + + if(action.name == "effect_player_tester") then + + local actionlist = {} + for i=1,#transistionFX do + + + + local actiond = {} + actiond.name = "start_effect" + actiond.value = transistionFX[i] + actiond.tag = action.tag + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "simple_message" + actiond.value = transistionFX[i] + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "wait_second" + actiond.value = 2 + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "stop_effect" + actiond.value = transistionFX[i] + actiond.tag = action.tag + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "wait_second" + actiond.value = 2 + + table.insert(actionlist,actiond) + + + end + + runSubActionList(actionlist, tag.."_effect_tester", tag,source,false,executortag) + end + + if(action.name == "effect_npc_tester") then + + local actionlist = {} + for i=1,#npcFX do + + + + local actiond = {} + actiond.name = "start_effect" + actiond.value = npcFX[i] + actiond.tag = action.tag + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "simple_message" + actiond.value = npcFX[i] + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "wait_second" + actiond.value = 2 + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "stop_effect" + actiond.value = npcFX[i] + actiond.tag = action.tag + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "wait_second" + actiond.value = 2 + + table.insert(actionlist,actiond) + + + end + + runSubActionList(actionlist, tag.."_effect_tester", tag,source,false,executortag) + end + + if(action.name == "effect_car_tester") then + + local actionlist = {} + for i=1,#carFX do + + + + local actiond = {} + actiond.name = "start_effect" + actiond.value = carFX[i] + actiond.tag = action.tag + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "simple_message" + actiond.value = carFX[i] + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "wait_second" + actiond.value = 2 + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "stop_effect" + actiond.value = carFX[i] + actiond.tag = action.tag + + table.insert(actionlist,actiond) + + actiond = {} + actiond.name = "wait_second" + actiond.value = 2 + + table.insert(actionlist,actiond) + + + end + + runSubActionList(actionlist, tag.."_effect_tester", tag,source,false,executortag) + end + + if(action.name == "change_interface_label_text") then + + if(currentInterfaceWidget ~= nil) then + currentInterfaceWidget[action.tag].ink:SetText(action.value) + end + end + if(action.name == "change_interface_cart") then + if(currentInterfaceWidget ~= nil) then + currentInterfaceWidget[action.tag].ink:SetText("Cart Total : "..CartPrice) + end + end + if(action.name == "open_radio") then + if GameController["PopupsManager"] then + openRadio() + else + Game.GetPlayer():SetWarningMessage("Open and close radio from vehicule before or reload an save to call the popup.") + end + end + if(action.name == "set_datapack_group") then + + for i = 1, #currentInteractGroup do + if(action.value == currentInteractGroup[i]) then + currentInteractGroupIndex = i + end + end + end + if(action.name == "set_datapack_group_index") then + + + currentInteractGroupIndex = action.value + end + + if(action.name == "set_selected_item") then + Keystone_currentSelectedItem = action.value + setVariable("Keystone_currentSelectedItem","title", action.value) + end + if(action.name == "set_selected_keystone_datapack") then + + for k,v in ipairs(arrayDatapack3) do + + if v.tag == action.value then + + Keystone_currentSelectedDatapack = v + ----print("select datapack") + end + + end + + + setVariable("Keystone_currentSelectedDatapack","name",Keystone_currentSelectedDatapack.name) + local desctab = splitByChunk(Keystone_currentSelectedDatapack.desc, 75) + local descc = "" + + for y=1,#desctab do + + + descc = descc.."\n"..desctab[y] + end + + + + setVariable("Keystone_currentSelectedDatapack","desc",descc) + + setVariable("Keystone_currentSelectedDatapack","tag",Keystone_currentSelectedDatapack.tag) + + setVariable("Keystone_currentSelectedDatapack","author",Keystone_currentSelectedDatapack.author) + + setVariable("Keystone_currentSelectedDatapack","file",Keystone_currentSelectedDatapack.file) + + setVariable("Keystone_currentSelectedDatapack","version",Keystone_currentSelectedDatapack.version) + + setVariable("Keystone_currentSelectedDatapack","data",Keystone_currentSelectedDatapack.data) + + local localversion = CurrentDownloadedVersion(Keystone_currentSelectedDatapack.tag) + local serverversion = GetDatapackOnlineVersion(Keystone_currentSelectedDatapack.tag) + + setVariable("Keystone_currentSelectedDatapack","serverversion",serverversion) + + setVariable("Keystone_currentSelectedDatapack","localversion",localversion) + + setVariable("Keystone_currentSelectedDatapack","isessential",tostring(#Keystone_currentSelectedDatapack.flags > 0 and table_contains(Keystone_currentSelectedDatapack.flags,"essential",false) == true and table_contains(Keystone_currentSelectedDatapack.flags,"debug",false) == false)) + + setVariable("Keystone_currentSelectedDatapack","isdownloaded",tostring(isDatapackDownloaded(Keystone_currentSelectedDatapack.tag))) + + setVariable("Keystone_currentSelectedDatapack","canbedownload",tostring(DatapackChecker(Keystone_currentSelectedDatapack) == true)) + + setVariable("Keystone_currentSelectedDatapack","needupdate",tostring((localversion~=serverversion and checkVersionNumber(localversion,serverversion) == true))) + + + end + + if(action.name == "refreshBrowser") then + CurrentAddress = action.address + + + if(LastBrowserSubaddress == nil) then LastBrowserSubaddress = "home" end + + + if(action.subaddress == "previous")then --go back to previous + + BrowserCybserscript = LastBrowserSubaddress + + else + + if(action.subaddress ~= "refresh")then --go back to previous + + + + if(BrowserCybserscript ~= action.subaddress) then --case of refresh + + LastBrowserSubaddress = BrowserCybserscript + + end + + BrowserCybserscript = action.subaddress + end + + end + + + + + + GameController["BrowserController"]:LoadWebPage(action.address) + end + + + + if(action.name == "open_datapack_group_ui" or action.name == "open_datapack_group_ui2") then + + ActivatedGroup2() + end + if(action.name == "open_menu") then + local startHub = StartHubMenuEvent.new() + startHub:SetStartMenu(action.value) + Game.GetUISystem():QueueEvent(startHub) + end - if(action.name == "open_phone") then - GameController["NewHudPhoneGameController"].PhoneSystem:QueueRequest( UsePhoneRequest.new()); - end - - - if(action.name == "close_menu") then - local closeHub = ForceCloseHubMenuEvent.new() - Game.GetUISystem():QueueEvent(closeHub) - end - if(action.name == "close_interface") then - -- openInterface = false - - currentInterface = nil - buttonsData = {} - UIPopupsManager.ClosePopup() - end - if(action.name == "lock_conversation" or action.name == "lock_message") then - setScore(action.tag,"unlocked",0) - PhoneHotkeyController_UpdateData(GameController["PhoneHotkeyController"]) - end - if(action.name == "unlock_conversation" or action.name == "unlock_message") then - setScore(action.tag,"unlocked",1) - PhoneHotkeyController_UpdateData(GameController["PhoneHotkeyController"]) - end - - if(action.name == "open_map_menu_to_position") then - local startHub = StartHubMenuEvent.new() - - local userData = MapMenuUserData.new() - userData.moveTo = Vector3.new(action.x, action.y, action.z) - - startHub:SetStartMenu("world_map",nil,userData) - Game.GetUISystem():QueueEvent(startHub) - - - end - - if(action.name == "show_hack_animation") then - - - - - - GameController["HUDProgressBarController"]:OnActivated(true) - GameController["HUDProgressBarController"]:UpdateTimerHeader(getLang(action.value)) - - end - - if(action.name == "change_hack_animation_percent") then - - if(action.text ~= nil and action.text ~= "") then - - GameController["HUDProgressBarController"]:UpdateTimerHeader(getLang(action.text)) - - end - GameController["HUDProgressBarController"]:UpdateTimerProgress((action.value/100)) - - end - - if(action.name == "hide_hack_animation") then - - - GameController["HUDProgressBarController"]:OnActivated(false) - GameController["HUDProgressBarController"]:UpdateTimerProgress((0/100)) - - end - - - - end - - if avregion then - if(action.name == "vehicule_autodrive_activate") then - local mappin = {} - mappin.x = action.x - mappin.y = action.y - mappin.z = action.z+5 - local actionlist = {} - - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - - local myPos = enti:GetWorldPosition() - local newPos = myPos - local angle = enti:GetWorldOrientation():ToEulerAngles() - - local tempangle = {} - tempangle.roll = 0 - tempangle.pitch = 0 - tempangle.yaw = 0 - - local numbertimes = 0 - local zpath=action.zfly - - - - newaction = {} - newaction.name = "wait_second" - newaction.value = 0.5 - table.insert(actionlist,newaction) - - if(action.isAV == true) then - local ztimes = action.zfly - myPos.z - local zpos = deepcopy(newPos.z,nil) - numbertimes = ztimes / zpath - - for i=1,ztimes do - - - zpos = zpos + 1 - - local newaction = {} - newaction.name = "teleport_entity_at_position" - newaction.tag = action.tag - newaction.x = newPos.x - newaction.y = newPos.y - newaction.z = zpos - newaction.angle = angle - newaction.collision = false - newaction.pathfinding = false - newaction.axis = "z" - table.insert(actionlist,newaction) - end - end - - - local destination = Vector4.new(mappin.x, myPos.y, myPos.z,1) - local dirVector = diffVector(myPos, destination) - local myyaw = 0 - local vdepart = LVector.new(myPos.x,myPos.y) - local varrive = LVector.new(mappin.x,mappin.y) - local diag = varrive-vdepart - local point = action.speed - local newangle = GetSingleton('Vector4'):ToRotation(dirVector) - local numtimes = diag*(1/point) - local path = deepcopy(vdepart,nil) - for i = 1,point do - path = path+numtimes - - - local newaction = {} - newaction.name = "teleport_entity_at_position" - newaction.tag = action.tag - newaction.x = path.x - newaction.y = path.y - newaction.z = action.zfly - newaction.angle = angle - newaction.pathfinding = action.pathfinding - newaction.collision = false - newaction.axis = "x" - table.insert(actionlist,newaction) - end - - newaction = {} - newaction.name = "wait_second" - newaction.value = 0.5 - table.insert(actionlist,newaction) - - if(action.isAV == true) then - - local ztimes = action.zfly - mappin.z - 3 - local zpos = deepcopy(ztimes,nil) - numbertimes = ztimes - - for i=1,numbertimes do - - - zpos = zpos - 1 - - local newaction = {} - newaction.name = "teleport_entity_at_position" - newaction.tag = action.tag - newaction.x = path.x - newaction.y = path.y - newaction.z = zpos - newaction.angle = angle - newaction.collision = true - newaction.pathfinding = false - newaction.axis = "z" - table.insert(actionlist,newaction) - end - - - end - - - runSubActionList(actionlist, tag.."_av_autodrive_activate", tag,source,false,executortag) - result = false - end - end - if(action.name == "vehicule_autodrive_activate_custom_mappin") then - if(mappinManager["selected_mappin"] ~= nil) then - - local mappin = mappinManager["selected_mappin"].position - local actionlist = {} - - local obj = getEntityFromManager(action.tag) - local enti = Game.FindEntityByID(obj.id) - local myPos = enti:GetWorldPosition() - local newPos = myPos - local angle = enti:GetWorldOrientation():ToEulerAngles() - - local tempangle = {} - tempangle.roll = 0 - tempangle.pitch = 0 - tempangle.yaw = 0 - - - local zpath=action.zfly - - local zspeed = 0.5 - - - newaction = {} - newaction.name = "wait_second" - newaction.value = 0.7 - table.insert(actionlist,newaction) - - if(action.isAV == true) then - local ztimes = action.zfly - myPos.z - local zpos = deepcopy(newPos.z,nil) - local numbertimes = (ztimes)/zspeed - print("numbertimes "..numbertimes) - - for i=1,numbertimes do - - - zpos = zpos + zspeed - - local newaction = {} - newaction.name = "teleport_entity_at_position" - newaction.tag = action.tag - newaction.x = newPos.x - newaction.y = newPos.y - newaction.z = zpos - newaction.angle = angle - newaction.collision = false - newaction.pathfinding = false - newaction.axis = "z" - table.insert(actionlist,newaction) - end - end - - - local destination = Vector4.new(mappin.x, mappin.y, myPos.z,1) - local dirVector = diffVector(myPos, destination) - local myyaw = 0 - local vdepart = LVector.new(myPos.x,myPos.y) - local varrive = LVector.new(mappin.x,mappin.y) - local diag = varrive-vdepart - local point = action.speed - local newangle = GetSingleton('Vector4'):ToRotation(dirVector) - local numtimes = diag*(1/point) - local path = deepcopy(vdepart,nil) - for i = 1,point do - path = path+numtimes - - - local newaction = {} - newaction.name = "teleport_entity_at_position" - newaction.tag = action.tag - newaction.x = path.x - newaction.y = path.y - newaction.z = action.zfly - newaction.angle = angle - newaction.pathfinding = action.pathfinding - newaction.collision = false - newaction.axis = "x" - table.insert(actionlist,newaction) - end - - newaction = {} - newaction.name = "wait_second" - newaction.value = 0.7 - table.insert(actionlist,newaction) - - if(action.isAV == true) then - - local ztimes = (action.zfly - mappin.z - 3) - local zpos = deepcopy(ztimes,nil) - local numbertimes = ztimes/zspeed - - for i=1,numbertimes do - - - zpos = zpos - zspeed - - local newaction = {} - newaction.name = "teleport_entity_at_position" - newaction.tag = action.tag - newaction.x = path.x - newaction.y = path.y - newaction.z = zpos - newaction.angle = angle - newaction.collision = true - newaction.pathfinding = false - newaction.axis = "z" - table.insert(actionlist,newaction) - end - - - end - - - runSubActionList(actionlist, tag.."_av_autodrive_activate__custom_mappin", tag,source,false,executortag) - result = false - end - end - if(action.name == "toggle_av_engine") then - local obj = getEntityFromManager(action.tag) - if(obj ~= nil) then - if(obj.isAV == true) then - obj.isAV = false - else - obj.isAV = true - end - end - end - if(action.name == "toggle_av_engine_for_current_drived_vehicule") then - local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - if (inVehicule) then - local vehicule = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - if(vehicule ~= nil) then - local obj = getEntityFromManagerById(vehicule:GetEntityID()) - if(obj.id == nil) then - local entity = {} - entity.id = vehicule:GetEntityID() - entity.tag = "vehicule_"..math.random(1,9999) - entity.tweak = "nope" - entity.takenSeat = {} - entity.isAV = false - local group = getGroupfromManager("AV") - entity.availableSeat = GetSeats(vehicule) - entity.driver = "player" - cyberscript.EntityManager[entity.tag]=entity - --logme(3,"new "..entity.tag) - obj = entity - end - logme(3,obj.tag) - local obj = getTrueEntityFromManager(obj.tag) - if(obj.isAV == true) then - obj.isAV = false - - for i=1, #cyberscript.GroupManager["AV"].entities do - local entityTag = cyberscript.GroupManager["AV"].entities[i] - if(entityTag == obj.tag) then - table.remove(cyberscript.GroupManager["AV"].entities,i) - end - end - --logme(3,"removedAV"..obj.tag) - else - - obj.isAV = true - if(cyberscript.GroupManager["AV"].entities == nil) then - cyberscript.GroupManager["AV"].entities = {} - end - logme(3,"addedAV"..obj.tag) - table.insert(cyberscript.GroupManager["AV"].entities,obj.tag) - end - end - end - end - end - - if customnpcregion then - - if(action.name == "npc_custom_edit_custom_npc") then - local npc = getCustomNPCbyTag(action.tag) - npc.spawnforced=true - npc.dospawnaction=action.dospawnaction - npc.doroutineaction=action.doroutineaction - npc.dodeathaction=action.dodeathaction - npc.dodespawnaction=action.dodespawnaction - npc.repeat_routine = action.repeat_routine - npc.auto_despawn = action.auto_despawn - if(action.replacelocation == true) then - npc.workinglocation.x = action.x - npc.workinglocation.y = action.y - npc.workinglocation.z = action.z - npc.workinglocation.range = action.range - end - if(action.appeareance ~= nil and action.appeareance ~= "") then - npc.appeareance = action.appearance - end - end - if(action.name == "npc_custom_despawn_custom_npc") then - local npc = getCustomNPCbyTag(action.tag) - npc.isspawn=false - npc.init=false - npc.appearancesetted = nil - npc.spawnforced=false - npc.dospawnaction=true - npc.doroutineaction=true - npc.dodeathaction=true - npc.dodespawnaction=true - npc.workinglocation = npc.location - if(workerTable[npc.tag.."_spawn"] ~= nil) then - workerTable[npc.tag.."_spawn"] = nil - end - if(workerTable[npc.tag.."_death"] ~= nil) then - workerTable[npc.tag.."_death"] = nil - end - if(workerTable[npc.tag.."_routine"] ~= nil) then - workerTable[npc.tag.."_routine"] = nil - end - despawnEntity(npc.tag) - if(workerTable[npc.tag.."_despawn"] == nil and #npc.despawnaction > 0) then - runActionList(npc.despawnaction, npc.tag.."_despawn", "interact",false,npc.tag) - end - end - if(action.name == "npc_custom_set_autodespawn") then - local npc = getCustomNPCByTag(action.tag) - npc.auto_despawn = action.value - end - if(action.name == "npc_custom_set_autoroutine") then - local npc = getCustomNPCByTag(action.tag) - npc.repeat_routine = action.value - end - if(action.name == "npc_custom_copy") then - local npc = getCustomNPCbyTag(action.sourcetag) - local newnpc = deepcopy(npc, newnpc) - newnpc.tag = action.newtag - newnpc.name = action.newname - addCustomNPC(newnpc) - end - end - - - - if scene then - if(action.name == "show_braindance_ui") then - - if(GameController["BraindanceGameController"] ~= nil) then - local root = GameController["BraindanceGameController"].rootWidget - - - - root:SetVisible(true) - - GameController["BraindanceGameController"].PlayLibraryAnimation(CName("SHOW")) - - - end - - end - - if(action.name == "bound_scene_to_braindance") then - - if(GameController["BraindanceGameController"] ~= nil and currentScene ~= nil) then - local margin = inkMargin.new({ top = -45}) - inkWidgetRef.SetMargin(GameController["BraindanceGameController"].cursorPoint, margin) - local margin = inkMargin.new({ left = 0}) - inkWidgetRef.SetMargin(GameController["BraindanceGameController"].currentTimerMarker, margin) - inkTextRef.SetText(GameController["BraindanceGameController"].currentTimerText, "0 : 0") - currentScene.isbraindance = true - - - - end - - end - - if(action.name == "unbound_scene_to_braindance") then - - if(GameController["BraindanceGameController"] ~= nil and currentScene ~= nil) then - local margin = inkMargin.new({ top = -45}) - inkWidgetRef.SetMargin(GameController["BraindanceGameController"].cursorPoint, margin) - currentScene.isbraindance = false - - - - end - - end - - if(action.name == "hide_braindance_ui") then - - if(GameController["BraindanceGameController"] ~= nil) then - local root = GameController["BraindanceGameController"].rootWidget - - - - root:SetVisible(false) - - - - - end - - end - - - - - - if(action.name == "load_scene") then - - local scene = cyberscript.cache["scene"][action.tag] - - if(scene ~= nil) then - - currentScene = scene.data - currentScene.index = 0 - if(GameController["BraindanceGameController"] ~= nil and currentScene.isbraindance == true) then - - local root = GameController["BraindanceGameController"].rootWidget - - - - - root:SetVisible(true) - - GameController["BraindanceGameController"].PlayLibraryAnimation(CName("SHOW")) - - local margin = inkMargin.new({ top = -45}) - inkWidgetRef.SetMargin(GameController["BraindanceGameController"].cursorPoint, margin) - local margin = inkMargin.new({ left = 0}) - inkWidgetRef.SetMargin(GameController["BraindanceGameController"].currentTimerMarker, margin) - inkTextRef.SetText(GameController["BraindanceGameController"].currentTimerText, "0 : 0") - - - - - end - else - - error("No scene founded for the tag "..action.tag) - - - end - - end - - if(action.name == "unload_scene") then - - - - if(currentScene ~= nil) then - - currentScene = nil - - - - - end - end - - if(action.name == "play_scene") then - - - - if(currentScene ~= nil) then - - - - - runActionList(currentScene.reset_action, currentScene.tag.."_reset", "interact",false,"scene") - - local actionlist = {} - - local actiontd = {} - actiontd.name = "wait_for_trigger" - actiontd.trigger = {} - actiontd.trigger.name = "event_is_finished" - actiontd.trigger.tag = currentScene.tag.."_reset" - - table.insert(actionlist,actiontd) - - for i=1,#currentScene.init_action do - - table.insert(actionlist,currentScene.init_action[i]) - - end - - - runActionList(actionlist, currentScene.tag.."_init", "interact",false,"scene") - - - actionlist = {} - - actiontd = {} - actiontd.name = "wait_for_trigger" - actiontd.trigger = {} - actiontd.trigger.name = "event_is_finished" - actiontd.trigger.tag = currentScene.tag.."_init" - - table.insert(actionlist,actiontd) - - for i=1,#currentScene.step do - - - local step = currentScene.step[i] - - - - for y=1,#step.action do - - table.insert(actionlist,step.action[y]) - - end - - end - - - for i=1,#currentScene.end_action do - - table.insert(actionlist,currentScene.end_action[i]) - - end - - - runActionList(actionlist, currentScene.tag.."_full", "interact",false,"scene") - else - - error("No scene loaded") - - end - end - - if(action.name == "reset_scene") then - - - - if(currentScene ~= nil) then - - - - - runActionList(currentScene.reset_action, currentScene.tag.."_reset", "interact",false,"scene") - currentScene.index = 0 - - end - end - - if(action.name == "init_scene") then - - - - if(currentScene ~= nil) then - - - - - runActionList(currentScene.init_action, currentScene.tag.."_init", "interact",false,"scene") - currentScene.index = 0 - else - - error("No scene loaded") - end - end - - if(action.name == "play_scene_step_index") then - - - - if(currentScene ~= nil) then - - - - if(currentScene.step[action.value] ~= nil) then - if (currentScene.isbraindance == true) then - - GameController["BraindanceGameController"].currentTime = (100/#currentScene.step * action.value)/100 - GameController["BraindanceGameController"]:SetBraindanceProgress() - - end - runActionList(currentScene.step[action.value].action, currentScene.tag.."_"..action.value, "interact",false,"scene") - currentScene.index = action.value - end - - end - end - - if(action.name == "play_scene_step_by_tag") then - - - - if(currentScene ~= nil) then - - - for i=1,#currentScene.step do - if(currentScene.step[i].tag == action.tag) then - if (currentScene.isbraindance == true) then - - GameController["BraindanceGameController"].currentTime = (100/#currentScene.step * i)/100 - GameController["BraindanceGameController"]:SetBraindanceProgress() - - end - runActionList(currentScene.step[i].action, currentScene.tag.."_"..i, "interact",false,"scene") - currentScene.index = i - end - end - - end - end - - if(action.name == "play_next_scene_step") then - - - - if(currentScene ~= nil) then - - - local index = currentScene.index +1 - - if(currentScene.step[index] ~= nil) then - if (currentScene.isbraindance == true) then - - GameController["BraindanceGameController"].currentTime = (100/#currentScene.step * index)/100 - GameController["BraindanceGameController"]:SetBraindanceProgress() - - end - - runActionList(currentScene.step[index].action, currentScene.tag.."_"..index, "interact",false,"scene") - currentScene.index = index - - end - - end - end - - if(action.name == "play_previous_scene_step") then - - - - if(currentScene ~= nil) then - - - local index = currentScene.index -1 - - if(currentScene.step[index] ~= nil) then - if (currentScene.isbraindance == true) then - - GameController["BraindanceGameController"].currentTime = (100/#currentScene.step * index)/100 - GameController["BraindanceGameController"]:SetBraindanceProgress() - - end - runActionList(currentScene.step[index].action, currentScene.tag.."_"..index, "interact",false,"scene") - currentScene.index = index - - end - - end - end - - - - - - if(action.name == "spawn_camera") then - local position = {} - local position = getPositionFromParameter(action) - - - local angle = {} - angle.roll = action.roll - angle.pitch = action.pitch - angle.yaw = action.yaw - - spawnCamera(action.tag,position,action.surveillance,angle) - - end - - if(action.name == "move_camera") then - local position = {} - local position = getPositionFromParameter(action) - - local angle = {} - angle.roll = action.roll - angle.pitch = action.pitch - angle.yaw = action.yaw - - moveCamera(action.tag,position,angle) - end - - if(action.name == "activate_camera") then - enableCamera(action.tag) - end - - if(action.name == "stop_camera") then - stopCamera(action.tag) - end - - - - - - end - - if hudregion then - - if(action.name == "change_hud_visibility") then - - if (cyberscript.cache["hud"][v.tag] ~= nil) then - - cyberscript.cache["hud"][v.tag].data.visible = action.value - - end - - end - - if(action.name == "change_hud_margin") then - - if (cyberscript.cache["hud"][v.tag] ~= nil) then - if(cyberscript.cache["hud"][v.tag].data.margin == nil) then cyberscript.cache["hud"][v.tag].data.margin = {} end - cyberscript.cache["hud"][v.tag].data.margin.top = action.top - cyberscript.cache["hud"][v.tag].data.margin.left = action.left - - end - - end - - if(action.name == "change_hud_color") then - - if (cyberscript.cache["hud"][v.tag] ~= nil) then - if(cyberscript.cache["hud"][v.tag].data.color == nil) then cyberscript.cache["hud"][v.tag].data.color = {} end - - cyberscript.cache["hud"][v.tag].data.color.red = action.red - cyberscript.cache["hud"][v.tag].data.color.green = action.green - cyberscript.cache["hud"][v.tag].data.color.blue = action.blue - - end - - end - - if(action.name == "change_hud_fontfamily") then - - if (cyberscript.cache["hud"][v.tag] ~= nil) then - - - cyberscript.cache["hud"][v.tag].data.fontfamily = action.value - - end - - end - - if(action.name == "change_hud_fontstyle") then - - if (cyberscript.cache["hud"][v.tag] ~= nil) then - - - cyberscript.cache["hud"][v.tag].data.fontstyle = action.value - - end - - end - - if(action.name == "change_hud_fontsize") then - - if (cyberscript.cache["hud"][v.tag] ~= nil) then - - - cyberscript.cache["hud"][v.tag].data.fontsize = action.value - - end - - end - - if(action.name == "change_hud_text") then - - if (cyberscript.cache["hud"][v.tag] ~= nil) then - - - cyberscript.cache["hud"][v.tag].data.text = action.value - - end - - end - - end - - if airegion then - if(action.name == "setup_ai_context") then - - AIhandler[action.aitag] = {} - AIhandler[action.aitag].context = action.value - - end - - if(action.name == "flush_ai") then - FlushChat(action.aitag) - AIhandler[action.aitag] = nil - - end - - if(action.name == "ask_ai") then - setupAIkey(action.aitag) - if(ScheduleChatCompletionRequest ~= null) then - ScheduleChatCompletionRequest(action.aitag,{ - {"User", action.value} - }); - else - --print("ai not found") - end - - end - - if(action.name == "ask_ai_with_context") then - setupAIkey(action.aitag) - if(ScheduleChatCompletionRequest ~= null) then - ScheduleChatCompletionRequest(action.aitag,{ - {"User", action.value}, - getAIContextOrDefault(action.aitag) - }); - else - --print("ai not found") - end - - end - if(action.name == "ask_ai_from_item") then - setupAIkey(action.aitag) - if(ScheduleChatCompletionRequest ~= null and - cyberscript.cache["ai"][action.tag]~=nil) then - local contextAI = {} - - for i,con in ipairs(cyberscript.cache["ai"][action.tag].data.contexts) do - local item = {} - checkContext(con) - table.insert(item,con.context_type) - table.insert(item,con.value) - table.insert(contextAI,item) - end - --print(dump(contextAI)) - ScheduleChatCompletionRequest(action.aitag,contextAI); - else - --print("ai not found") - end - - end - - if(action.name == "ask_ai_from_item_with_value") then - setupAIkey(action.aitag) - if(ScheduleChatCompletionRequest ~= nil and - cyberscript.cache["ai"][action.tag]~=nil) then - local contextAI = {} - - for i,con in ipairs(cyberscript.cache["ai"][action.tag].data.contexts) do - local item = {} - checkContext(con) - table.insert(item,con.context_type) - table.insert(item,con.value) - table.insert(contextAI,item) - end - - local item = {} - table.insert(item,"User") - table.insert(item,action.value) - table.insert(contextAI,item) - - --print(dump(contextAI)) - - ScheduleChatCompletionRequest(action.aitag,contextAI); - else - --print("ai not found") - end - - end - - if(action.name == "ask_ai_from_item_with_new_contexts") then - setupAIkey(action.aitag) - if(ScheduleChatCompletionRequest ~= nil and - cyberscript.cache["ai"][action.tag]~=nil) then - local contextAI = {} - - for i,con in ipairs(cyberscript.cache["ai"][action.tag].data.contexts) do - local item = {} - checkContext(con) - table.insert(item,con.context_type) - table.insert(item,con.value) - table.insert(contextAI,item) - end - - for i,con in ipairs(action.contexts) do - checkContext(con) - local item = {} - table.insert(item,con.context_type) - table.insert(item,con.value) - table.insert(contextAI,item) - end - - --print(dump(contextAI)) - - ScheduleChatCompletionRequest(action.aitag,contextAI); - else - --print("ai not found") - end - - end - - if(action.name == "get_ai_answer_in_score") then - - if(ScheduleChatCompletionRequest ~= null) then - setVariable(action.variable,action.key,AIhandler[action.aitag].answer) - else - --print("ai not found") - end - - end - - - if(action.name == "set_choice_from_ai") then - --logme(3,"is logme(10,source) - local usedial = {} - - usedial.desc = "" - usedial.speaker = "V" - - usedial.header = {} - usedial.header.version = 3 - - usedial.requirement = {} - usedial.trigger = {} - usedial.context = {} - - usedial.options = {} - - --print(getAIAnswerOrDefault(action.aitag)) - local item = json.decode(getAIAnswerOrDefault(action.aitag)) - - - - if(item.questions ~= nil) then - - _,n = item.answer:gsub("%S+","") - - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = action.speaker - actionss.target = "player" - actionss.duration = math.ceil(n*0.2) - actionss.title = item.answer - local actionlist = {} - table.insert(actionlist,actionss) - - - - for i,v in ipairs(item.questions) do - local answer = {} - answer.requirement = {} - answer.trigger = {} - answer.context = {} - answer.description = v - answer.style = {} - answer.style.color = {} - answer.action = {} - - local actionss = {} - actionss.name = "ask_ai" - actionss.tag = "dialog_template" - actionss.value = v - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = "V" - actionss.target = "player" - actionss.duration = 5 - actionss.title = v - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "wait_for_ai_answer" - - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "set_choice_from_ai" - actionss.speaker = action.speaker - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - - table.insert(usedial.options,answer) - end - - - - local answer = {} - answer.requirement = {} - answer.trigger = {} - answer.context = {} - answer.description = "Tell me more about it." - answer.style = {} - answer.style.color = {} - answer.action = {} - - local actionss = {} - actionss.name = "ask_ai" - actionss.tag = "dialog_template" - actionss.value = "Tell me more about it." - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = "V" - actionss.target = "player" - actionss.duration = 5 - actionss.title = "Tell me more about it." - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "wait_for_ai_answer" - - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "set_choice_from_ai" - actionss.speaker = action.speaker - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - table.insert(usedial.options,answer) - - local answer = {} - answer.requirement = {} - answer.trigger = {} - answer.context = {} - answer.description = "Wait... Can you repeat what you said ?" - answer.style = {} - answer.style.color = {} - answer.action = {} - - local actionss = {} - actionss.name = "ask_ai" - actionss.tag = "dialog_template" - actionss.value = "Wait... Can you repeat what you said ?" - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = "V" - actionss.target = "player" - actionss.duration = 5 - actionss.title = "Wait... Can you repeat what you said ?" - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "wait_for_ai_answer" - - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "set_choice_from_ai" - actionss.speaker = action.speaker - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - table.insert(usedial.options,answer) - - - local answer = {} - answer.requirement = {} - answer.trigger = {} - answer.context = {} - answer.description = "Got someone for that ?" - answer.style = {} - answer.style.color = {} - answer.action = {} - - local actionss = {} - actionss.name = "ask_ai_from_item" - actionss.tag = "quest" - - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = "V" - actionss.target = "player" - actionss.duration = 5 - actionss.title = "Got someone for that ?" - table.insert(answer.action,actionss) - - - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = action.speaker - actionss.target = "player" - actionss.duration = 5 - actionss.title = "I will send you the informations later. Walls got mics here." - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = "V" - actionss.target = "player" - actionss.duration = 5 - actionss.title = "Thanks !" - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "wait_for_ai_answer" - - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - table.insert(usedial.options,answer) - - - - local answer = {} - answer.requirement = {} - answer.trigger = {} - answer.context = {} - answer.description = "We talk later." - answer.style = {} - answer.style.color = {} - answer.action = {} - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = "V" - actionss.target = "player" - actionss.duration = 5 - actionss.title = "We talk later." - table.insert(answer.action,actionss) - local actionss = {} - actionss.name = "subtitle" - actionss.type = 1 - actionss.speaker = action.speaker - actionss.target = "player" - actionss.duration = 5 - actionss.title = "See ya around !" - table.insert(answer.action,actionss) - local actionss = {} - actionss.name = "flush_ai" - actionss.aitag = action.aitag - table.insert(answer.action,actionss) - - table.insert(usedial.options,answer) - local actionss = {} - actionss.name = "set_generated_dialog" - actionss.item = usedial - - table.insert(actionlist,actionss) - runSubActionList(actionlist, tag.."_event_", tag,source,false,exector,bypassmenu) - - - - else - - --print("Noep") - end - - - end - - - if(action.name == "create_quest_from_ai") then - - local questos = json.decode(getAIAnswerOrDefault(action.aitag)) - local data = {} - local missiontag = "ai_quest_tag_"..math.random(1,99999) - - cyberscript.cache["mission"][missiontag] = {} - cyberscript.cache["mission"][missiontag].data = {} - cyberscript.cache["mission"][missiontag].file = "datapack/".."cyberai".."/".."mission".."/"..missiontag..".json" - cyberscript.cache["mission"][missiontag].datapack = "cyberai" - cyberscript.cache["mission"][missiontag].scripttype = "mission" - - local quest = {} - quest.header = {} - quest.header.version = 1 - - quest.tag = missiontag - quest.objectives = {} - - for i,aiobj in ipairs(questos.objectives) do - - local objective = {} - - - - objective.resume_action = {} - objective.extra = {} - objective.action = {} - objective.tag = missiontag.."_".."obj_"..i - objective.title = aiobj.title - objective.id = missiontag.."_".."obj_"..i - objective.trigger = {} - objective.state = {} - objective.failaction = {} - objective.isOptional = false - objective.isoptionnal = false - objective.requirement ={} - objective.unlock = {} - - - table.insert(quest.objectives,objective) - - - end - - - - quest.district = EgamedataDistrict[questos.place] - - quest.failure_condition = {} - quest.failure_condition.player_death = {} - quest.failure_condition.player_death.name = "player_death" - quest.failure_condition.player_death.helperTitle = "Player : is Dead" - quest.failure_condition.player_death.helper = "This trigger will be triggered when you are dead" - quest.failure_condition_requirement = {} - quest.failure_condition_requirement[1] = {"player_death"} - quest.failure_action = {} - - - quest.trigger_condition = {} - quest.trigger_condition.auto = {} - quest.trigger_condition.auto.name = "auto" - quest.trigger_condition.auto.helperTitle = "auto" - quest.trigger_condition.auto.helper = "auto" - quest.trigger_condition_requirement = {} - quest.trigger_condition_requirement[1] = {"auto"} - - quest.failure_action = {} - - quest.extra ={} - quest.context = {} - - - quest.end_action = {} - quest.reset_action = {} - - quest.unlock_action = {} - quest.content = getLang(questos.description) - quest.recommandedlevel = 5 - quest.title = getLang(questos.title) - quest.questtype = 2 - quest.recurrent = false - - quest.alreadyStart = false - quest.column = 1 - quest.row = 1 - - - cyberscript.cache["mission"][missiontag].data = quest - - pcall(function() - QuestManager.RemoveQuest(missiontag) - setScore(missiontag,"Score",nil) - QuestManager.MarkQuestAsInactive(missiontag) - QuestManager.MarkAllObjectiveOfQuestAs(missiontag,1) - QuestManager.MarkQuestAsUnVisited(missiontag) - end) - loadQuestToUI(quest) - end - - if(action.name == "set_generated_dialog") then - --print(dump(action.item)) - createDialog(action.item) - - end - if(action.name == "ai_phone_notification") then - local itemjson = json.decode(getAIAnswerOrDefault(action.aitag)) - - --print("mar1"..itemjson.answer) - - if(itemjson.questions ~= nil) then - local test = getLang(action.speaker) - local openAction = OpenMessengerNotificationAction.new() - openAction.eventDispatcher = GameController["JournalNotificationQueue"] - local userData = PhoneMessageNotificationViewData.new() - userData.title = test - --print("mar2"..itemjson.answer) - userData.SMSText = itemjson.answer - userData.action = openAction - userData.animation = CName('notification_phone_MSG') - userData.soundEvent = CName('PhoneSmsPopup') - userData.soundAction = CName('OnOpen') - currentPhoneDialogPopup = gameJournalPhoneMessage.new() - currentPhoneDialogPopup.sender = 1 - currentPhoneDialogPopup.text = itemjson.answser - currentPhoneDialogPopup.delay = -9999 - currentPhoneDialogPopup.id = test - - - - - - if(AIconversation[action.conversation] == nil and action.conversation ~= "") then - AIconversation[action.conversation] = {} - AIconversation[action.conversation].unlock = true - AIconversation[action.conversation].speaker = action.speaker - AIconversation[action.conversation].message = {} - end - - - - - - AIconversation[action.conversation].tag = action.conversation - - local message = {} - message.tag = action.conversation.."_"..(#AIconversation[action.conversation].message+1) - - message.text= itemjson.answer - message.unlock = true - message.readed = true - message.unlocknext = "" - message.sender = 0 - message.choices = {} - - for i,v in ipairs(itemjson.questions) do - local answer = {} - answer.action_bypassmenu_execution = false - answer.tag = action.conversation.."_"..(#AIconversation[action.conversation].message+1).."_".."choice"..i - - answer.unlocknext = "" - answer.text = v - answer.trigger = {} - answer.context = {} - answer.action = {} - answer.requirement = {} - - local actionss = {} - actionss.name = "ask_ai_from_item_with_value" - actionss.tag = "dialog_template" - actionss.value = v - actionss.aitag = action.aitag - - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "wait_for_ai_answer" - actionss.aitag = action.aitag - table.insert(answer.action,actionss) - - local actionss = {} - actionss.name = "add_v_message_to_ai_phone" - actionss.value = v - actionss.conversation = action.conversation - table.insert(answer.action,actionss) - - - - - - local actionss = {} - actionss.name = "ai_phone_notification" - actionss.speaker = action.speaker - actionss.duration = 5 - actionss.conversation = action.conversation - table.insert(answer.action,actionss) - - - table.insert(message.choices,answer) - end - - - table.insert(AIconversation[action.conversation].message,message) - currentPhoneConversation = AIconversation[action.conversation] - currentPhoneConversation.currentchoices = {} - currentPhoneConversation.loaded = 0 - currentPhoneConversation.speaker = action.speaker - - - --print(dump(currentPhoneConversation)) - - - local notificationData = gameuiGenericNotificationData.new() - notificationData.time = action.duration - notificationData.widgetLibraryItemName = CName('notification_message') - notificationData.notificationData = userData - GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) - - - end - end - - if(action.name == "add_v_message_to_ai_phone") then - if(AIconversation[action.conversation] == nil and action.conversation ~= "") then - AIconversation[action.conversation] = {} - AIconversation[action.conversation].unlock = true - AIconversation[action.conversation].speaker = action.speaker - AIconversation[action.conversation].message = {} - end - - - - - - AIconversation[action.conversation].tag = action.conversation - - local message = {} - message.tag = action.conversation.."_"..(#AIconversation[action.conversation].message+1) - - message.text= action.value - message.unlock = true - message.readed = true - message.unlocknext = "" - message.sender = 1 - message.choices = {} - end - - - end - - end) - - if status == false then - - - logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty(action)).." tag "..tag.." parent "..parent.." index "..index,true) - if(action.fail_action ~= nil and #action.fail_action > 0) then - runActionList(action.fail_action, tag.."_failure", source,false,executortag) - - end - - - - end - - if(action.output == true) then - - logme(1,action.name,true) - logme(1,dump(action),true) - logme(1,tostring(result),true) - - end - - end - - return result -end + if(action.name == "open_phone") then + GameController["NewHudPhoneGameController"].PhoneSystem:QueueRequest( UsePhoneRequest.new()); + end + + + if(action.name == "close_menu") then + local closeHub = ForceCloseHubMenuEvent.new() + Game.GetUISystem():QueueEvent(closeHub) + end + if(action.name == "close_interface") then + -- openInterface = false + + currentInterface = nil + buttonsData = {} + UIPopupsManager.ClosePopup() + end + if(action.name == "lock_conversation" or action.name == "lock_message") then + setScore(action.tag,"unlocked",0) + PhoneHotkeyController_UpdateData(GameController["PhoneHotkeyController"]) + end + if(action.name == "unlock_conversation" or action.name == "unlock_message") then + setScore(action.tag,"unlocked",1) + PhoneHotkeyController_UpdateData(GameController["PhoneHotkeyController"]) + end + + if(action.name == "open_map_menu_to_position") then + local startHub = StartHubMenuEvent.new() + + local userData = MapMenuUserData.new() + userData.moveTo = Vector3.new(action.x, action.y, action.z) + + startHub:SetStartMenu("world_map",nil,userData) + Game.GetUISystem():QueueEvent(startHub) + + + end + + if(action.name == "show_hack_animation") then + + + + + + GameController["HUDProgressBarController"]:OnActivated(true) + GameController["HUDProgressBarController"]:UpdateTimerHeader(getLang(action.value)) + + end + + if(action.name == "change_hack_animation_percent") then + + if(action.text ~= nil and action.text ~= "") then + + GameController["HUDProgressBarController"]:UpdateTimerHeader(getLang(action.text)) + + end + GameController["HUDProgressBarController"]:UpdateTimerProgress((action.value/100)) + + end + + if(action.name == "hide_hack_animation") then + + + GameController["HUDProgressBarController"]:OnActivated(false) + GameController["HUDProgressBarController"]:UpdateTimerProgress((0/100)) + + end + + + + end + + if avregion then + if(action.name == "vehicule_autodrive_activate") then + local mappin = {} + mappin.x = action.x + mappin.y = action.y + mappin.z = action.z+5 + local actionlist = {} + + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + + local myPos = enti:GetWorldPosition() + local newPos = myPos + local angle = enti:GetWorldOrientation():ToEulerAngles() + + local tempangle = {} + tempangle.roll = 0 + tempangle.pitch = 0 + tempangle.yaw = 0 + + local numbertimes = 0 + local zpath=action.zfly + + + + newaction = {} + newaction.name = "wait_second" + newaction.value = 0.5 + table.insert(actionlist,newaction) + + if(action.isAV == true) then + local ztimes = action.zfly - myPos.z + local zpos = deepcopy(newPos.z,nil) + numbertimes = ztimes / zpath + + for i=1,ztimes do + + + zpos = zpos + 1 + + local newaction = {} + newaction.name = "teleport_entity_at_position" + newaction.tag = action.tag + newaction.x = newPos.x + newaction.y = newPos.y + newaction.z = zpos + newaction.angle = angle + newaction.collision = false + newaction.pathfinding = false + newaction.axis = "z" + table.insert(actionlist,newaction) + end + end + + + local destination = Vector4.new(mappin.x, myPos.y, myPos.z,1) + local dirVector = diffVector(myPos, destination) + local myyaw = 0 + local vdepart = LVector.new(myPos.x,myPos.y) + local varrive = LVector.new(mappin.x,mappin.y) + local diag = varrive-vdepart + local point = action.speed + local newangle = GetSingleton('Vector4'):ToRotation(dirVector) + local numtimes = diag*(1/point) + local path = deepcopy(vdepart,nil) + for i = 1,point do + path = path+numtimes + + + local newaction = {} + newaction.name = "teleport_entity_at_position" + newaction.tag = action.tag + newaction.x = path.x + newaction.y = path.y + newaction.z = action.zfly + newaction.angle = angle + newaction.pathfinding = action.pathfinding + newaction.collision = false + newaction.axis = "x" + table.insert(actionlist,newaction) + end + + newaction = {} + newaction.name = "wait_second" + newaction.value = 0.5 + table.insert(actionlist,newaction) + + if(action.isAV == true) then + + local ztimes = action.zfly - mappin.z - 3 + local zpos = deepcopy(ztimes,nil) + numbertimes = ztimes + + for i=1,numbertimes do + + + zpos = zpos - 1 + + local newaction = {} + newaction.name = "teleport_entity_at_position" + newaction.tag = action.tag + newaction.x = path.x + newaction.y = path.y + newaction.z = zpos + newaction.angle = angle + newaction.collision = true + newaction.pathfinding = false + newaction.axis = "z" + table.insert(actionlist,newaction) + end + + + end + + + runSubActionList(actionlist, tag.."_av_autodrive_activate", tag,source,false,executortag) + result = false + end + end + if(action.name == "vehicule_autodrive_activate_custom_mappin") then + if(mappinManager["selected_mappin"] ~= nil) then + + local mappin = mappinManager["selected_mappin"].position + local actionlist = {} + + local obj = getEntityFromManager(action.tag) + local enti = safeFindEntityByID(obj) + local myPos = enti:GetWorldPosition() + local newPos = myPos + local angle = enti:GetWorldOrientation():ToEulerAngles() + + local tempangle = {} + tempangle.roll = 0 + tempangle.pitch = 0 + tempangle.yaw = 0 + + + local zpath=action.zfly + + local zspeed = 0.5 + + + newaction = {} + newaction.name = "wait_second" + newaction.value = 0.7 + table.insert(actionlist,newaction) + + if(action.isAV == true) then + local ztimes = action.zfly - myPos.z + local zpos = deepcopy(newPos.z,nil) + local numbertimes = (ztimes)/zspeed + print("numbertimes "..numbertimes) + + for i=1,numbertimes do + + + zpos = zpos + zspeed + + local newaction = {} + newaction.name = "teleport_entity_at_position" + newaction.tag = action.tag + newaction.x = newPos.x + newaction.y = newPos.y + newaction.z = zpos + newaction.angle = angle + newaction.collision = false + newaction.pathfinding = false + newaction.axis = "z" + table.insert(actionlist,newaction) + end + end + + + local destination = Vector4.new(mappin.x, mappin.y, myPos.z,1) + local dirVector = diffVector(myPos, destination) + local myyaw = 0 + local vdepart = LVector.new(myPos.x,myPos.y) + local varrive = LVector.new(mappin.x,mappin.y) + local diag = varrive-vdepart + local point = action.speed + local newangle = GetSingleton('Vector4'):ToRotation(dirVector) + local numtimes = diag*(1/point) + local path = deepcopy(vdepart,nil) + for i = 1,point do + path = path+numtimes + + + local newaction = {} + newaction.name = "teleport_entity_at_position" + newaction.tag = action.tag + newaction.x = path.x + newaction.y = path.y + newaction.z = action.zfly + newaction.angle = angle + newaction.pathfinding = action.pathfinding + newaction.collision = false + newaction.axis = "x" + table.insert(actionlist,newaction) + end + + newaction = {} + newaction.name = "wait_second" + newaction.value = 0.7 + table.insert(actionlist,newaction) + + if(action.isAV == true) then + + local ztimes = (action.zfly - mappin.z - 3) + local zpos = deepcopy(ztimes,nil) + local numbertimes = ztimes/zspeed + + for i=1,numbertimes do + + + zpos = zpos - zspeed + + local newaction = {} + newaction.name = "teleport_entity_at_position" + newaction.tag = action.tag + newaction.x = path.x + newaction.y = path.y + newaction.z = zpos + newaction.angle = angle + newaction.collision = true + newaction.pathfinding = false + newaction.axis = "z" + table.insert(actionlist,newaction) + end + + + end + + + runSubActionList(actionlist, tag.."_av_autodrive_activate__custom_mappin", tag,source,false,executortag) + result = false + end + end + if(action.name == "toggle_av_engine") then + local obj = getEntityFromManager(action.tag) + if(obj ~= nil) then + if(obj.isAV == true) then + obj.isAV = false + else + obj.isAV = true + end + end + end + if(action.name == "toggle_av_engine_for_current_drived_vehicule") then + local inVehicule = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + if (inVehicule) then + local vehicule = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + if(vehicule ~= nil) then + local obj = getEntityFromManagerById(vehicule:GetEntityID()) + if(obj.id == nil) then + local entity = {} + entity.id = vehicule:GetEntityID() + entity.tag = "vehicule_"..math.random(1,9999) + entity.tweak = "nope" + entity.takenSeat = {} + entity.isAV = false + local group = getGroupfromManager("AV") + entity.availableSeat = GetSeats(vehicule) + entity.driver = "player" + cyberscript.EntityManager[entity.tag]=entity + --logme(3,"new "..entity.tag) + obj = entity + end + logme(3,obj.tag) + local obj = getTrueEntityFromManager(obj.tag) + if(obj.isAV == true) then + obj.isAV = false + + for i=1, #cyberscript.GroupManager["AV"].entities do + local entityTag = cyberscript.GroupManager["AV"].entities[i] + if(entityTag == obj.tag) then + table.remove(cyberscript.GroupManager["AV"].entities,i) + end + end + --logme(3,"removedAV"..obj.tag) + else + + obj.isAV = true + if(cyberscript.GroupManager["AV"].entities == nil) then + cyberscript.GroupManager["AV"].entities = {} + end + logme(3,"addedAV"..obj.tag) + table.insert(cyberscript.GroupManager["AV"].entities,obj.tag) + end + end + end + end + end + + if customnpcregion then + + if(action.name == "npc_custom_edit_custom_npc") then + local npc = getCustomNPCbyTag(action.tag) + npc.spawnforced=true + npc.dospawnaction=action.dospawnaction + npc.doroutineaction=action.doroutineaction + npc.dodeathaction=action.dodeathaction + npc.dodespawnaction=action.dodespawnaction + npc.repeat_routine = action.repeat_routine + npc.auto_despawn = action.auto_despawn + if(action.replacelocation == true) then + npc.workinglocation.x = action.x + npc.workinglocation.y = action.y + npc.workinglocation.z = action.z + npc.workinglocation.range = action.range + end + if(action.appeareance ~= nil and action.appeareance ~= "") then + npc.appeareance = action.appearance + end + end + if(action.name == "npc_custom_despawn_custom_npc") then + local npc = getCustomNPCbyTag(action.tag) + npc.isspawn=false + npc.init=false + npc.appearancesetted = nil + npc.spawnforced=false + npc.dospawnaction=true + npc.doroutineaction=true + npc.dodeathaction=true + npc.dodespawnaction=true + npc.workinglocation = npc.location + if(workerTable[npc.tag.."_spawn"] ~= nil) then + workerTable[npc.tag.."_spawn"] = nil + end + if(workerTable[npc.tag.."_death"] ~= nil) then + workerTable[npc.tag.."_death"] = nil + end + if(workerTable[npc.tag.."_routine"] ~= nil) then + workerTable[npc.tag.."_routine"] = nil + end + despawnEntity(npc.tag) + if(workerTable[npc.tag.."_despawn"] == nil and #npc.despawnaction > 0) then + runActionList(npc.despawnaction, npc.tag.."_despawn", "interact",false,npc.tag) + end + end + if(action.name == "npc_custom_set_autodespawn") then + local npc = getCustomNPCByTag(action.tag) + npc.auto_despawn = action.value + end + if(action.name == "npc_custom_set_autoroutine") then + local npc = getCustomNPCByTag(action.tag) + npc.repeat_routine = action.value + end + if(action.name == "npc_custom_copy") then + local npc = getCustomNPCbyTag(action.sourcetag) + local newnpc = deepcopy(npc, newnpc) + newnpc.tag = action.newtag + newnpc.name = action.newname + addCustomNPC(newnpc) + end + end + + + + if scene then + if(action.name == "show_braindance_ui") then + + if(GameController["BraindanceGameController"] ~= nil) then + local root = GameController["BraindanceGameController"].rootWidget + + + + root:SetVisible(true) + + GameController["BraindanceGameController"].PlayLibraryAnimation(CName("SHOW")) + + + end + + end + + if(action.name == "bound_scene_to_braindance") then + + if(GameController["BraindanceGameController"] ~= nil and currentScene ~= nil) then + local margin = inkMargin.new({ top = -45}) + inkWidgetRef.SetMargin(GameController["BraindanceGameController"].cursorPoint, margin) + local margin = inkMargin.new({ left = 0}) + inkWidgetRef.SetMargin(GameController["BraindanceGameController"].currentTimerMarker, margin) + inkTextRef.SetText(GameController["BraindanceGameController"].currentTimerText, "0 : 0") + currentScene.isbraindance = true + + + + end + + end + + if(action.name == "unbound_scene_to_braindance") then + + if(GameController["BraindanceGameController"] ~= nil and currentScene ~= nil) then + local margin = inkMargin.new({ top = -45}) + inkWidgetRef.SetMargin(GameController["BraindanceGameController"].cursorPoint, margin) + currentScene.isbraindance = false + + + + end + + end + + if(action.name == "hide_braindance_ui") then + + if(GameController["BraindanceGameController"] ~= nil) then + local root = GameController["BraindanceGameController"].rootWidget + + + + root:SetVisible(false) + + + + + end + + end + + + + + + if(action.name == "load_scene") then + + local scene = cyberscript.cache["scene"][action.tag] + + if(scene ~= nil) then + + currentScene = scene.data + currentScene.index = 0 + if(GameController["BraindanceGameController"] ~= nil and currentScene.isbraindance == true) then + + local root = GameController["BraindanceGameController"].rootWidget + + + + + root:SetVisible(true) + + GameController["BraindanceGameController"].PlayLibraryAnimation(CName("SHOW")) + + local margin = inkMargin.new({ top = -45}) + inkWidgetRef.SetMargin(GameController["BraindanceGameController"].cursorPoint, margin) + local margin = inkMargin.new({ left = 0}) + inkWidgetRef.SetMargin(GameController["BraindanceGameController"].currentTimerMarker, margin) + inkTextRef.SetText(GameController["BraindanceGameController"].currentTimerText, "0 : 0") + + + + + end + else + + error("No scene founded for the tag "..action.tag) + + + end + + end + + if(action.name == "unload_scene") then + + + + if(currentScene ~= nil) then + + currentScene = nil + + + + + end + end + + if(action.name == "play_scene") then + + + + if(currentScene ~= nil) then + + + + + runActionList(currentScene.reset_action, currentScene.tag.."_reset", "interact",false,"scene") + + local actionlist = {} + + local actiontd = {} + actiontd.name = "wait_for_trigger" + actiontd.trigger = {} + actiontd.trigger.name = "event_is_finished" + actiontd.trigger.tag = currentScene.tag.."_reset" + + table.insert(actionlist,actiontd) + + for i=1,#currentScene.init_action do + + table.insert(actionlist,currentScene.init_action[i]) + + end + + + runActionList(actionlist, currentScene.tag.."_init", "interact",false,"scene") + + + actionlist = {} + + actiontd = {} + actiontd.name = "wait_for_trigger" + actiontd.trigger = {} + actiontd.trigger.name = "event_is_finished" + actiontd.trigger.tag = currentScene.tag.."_init" + + table.insert(actionlist,actiontd) + + for i=1,#currentScene.step do + + + local step = currentScene.step[i] + + + + for y=1,#step.action do + + table.insert(actionlist,step.action[y]) + + end + + end + + + for i=1,#currentScene.end_action do + + table.insert(actionlist,currentScene.end_action[i]) + + end + + + runActionList(actionlist, currentScene.tag.."_full", "interact",false,"scene") + else + + error("No scene loaded") + + end + end + + if(action.name == "reset_scene") then + + + + if(currentScene ~= nil) then + + + + + runActionList(currentScene.reset_action, currentScene.tag.."_reset", "interact",false,"scene") + currentScene.index = 0 + + end + end + + if(action.name == "init_scene") then + + + + if(currentScene ~= nil) then + + + + + runActionList(currentScene.init_action, currentScene.tag.."_init", "interact",false,"scene") + currentScene.index = 0 + else + + error("No scene loaded") + end + end + + if(action.name == "play_scene_step_index") then + + + + if(currentScene ~= nil) then + + + + if(currentScene.step[action.value] ~= nil) then + if (currentScene.isbraindance == true) then + + GameController["BraindanceGameController"].currentTime = (100/#currentScene.step * action.value)/100 + GameController["BraindanceGameController"]:SetBraindanceProgress() + + end + runActionList(currentScene.step[action.value].action, currentScene.tag.."_"..action.value, "interact",false,"scene") + currentScene.index = action.value + end + + end + end + + if(action.name == "play_scene_step_by_tag") then + + + + if(currentScene ~= nil) then + + + for i=1,#currentScene.step do + if(currentScene.step[i].tag == action.tag) then + if (currentScene.isbraindance == true) then + + GameController["BraindanceGameController"].currentTime = (100/#currentScene.step * i)/100 + GameController["BraindanceGameController"]:SetBraindanceProgress() + + end + runActionList(currentScene.step[i].action, currentScene.tag.."_"..i, "interact",false,"scene") + currentScene.index = i + end + end + + end + end + + if(action.name == "play_next_scene_step") then + + + + if(currentScene ~= nil) then + + + local index = currentScene.index +1 + + if(currentScene.step[index] ~= nil) then + if (currentScene.isbraindance == true) then + + GameController["BraindanceGameController"].currentTime = (100/#currentScene.step * index)/100 + GameController["BraindanceGameController"]:SetBraindanceProgress() + + end + + runActionList(currentScene.step[index].action, currentScene.tag.."_"..index, "interact",false,"scene") + currentScene.index = index + + end + + end + end + + if(action.name == "play_previous_scene_step") then + + + + if(currentScene ~= nil) then + + + local index = currentScene.index -1 + + if(currentScene.step[index] ~= nil) then + if (currentScene.isbraindance == true) then + + GameController["BraindanceGameController"].currentTime = (100/#currentScene.step * index)/100 + GameController["BraindanceGameController"]:SetBraindanceProgress() + + end + runActionList(currentScene.step[index].action, currentScene.tag.."_"..index, "interact",false,"scene") + currentScene.index = index + + end + + end + end + + + + + + if(action.name == "spawn_camera") then + local position = {} + local position = getPositionFromParameter(action) + + + local angle = {} + angle.roll = action.roll + angle.pitch = action.pitch + angle.yaw = action.yaw + + spawnCamera(action.tag,position,action.surveillance,angle) + + end + + if(action.name == "move_camera") then + local position = {} + local position = getPositionFromParameter(action) + + local angle = {} + angle.roll = action.roll + angle.pitch = action.pitch + angle.yaw = action.yaw + + moveCamera(action.tag,position,angle) + end + + if(action.name == "activate_camera") then + enableCamera(action.tag) + end + + if(action.name == "stop_camera") then + stopCamera(action.tag) + end + + + + + + end + + if hudregion then + + if(action.name == "change_hud_visibility") then + + if (cyberscript.cache["hud"][v.tag] ~= nil) then + + cyberscript.cache["hud"][v.tag].data.visible = action.value + + end + + end + + if(action.name == "change_hud_margin") then + + if (cyberscript.cache["hud"][v.tag] ~= nil) then + if(cyberscript.cache["hud"][v.tag].data.margin == nil) then cyberscript.cache["hud"][v.tag].data.margin = {} end + cyberscript.cache["hud"][v.tag].data.margin.top = action.top + cyberscript.cache["hud"][v.tag].data.margin.left = action.left + + end + + end + + if(action.name == "change_hud_color") then + + if (cyberscript.cache["hud"][v.tag] ~= nil) then + if(cyberscript.cache["hud"][v.tag].data.color == nil) then cyberscript.cache["hud"][v.tag].data.color = {} end + + cyberscript.cache["hud"][v.tag].data.color.red = action.red + cyberscript.cache["hud"][v.tag].data.color.green = action.green + cyberscript.cache["hud"][v.tag].data.color.blue = action.blue + + end + + end + + if(action.name == "change_hud_fontfamily") then + + if (cyberscript.cache["hud"][v.tag] ~= nil) then + + + cyberscript.cache["hud"][v.tag].data.fontfamily = action.value + + end + + end + + if(action.name == "change_hud_fontstyle") then + + if (cyberscript.cache["hud"][v.tag] ~= nil) then + + + cyberscript.cache["hud"][v.tag].data.fontstyle = action.value + + end + + end + + if(action.name == "change_hud_fontsize") then + + if (cyberscript.cache["hud"][v.tag] ~= nil) then + + + cyberscript.cache["hud"][v.tag].data.fontsize = action.value + + end + + end + + if(action.name == "change_hud_text") then + + if (cyberscript.cache["hud"][v.tag] ~= nil) then + + + cyberscript.cache["hud"][v.tag].data.text = action.value + + end + + end + + end + + if airegion then + if(action.name == "setup_ai_context") then + + AIhandler[action.aitag] = {} + AIhandler[action.aitag].context = action.value + + end + + if(action.name == "flush_ai") then + FlushChat(action.aitag) + AIhandler[action.aitag] = nil + + end + + if(action.name == "ask_ai") then + setupAIkey(action.aitag) + if(ScheduleChatCompletionRequest ~= null) then + ScheduleChatCompletionRequest(action.aitag,{ + {"User", action.value} + }); + else + --print("ai not found") + end + + end + + if(action.name == "ask_ai_with_context") then + setupAIkey(action.aitag) + if(ScheduleChatCompletionRequest ~= null) then + ScheduleChatCompletionRequest(action.aitag,{ + {"User", action.value}, + getAIContextOrDefault(action.aitag) + }); + else + --print("ai not found") + end + + end + if(action.name == "ask_ai_from_item") then + setupAIkey(action.aitag) + if(ScheduleChatCompletionRequest ~= null and + cyberscript.cache["ai"][action.tag]~=nil) then + local contextAI = {} + + for i,con in ipairs(cyberscript.cache["ai"][action.tag].data.contexts) do + local item = {} + checkContext(con) + table.insert(item,con.context_type) + table.insert(item,con.value) + table.insert(contextAI,item) + end + --print(dump(contextAI)) + ScheduleChatCompletionRequest(action.aitag,contextAI); + else + --print("ai not found") + end + + end + + if(action.name == "ask_ai_from_item_with_value") then + setupAIkey(action.aitag) + if(ScheduleChatCompletionRequest ~= nil and + cyberscript.cache["ai"][action.tag]~=nil) then + local contextAI = {} + + for i,con in ipairs(cyberscript.cache["ai"][action.tag].data.contexts) do + local item = {} + checkContext(con) + table.insert(item,con.context_type) + table.insert(item,con.value) + table.insert(contextAI,item) + end + + local item = {} + table.insert(item,"User") + table.insert(item,action.value) + table.insert(contextAI,item) + + --print(dump(contextAI)) + + ScheduleChatCompletionRequest(action.aitag,contextAI); + else + --print("ai not found") + end + + end + + if(action.name == "ask_ai_from_item_with_new_contexts") then + setupAIkey(action.aitag) + if(ScheduleChatCompletionRequest ~= nil and + cyberscript.cache["ai"][action.tag]~=nil) then + local contextAI = {} + + for i,con in ipairs(cyberscript.cache["ai"][action.tag].data.contexts) do + local item = {} + checkContext(con) + table.insert(item,con.context_type) + table.insert(item,con.value) + table.insert(contextAI,item) + end + + for i,con in ipairs(action.contexts) do + checkContext(con) + local item = {} + table.insert(item,con.context_type) + table.insert(item,con.value) + table.insert(contextAI,item) + end + + --print(dump(contextAI)) + + ScheduleChatCompletionRequest(action.aitag,contextAI); + else + --print("ai not found") + end + + end + + if(action.name == "get_ai_answer_in_score") then + + if(ScheduleChatCompletionRequest ~= null) then + setVariable(action.variable,action.key,AIhandler[action.aitag].answer) + else + --print("ai not found") + end + + end + + + if(action.name == "set_choice_from_ai") then + --logme(3,"is logme(10,source) + local usedial = {} + + usedial.desc = "" + usedial.speaker = "V" + + usedial.header = {} + usedial.header.version = 3 + + usedial.requirement = {} + usedial.trigger = {} + usedial.context = {} + + usedial.options = {} + + --print(getAIAnswerOrDefault(action.aitag)) + local item = json.decode(getAIAnswerOrDefault(action.aitag)) + + + + if(item.questions ~= nil) then + + _,n = item.answer:gsub("%S+","") + + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = action.speaker + actionss.target = "player" + actionss.duration = math.ceil(n*0.2) + actionss.title = item.answer + local actionlist = {} + table.insert(actionlist,actionss) + + + + for i,v in ipairs(item.questions) do + local answer = {} + answer.requirement = {} + answer.trigger = {} + answer.context = {} + answer.description = v + answer.style = {} + answer.style.color = {} + answer.action = {} + + local actionss = {} + actionss.name = "ask_ai" + actionss.tag = "dialog_template" + actionss.value = v + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = "V" + actionss.target = "player" + actionss.duration = 5 + actionss.title = v + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "wait_for_ai_answer" + + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "set_choice_from_ai" + actionss.speaker = action.speaker + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + + table.insert(usedial.options,answer) + end + + + + local answer = {} + answer.requirement = {} + answer.trigger = {} + answer.context = {} + answer.description = "Tell me more about it." + answer.style = {} + answer.style.color = {} + answer.action = {} + + local actionss = {} + actionss.name = "ask_ai" + actionss.tag = "dialog_template" + actionss.value = "Tell me more about it." + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = "V" + actionss.target = "player" + actionss.duration = 5 + actionss.title = "Tell me more about it." + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "wait_for_ai_answer" + + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "set_choice_from_ai" + actionss.speaker = action.speaker + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + table.insert(usedial.options,answer) + + local answer = {} + answer.requirement = {} + answer.trigger = {} + answer.context = {} + answer.description = "Wait... Can you repeat what you said ?" + answer.style = {} + answer.style.color = {} + answer.action = {} + + local actionss = {} + actionss.name = "ask_ai" + actionss.tag = "dialog_template" + actionss.value = "Wait... Can you repeat what you said ?" + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = "V" + actionss.target = "player" + actionss.duration = 5 + actionss.title = "Wait... Can you repeat what you said ?" + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "wait_for_ai_answer" + + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "set_choice_from_ai" + actionss.speaker = action.speaker + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + table.insert(usedial.options,answer) + + + local answer = {} + answer.requirement = {} + answer.trigger = {} + answer.context = {} + answer.description = "Got someone for that ?" + answer.style = {} + answer.style.color = {} + answer.action = {} + + local actionss = {} + actionss.name = "ask_ai_from_item" + actionss.tag = "quest" + + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = "V" + actionss.target = "player" + actionss.duration = 5 + actionss.title = "Got someone for that ?" + table.insert(answer.action,actionss) + + + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = action.speaker + actionss.target = "player" + actionss.duration = 5 + actionss.title = "I will send you the informations later. Walls got mics here." + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = "V" + actionss.target = "player" + actionss.duration = 5 + actionss.title = "Thanks !" + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "wait_for_ai_answer" + + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + table.insert(usedial.options,answer) + + + + local answer = {} + answer.requirement = {} + answer.trigger = {} + answer.context = {} + answer.description = "We talk later." + answer.style = {} + answer.style.color = {} + answer.action = {} + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = "V" + actionss.target = "player" + actionss.duration = 5 + actionss.title = "We talk later." + table.insert(answer.action,actionss) + local actionss = {} + actionss.name = "subtitle" + actionss.type = 1 + actionss.speaker = action.speaker + actionss.target = "player" + actionss.duration = 5 + actionss.title = "See ya around !" + table.insert(answer.action,actionss) + local actionss = {} + actionss.name = "flush_ai" + actionss.aitag = action.aitag + table.insert(answer.action,actionss) + + table.insert(usedial.options,answer) + local actionss = {} + actionss.name = "set_generated_dialog" + actionss.item = usedial + + table.insert(actionlist,actionss) + runSubActionList(actionlist, tag.."_event_", tag,source,false,exector,bypassmenu) + + + + else + + --print("Noep") + end + + + end + + + if(action.name == "create_quest_from_ai") then + + local questos = json.decode(getAIAnswerOrDefault(action.aitag)) + local data = {} + local missiontag = "ai_quest_tag_"..math.random(1,99999) + + cyberscript.cache["mission"][missiontag] = {} + cyberscript.cache["mission"][missiontag].data = {} + cyberscript.cache["mission"][missiontag].file = "datapack/".."cyberai".."/".."mission".."/"..missiontag..".json" + cyberscript.cache["mission"][missiontag].datapack = "cyberai" + cyberscript.cache["mission"][missiontag].scripttype = "mission" + + local quest = {} + quest.header = {} + quest.header.version = 1 + + quest.tag = missiontag + quest.objectives = {} + + for i,aiobj in ipairs(questos.objectives) do + + local objective = {} + + + + objective.resume_action = {} + objective.extra = {} + objective.action = {} + objective.tag = missiontag.."_".."obj_"..i + objective.title = aiobj.title + objective.id = missiontag.."_".."obj_"..i + objective.trigger = {} + objective.state = {} + objective.failaction = {} + objective.isOptional = false + objective.isoptionnal = false + objective.requirement ={} + objective.unlock = {} + + + table.insert(quest.objectives,objective) + + + end + + + + quest.district = EgamedataDistrict[questos.place] + + quest.failure_condition = {} + quest.failure_condition.player_death = {} + quest.failure_condition.player_death.name = "player_death" + quest.failure_condition.player_death.helperTitle = "Player : is Dead" + quest.failure_condition.player_death.helper = "This trigger will be triggered when you are dead" + quest.failure_condition_requirement = {} + quest.failure_condition_requirement[1] = {"player_death"} + quest.failure_action = {} + + + quest.trigger_condition = {} + quest.trigger_condition.auto = {} + quest.trigger_condition.auto.name = "auto" + quest.trigger_condition.auto.helperTitle = "auto" + quest.trigger_condition.auto.helper = "auto" + quest.trigger_condition_requirement = {} + quest.trigger_condition_requirement[1] = {"auto"} + + quest.failure_action = {} + + quest.extra ={} + quest.context = {} + + + quest.end_action = {} + quest.reset_action = {} + + quest.unlock_action = {} + quest.content = getLang(questos.description) + quest.recommandedlevel = 5 + quest.title = getLang(questos.title) + quest.questtype = 2 + quest.recurrent = false + + quest.alreadyStart = false + quest.column = 1 + quest.row = 1 + + + cyberscript.cache["mission"][missiontag].data = quest + + pcall(function() + QuestManager.RemoveQuest(missiontag) + setScore(missiontag,"Score",nil) + QuestManager.MarkQuestAsInactive(missiontag) + QuestManager.MarkAllObjectiveOfQuestAs(missiontag,1) + QuestManager.MarkQuestAsUnVisited(missiontag) + end) + loadQuestToUI(quest) + end + + if(action.name == "set_generated_dialog") then + --print(dump(action.item)) + createDialog(action.item) + + end + if(action.name == "ai_phone_notification") then + local itemjson = json.decode(getAIAnswerOrDefault(action.aitag)) + + --print("mar1"..itemjson.answer) + + if(itemjson.questions ~= nil) then + local test = getLang(action.speaker) + local openAction = OpenMessengerNotificationAction.new() + openAction.eventDispatcher = GameController["JournalNotificationQueue"] + local userData = PhoneMessageNotificationViewData.new() + userData.title = test + --print("mar2"..itemjson.answer) + userData.SMSText = itemjson.answer + userData.action = openAction + userData.animation = CName('notification_phone_MSG') + userData.soundEvent = CName('PhoneSmsPopup') + userData.soundAction = CName('OnOpen') + currentPhoneDialogPopup = gameJournalPhoneMessage.new() + currentPhoneDialogPopup.sender = 1 + currentPhoneDialogPopup.text = itemjson.answser + currentPhoneDialogPopup.delay = -9999 + currentPhoneDialogPopup.id = test + + + + + + if(AIconversation[action.conversation] == nil and action.conversation ~= "") then + AIconversation[action.conversation] = {} + AIconversation[action.conversation].unlock = true + AIconversation[action.conversation].speaker = action.speaker + AIconversation[action.conversation].message = {} + end + + + + + + AIconversation[action.conversation].tag = action.conversation + + local message = {} + message.tag = action.conversation.."_"..(#AIconversation[action.conversation].message+1) + + message.text= itemjson.answer + message.unlock = true + message.readed = true + message.unlocknext = "" + message.sender = 0 + message.choices = {} + + for i,v in ipairs(itemjson.questions) do + local answer = {} + answer.action_bypassmenu_execution = false + answer.tag = action.conversation.."_"..(#AIconversation[action.conversation].message+1).."_".."choice"..i + + answer.unlocknext = "" + answer.text = v + answer.trigger = {} + answer.context = {} + answer.action = {} + answer.requirement = {} + + local actionss = {} + actionss.name = "ask_ai_from_item_with_value" + actionss.tag = "dialog_template" + actionss.value = v + actionss.aitag = action.aitag + + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "wait_for_ai_answer" + actionss.aitag = action.aitag + table.insert(answer.action,actionss) + + local actionss = {} + actionss.name = "add_v_message_to_ai_phone" + actionss.value = v + actionss.conversation = action.conversation + table.insert(answer.action,actionss) + + + + + + local actionss = {} + actionss.name = "ai_phone_notification" + actionss.speaker = action.speaker + actionss.duration = 5 + actionss.conversation = action.conversation + table.insert(answer.action,actionss) + + + table.insert(message.choices,answer) + end + + + table.insert(AIconversation[action.conversation].message,message) + currentPhoneConversation = AIconversation[action.conversation] + currentPhoneConversation.currentchoices = {} + currentPhoneConversation.loaded = 0 + currentPhoneConversation.speaker = action.speaker + + + --print(dump(currentPhoneConversation)) + + + local notificationData = gameuiGenericNotificationData.new() + notificationData.time = action.duration + notificationData.widgetLibraryItemName = CName('notification_message') + notificationData.notificationData = userData + GameController["JournalNotificationQueue"]:AddNewNotificationData(notificationData) + + + end + end + + if(action.name == "add_v_message_to_ai_phone") then + if(AIconversation[action.conversation] == nil and action.conversation ~= "") then + AIconversation[action.conversation] = {} + AIconversation[action.conversation].unlock = true + AIconversation[action.conversation].speaker = action.speaker + AIconversation[action.conversation].message = {} + end + + + + + + AIconversation[action.conversation].tag = action.conversation + + local message = {} + message.tag = action.conversation.."_"..(#AIconversation[action.conversation].message+1) + + message.text= action.value + message.unlock = true + message.readed = true + message.unlocknext = "" + message.sender = 1 + message.choices = {} + end + + + end + + end) + + if status == false then + + + logme(1,getLang("scripting_error") .. retval.." Action : "..tostring(JSON:encode_pretty(action)).." tag "..tag.." parent "..parent.." index "..index,true) + if(action.fail_action ~= nil and #action.fail_action > 0) then + runActionList(action.fail_action, tag.."_failure", source,false,executortag) + + end + + + + end + + if(action.output == true) then + + logme(1,action.name,true) + logme(1,dump(action),true) + logme(1,tostring(result),true) + + end + + end + + return result +end function getPositionFromParameter(action) - local position = {} - - - if(action.position == "at") then - position.x = action.x - position.y = action.y - position.z = action.z - end - if(action.position == "manager") then - if(cyberscript.PositionManager[action.position_tag] ~= nil and cyberscript.PositionManager[action.position_tag].pending == false) then - position.x = cyberscript.PositionManager[action.position_tag].x - position.y = cyberscript.PositionManager[action.position_tag].y - position.z = cyberscript.PositionManager[action.position_tag].z - - if(cyberscript.PositionManager[action.position_tag].fromgarage ~= nil and cyberscript.PositionManager[action.position_tag].fromgarage == true) then - action.yaw = cyberscript.PositionManager[action.position_tag].yaw - action.pitch = cyberscript.PositionManager[action.position_tag].pitch - action.roll = cyberscript.PositionManager[action.position_tag].roll - end - - end - end - if(action.position == "relative_to_entity") then - local positionVec4 = {} - local entity = nil - - local obj = getEntityFromManager(action.position_tag) - if(obj.id ~= nil ) then - entity = Game.FindEntityByID(obj.id) - if(entity ~= nil ) then - positionVec4 = entity:GetWorldPosition() - - if(action.position_spawnlocation ~= nil and action.position_spawnlocation == true) then - - if(obj.spawnlocation ~= nil) then - positionVec4 = obj.spawnlocation - else - positionVec4.x = 0 - positionVec4.y = 0 - positionVec4.z = 0 - end - end - - if(action.position_way ~= nil and (action.position_way ~= "" or action.position_way ~= "normal")) then - if(action.position_way == "behind") then - positionVec4 = getBehindPosition(entity,action.position_distance) - end - if(action.position_way == "forward") then - positionVec4 = getForwardPosition(entity,action.position_distance) - - end - - if(action.position_way == "forward_relative") then - positionVec4 = getForwardPosition2(entity,action.position_distance,action) - - end - end - - - position.x = positionVec4.x - position.y = positionVec4.y - position.z = positionVec4.z - end - end - end - if(action.position == "player_look_at") then - local positionVec4 = getForwardPosition(Game.GetPlayer(),action.position_lookatdistance) - position.x = positionVec4.x - position.y = positionVec4.y - position.z = positionVec4.z - end - - - if(action.position == "node") then - - local node = nil - - if(action.position_tag == "current")then - - - local position = Game.GetPlayer():GetWorldPosition() - local range = 70 - if(action.position_range ~= nil) then - range = action.position_range - end - node = getNodefromPosition(position.x,position.y,position.z,range) - - - else - - node = getNode(action.position_tag) - - end - - - if node ~= nil then - if(action.position_node_usegameplay == true) then - position.x = node.gameplay_x - position.y = node.gameplay_y - position.z = node.gameplay_z - else - position.x = node.x - position.y = node.y - position.z = node.z - end - - end - end - if(action.position == "poi") then - - - if(action.position_poi_district == "current") then - action.position_poi_district = currentDistricts2.EnumName - end - - if(action.position_poi_district== "random") then - action.position_poi_district = arrayDistricts[math.random(1,#arrayDistricts)].EnumName - end - - - if(action.position_poi_subdistrict == "current") then - - - if(currentDistricts2.districtLabels ~=nil and #currentDistricts2.districtLabels > 1) then - - action.position_poi_subdistrict = currentDistricts2.districtLabels[2] - - else - - action.position_poi_district = currentDistricts2.EnumName - - end - end - - if(action.position_poi_subdistrict == "random") then - local district = arrayDistricts[math.random(1,#arrayDistricts)] - action.position_poi_subdistrict = district.SubDistrict[math.random(1,#district.SubDistrict)] - end - - local range = 70 - if(action.position_range ~= nil) then - range = action.position_range - end - if action.position_poi_search == nil then action.position_poi_search = "type" end - if action.position_poi_searchdistance == nil then action.position_poi_searchdistance = "random" end - local currentpoi = nil - currentpoi = FindPOI(action.position_tag,action.position_poi_district,action.position_poi_subdistrict,action.position_poi_is_for_car,action.position_poi_type,action.position_poi_use_location_tag,action.position_poi_from_position,range,action.position_poi_from_position_x,action.position_poi_from_position_y,action.position_poi_from_position_z,action.position_poi_search,action.position_poi_searchdistance) - if(currentpoi ~= nil) then - position.x = currentpoi.x - position.y = currentpoi.y - position.z = currentpoi.z - - end - end - - if(action.position == "current_poi") then - - - - if(currentPOI ~= nil) then - - if( - - (action.position_poi_is_for_car == nil or action.position_poi_is_for_car == "" or (action.position_poi_is_for_car ~= nil and action.position_poi_is_for_car == currentPOI.inVehicule)) and - (action.type == nil or action.type == "" or (action.type ~= nil and action.type == currentPOI.type)) and - (action.district == nil or action.district == "" or (action.district ~= nil and action.district == currentPOI.district)) and - (action.subdistrict == nil or action.subdistrict == "" or (action.subdistrict ~= nil and action.subdistrict == currentPOI.subdistrict)) - - ) then - - position.x = currentpoi.x - position.y = currentpoi.y - position.z = currentpoi.z - - - end - end - end - if(action.position == "mappin") then - - - if(action.position_tag == "current")then - if(ActivecustomMappin ~= nil)then - local mappin = ActivecustomMappin:GetWorldPosition() - position.x = mappin.x - position.y = mappin.y - position.z = mappin.z - - end - else - local mappin = getMappinByTag(action.position_tag) - if(mappin)then - position.x = mappin.position.x - position.y = mappin.position.y - position.z = mappin.position.z - - end - end - end - if(action.position == "fasttravel") then - local markerref = nil - local tempos = nil - - if(action.position_tag == "current")then - - if(ActiveFastTravelMappin ~= nil)then - position.x = ActiveFastTravelMappin.position.x - position.y = ActiveFastTravelMappin.position.y - position.z = ActiveFastTravelMappin.position.z - - end - - else - - - for j=1, #mappedFastTravelPoint do - local point = mappedFastTravelPoint[j] - if(point.markerref == action.position_tag) then - markerref = point.markerrefdata - tempos = point.position - break - end - end - - if(markerref)then - position.x = tempos.x - position.y = tempos.y - position.z = tempos.z - - end - - - end - - end - if(action.position == "custom_place") then - local house = nil - - if(action.position_tag == "current")then - if(currentHouse ~= nil) then - if(action.position_house_way == "default") then - position.x = currentHouse.x - position.y = currentHouse.y - position.z = currentHouse.z - end - if(action.position_house_way == "Enter") then - position.x = currentHouse.enter_x - position.y = currentHouse.enter_y - position.z = currentHouse.enter_z - end - if(action.position_house_way == "Exit") then - position.x = currentHouse.exit_x - position.y = currentHouse.exit_y - position.z = currentHouse.exit_z - end - - end - else - house = getHouseByTag(action.position_tag) - if(house ~= nil) then - if(action.position_house_way == "default") then - position.x = house.x - position.y = house.y - position.z = house.z - end - if(action.position_house_way == "enter") then - position.x = house.enter_x - position.y = house.enter_y - position.z = house.enter_z - end - if(action.position_house_way == "exit") then - position.x = house.exit_x - position.y = house.exit_y - position.z = house.exit_z - end - - end - end - - - - end - if(action.position == "custom_room") then - local room =nil - if(action.position_tag == "current")then - - if(currentRoom ~= nil) then - position.x = currentRoom.x - position.y = currentRoom.y - position.z = currentRoom.z - - end - - else - getRoomByTag(action.position_tag,action.position_house_tag) - if(room ~= nil) then - position.x = room.x - position.y = room.y - position.z = room.z - - end - - end - - end - - local positiontemp = deepcopy(position,nil) - - if(positiontemp.x ~= nil and action.position ~= "at" and action.position_way ~= "forward_relative") then - positiontemp.x = positiontemp.x + action.x - positiontemp.y = positiontemp.y + action.y - positiontemp.z = positiontemp.z + action.z - - end - - return positiontemp - + local position = {} + + + if(action.position == "at") then + position.x = action.x + position.y = action.y + position.z = action.z + end + if(action.position == "manager") then + if(cyberscript.PositionManager[action.position_tag] ~= nil and cyberscript.PositionManager[action.position_tag].pending == false) then + position.x = cyberscript.PositionManager[action.position_tag].x + position.y = cyberscript.PositionManager[action.position_tag].y + position.z = cyberscript.PositionManager[action.position_tag].z + + if(cyberscript.PositionManager[action.position_tag].fromgarage ~= nil and cyberscript.PositionManager[action.position_tag].fromgarage == true) then + action.yaw = cyberscript.PositionManager[action.position_tag].yaw + action.pitch = cyberscript.PositionManager[action.position_tag].pitch + action.roll = cyberscript.PositionManager[action.position_tag].roll + end + + end + end + if(action.position == "relative_to_entity") then + local positionVec4 = {} + local entity = nil + + local obj = getEntityFromManager(action.position_tag) + if(obj.id ~= nil ) then + entity = safeFindEntityByID(obj) + if(entity ~= nil ) then + positionVec4 = entity:GetWorldPosition() + + if(action.position_spawnlocation ~= nil and action.position_spawnlocation == true) then + + if(obj.spawnlocation ~= nil) then + positionVec4 = obj.spawnlocation + else + positionVec4.x = 0 + positionVec4.y = 0 + positionVec4.z = 0 + end + end + + if(action.position_way ~= nil and (action.position_way ~= "" or action.position_way ~= "normal")) then + if(action.position_way == "behind") then + positionVec4 = getBehindPosition(entity,action.position_distance) + end + if(action.position_way == "forward") then + positionVec4 = getForwardPosition(entity,action.position_distance) + + end + + if(action.position_way == "forward_relative") then + positionVec4 = getForwardPosition2(entity,action.position_distance,action) + + end + end + + + position.x = positionVec4.x + position.y = positionVec4.y + position.z = positionVec4.z + end + end + end + if(action.position == "player_look_at") then + local positionVec4 = getForwardPosition(Game.GetPlayer(),action.position_lookatdistance) + position.x = positionVec4.x + position.y = positionVec4.y + position.z = positionVec4.z + end + + + if(action.position == "node") then + + local node = nil + + if(action.position_tag == "current")then + + + local position = Game.GetPlayer():GetWorldPosition() + local range = 70 + if(action.position_range ~= nil) then + range = action.position_range + end + node = getNodefromPosition(position.x,position.y,position.z,range) + + + else + + node = getNode(action.position_tag) + + end + + + if node ~= nil then + if(action.position_node_usegameplay == true) then + position.x = node.gameplay_x + position.y = node.gameplay_y + position.z = node.gameplay_z + else + position.x = node.x + position.y = node.y + position.z = node.z + end + + end + end + if(action.position == "poi") then + + + if(action.position_poi_district == "current") then + action.position_poi_district = currentDistricts2.EnumName + end + + if(action.position_poi_district== "random") then + action.position_poi_district = arrayDistricts[math.random(1,#arrayDistricts)].EnumName + end + + + if(action.position_poi_subdistrict == "current") then + + + if(currentDistricts2.districtLabels ~=nil and #currentDistricts2.districtLabels > 1) then + + action.position_poi_subdistrict = currentDistricts2.districtLabels[2] + + else + + action.position_poi_district = currentDistricts2.EnumName + + end + end + + if(action.position_poi_subdistrict == "random") then + local district = arrayDistricts[math.random(1,#arrayDistricts)] + action.position_poi_subdistrict = district.SubDistrict[math.random(1,#district.SubDistrict)] + end + + local range = 70 + if(action.position_range ~= nil) then + range = action.position_range + end + if action.position_poi_search == nil then action.position_poi_search = "type" end + if action.position_poi_searchdistance == nil then action.position_poi_searchdistance = "random" end + local currentpoi = nil + currentpoi = FindPOI(action.position_tag,action.position_poi_district,action.position_poi_subdistrict,action.position_poi_is_for_car,action.position_poi_type,action.position_poi_use_location_tag,action.position_poi_from_position,range,action.position_poi_from_position_x,action.position_poi_from_position_y,action.position_poi_from_position_z,action.position_poi_search,action.position_poi_searchdistance) + if(currentpoi ~= nil) then + position.x = currentpoi.x + position.y = currentpoi.y + position.z = currentpoi.z + + end + end + + if(action.position == "current_poi") then + + + + if(currentPOI ~= nil) then + + if( + + (action.position_poi_is_for_car == nil or action.position_poi_is_for_car == "" or (action.position_poi_is_for_car ~= nil and action.position_poi_is_for_car == currentPOI.inVehicule)) and + (action.type == nil or action.type == "" or (action.type ~= nil and action.type == currentPOI.type)) and + (action.district == nil or action.district == "" or (action.district ~= nil and action.district == currentPOI.district)) and + (action.subdistrict == nil or action.subdistrict == "" or (action.subdistrict ~= nil and action.subdistrict == currentPOI.subdistrict)) + + ) then + + position.x = currentpoi.x + position.y = currentpoi.y + position.z = currentpoi.z + + + end + end + end + if(action.position == "mappin") then + + + if(action.position_tag == "current")then + if(ActivecustomMappin ~= nil)then + local mappin = ActivecustomMappin:GetWorldPosition() + position.x = mappin.x + position.y = mappin.y + position.z = mappin.z + + end + else + local mappin = getMappinByTag(action.position_tag) + if(mappin)then + position.x = mappin.position.x + position.y = mappin.position.y + position.z = mappin.position.z + + end + end + end + if(action.position == "fasttravel") then + local markerref = nil + local tempos = nil + + if(action.position_tag == "current")then + + if(ActiveFastTravelMappin ~= nil)then + position.x = ActiveFastTravelMappin.position.x + position.y = ActiveFastTravelMappin.position.y + position.z = ActiveFastTravelMappin.position.z + + end + + else + + + for j=1, #mappedFastTravelPoint do + local point = mappedFastTravelPoint[j] + if(point.markerref == action.position_tag) then + markerref = point.markerrefdata + tempos = point.position + break + end + end + + if(markerref)then + position.x = tempos.x + position.y = tempos.y + position.z = tempos.z + + end + + + end + + end + if(action.position == "custom_place") then + local house = nil + + if(action.position_tag == "current")then + if(currentHouse ~= nil) then + if(action.position_house_way == "default") then + position.x = currentHouse.x + position.y = currentHouse.y + position.z = currentHouse.z + end + if(action.position_house_way == "Enter") then + position.x = currentHouse.enter_x + position.y = currentHouse.enter_y + position.z = currentHouse.enter_z + end + if(action.position_house_way == "Exit") then + position.x = currentHouse.exit_x + position.y = currentHouse.exit_y + position.z = currentHouse.exit_z + end + + end + else + house = getHouseByTag(action.position_tag) + if(house ~= nil) then + if(action.position_house_way == "default") then + position.x = house.x + position.y = house.y + position.z = house.z + end + if(action.position_house_way == "enter") then + position.x = house.enter_x + position.y = house.enter_y + position.z = house.enter_z + end + if(action.position_house_way == "exit") then + position.x = house.exit_x + position.y = house.exit_y + position.z = house.exit_z + end + + end + end + + + + end + if(action.position == "custom_room") then + local room =nil + if(action.position_tag == "current")then + + if(currentRoom ~= nil) then + position.x = currentRoom.x + position.y = currentRoom.y + position.z = currentRoom.z + + end + + else + getRoomByTag(action.position_tag,action.position_house_tag) + if(room ~= nil) then + position.x = room.x + position.y = room.y + position.z = room.z + + end + + end + + end + + local positiontemp = deepcopy(position,nil) + + if(positiontemp.x ~= nil and action.position ~= "at" and action.position_way ~= "forward_relative") then + positiontemp.x = positiontemp.x + action.x + positiontemp.y = positiontemp.y + action.y + positiontemp.z = positiontemp.z + action.z + + end + + return positiontemp + end function GeneratefromContext(item,context) - - local text = context.text - - if context.alpha == nil or context.alpha == false then - - for k,v in pairs(context.values)do - - if v.trigger == nil or checkTriggerRequirement(v.requirement,v.trigger)then - - if(v.action ~= nil and #v.action > 0) then - - runActionList(v.action, k, "see", false,"see",false) - end - - local status, retval = pcall(function() - local value = GenerateTextFromContextValues(context, v,item) - - if((type(value) == "number" or type(value) == "string" or type(value) == "boolean") and v.type ~= "object" and v.type ~= "list") then - text = text:gsub("##"..k, tostring(value)) - - else - - text = value - - end - end) - - if status == false then - - logme(1,getLang("see_context_error") .. retval.." Context : "..tostring(JSON:encode_pretty(context)),true) - if(context.fail_action ~= nil and #context.fail_action > 0) then - runActionList(context.fail_action, "context_failure", "see",false,nil) - - end - - end - end - end - - else - - for k,v in orderedPairs(context.values)do - - if v.trigger == nil or checkTriggerRequirement(v.requirement,v.trigger)then - - if(v.action ~= nil and #v.action > 0) then - - runActionList(v.action, k, "see", false,"see",false) - end - - - local value = GenerateTextFromContextValues(context, v,item) - - if((type(value) == "number" or type(value) == "string" or type(value) == "boolean") and v.type ~= "object" and v.type ~= "list") then - text = text:gsub("##"..k, tostring(value)) - - else - - text = value - - end - end - end - - - end - - - - - if(context.type ~= nil and context.type =="number") then - if (text ~= "") then - - local funcs = loadstring("return " .. tostring(text),"") - - local res,msg = pcall(function() - - text = tonumber(funcs()) - end) - - if res == false then - - text = tonumber("") - - end - - else - - text = tonumber(text) - end - end - - if(context.type ~= nil and context.type =="text") then - text = tostring(text) - end - - if(context.type ~= nil and context.type =="funcs") then - if (text ~= "") then - - local funcs = loadstring("return " .. tostring(text),"") - - local res,msg = pcall(function() - - text = tostring(funcs()) - end) - - if res == false then - - text = tostring("") - - end - - else - - text = tostring(text) - end - end - - if(context.type ~= nil and context.type =="boolean") then - text = toboolean(text) - end - - return text - + + local text = context.text + + if context.alpha == nil or context.alpha == false then + + for k,v in pairs(context.values)do + + if v.trigger == nil or checkTriggerRequirement(v.requirement,v.trigger)then + + if(v.action ~= nil and #v.action > 0) then + + runActionList(v.action, k, "see", false,"see",false) + end + + local status, retval = pcall(function() + local value = GenerateTextFromContextValues(context, v,item) + + if((type(value) == "number" or type(value) == "string" or type(value) == "boolean") and v.type ~= "object" and v.type ~= "list") then + text = text:gsub("##"..k, tostring(value)) + + else + + text = value + + end + end) + + if status == false then + + logme(1,getLang("see_context_error") .. retval.." Context : "..tostring(JSON:encode_pretty(context)),true) + if(context.fail_action ~= nil and #context.fail_action > 0) then + runActionList(context.fail_action, "context_failure", "see",false,nil) + + end + + end + end + end + + else + + for k,v in orderedPairs(context.values)do + + if v.trigger == nil or checkTriggerRequirement(v.requirement,v.trigger)then + + if(v.action ~= nil and #v.action > 0) then + + runActionList(v.action, k, "see", false,"see",false) + end + + + local value = GenerateTextFromContextValues(context, v,item) + + if((type(value) == "number" or type(value) == "string" or type(value) == "boolean") and v.type ~= "object" and v.type ~= "list") then + text = text:gsub("##"..k, tostring(value)) + + else + + text = value + + end + end + end + + + end + + + + + if(context.type ~= nil and context.type =="number") then + if (text ~= "") then + + local funcs = loadstring("return " .. tostring(text),"") + + local res,msg = pcall(function() + + text = tonumber(funcs()) + end) + + if res == false then + + text = tonumber("") + + end + + else + + text = tonumber(text) + end + end + + if(context.type ~= nil and context.type =="text") then + text = tostring(text) + end + + if(context.type ~= nil and context.type =="funcs") then + if (text ~= "") then + + local funcs = loadstring("return " .. tostring(text),"") + + local res,msg = pcall(function() + + text = tostring(funcs()) + end) + + if res == false then + + text = tostring("") + + end + + else + + text = tostring(text) + end + end + + if(context.type ~= nil and context.type =="boolean") then + text = toboolean(text) + end + + return text + end function GenerateTextFromContextValues(context, v,source) - - local value = "" + + local value = "" - checkContext(v) - - if(v.context_value ~= nil) then - - v[v.replace] = GenerateTextFromContextValues(context, context.values[v.context_value],source) - - end + checkContext(v) + + if(v.context_value ~= nil) then + + v[v.replace] = GenerateTextFromContextValues(context, context.values[v.context_value],source) + + end - if(v.type == "context_props")then - - - print(dump(context)) - value = GenerateTextFromContextValues(context, context.values[v.prop],source) - - end - - if(v.type == "current_district") then - - if(v.prop == "tag") then - value = getVariable("current_district","tag") - end - - if(v.prop == "state") then - value = getVariable("current_district","state") - end - - if(v.prop == "subdistrict") then - value = getVariable("current_district","subdistrict_enum") - end - - end - - if(v.type == "group") then - - local group = getGroupfromManager(v.tag) - if(group ~= nil) then - - value = #group.entities - - - end - end - - if(v.type == "faction") then - - if(v.searchprops ~= nil) then - - value = SearchinTable(cyberscript.cache["faction"], v.searchprops, v.searchvalue,"data")[v.prop] - - else - if(v.tag == "random") then - - - - value = getRandomPairfromTable(cyberscript.cache["faction"]).value.data[v.prop] - else - if(v.tag == "player") then - v.tag = getVariableKey("player","current_gang") - value = cyberscript.cache["faction"][v.tag].data[v.prop] - - else - value = cyberscript.cache["faction"][v.tag].data[v.prop] - end - - end - - - - end - end - - if(v.type == "shard") then - - if(v.searchprops ~= nil) then - - value = SearchinTable(cyberscript.cache["shard"], v.searchprops, v.searchvalue,"data")[v.prop] - - else - if(v.tag == "random") then - - - - value = getRandomPairfromTable(cyberscript.cache["shard"]).value.data[v.prop] - else - - value = cyberscript.cache["shard"][v.tag].data[v.prop] - - end - - - - end - end - - if(v.type == "player") then - - if(v.key == "item_amount") then - - value = getStackableItemAmount(v.value) - - - end - - if(v.key == "item_is_equipped") then - - value = tostring(isEquipped(v.value)) - - - end - - if(v.key == "query_equipped_item") then - - value = tostring(haveOneEquippedMatch(v.value)) - - - end - - if(v.key == "skill") or (v.key == "perk") or (v.key == "attribute") then - value = getAtttribute(v.key, v.value) - end - - if(v.key == "combatstate") then - local player = Game.GetPlayer() - local state = player:GetCurrentCombatState() - - value = EnumInt(state) - end - - if(v.key == "current_gang") then - - value = getVariableKey("player","current_gang") - - end + if(v.type == "context_props")then + + + print(dump(context)) + value = GenerateTextFromContextValues(context, context.values[v.prop],source) + + end + + if(v.type == "current_district") then + + if(v.prop == "tag") then + value = getVariable("current_district","tag") + end + + if(v.prop == "state") then + value = getVariable("current_district","state") + end + + if(v.prop == "subdistrict") then + value = getVariable("current_district","subdistrict_enum") + end + + end + + if(v.type == "group") then + + local group = getGroupfromManager(v.tag) + if(group ~= nil) then + + value = #(group and (group and group.entities or {}) or {}) + + + end + end + + if(v.type == "faction") then + + if(v.searchprops ~= nil) then + + value = SearchinTable(cyberscript.cache["faction"], v.searchprops, v.searchvalue,"data")[v.prop] + + else + if(v.tag == "random") then + + + + value = getRandomPairfromTable(cyberscript.cache["faction"]).value.data[v.prop] + else + if(v.tag == "player") then + v.tag = getVariableKey("player","current_gang") + value = cyberscript.cache["faction"][v.tag].data[v.prop] + + else + value = cyberscript.cache["faction"][v.tag].data[v.prop] + end + + end + + + + end + end + + if(v.type == "shard") then + + if(v.searchprops ~= nil) then + + value = SearchinTable(cyberscript.cache["shard"], v.searchprops, v.searchvalue,"data")[v.prop] + + else + if(v.tag == "random") then + + + + value = getRandomPairfromTable(cyberscript.cache["shard"]).value.data[v.prop] + else + + value = cyberscript.cache["shard"][v.tag].data[v.prop] + + end + + + + end + end + + if(v.type == "player") then + + if(v.key == "item_amount") then + + value = getStackableItemAmount(v.value) + + + end + + if(v.key == "item_is_equipped") then + + value = tostring(isEquipped(v.value)) + + + end + + if(v.key == "query_equipped_item") then + + value = tostring(haveOneEquippedMatch(v.value)) + + + end + + if(v.key == "skill") or (v.key == "perk") or (v.key == "attribute") then + value = getAtttribute(v.key, v.value) + end + + if(v.key == "combatstate") then + local player = Game.GetPlayer() + local state = player:GetCurrentCombatState() + + value = EnumInt(state) + end + + if(v.key == "current_gang") then + + value = getVariableKey("player","current_gang") + + end - if(v.key == "cred") then - - local mod_score = Game.GetStatsSystem():GetStatValue(Game.GetPlayer():GetEntityID(), "StreetCred") - - value = tonumber(mod_score) - - end + if(v.key == "cred") then + + local mod_score = Game.GetStatsSystem():GetStatValue(Game.GetPlayer():GetEntityID(), "StreetCred") + + value = tonumber(mod_score) + + end - if(v.key == "level") then - - local mod_score = Game.GetStatsSystem():GetStatValue(Game.GetPlayer():GetEntityID(), "Level") - - value = tonumber(mod_score) - - end - - if(v.key == "lifepath") then - local player = Game.GetPlayer() - local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() - local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) - local path = playerDevSystem:GetLifePath(player) - - value = EnumInt(path) - end - end - - if(v.type == "corpo") then - - - if(v.searchprops ~= nil) then - - value = SearchinTable(cyberscript.cache["corpo"], v.searchprops, v.searchvalue,nil)[v.prop] - - else - - if(v.tag ~= "random") then - if(cyberscript.cache["corpo"][v.tag] ~= nil) then - - value = cyberscript.cache["corpo"][v.tag][v.prop] - end - else - local corpo = getRandomPairfromTable(cyberscript.cache["corpo"]) - - if(corpo ~= nil) then - - value =corpo[v.prop] - end - - end - end - end - - if(v.type == "lang") then - value = getLang(v.tag) - - end - - if(v.type == "random_lang") then - - - local index = math.random(1,#v.list) - - value = getLang(v.list[index]) - - - - end - - if(v.type == "district_leader" or v.type == "subdistrict_leader") then - local gangs = getGangfromDistrict(v.tag,0) - if(#gangs > 0) then - - value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] - - - end - end - - if(v.type == "current_district_leader") then - local gangs = getGangfromDistrict(currentDistricts2.Tag,0) - if(#gangs > 0) then - value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] - - end - end - - if(v.type == "current_subdistrict_leader") then - local gangs = {} - for j, test in ipairs(currentDistricts2.districtLabels) do - if j > 1 then - gangs = getGangfromDistrict(test,0) - if(#gangs > 0) then - break - end - end - end - - if(#gangs > 0) then - value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] - - end - end - - if(v.type == "district_rival" or v.type == "subdistrict_rival") then - local gangs = {} - - if(v.tag == "player") then - - v.tag = getVariableKey("player","current_gang") - - end - - local gangs = getGangRivalfromDistrict(v.tag,v.district,0) - - if(#gangs > 0) then - value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] - - end - end - - if(v.type == "current_district_rival") then - - local gangs = {} - - if(v.tag == "player") then - - v.tag = getVariableKey("player","current_gang") - - end - - local gangs = getGangRivalfromDistrict(v.tag,currentDistricts2.Tag,0) - if(#gangs > 0) then - value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] - - end - end - - if(v.type == "current_subdistrict_rival") then - - local gangs = {} - - if(v.tag == "player") then - - v.tag = getVariableKey("player","current_gang") - - end - - - for j, test in ipairs(currentDistricts2.districtLabels) do - if j > 1 then - gangs = getGangRivalfromDistrict(v.tag,test,0) - if(#gangs > 0) then - break - end - end - end - if(#gangs > 0) then - value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] - - end - end - - if(v.type == "entity") then - -- ----print(v.tag) - local obj = getEntityFromManager(v.tag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - - if(v.key == "position") then - - local pos = enti:GetWorldPosition() - local obj = {} - - obj.x = pos.x - obj.y = pos.y - obj.z = pos.z - - -- ----print(dump(obj)) - - value = obj[v.prop] - - end - - if(v.key == "distance") then - - if(v.target == "entity") then - local obj = getEntityFromManager(v.targettag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local pos = enti:GetWorldPosition() - value = getDistance(pos, mappinManager[v.tag]["position"]) - end - - - end - - end - - - if(v.target == "mappin") then - local obj = getMappinByTag(v.targettag) - if(obj ~= nil) then - - value = getDistance(obj.position, mappinManager[v.tag]["position"]) - - - end - - end - - - - end - - if(v.key == "head_position") then - - - local components = enti:FindComponentByName("Item_Attachment_Slot") - ------print("compo"..GameDump(components)) - if(components~= nil) then - local _,head = components:GetSlotTransform("Head") - -- ----print("head"..GameDump(head)) - if(head ~= nil) then - -- ----print("yyyy") - local pos = head:GetWorldPosition():ToVector4() - local pos2 = head:GetForward() - local pos3 = head:GetInverse():GetWorldPosition():ToVector4() - local obj = {} - - obj.x = pos.x-(pos2.x*0.25) - obj.y = pos.y-(pos2.y*0.25) - obj.z = pos.z - - -- ----print(dump(obj)) - value = obj[v.prop] - end - - end - - - - end - - if(v.key == "slot_position") then - - local compo = "Item_Attachment_Slot" - if (v.tag == "player") then - compo = "ItemAttachmentSlots" - end - - local components = enti:FindComponentByName(compo) - ------print("compo"..GameDump(components)) - if(components~= nil) then - local _,head = components:GetSlotTransform(v.slot) - -- ----print("head"..GameDump(head)) - if(head ~= nil) then - -- ----print("yyyy") - local pos = {} - local action = {} - action.x = v.offset_x or 0 - action.y = v.offset_y or 0 - action.z = v.offset_z or 0 - if(v.relative) then - - pos = getForwardPosition2(head,0,action,true) - - else - - pos = head:GetWorldPosition():ToVector4() - - end + if(v.key == "level") then + + local mod_score = Game.GetStatsSystem():GetStatValue(Game.GetPlayer():GetEntityID(), "Level") + + value = tonumber(mod_score) + + end + + if(v.key == "lifepath") then + local player = Game.GetPlayer() + local scriptableSystemsContainer = Game.GetScriptableSystemsContainer() + local playerDevSystem = scriptableSystemsContainer:Get(CName.new('PlayerDevelopmentSystem')) + local path = playerDevSystem:GetLifePath(player) + + value = EnumInt(path) + end + end + + if(v.type == "corpo") then + + + if(v.searchprops ~= nil) then + + value = SearchinTable(cyberscript.cache["corpo"], v.searchprops, v.searchvalue,nil)[v.prop] + + else + + if(v.tag ~= "random") then + if(cyberscript.cache["corpo"][v.tag] ~= nil) then + + value = cyberscript.cache["corpo"][v.tag][v.prop] + end + else + local corpo = getRandomPairfromTable(cyberscript.cache["corpo"]) + + if(corpo ~= nil) then + + value =corpo[v.prop] + end + + end + end + end + + if(v.type == "lang") then + value = getLang(v.tag) + + end + + if(v.type == "random_lang") then + + + local index = math.random(1,#v.list) + + value = getLang(v.list[index]) + + + + end + + if(v.type == "district_leader" or v.type == "subdistrict_leader") then + local gangs = getGangfromDistrict(v.tag,0) + if(#gangs > 0) then + + value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] + + + end + end + + if(v.type == "current_district_leader") then + local gangs = getGangfromDistrict(currentDistricts2.Tag,0) + if(#gangs > 0) then + value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] + + end + end + + if(v.type == "current_subdistrict_leader") then + local gangs = {} + for j, test in ipairs(currentDistricts2.districtLabels) do + if j > 1 then + gangs = getGangfromDistrict(test,0) + if(#gangs > 0) then + break + end + end + end + + if(#gangs > 0) then + value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] + + end + end + + if(v.type == "district_rival" or v.type == "subdistrict_rival") then + local gangs = {} + + if(v.tag == "player") then + + v.tag = getVariableKey("player","current_gang") + + end + + local gangs = getGangRivalfromDistrict(v.tag,v.district,0) + + if(#gangs > 0) then + value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] + + end + end + + if(v.type == "current_district_rival") then + + local gangs = {} + + if(v.tag == "player") then + + v.tag = getVariableKey("player","current_gang") + + end + + local gangs = getGangRivalfromDistrict(v.tag,currentDistricts2.Tag,0) + if(#gangs > 0) then + value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] + + end + end + + if(v.type == "current_subdistrict_rival") then + + local gangs = {} + + if(v.tag == "player") then + + v.tag = getVariableKey("player","current_gang") + + end + + + for j, test in ipairs(currentDistricts2.districtLabels) do + if j > 1 then + gangs = getGangRivalfromDistrict(v.tag,test,0) + if(#gangs > 0) then + break + end + end + end + if(#gangs > 0) then + value = cyberscript.cache["faction"][gangs[1].tag].data[v.prop] + + end + end + + if(v.type == "entity") then + -- ----print(v.tag) + local obj = getEntityFromManager(v.tag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + + if(v.key == "position") then + + local pos = enti:GetWorldPosition() + local obj = {} + + obj.x = pos.x + obj.y = pos.y + obj.z = pos.z + + -- ----print(dump(obj)) + + value = obj[v.prop] + + end + + if(v.key == "distance") then + + if(v.target == "entity") then + local obj = getEntityFromManager(v.targettag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local pos = enti:GetWorldPosition() + value = getDistance(pos, mappinManager[v.tag]["position"]) + end + + + end + + end + + + if(v.target == "mappin") then + local obj = getMappinByTag(v.targettag) + if(obj ~= nil) then + + value = getDistance(obj.position, mappinManager[v.tag]["position"]) + + + end + + end + + + + end + + if(v.key == "head_position") then + + + local components = enti:FindComponentByName("Item_Attachment_Slot") + ------print("compo"..GameDump(components)) + if(components~= nil) then + local _,head = components:GetSlotTransform("Head") + -- ----print("head"..GameDump(head)) + if(head ~= nil) then + -- ----print("yyyy") + local pos = head:GetWorldPosition():ToVector4() + local pos2 = head:GetForward() + local pos3 = head:GetInverse():GetWorldPosition():ToVector4() + local obj = {} + + obj.x = pos.x-(pos2.x*0.25) + obj.y = pos.y-(pos2.y*0.25) + obj.z = pos.z + + -- ----print(dump(obj)) + value = obj[v.prop] + end + + end + + + + end + + if(v.key == "slot_position") then + + local compo = "Item_Attachment_Slot" + if (v.tag == "player") then + compo = "ItemAttachmentSlots" + end + + local components = enti:FindComponentByName(compo) + ------print("compo"..GameDump(components)) + if(components~= nil) then + local _,head = components:GetSlotTransform(v.slot) + -- ----print("head"..GameDump(head)) + if(head ~= nil) then + -- ----print("yyyy") + local pos = {} + local action = {} + action.x = v.offset_x or 0 + action.y = v.offset_y or 0 + action.z = v.offset_z or 0 + if(v.relative) then + + pos = getForwardPosition2(head,0,action,true) + + else + + pos = head:GetWorldPosition():ToVector4() + + end - local obj = {} - - obj.x = pos.x - obj.y = pos.y - obj.z = pos.z - - -- ----print(dump(obj)) - value = obj[v.prop] - end - - end - - - - end - - if(v.key == "look_at") then - if v.distance == nil then v.distance =0 end - local playerPos, playerAngle = targetS:GetCrosshairData(Game.GetPlayer()) - local playerFootPos = Game.GetPlayer():GetWorldPosition() - playerPos.z = playerPos.z + 0.5 - local playerDeltaWorldPos = Delta(playerPos, playerFootPos) - playerDeltaWorldPos.w = 1 - local playerOldPos = playerPos - local playerDeltaPos = Delta(playerOldPos, playerPos) - local phi = math.atan2(playerAngle.y, playerAngle.x) - -- if (objPush == true) then - -- objectDist = objectDist + 0.5 - -- objPush = false - -- end - -- if (objPull == true) then - -- objectDist = objectDist - 0.5 - -- objPull = false - -- end - local poss = Vector4.new(((v.distance * math.cos(phi)) + playerPos.x), ((v.distance * math.sin(phi)) + playerPos.y), (v.distance * math.sin(playerAngle.z) + playerPos.z),1) - local obj = Vector4Add(playerDeltaWorldPos, poss) - - - value = obj[v.prop] - - end - - if(v.key == "head_orientation") then - - local components = enti:FindComponentByName("Item_Attachment_Slot") - - if(components~= nil) then - local _,head = components:GetSlotTransform("Head") - - if(head ~= nil) then - - local angle = head:GetOrientation():ToEulerAngles() - local obj = {} - - obj.yaw = angle.yaw - obj.pitch = angle.pitch - obj.roll = angle.roll - ------print(dump(obj)) - value = obj[v.prop] - end - - end - - end - - if(v.key == "slot_orientation") then - - local compo = "Item_Attachment_Slot" - if (v.tag == "player") then - compo = "ItemAttachmentSlots" - end - - local components = enti:FindComponentByName(compo) - ------print("compo"..GameDump(components)) - if(components~= nil) then - local _,head = components:GetSlotTransform(v.slot) - -- ----print("head"..GameDump(head)) - if(head ~= nil) then - -- ----print("yyyy") - local angle = head:GetOrientation():ToEulerAngles() - local obj = {} - - obj.yaw = angle.yaw - obj.pitch = angle.pitch - obj.roll = angle.roll - ------print(dump(obj)) - value = obj[v.prop] - end - - end - - - - end - - if(v.key == "forward") then - local action = {} - action.x = v.offset_x or 0 - action.y = v.offset_y or 0 - action.z = v.offset_z or 0 + local obj = {} + + obj.x = pos.x + obj.y = pos.y + obj.z = pos.z + + -- ----print(dump(obj)) + value = obj[v.prop] + end + + end + + + + end + + if(v.key == "look_at") then + if v.distance == nil then v.distance =0 end + local playerPos, playerAngle = targetS:GetCrosshairData(Game.GetPlayer()) + local playerFootPos = Game.GetPlayer():GetWorldPosition() + playerPos.z = playerPos.z + 0.5 + local playerDeltaWorldPos = Delta(playerPos, playerFootPos) + playerDeltaWorldPos.w = 1 + local playerOldPos = playerPos + local playerDeltaPos = Delta(playerOldPos, playerPos) + local phi = math.atan2(playerAngle.y, playerAngle.x) + -- if (objPush == true) then + -- objectDist = objectDist + 0.5 + -- objPush = false + -- end + -- if (objPull == true) then + -- objectDist = objectDist - 0.5 + -- objPull = false + -- end + local poss = Vector4.new(((v.distance * math.cos(phi)) + playerPos.x), ((v.distance * math.sin(phi)) + playerPos.y), (v.distance * math.sin(playerAngle.z) + playerPos.z),1) + local obj = Vector4Add(playerDeltaWorldPos, poss) + + + value = obj[v.prop] + + end + + if(v.key == "head_orientation") then + + local components = enti:FindComponentByName("Item_Attachment_Slot") + + if(components~= nil) then + local _,head = components:GetSlotTransform("Head") + + if(head ~= nil) then + + local angle = head:GetOrientation():ToEulerAngles() + local obj = {} + + obj.yaw = angle.yaw + obj.pitch = angle.pitch + obj.roll = angle.roll + ------print(dump(obj)) + value = obj[v.prop] + end + + end + + end + + if(v.key == "slot_orientation") then + + local compo = "Item_Attachment_Slot" + if (v.tag == "player") then + compo = "ItemAttachmentSlots" + end + + local components = enti:FindComponentByName(compo) + ------print("compo"..GameDump(components)) + if(components~= nil) then + local _,head = components:GetSlotTransform(v.slot) + -- ----print("head"..GameDump(head)) + if(head ~= nil) then + -- ----print("yyyy") + local angle = head:GetOrientation():ToEulerAngles() + local obj = {} + + obj.yaw = angle.yaw + obj.pitch = angle.pitch + obj.roll = angle.roll + ------print(dump(obj)) + value = obj[v.prop] + end + + end + + + + end + + if(v.key == "forward") then + local action = {} + action.x = v.offset_x or 0 + action.y = v.offset_y or 0 + action.z = v.offset_z or 0 - local pos = getForwardPosition2(enti,0,action) - - local obj = {} - - - -- if testcoef == nil then testcoef = 1 end - -- v.coef = testcoef - obj.x = pos.x - obj.y = pos.y - obj.z = pos.z - value = obj[v.prop] - - end - - if(v.key == "orientation") then - - local qat = enti:GetWorldOrientation() - local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) - local obj = {} - - obj.yaw = angle.yaw - obj.pitch = angle.pitch - obj.roll = angle.roll - - value = obj[v.prop] - - - end - - if(v.key == "tag") then - - - value = obj.tag - - end - - if(v.key == "appearance") then - - - value = Game.NameToString(enti:GetCurrentAppearanceName()) - - end - - if(v.key == "tweak") then - - - value = tostring(obj.tweak) - - end - - if(v.key == "context") then - - - value = Game.NameToString(enti:GetCurrentContext()) - - end - - if(v.key == "displayname") then - - - value = Game.NameToString(enti:GetDisplayName()) - - end - - if(v.key == "fullname") then - - - value = enti:GetTweakDBFullDisplayName(false) - - end - - if(v.key == "gang") then - - value = getGangForEntity(enti) - - - end - - if(v.key == "group") then - local group = getEntityGroupfromEntityTag(obj.tag) - if(group ~= nil) then - - value = group.tag - - - end - end - - if(v.key == "radio_index") then - local ps = enti:GetDevicePS() - value = ps.activeStation - end - - if(v.key == "radio_name") then - local ps = enti:GetDevicePS() - local stations = { - [0] = "89.3 - Radio Vexelstrom", - [1] = "92.9 - Night FM", - [2] = "101.9 - The Dirge", - [3] = "103.5 - Radio Pebkac", - [4] = "88.9 - Pacific Dreams", - [5] = "107.3 - Morro Rock Radio", - [6] = "98.7 - Body Heat Radio", - [7] = "106.9 - 30 Principales", - [8] = "96.1 - Ritual FM", - [9] = "95.2 - Samizdat Radio", - [10] = "91.9 - Royal Blue Radio", - [11] = "89.7 - Growl FM", - [12] = "107.5 - Dark Star", - [13] = "99.9 - Impulse", - } - value = stations[ps.activeStation] - end - - end - - end - end - - if(v.type == "mappin") then - - if(v.searchprops ~= nil) then - - value = SearchinTable(mappinManager, v.searchprops, v.searchvalue,nil)[v.prop] - - else - if(v.tag ~= "random") then - if(v.prop == "distance") then - - if(v.target == "entity") then - local obj = getEntityFromManager(v.targettag) - if(obj.id ~= nil) then - local enti = Game.FindEntityByID(obj.id) - if(enti ~= nil) then - local pos = enti:GetWorldPosition() - value = getDistance(pos, mappinManager[v.tag]["position"]) - end - - - end - - end - - - if(v.target == "mappin") then - local obj = getMappinByTag(v.targettag) - if(obj ~= nil) then - - value = getDistance(obj.position, mappinManager[v.tag]["position"]) - - - end - - end - - - - end - - if(v.prop ~= "distance") then - if(v.prop == "x" or v.prop =="y" or v.prop == "z") then - value = mappinManager[v.tag]["position"][v.prop] - - - - else - value = mappinManager[v.tag][v.prop] - - - end - end - - else - - - if(v.prop == "x" or v.prop =="y" or v.prop == "z") then - value = getRandomPairfromTable(mappinManager).value["position"][v.prop] - - - - else - value = getRandomPairfromTable(mappinManager).value[v.prop] - - - end - - end - end - end - - if(v.type == "fixer") then - if(v.searchprops ~= nil) then - - value = SearchinTable(cyberscript.cache["fixer"], v.searchprops, v.searchvalue,"data")[v.prop] - - else - if(v.tag ~= "random") then - value = cyberscript.cache["fixer"][v.tag].data[v.prop] - - else - value = getRandomPairfromTable(cyberscript.cache["fixer"]).value.data[v.prop] - - end - end - end - - if(v.type == "current_fixer" and currentfixer ~= nil) then - - - value = currentfixer[v.prop] - - - end - - - if(v.type == "place") then - if(v.searchprops ~= nil) then - - value = SearchinTable(cyberscript.cache["place"], v.searchprops, v.searchvalue,"data")[v.prop] - - else - if(v.tag ~= "random") then - value = cyberscript.cache["place"][v.tag].data[v.prop] - - else - value = getRandomPairfromTable(cyberscript.cache["place"]).value.data[v.prop] - - end - end - end - - if(v.type == "current_sound" and cyberscript.soundmanager[v.tag] ~= nil) then - - value = cyberscript.soundmanager[v.tag][v.prop] - - end - - if(v.type == "current_radio" and currentRadio ~= nil) then - - value = currentRadio[v.prop] - - end - - - if(v.type == "sound" and cyberscript.cache["sound"][v.tag] ~=nil) then - - value = cyberscript.cache["sound"][v.tag].sound[v.prop] - - end - - - if(v.type == "radio" and cyberscript.cache["radio"][v.tag] ~=nil) then - - value = cyberscript.cache["radio"][v.tag].data[v.prop] - - end - - if(v.type == "current_radio" and currentRadio ~= nil) then - - value = currentRadio[v.prop] - - end - - if(v.type == "current_place" and currentHouse ~= nil) then - - value = currentHouse[v.prop] - - end - - if(v.type == "current_room" and currentRoom ~= nil) then - - value = currentRoom[v.prop] - - end - - if(v.type == "current_poi" and currentPOI ~= nil) then - ------print(dump(currentPOI)) - - value = currentPOI[v.prop] - end - - if(v.type == "poi") then - - - - local currentpoi = nil - currentpoi = FindPOI(v.argument.position_tag,v.argument.position_poi_district,v.argument.position_poi_subdistrict,v.argument.position_poi_is_for_car,v.argument.position_poi_type,v.argument.position_poi_use_location_tag,v.argument.position_poi_from_position,v.argument.position_range,v.argument.position_poi_from_position_x,v.argument.position_poi_from_position_y,v.argument.position_poi_from_position_z,v.argument.position_poi_search,v.argument.position_poi_searchdistance) - if(currentpoi ~= nil) then - - value = currentpoi[v.prop] - - end - - - - - end - - if(v.type == "node") then - if(v.searchprops ~= nil) then - - value = SearchinTable(cyberscript.cache["node"], v.searchprops, v.searchvalue,"data")[v.prop] - - else - if(v.tag ~= "random") then - value = cyberscript.cache["node"][v.tag].data[v.prop] - - else - value = getRandomPairfromTable(cyberscript.cache["node"]).value.data[v.prop] - - end - end - end - - if(v.type == "custom_npc") then - if(v.searchprops ~= nil) then - - value = SearchinTable(cyberscript.cache["npc"], v.searchprops, v.searchvalue,"data")[v.prop] - - else - if(v.tag ~= "random") then - - if(v.prop == "x" or v.prop =="y" or v.prop == "z") then - value = cyberscript.cache["npc"][v.tag].data["location"][v.prop] - - - else - value = cyberscript.cache["npc"][v.tag].data[v.prop] - - - end - - - else - - - if(v.prop == "x" or v.prop =="y" or v.prop == "z") then - value = getRandomPairfromTable(cyberscript.cache["npc"]).value.data["location"][v.prop] - - - else - value = getRandomPairfromTable(cyberscript.cache["npc"]).value.data[v.prop] - - - end - end - end - end - - if(v.type == "npc") then - if(v.searchprops ~= nil) then - - value = SearchinTable(cyberscript.entitieshash, v.searchprops, v.searchvalue,nil)[v.prop] - - else - - - local npc = getNPCByName(v.tag) - - if(npc ~= nil) then - value = npc[v.prop] - end - - - - - - - - - - end - end - - - - if(v.type == "variable" or v.type == "score") then - value = getVariableKey(v.variable,v.key) - - if(isArray(value))then - if(v.index == nil) then - local index = math.random(1,#value) - - value = value[index] - - - else - value = value[v.index] - end - end - - - - end - - if(v.type == "random_variable_key" or v.type == "random_score_key") then - value = getRandomPairfromTable(currentSave.Variable[v.variable]).value - - - end - - if(v.type == "text")then - - - - - - value = v.value - - end + local pos = getForwardPosition2(enti,0,action) + + local obj = {} + + + -- if testcoef == nil then testcoef = 1 end + -- v.coef = testcoef + obj.x = pos.x + obj.y = pos.y + obj.z = pos.z + value = obj[v.prop] + + end + + if(v.key == "orientation") then + + local qat = enti:GetWorldOrientation() + local angle = GetSingleton('Quaternion'):ToEulerAngles(qat) + local obj = {} + + obj.yaw = angle.yaw + obj.pitch = angle.pitch + obj.roll = angle.roll + + value = obj[v.prop] + + + end + + if(v.key == "tag") then + + + value = obj.tag + + end + + if(v.key == "appearance") then + + + value = Game.NameToString(enti:GetCurrentAppearanceName()) + + end + + if(v.key == "tweak") then + + + value = tostring(obj.tweak) + + end + + if(v.key == "context") then + + + value = Game.NameToString(enti:GetCurrentContext()) + + end + + if(v.key == "displayname") then + + + value = Game.NameToString(enti:GetDisplayName()) + + end + + if(v.key == "fullname") then + + + value = enti:GetTweakDBFullDisplayName(false) + + end + + if(v.key == "gang") then + + value = getGangForEntity(enti) + + + end + + if(v.key == "group") then + local group = getEntityGroupfromEntityTag(obj.tag) + if(group ~= nil) then + + value = group.tag + + + end + end + + if(v.key == "radio_index") then + local ps = enti:GetDevicePS() + value = ps.activeStation + end + + if(v.key == "radio_name") then + local ps = enti:GetDevicePS() + local stations = { + [0] = "89.3 - Radio Vexelstrom", + [1] = "92.9 - Night FM", + [2] = "101.9 - The Dirge", + [3] = "103.5 - Radio Pebkac", + [4] = "88.9 - Pacific Dreams", + [5] = "107.3 - Morro Rock Radio", + [6] = "98.7 - Body Heat Radio", + [7] = "106.9 - 30 Principales", + [8] = "96.1 - Ritual FM", + [9] = "95.2 - Samizdat Radio", + [10] = "91.9 - Royal Blue Radio", + [11] = "89.7 - Growl FM", + [12] = "107.5 - Dark Star", + [13] = "99.9 - Impulse", + } + value = stations[ps.activeStation] + end + + end + + end + end + + if(v.type == "mappin") then + + if(v.searchprops ~= nil) then + + value = SearchinTable(mappinManager, v.searchprops, v.searchvalue,nil)[v.prop] + + else + if(v.tag ~= "random") then + if(v.prop == "distance") then + + if(v.target == "entity") then + local obj = getEntityFromManager(v.targettag) + if(obj.id ~= nil) then + local enti = safeFindEntityByID(obj) + if(enti ~= nil) then + local pos = enti:GetWorldPosition() + value = getDistance(pos, mappinManager[v.tag]["position"]) + end + + + end + + end + + + if(v.target == "mappin") then + local obj = getMappinByTag(v.targettag) + if(obj ~= nil) then + + value = getDistance(obj.position, mappinManager[v.tag]["position"]) + + + end + + end + + + + end + + if(v.prop ~= "distance") then + if(v.prop == "x" or v.prop =="y" or v.prop == "z") then + value = mappinManager[v.tag]["position"][v.prop] + + + + else + value = mappinManager[v.tag][v.prop] + + + end + end + + else + + + if(v.prop == "x" or v.prop =="y" or v.prop == "z") then + value = getRandomPairfromTable(mappinManager).value["position"][v.prop] + + + + else + value = getRandomPairfromTable(mappinManager).value[v.prop] + + + end + + end + end + end + + if(v.type == "fixer") then + if(v.searchprops ~= nil) then + + value = SearchinTable(cyberscript.cache["fixer"], v.searchprops, v.searchvalue,"data")[v.prop] + + else + if(v.tag ~= "random") then + value = cyberscript.cache["fixer"][v.tag].data[v.prop] + + else + value = getRandomPairfromTable(cyberscript.cache["fixer"]).value.data[v.prop] + + end + end + end + + if(v.type == "current_fixer" and currentfixer ~= nil) then + + + value = currentfixer[v.prop] + + + end + + + if(v.type == "place") then + if(v.searchprops ~= nil) then + + value = SearchinTable(cyberscript.cache["place"], v.searchprops, v.searchvalue,"data")[v.prop] + + else + if(v.tag ~= "random") then + value = cyberscript.cache["place"][v.tag].data[v.prop] + + else + value = getRandomPairfromTable(cyberscript.cache["place"]).value.data[v.prop] + + end + end + end + + if(v.type == "current_sound" and cyberscript.soundmanager[v.tag] ~= nil) then + + value = cyberscript.soundmanager[v.tag][v.prop] + + end + + if(v.type == "current_radio" and currentRadio ~= nil) then + + value = currentRadio[v.prop] + + end + + + if(v.type == "sound" and cyberscript.cache["sound"][v.tag] ~=nil) then + + value = cyberscript.cache["sound"][v.tag].sound[v.prop] + + end + + + if(v.type == "radio" and cyberscript.cache["radio"][v.tag] ~=nil) then + + value = cyberscript.cache["radio"][v.tag].data[v.prop] + + end + + if(v.type == "current_radio" and currentRadio ~= nil) then + + value = currentRadio[v.prop] + + end + + if(v.type == "current_place" and currentHouse ~= nil) then + + value = currentHouse[v.prop] + + end + + if(v.type == "current_room" and currentRoom ~= nil) then + + value = currentRoom[v.prop] + + end + + if(v.type == "current_poi" and currentPOI ~= nil) then + ------print(dump(currentPOI)) + + value = currentPOI[v.prop] + end + + if(v.type == "poi") then + + + + local currentpoi = nil + currentpoi = FindPOI(v.argument.position_tag,v.argument.position_poi_district,v.argument.position_poi_subdistrict,v.argument.position_poi_is_for_car,v.argument.position_poi_type,v.argument.position_poi_use_location_tag,v.argument.position_poi_from_position,v.argument.position_range,v.argument.position_poi_from_position_x,v.argument.position_poi_from_position_y,v.argument.position_poi_from_position_z,v.argument.position_poi_search,v.argument.position_poi_searchdistance) + if(currentpoi ~= nil) then + + value = currentpoi[v.prop] + + end + + + + + end + + if(v.type == "node") then + if(v.searchprops ~= nil) then + + value = SearchinTable(cyberscript.cache["node"], v.searchprops, v.searchvalue,"data")[v.prop] + + else + if(v.tag ~= "random") then + value = cyberscript.cache["node"][v.tag].data[v.prop] + + else + value = getRandomPairfromTable(cyberscript.cache["node"]).value.data[v.prop] + + end + end + end + + if(v.type == "custom_npc") then + if(v.searchprops ~= nil) then + + value = SearchinTable(cyberscript.cache["npc"], v.searchprops, v.searchvalue,"data")[v.prop] + + else + if(v.tag ~= "random") then + + if(v.prop == "x" or v.prop =="y" or v.prop == "z") then + value = cyberscript.cache["npc"][v.tag].data["location"][v.prop] + + + else + value = cyberscript.cache["npc"][v.tag].data[v.prop] + + + end + + + else + + + if(v.prop == "x" or v.prop =="y" or v.prop == "z") then + value = getRandomPairfromTable(cyberscript.cache["npc"]).value.data["location"][v.prop] + + + else + value = getRandomPairfromTable(cyberscript.cache["npc"]).value.data[v.prop] + + + end + end + end + end + + if(v.type == "npc") then + if(v.searchprops ~= nil) then + + value = SearchinTable(cyberscript.entitieshash, v.searchprops, v.searchvalue,nil)[v.prop] + + else + + + local npc = getNPCByName(v.tag) + + if(npc ~= nil) then + value = npc[v.prop] + end + + + + + + + + + + end + end + + + + if(v.type == "variable" or v.type == "score") then + value = getVariableKey(v.variable,v.key) + + if(isArray(value))then + if(v.index == nil) then + local index = math.random(1,#value) + + value = value[index] + + + else + value = value[v.index] + end + end + + + + end + + if(v.type == "random_variable_key" or v.type == "random_score_key") then + value = getRandomPairfromTable(currentSave.Variable[v.variable]).value + + + end + + if(v.type == "text")then + + + + + + value = v.value + + end - if(v.type == "props")then - - - - value = source[v.prop] - - end - - if(v.type == "random_text") then - - if(#v.list > 1) then - local index = math.random(1,#v.list) - - value = v.list[index] - - else - - value = v.list[1] - end - - - end - - if(v.type == "number")then - - - - - - value = tonumber(v.value) - - end - - if(v.type == "random_number") then - - if(#v.list > 1) then - local index = math.random(1,#v.list) - - value = v.list[index] - - - else - - value = v.list[1] - end - - - end - - if(v.type == "random_math" or v.type == "random_range") then - - - local index = math.random(v.min,v.max) - - value = index - - - - - end - - if(v.type == "scannerdata" and ScannerInfoManager[v.tag] ~= nil)then - - - - if(v.prop == "primaryname" or v.prop == "secondaryname" or v.prop == "text" or v.prop == "entityname") then - - - - value = ScannerInfoManager[v.tag][v.prop] - - - - end - - if(v.prop == "level" or v.prop == "rarity" or v.prop == "attitude") then - - - - value = ScannerInfoManager[v.tag][v.prop] - - - - end - - - if(v.prop == "reward" or v.prop == "streetreward" or v.prop == "danger" and ScannerInfoManager[v.tag]["bounty"] ~= nil) then - - - - value = ScannerInfoManager[v.tag]["bounty"][v.prop] - - - - end - - - if(v.prop == "issuedby" and ScannerInfoManager[v.tag]["bounty"] ~= nil ) then - - - - value = ScannerInfoManager[v.tag]["bounty"][v.prop] - - - - end - - - - - - if(v.prop == "customtransgressions" or v.prop == "transgressions" and ScannerInfoManager[v.tag]["bounty"] ~= nil and #ScannerInfoManager[v.tag]["bounty"][v.prop] > 0) then - - if(v.index == nil) then - local index = math.random(1,#ScannerInfoManager[v.tag]["bounty"][v.prop]) - - value = ScannerInfoManager[v.tag]["bounty"][v.prop][index] - else - - value = ScannerInfoManager[v.tag]["bounty"][v.prop][v.index] - end - end - - - - - - - - end - - if(v.type == "current_scannerdata" and currentScannerItem ~= nil)then - - if(v.prop == "primaryname" or v.prop == "secondaryname" or v.prop == "text" or v.prop == "entityname") then - - - - value = currentScannerItem[v.prop] - - - - end - - if(v.prop == "level" or v.prop == "rarity" or v.prop == "attitude") then - - - - value = currentScannerItem[v.prop] - - - - end - - - if(v.prop == "reward" or v.prop == "streetreward" or v.prop == "danger" and currentScannerItem["bounty"] ~= nil) then - - - - value = currentScannerItem["bounty"][v.prop] - - - - end - - - if(v.prop == "issuedby" and currentScannerItem["bounty"] ~= nil ) then - - - - value = currentScannerItem["bounty"][v.prop] - - - - end - - - - - - if(v.prop == "customtransgressions" or v.prop == "transgressions" and currentScannerItem["bounty"] ~= nil and #currentScannerItem["bounty"][v.prop] > 0) then - - - if(v.index == nil) then - local index = math.random(1,#ScannerInfoManager[v.tag]["bounty"][v.prop]) - - value = currentScannerItem[v.prop][index] - else - - value = currentScannerItem[v.prop][v.index] - end - - end - - - - - - - - end - - if(v.type == "corpo_news")then - if(#corpoNews > 0) then - local id = math.random(1,#corpoNews) - value = corpoNews[id] - else - value = "No News, please connect to Keystone on PC first." - end - end - - if(v.type == "stock") then - - - if(arrayMarket ~= nil and #arrayMarket > 0) then - - for k,stock in ipairs(arrayMarket) do - - if(stock.tag == v.tag) then - - value = stock[v.prop] - - end - - end - - end - - - end - - if(v.type == "object") then - - value = v.value - - end + if(v.type == "props")then + + + + value = source[v.prop] + + end + + if(v.type == "random_text") then + + if(#v.list > 1) then + local index = math.random(1,#v.list) + + value = v.list[index] + + else + + value = v.list[1] + end + + + end + + if(v.type == "number")then + + + + + + value = tonumber(v.value) + + end + + if(v.type == "random_number") then + + if(#v.list > 1) then + local index = math.random(1,#v.list) + + value = v.list[index] + + + else + + value = v.list[1] + end + + + end + + if(v.type == "random_math" or v.type == "random_range") then + + + local index = math.random(v.min,v.max) + + value = index + + + + + end + + if(v.type == "scannerdata" and ScannerInfoManager[v.tag] ~= nil)then + + + + if(v.prop == "primaryname" or v.prop == "secondaryname" or v.prop == "text" or v.prop == "entityname") then + + + + value = ScannerInfoManager[v.tag][v.prop] + + + + end + + if(v.prop == "level" or v.prop == "rarity" or v.prop == "attitude") then + + + + value = ScannerInfoManager[v.tag][v.prop] + + + + end + + + if(v.prop == "reward" or v.prop == "streetreward" or v.prop == "danger" and ScannerInfoManager[v.tag]["bounty"] ~= nil) then + + + + value = ScannerInfoManager[v.tag]["bounty"][v.prop] + + + + end + + + if(v.prop == "issuedby" and ScannerInfoManager[v.tag]["bounty"] ~= nil ) then + + + + value = ScannerInfoManager[v.tag]["bounty"][v.prop] + + + + end + + + + + + if(v.prop == "customtransgressions" or v.prop == "transgressions" and ScannerInfoManager[v.tag]["bounty"] ~= nil and #ScannerInfoManager[v.tag]["bounty"][v.prop] > 0) then + + if(v.index == nil) then + local index = math.random(1,#ScannerInfoManager[v.tag]["bounty"][v.prop]) + + value = ScannerInfoManager[v.tag]["bounty"][v.prop][index] + else + + value = ScannerInfoManager[v.tag]["bounty"][v.prop][v.index] + end + end + + + + + + + + end + + if(v.type == "current_scannerdata" and currentScannerItem ~= nil)then + + if(v.prop == "primaryname" or v.prop == "secondaryname" or v.prop == "text" or v.prop == "entityname") then + + + + value = currentScannerItem[v.prop] + + + + end + + if(v.prop == "level" or v.prop == "rarity" or v.prop == "attitude") then + + + + value = currentScannerItem[v.prop] + + + + end + + + if(v.prop == "reward" or v.prop == "streetreward" or v.prop == "danger" and currentScannerItem["bounty"] ~= nil) then + + + + value = currentScannerItem["bounty"][v.prop] + + + + end + + + if(v.prop == "issuedby" and currentScannerItem["bounty"] ~= nil ) then + + + + value = currentScannerItem["bounty"][v.prop] + + + + end + + + + + + if(v.prop == "customtransgressions" or v.prop == "transgressions" and currentScannerItem["bounty"] ~= nil and #currentScannerItem["bounty"][v.prop] > 0) then + + + if(v.index == nil) then + local index = math.random(1,#ScannerInfoManager[v.tag]["bounty"][v.prop]) + + value = currentScannerItem[v.prop][index] + else + + value = currentScannerItem[v.prop][v.index] + end + + end + + + + + + + + end + + if(v.type == "corpo_news")then + if(#corpoNews > 0) then + local id = math.random(1,#corpoNews) + value = corpoNews[id] + else + value = "No News, please connect to Keystone on PC first." + end + end + + if(v.type == "stock") then + + + if(arrayMarket ~= nil and #arrayMarket > 0) then + + for k,stock in ipairs(arrayMarket) do + + if(stock.tag == v.tag) then + + value = stock[v.prop] + + end + + end + + end + + + end + + if(v.type == "object") then + + value = v.value + + end - if(v.type == "tweakdb") then - - value = TweakDB:GetFlat(v.value) - - end + if(v.type == "tweakdb") then + + value = TweakDB:GetFlat(v.value) + + end - if(v.type == "executortag") then - - if(source.executortag ~= nil) then - print(source.executortag) - value = source.executortag - end - - end - - if(v.type == "trigger") then - value = checkTrigger(v.trigger) - end - - if(v.type == "action") then - local status, result = pcall(executeAction(v.action,"context_action_"..tostring(math.random(1,99999)),"",1,"interact","see")) - - value = status - end - - - if(v.type == "list") then - local list = {} - for key,item in pairs(v.items)do - - - - if item.trigger == nil or checkTriggerRequirement(item.requirement,item.trigger) then - local result = GenerateTextFromContextValues(context, item,source) - - table.insert(list,result) - - end - - value = list - - end - end - - if(value == nil) then value = "" end - - local obj = deepcopy(value,nil) - - value = obj - - - if(v.outputtype ~= nil and v.outputtype =="number") then - value = tonumber(value) - end - - if(v.outputtype ~= nil and v.outputtype =="text") then - value = tostring(value) - end - - if(v.outputtype ~= nil and v.outputtype =="boolean") then - value = toboolean(value) - end - - - return value - -end + if(v.type == "executortag") then + + if(source.executortag ~= nil) then + print(source.executortag) + value = source.executortag + end + + end + + if(v.type == "trigger") then + value = checkTrigger(v.trigger) + end + + if(v.type == "action") then + local status, result = pcall(executeAction(v.action,"context_action_"..tostring(math.random(1,99999)),"",1,"interact","see")) + + value = status + end + + + if(v.type == "list") then + local list = {} + for key,item in pairs(v.items)do + + + + if item.trigger == nil or checkTriggerRequirement(item.requirement,item.trigger) then + local result = GenerateTextFromContextValues(context, item,source) + + table.insert(list,result) + + end + + value = list + + end + end + + if(value == nil) then value = "" end + + local obj = deepcopy(value,nil) + + value = obj + + + if(v.outputtype ~= nil and v.outputtype =="number") then + value = tonumber(value) + end + + if(v.outputtype ~= nil and v.outputtype =="text") then + value = tostring(value) + end + + if(v.outputtype ~= nil and v.outputtype =="boolean") then + value = toboolean(value) + end + + + return value + +end function getDistance(objA, objB) - -- Get the length for each of the components x and y - local xDist = objB.x - objA.x - local yDist = objB.y - objA.y - - return math.sqrt( (xDist ^ 2) + (yDist ^ 2) ) + -- Get the length for each of the components x and y + local xDist = objB.x - objA.x + local yDist = objB.y - objA.y + + return math.sqrt( (xDist ^ 2) + (yDist ^ 2) ) end function toboolean(str) - local bool = false - if str == "true" then - bool = true - end - return bool -end \ No newline at end of file + local bool = false + if str == "true" then + bool = true + end + return bool +end \ No newline at end of file diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/ui.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/ui.lua index b25cb8d..6944efc 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/ui.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/ui.lua @@ -2,1736 +2,1792 @@ logme(1,"CyberScript: UI module loaded") cyberscript.module = cyberscript.module + 1 ---Main Function--- function windowsManager() -- manage and toggle UI windows - - if draw and initFinished then--others windows - ImageFrame() - if ImGui.BeginPopupModal("locationdesc2", true) then - ImGui.SetWindowPos(800, 600) - local DropdownOptions = {"Kill ", "Escort", "Explore", "Ambush", "CustomPlace","Metro"} - local DropdownSelected = "" - ImGui.Text("This location file is for : ") - ImGui.Text(DropdownOptions[currentreason]) - if ImGui.Button("Valid and close") then - pathtick = 0 - savelocation.isFor = currentreason - closeSaveLocation() - ImGui.CloseCurrentPopup() - saveLocationEnabled = false - end - ImGui.EndPopup() - end - - if file_exists("editor/editor.lua") then - editorUIManager["editorWindows"] = overlayOpen - end - - - if(overlayOpen ) then - - - if file_exists("editor/editor.lua") then - cyberscript.editor2.editorWindowsManager() - end - - end - - - if(openColorPicker) then - colorPicker() - end - - - if isFadeIn then - fadeinwindows() - end - - - if openInterface then - WindowsItem() - end - end + + if draw and initFinished then--others windows + ImageFrame() + if ImGui.BeginPopupModal("locationdesc2", true) then + ImGui.SetWindowPos(800, 600) + local DropdownOptions = {"Kill ", "Escort", "Explore", "Ambush", "CustomPlace","Metro"} + local DropdownSelected = "" + ImGui.Text("This location file is for : ") + ImGui.Text(DropdownOptions[currentreason]) + if ImGui.Button("Valid and close") then + pathtick = 0 + savelocation.isFor = currentreason + closeSaveLocation() + ImGui.CloseCurrentPopup() + saveLocationEnabled = false + end + ImGui.EndPopup() + end + + if file_exists("editor/editor.lua") then + editorUIManager["editorWindows"] = overlayOpen + end + + + if(overlayOpen ) then + + + if file_exists("editor/editor.lua") then + cyberscript.editor2.editorWindowsManager() + end + + end + + + if(openColorPicker) then + colorPicker() + end + + + if isFadeIn then + fadeinwindows() + end + + + if openInterface then + WindowsItem() + end + end end function refreshUIWidget() - - if(currentInterfaceWidget ~= nil) then - - for k,interface in pairs(currentInterfaceWidget) do - for i,control in ipairs(interface.controls) do - - - local leftmargin = 540 - local topmargin = -uimargintop - local labelcount = 0 - local havebutton = false - local buttoncount = 0 - local havetext = false - local fontsize = uifont - local width = 400 - local height = 100 - local scalewidth = 0.5 - local scaleheight = 0.5 - local translationheight = 0 - local translationwidth = 0 - local transformheight = 0 - local transformwidth = 0 - local horizontalalign = 1 - local verticalalign = 1 - - - - - checkContext(control.data) - - - - -- if(control.data.margin == nil ) then - -- control.data.margin = {} - -- end - -- if(control.data.style == nil ) then - -- control.data.style = {} - -- end - - local bgcolor = HDRColor.new({ Red = 0.054902, Green = 0.054902, Blue = 0.090196, Alpha = 1.0 }) - - local textcolor = HDRColor.new({ Red = 1.1761, Green = 0.3809, Blue = 0.3476, Alpha = 1.0 }) - - - -- if control.data.margin == nil then control.data.margin = {} end - -- if control.data.childmargin == nil then control.data.childmargin = {} end - -- if control.data.style == nil then control.data.style = {} end - -- if control.data.size == nil then control.data.size = {} end - -- if control.data.scale == nil then control.data.scale = {} end - -- if control.translation == nil then control.translation = {} end - -- if control.transform == nil then control.transform = {} end - if(control.data.bgcolor ~= nil and control.data.bgcolor.red ~= nil ) then bgcolor = gamecolorStyle(control.data.bgcolor) end - if(control.data.textcolor ~= nil and control.data.textcolor.red ~= nil ) then textcolor = gamecolorStyle(control.data.textcolor) end - - -- if(control.data.fittocontent == nil) then control.data.fittocontent = true end - -- if(control.data.opacity == nil) then control.data.opacity = 1 end - -- if(control.data.rotation == nil) then control.data.rotation = 0 end - -- if(control.data.interactive == nil) then control.data.interactive = false end - - -- if(control.data.event == nil) then control.data.event = {} end - - - -- if(control.data.horizontalalign == nil) then control.data.horizontalalign = 1 end - -- if(control.data.anchor == nil) then control.data.anchor = 15 end - -- if(control.data.verticalalign == nil) then control.data.verticalalign = 1 end - if(control.data.style.fontsize ~= nil and control.data.style.fontsize ~= "") then fontsize = control.data.style.fontsize end - if(control.data.size.width ~= nil and control.data.size.width ~= "") then width = control.data.size.width end - if(control.data.size.height ~= nil and control.data.size.height ~= "") then height = control.data.size.height end - if(control.data.scale.height ~= nil and control.data.scale.height ~= "") then scaleheight = control.data.scale.height end - if(control.data.scale.width ~= nil and control.data.scale.width ~= "") then scalewidth = control.data.scale.width end - - if(control.data.translation.height ~= nil and control.data.translation.height ~= "") then translationheight = control.data.translation.height end - if(control.data.translation.width ~= nil and control.data.translation.width ~= "") then translationwidth = control.data.translation.width end - - if(control.data.transform.height ~= nil and control.data.transform.height ~= "") then transformheight = control.data.transform.height end - if(control.data.transform.width ~= nil and control.data.transform.width ~= "") then transformwidth= control.data.transform.width end - - -- if(control.data.scrollspeed and (control.data.scrolldelay == nil or control.data.autoscroll == nil)) then control.data.scrolldelay = 1 control.data.autoscroll = true end - - - -- if(control.data.visible == nil) then control.data.visible = true end - - if(control.data.output == true) then - - ----print(dump(control.data)) - logme(1,dump(control.data)) - - end - - - if(control.data.type == "label" or control.data.type == "textinput") then - - - - -- labelcount = labelcount +1 - -- topmargin = topmargin+uimargintop - -- local texttoDisplay = "" - - - - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"text")) or (table_contains(control.data.dynamic,"default")) then - - if(control.split and control.split > 0) then - - local desctab = splitByChunk(getLang(control.data.text), control.data.split) - local descc = "" - - for y=1,#desctab do - - - descc = descc.."\n"..desctab[y] - end - if(control.ink:GetText() ~= descc) then - control.ink:SetText(descc) - end - else - - if(control.ink:GetText() ~= getLang(control.data.text)) then - control.ink:SetText(getLang(control.data.text)) - end - - end - - - if(control.data.scrollspeed and control.data.scrollspeed > 0) then - - control.ink:SetScrollTextSpeed(control.data.scrollspeed) - control.ink.scrollDelay = control.data.scrolldelay - control.ink:EnableAutoScroll(control.data.autoscroll) - - end - - end - - - end - - - - if(control.data.type == "image") then - - -- control.ink:SetAtlasResource(ResRef.FromName(control.data.tweak)) - -- control.ink:SetTexturePart(control.data.texture) - -- local stickerTweakId = control.data.tweak - -- local stickerRecord = TDB.GetPhotoModeStickerRecord(stickerTweakId) - -- if(stickerRecord ~= nil) then - -- widget:SetAtlasResource(stickerRecord:AtlasName()) - -- widget:SetTexturePart(stickerRecord:ImagePartName()) - - - -- end - end - - - - - if(control.type == "shape") then - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"shape")) then - control.ink.shapeVariant = Enum.new('inkEShapeVariant', control.data.shapevariant) - control.ink.lineThickness = control.data.linethickness - control.ink.endCapStyle = Enum.new('inkEEndCapStyle', control.data.endcapstyle) - control.ink.borderColor = gamecolorStyle(control.data.textcolor) - - control.ink.nineSliceScale = inkMargin.new({}) - local vertextt = {} - for i,vertex in ipairs(control.data.vertex) do - - local vector = Vector2.new({X=vertex.x,Y=vertex.y}) - table.insert(vertextt,vector) - - - - end - control.ink.vertexList = vertextt - - - - control.ink.useNineSlice = true - end - - end - - - - - if(control.data.type ~= "scrollarea" and control.data.type ~= "button") then - - - - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"color")) or (table_contains(control.data.dynamic,"default") ) then - - -- if(control.tag == "popup_border") then - - -- --print(dump(control.data.textcolor)) - - -- end - - - control.ink:SetTintColor(textcolor) - end - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"visible") )or (table_contains(control.data.dynamic,"default") ) then - - - control.ink:SetVisible(control.data.visible) - end - - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"opacity")) or (table_contains(control.data.dynamic,"default") ) then - control.ink:SetOpacity(control.data.opacity) - end - - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"rotation")) or (table_contains(control.data.dynamic,"default")) then - control.ink:SetRotation(control.data.rotation) - end - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"size")) or (table_contains(control.data.dynamic,"default")) then - control.ink:SetSize(Vector2.new({ X = width, Y = height })) - end - - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"margin")) or (table_contains(control.data.dynamic,"default")) then - control.ink:SetMargin(inkMargin.new(control.data.margin)) - end - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"translation")) or (table_contains(control.data.dynamic,"default")) then - control.ink:SetTranslation(Vector2.new({ X = translationwidth, Y = translationheight })) - end - - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"padding")) or (table_contains(control.data.dynamic,"default")) then - control.ink:SetPadding(inkMargin.new(control.data.padding)) - end - - - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"pivot")) or (table_contains(control.data.dynamic,"default")) then - control.ink:SetRenderTransformPivot(Vector2.new({ X = transformwidth, Y = transformheight })) - end - - else - - - -- control.ink.root:SetFitToContent(control.data.fittocontent) - -- control.ink.root:SetTintColor(textcolor) - -- control.ink.root:SetSize(Vector2.new({ X = width, Y = height })) - -- control.ink.root:SetScale(Vector2.new({ X = scalewidth, Y = scaleheight })) - -- control.ink.root:SetInteractive(control.data.interactive) - -- control.ink.root:SetMargin(inkMargin.new(control.data.margin)) - -- control.ink.root:SetAnchor(control.data.anchor) - -- control.ink.root:SetAnchorPoint(Vector2.new({ X = 0, Y = 0 })) - -- control.ink.root:SetOpacity(control.data.opacity) - -- control.ink.root:SetRotation(control.data.rotation) - if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"visible")) or (table_contains(control.data.dynamic,"default")) then - - if control.ink:GetRootWidget().name ~=nil then control.ink:GetRootWidget():SetVisible(control.data.visible) end - end - -- control.ink.root:SetTranslation(Vector2.new({ X = translationwidth, Y = translationheight })) - -- control.ink.root:SetPadding(inkMargin.new(control.data.padding)) - -- control.ink.root:SetRenderTransformPivot(Vector2.new({ X = transformwidth, Y = transformheight })) - - - - end - - end - - - - end - - - end - - - - - - - - - + + if(currentInterfaceWidget ~= nil) then + + for k,interface in pairs(currentInterfaceWidget) do + for i,control in ipairs(interface.controls) do + + + local leftmargin = 540 + local topmargin = -uimargintop + local labelcount = 0 + local havebutton = false + local buttoncount = 0 + local havetext = false + local fontsize = uifont + local width = 400 + local height = 100 + local scalewidth = 0.5 + local scaleheight = 0.5 + local translationheight = 0 + local translationwidth = 0 + local transformheight = 0 + local transformwidth = 0 + local horizontalalign = 1 + local verticalalign = 1 + + + + + checkContext(control.data) + + + + -- if(control.data.margin == nil ) then + -- control.data.margin = {} + -- end + -- if(control.data.style == nil ) then + -- control.data.style = {} + -- end + + local bgcolor = HDRColor.new({ Red = 0.054902, Green = 0.054902, Blue = 0.090196, Alpha = 1.0 }) + + local textcolor = HDRColor.new({ Red = 1.1761, Green = 0.3809, Blue = 0.3476, Alpha = 1.0 }) + + + -- if control.data.margin == nil then control.data.margin = {} end + -- if control.data.childmargin == nil then control.data.childmargin = {} end + -- if control.data.style == nil then control.data.style = {} end + -- if control.data.size == nil then control.data.size = {} end + -- if control.data.scale == nil then control.data.scale = {} end + -- if control.translation == nil then control.translation = {} end + -- if control.transform == nil then control.transform = {} end + if(control.data.bgcolor ~= nil and control.data.bgcolor.red ~= nil ) then bgcolor = gamecolorStyle(control.data.bgcolor) end + if(control.data.textcolor ~= nil and control.data.textcolor.red ~= nil ) then textcolor = gamecolorStyle(control.data.textcolor) end + + -- if(control.data.fittocontent == nil) then control.data.fittocontent = true end + -- if(control.data.opacity == nil) then control.data.opacity = 1 end + -- if(control.data.rotation == nil) then control.data.rotation = 0 end + -- if(control.data.interactive == nil) then control.data.interactive = false end + + -- if(control.data.event == nil) then control.data.event = {} end + + + -- if(control.data.horizontalalign == nil) then control.data.horizontalalign = 1 end + -- if(control.data.anchor == nil) then control.data.anchor = 15 end + -- if(control.data.verticalalign == nil) then control.data.verticalalign = 1 end + if(control.data.style.fontsize ~= nil and control.data.style.fontsize ~= "") then fontsize = control.data.style.fontsize end + if(control.data.size.width ~= nil and control.data.size.width ~= "") then width = control.data.size.width end + if(control.data.size.height ~= nil and control.data.size.height ~= "") then height = control.data.size.height end + if(control.data.scale.height ~= nil and control.data.scale.height ~= "") then scaleheight = control.data.scale.height end + if(control.data.scale.width ~= nil and control.data.scale.width ~= "") then scalewidth = control.data.scale.width end + + if(control.data.translation.height ~= nil and control.data.translation.height ~= "") then translationheight = control.data.translation.height end + if(control.data.translation.width ~= nil and control.data.translation.width ~= "") then translationwidth = control.data.translation.width end + + if(control.data.transform.height ~= nil and control.data.transform.height ~= "") then transformheight = control.data.transform.height end + if(control.data.transform.width ~= nil and control.data.transform.width ~= "") then transformwidth= control.data.transform.width end + + -- if(control.data.scrollspeed and (control.data.scrolldelay == nil or control.data.autoscroll == nil)) then control.data.scrolldelay = 1 control.data.autoscroll = true end + + + -- if(control.data.visible == nil) then control.data.visible = true end + + if(control.data.output == true) then + + ----print(dump(control.data)) + logme(1,dump(control.data)) + + end + + + if(control.data.type == "label" or control.data.type == "textinput") then + + + + -- labelcount = labelcount +1 + -- topmargin = topmargin+uimargintop + -- local texttoDisplay = "" + + + + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"text")) or (table_contains(control.data.dynamic,"default")) then + + if(control.split and control.split > 0) then + + local desctab = splitByChunk(getLang(control.data.text), control.data.split) + local descc = "" + + for y=1,#desctab do + + + descc = descc.."\n"..desctab[y] + end + if(control.ink:GetText() ~= descc) then + control.ink:SetText(descc) + end + else + + if(control.ink:GetText() ~= getLang(control.data.text)) then + control.ink:SetText(getLang(control.data.text)) + end + + end + + + if(control.data.scrollspeed and control.data.scrollspeed > 0) then + + control.ink:SetScrollTextSpeed(control.data.scrollspeed) + control.ink.scrollDelay = control.data.scrolldelay + control.ink:EnableAutoScroll(control.data.autoscroll) + + end + + end + + + end + + + + if(control.data.type == "image") then + + -- control.ink:SetAtlasResource(ResRef.FromName(control.data.tweak)) + -- control.ink:SetTexturePart(control.data.texture) + -- local stickerTweakId = control.data.tweak + -- local stickerRecord = TDB.GetPhotoModeStickerRecord(stickerTweakId) + -- if(stickerRecord ~= nil) then + -- widget:SetAtlasResource(stickerRecord:AtlasName()) + -- widget:SetTexturePart(stickerRecord:ImagePartName()) + + + -- end + end + + + + + if(control.type == "shape") then + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"shape")) then + control.ink.shapeVariant = Enum.new('inkEShapeVariant', control.data.shapevariant) + control.ink.lineThickness = control.data.linethickness + control.ink.endCapStyle = Enum.new('inkEEndCapStyle', control.data.endcapstyle) + control.ink.borderColor = gamecolorStyle(control.data.textcolor) + + control.ink.nineSliceScale = inkMargin.new({}) + local vertextt = {} + for i,vertex in ipairs(control.data.vertex) do + + local vector = Vector2.new({X=vertex.x,Y=vertex.y}) + table.insert(vertextt,vector) + + + + end + control.ink.vertexList = vertextt + + + + control.ink.useNineSlice = true + end + + end + + + + + if(control.data.type ~= "scrollarea" and control.data.type ~= "button") then + + + + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"color")) or (table_contains(control.data.dynamic,"default") ) then + + -- if(control.tag == "popup_border") then + + -- --print(dump(control.data.textcolor)) + + -- end + + + control.ink:SetTintColor(textcolor) + end + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"visible") )or (table_contains(control.data.dynamic,"default") ) then + + + control.ink:SetVisible(control.data.visible) + end + + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"opacity")) or (table_contains(control.data.dynamic,"default") ) then + control.ink:SetOpacity(control.data.opacity) + end + + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"rotation")) or (table_contains(control.data.dynamic,"default")) then + control.ink:SetRotation(control.data.rotation) + end + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"size")) or (table_contains(control.data.dynamic,"default")) then + control.ink:SetSize(Vector2.new({ X = width, Y = height })) + end + + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"margin")) or (table_contains(control.data.dynamic,"default")) then + control.ink:SetMargin(inkMargin.new(control.data.margin)) + end + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"translation")) or (table_contains(control.data.dynamic,"default")) then + control.ink:SetTranslation(Vector2.new({ X = translationwidth, Y = translationheight })) + end + + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"padding")) or (table_contains(control.data.dynamic,"default")) then + control.ink:SetPadding(inkMargin.new(control.data.padding)) + end + + + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"pivot")) or (table_contains(control.data.dynamic,"default")) then + control.ink:SetRenderTransformPivot(Vector2.new({ X = transformwidth, Y = transformheight })) + end + + else + + + -- control.ink.root:SetFitToContent(control.data.fittocontent) + -- control.ink.root:SetTintColor(textcolor) + -- control.ink.root:SetSize(Vector2.new({ X = width, Y = height })) + -- control.ink.root:SetScale(Vector2.new({ X = scalewidth, Y = scaleheight })) + -- control.ink.root:SetInteractive(control.data.interactive) + -- control.ink.root:SetMargin(inkMargin.new(control.data.margin)) + -- control.ink.root:SetAnchor(control.data.anchor) + -- control.ink.root:SetAnchorPoint(Vector2.new({ X = 0, Y = 0 })) + -- control.ink.root:SetOpacity(control.data.opacity) + -- control.ink.root:SetRotation(control.data.rotation) + if(control.data.dynamic == nil) or (table_contains(control.data.dynamic,"visible")) or (table_contains(control.data.dynamic,"default")) then + + if control.ink:GetRootWidget().name ~=nil then control.ink:GetRootWidget():SetVisible(control.data.visible) end + end + -- control.ink.root:SetTranslation(Vector2.new({ X = translationwidth, Y = translationheight })) + -- control.ink.root:SetPadding(inkMargin.new(control.data.padding)) + -- control.ink.root:SetRenderTransformPivot(Vector2.new({ X = transformwidth, Y = transformheight })) + + + + end + + end + + + + end + + + end + + + + + + + + + end ---Misc Function--- function showInputHint(key, text, prio, holdAnimation, tag) - - local hold = holdAnimation or false - - local evt = UpdateInputHintEvent.new() - - local data = InputHintData.new() - data.action = key - data.source = "CyberScript" - data. - localizedLabel = text - data.enableHoldAnimation = hold - data.sortingPriority = prio or 1 - evt = UpdateInputHintEvent.new() - evt.data = data - evt.show = true - evt.targetHintContainer = "GameplayInputHelper" - Game.GetUISystem():QueueEvent(evt) - table.insert(currentInputHintList, {tag = tag, key = key}) + + local hold = holdAnimation or false + + local evt = UpdateInputHintEvent.new() + + local data = InputHintData.new() + data.action = key + data.source = "CyberScript" + data. + localizedLabel = text + data.enableHoldAnimation = hold + data.sortingPriority = prio or 1 + evt = UpdateInputHintEvent.new() + evt.data = data + evt.show = true + evt.targetHintContainer = "GameplayInputHelper" + Game.GetUISystem():QueueEvent(evt) + table.insert(currentInputHintList, {tag = tag, key = key}) end function hideCustomHints(tag) - - local evt = DeleteInputHintBySourceEvent.new() - evt.source = "CyberScript" - evt.targetHintContainer = "GameplayInputHelper" - Game.GetUISystem():QueueEvent(evt) + + local evt = DeleteInputHintBySourceEvent.new() + evt.source = "CyberScript" + evt.targetHintContainer = "GameplayInputHelper" + Game.GetUISystem():QueueEvent(evt) end function createdefaultOption(tag,maxkey) - local defaultinput = {} - defaultinput[tag] = {} - defaultinput[tag]["repeatable"] = false - defaultinput[tag]["keyboard"] = {} - defaultinput[tag]["gamepad"] = {} - for i=1,maxkey do - - defaultinput[tag]["keyboard"]["key_"..i] = "IK_F1" - defaultinput[tag]["keyboard"]["hold_"..i] = false - defaultinput[tag]["gamepad"]["key_"..i] = "IK_F1" - defaultinput[tag]["gamepad"]["hold_"..i] = false - - end - - defaultinput[tag]["keyboard"]["keys"] = 1 - defaultinput[tag]["gamepad"]["keys"] = 1 - + local defaultinput = {} + defaultinput[tag] = {} + defaultinput[tag]["repeatable"] = false + defaultinput[tag]["keyboard"] = {} + defaultinput[tag]["gamepad"] = {} + for i=1,maxkey do + + defaultinput[tag]["keyboard"]["key_"..i] = "IK_F1" + defaultinput[tag]["keyboard"]["hold_"..i] = false + defaultinput[tag]["gamepad"]["key_"..i] = "IK_F1" + defaultinput[tag]["gamepad"]["hold_"..i] = false + + end + + defaultinput[tag]["keyboard"]["keys"] = 1 + defaultinput[tag]["gamepad"]["keys"] = 1 + return defaultinput end function buildWebPageBountonSquare(parent,imageprop,textprop,page,action,customimage) - local selectionImage = inkImage.new() - - if(customimage ~= nil and customimage == true) then - selectionImage:SetAtlasResource(ResRef.FromName(imageprop.tweak)) - selectionImage:SetTexturePart(imageprop.texture) - imageprop.scale.x = 1.3 - imageprop.scale.y = 1 - - else - local stickerRecord = TDB.GetPhotoModeStickerRecord(imageprop.tweak) - selectionImage:SetAtlasResource(stickerRecord:AtlasName()) - selectionImage:SetTexturePart(stickerRecord:ImagePartName()) - - - end - - - selectionImage:SetName(CName.new(imageprop.tag)) - selectionImage:SetMargin(imageprop.margin) - selectionImage:SetSize(Vector2.new({ X = imageprop.size.x, Y = imageprop.size.y })) - selectionImage:SetFitToContent(imageprop.fittocontent) - - selectionImage:SetScale(Vector2.new({ X = imageprop.scale.x, Y = imageprop.scale.y })) - selectionImage:Reparent(parent, 0) - selectionImage:SetInteractive(true) - - local descText = inkText.new() - descText:SetName(CName.new(textprop.tag)) - descText:SetText(textprop.text) - descText:SetFontFamily('base\\gameplay\\gui\\fonts\\raj\\raj.inkfontfamily') - descText:SetFontStyle('Semi-Bold') - descText:SetFontSize(textprop.fontsize) - descText:SetTintColor(textprop.textcolor) - descText:SetHorizontalAlignment(textHorizontalAlignment.Center) - descText:SetVerticalAlignment(textVerticalAlignment.Center) - descText:SetMargin(textprop.margin) - descText:SetLetterCase(1) - descText:SetScale(Vector2.new({ X = textprop.scale.x, Y = textprop.scale.y })) - descText:SetSize(Vector2.new({ X = textprop.size.x, Y = textprop.size.y })) - descText:Reparent(parent, 1) - - - EventProxy.RegisterCallback(selectionImage, 'OnRelease', function(_, evt) - - - - - if(action ~= nil and #action > 0) then - - runActionList(action, "WebButtonEvent", "interact",false,"nothing",true) - - end - - - --+ GameController["WebPage"] = self:FillPageFromJournal(page) - - evt:Handle() - end) - - - - + local selectionImage = inkImage.new() + + if(customimage ~= nil and customimage == true) then + selectionImage:SetAtlasResource(ResRef.FromName(imageprop.tweak)) + selectionImage:SetTexturePart(imageprop.texture) + imageprop.scale.x = 1.3 + imageprop.scale.y = 1 + + else + local stickerRecord = TDB.GetPhotoModeStickerRecord(imageprop.tweak) + selectionImage:SetAtlasResource(stickerRecord:AtlasName()) + selectionImage:SetTexturePart(stickerRecord:ImagePartName()) + + + end + + + selectionImage:SetName(CName.new(imageprop.tag)) + selectionImage:SetMargin(imageprop.margin) + selectionImage:SetSize(Vector2.new({ X = imageprop.size.x, Y = imageprop.size.y })) + selectionImage:SetFitToContent(imageprop.fittocontent) + + selectionImage:SetScale(Vector2.new({ X = imageprop.scale.x, Y = imageprop.scale.y })) + selectionImage:Reparent(parent, 0) + selectionImage:SetInteractive(true) + + local descText = inkText.new() + descText:SetName(CName.new(textprop.tag)) + descText:SetText(textprop.text) + descText:SetFontFamily('base\\gameplay\\gui\\fonts\\raj\\raj.inkfontfamily') + descText:SetFontStyle('Semi-Bold') + descText:SetFontSize(textprop.fontsize) + descText:SetTintColor(textprop.textcolor) + descText:SetHorizontalAlignment(textHorizontalAlignment.Center) + descText:SetVerticalAlignment(textVerticalAlignment.Center) + descText:SetMargin(textprop.margin) + descText:SetLetterCase(1) + descText:SetScale(Vector2.new({ X = textprop.scale.x, Y = textprop.scale.y })) + descText:SetSize(Vector2.new({ X = textprop.size.x, Y = textprop.size.y })) + descText:Reparent(parent, 1) + + + EventProxy.RegisterCallback(selectionImage, 'OnRelease', function(_, evt) + + + + + if(action ~= nil and #action > 0) then + + runActionList(action, "WebButtonEvent", "interact",false,"nothing",true) + + end + + + --+ GameController["WebPage"] = self:FillPageFromJournal(page) + + evt:Handle() + end) + + + + end function makeCustomInterface(parentroot,interface) - - local rootWidget = parentroot - - - currentevt = {} - currentscroll = {} - - - - - local leftmargin = 540 - local topmargin = -uimargintop - local labelcount = 0 - local havebutton = false - local buttoncount = 0 - local havetext = false - local fontsize = uifont - local width = 400 - local height = 100 - local scalewidth = 0.5 - local scaleheight = 0.5 - local translationheight = 0 - local translationwidth = 0 - local transformheight = 0 - local transformwidth = 0 - local horizontalalign = 1 - local verticalalign = 1 - - if(interface.onload_action ~= nil and #interface.onload_action > 0) then - - runActionList(interface.onload_action, interface.tag, "interact",false,"nothing",true) - - end - currentInterfaceWidgetTest = {} - currentInterfaceWidget[interface.tag] = {} - currentInterfaceWidget[interface.tag].controls = {} - currentInterfaceWidget[interface.tag].parent = parentroot - - - for i,control in ipairs(interface.controls) do - local status, result = pcall( function() - if(checkTriggerRequirement(control["requirement"],control["trigger"])) then - - checkContext(control) - local bgcolor = HDRColor.new({ Red = 0.054902, Green = 0.054902, Blue = 0.090196, Alpha = 1.0 }) - - local textcolor = HDRColor.new({ Red = 1.1761, Green = 0.3809, Blue = 0.3476, Alpha = 1.0 }) - - - if control.margin == nil then control.margin = {} end - if control.childmargin == nil then control.childmargin = {} end - if control.padding == nil then control.padding = {} end - if control.style == nil then control.style = {} end - if control.size == nil then control.size = {} end - if control.scale == nil then control.scale = {} end - if control.translation == nil then control.translation = {} end - if control.transform == nil then control.transform = {} end - - if(control.bgcolor ~= nil and control.bgcolor.red ~= nil ) then bgcolor = gamecolorStyle(control.bgcolor) end - if(control.textcolor ~= nil and control.textcolor.red ~= nil ) then textcolor = gamecolorStyle(control.textcolor) end - - if(control.fittocontent == nil) then control.fittocontent = true end - if(control.opacity == nil) then control.opacity = 1 end - if(control.rotation == nil) then control.rotation = 0 end - if(control.interactive == nil) then control.interactive = false end - - if(control.event == nil) then control.event = {} end - - - if(control.horizontalalign == nil) then control.horizontalalign = 1 end - if(control.anchor == nil) then control.anchor = 15 end - if(control.verticalalign == nil) then control.verticalalign = 1 end - if(control.style.fontsize ~= nil and control.style.fontsize ~= "") then fontsize = control.style.fontsize end - if(control.size.width ~= nil and control.size.width ~= "") then width = control.size.width end - if(control.size.height ~= nil and control.size.height ~= "") then height = control.size.height end - if(control.scale.height ~= nil and control.scale.height ~= "") then scaleheight = control.scale.height end - if(control.scale.width ~= nil and control.scale.width ~= "") then scalewidth = control.scale.width end - - if(control.translation.height ~= nil and control.translation.height ~= "") then translationheight = control.translation.height end - if(control.translation.width ~= nil and control.translation.width ~= "") then translationwidth = control.translation.width end - - if(control.transform.height ~= nil and control.transform.height ~= "") then transformheight = control.transform.height end - if(control.transform.width ~= nil and control.transform.width ~= "") then transformwidth= control.transform.width end - - - if(control.visible == nil) then control.visible = true end - if(control.scrollspeed and (control.scrolldelay == nil or control.autoscroll == nil)) then control.scrolldelay = 30 control.autoscroll = true end - - local obj = {} - - obj.tag = control.tag - obj.data = control - obj.type = control.type - - - - local widgetcontrol = nil - - - - - - - - if(control.type == "label" or control.type == "textinput") then - - - - labelcount = labelcount +1 - topmargin = topmargin+uimargintop - local texttoDisplay = "" - - if(control.type == "textinput") then - widgetcontrol = inkTextInput.new() - - else - widgetcontrol = inkText.new() - - end - - if(control.split and control.split > 0) then - - local desctab = splitByChunk(getLang(control.text), control.split) - local descc = desctab - - - widgetcontrol:SetText(descc) - else - widgetcontrol:SetText(getLang(control.text)) - end - - widgetcontrol:SetFontFamily('base\\gameplay\\gui\\fonts\\raj\\raj.inkfontfamily') - widgetcontrol:SetFontStyle('Medium') - widgetcontrol:SetFontSize(fontsize) - widgetcontrol:SetHorizontalAlignment(control.horizontalalign) - widgetcontrol:SetVerticalAlignment(control.verticalalign) - - - if(control.scrollspeed and control.scrollspeed > 0) then - - widgetcontrol:SetScrollTextSpeed(control.scrollspeed) - widgetcontrol.scrollDelay = control.scrolldelay - widgetcontrol:EnableAutoScroll(control.autoscroll) - - end - - - - end - - - - if(control.type == "image") then - widgetcontrol = inkImage.new() - widgetcontrol:SetAtlasResource(ResRef.FromName(control.tweak)) - widgetcontrol:SetTexturePart(control.texture) - -- local stickerTweakId = control.tweak - -- local stickerRecord = TDB.GetPhotoModeStickerRecord(stickerTweakId) - -- if(stickerRecord ~= nil) then - -- widgetcontrol:SetAtlasResource(stickerRecord:AtlasName()) - -- widgetcontrol:SetTexturePart(stickerRecord:ImagePartName()) - - -- end - end - - if(control.type == "button") then - control.interactive = true - - - local buttonData = { - name = StringToName(control.tag), - text = control.title, - value = i, - tag = control.tag, - action = control.action - } - local fontsize = uifont - widgetcontrol = UIButton.Create(buttonData.name, buttonData.text,fontsize, control.size.width, control.size.height,control.margin,bgcolor,textcolor) - - widgetcontrol:RegisterCallback('OnRelease', function(button, evt) - - - runActionList(control.action, control.tag, "interact",false,"nothing",false) - - evt:Handle() - - end) - widgetcontrol:RegisterCallback('OnEnter', function(_, evt) - - if(control.onenter_action ~= nil and #control.onenter_action > 0) then - runActionList(control.onenter_action, control.tag.."_onenter", "interact",false,"nothing",false) - end - - evt:Handle() - end) - widgetcontrol:RegisterCallback('OnLeave', function(_, evt) - - if(control.onleave_action ~= nil and #control.onleave_action > 0) then - runActionList(control.onleave_action, control.tag.."_onleave", "interact",false,"nothing",false) - end - - evt:Handle() - end) - - --logme(2,"button") - end - - if(control.type == "scrollarea") then - - - - widgetcontrol = UIScroller.Create(control.tag) - - - - - - - - Cron.NextTick(function() - widgetcontrol:UpdateContent(true) - end) - - end - - if(control.type == "area") then - widgetcontrol = inkCanvas.new() - - end - - if(control.type == "vertical_area") then - widgetcontrol = inkVerticalPanelWidget.new() - - - widgetcontrol:SetChildMargin(inkMargin.new(control.childmargin)) - - end - - if(control.type == "horizontal_area") then - widgetcontrol = inkHorizontalPanelWidget.new() - - widgetcontrol:SetChildMargin(inkMargin.new(control.childmargin)) - - end - - if(control.type == "rectangle") then - widgetcontrol = inkRectangleWidget.new() - - end - - if(control.type == "circle") then - widgetcontrol = inkCirclewWidget.new() - - end - - - if(control.type == "shape") then - - widgetcontrol = inkShapeWidget.new() - widgetcontrol.shapeVariant = Enum.new('inkEShapeVariant', control.shapevariant) - widgetcontrol.lineThickness = control.linethickness - widgetcontrol.endCapStyle = Enum.new('inkEEndCapStyle', control.endcapstyle) - widgetcontrol.borderColor = gamecolorStyle(control.textcolor) - - widgetcontrol.nineSliceScale = inkMargin.new({}) - local vertextt = {} - for i,vertex in ipairs(control.vertex) do - - local vector = Vector2.new({X=vertex.x,Y=vertex.y}) - table.insert(vertextt,vector) - - - - end - widgetcontrol.vertexList = vertextt - - - - widgetcontrol.useNineSlice = true - - - end - - - if(control.type == "scrollarea") then - if(control.parent == nil or control.parent == "")then - widgetcontrol:GetRootWidget():Reparent(parentroot, -1) - else - local parentv = getInkWidgetControl(interface.tag,control.parent) - if(parentv ~= nil ) then - widgetcontrol:GetRootWidget():Reparent(parentv.ink, -1) - - else - widgetcontrol:Reparent(parentroot, -1) - - end - end - - else - if(control.parent == nil or control.parent == "")then - widgetcontrol:Reparent(parentroot, -1) - - else - local parentv = getInkWidgetControl(interface.tag,control.parent) - - if(parentv ~= nil ) then - - - - if(parentv.type ~= nil and parentv.type == "scrollarea") then - - local scrollContent = parentv.ink:GetContentWidget() - widgetcontrol:Reparent(scrollContent, -1) - - else - - - widgetcontrol:Reparent(parentv.ink, -1) - - end - else - widgetcontrol:Reparent(parentroot, -1) - - end - end - - end - - - - if control.interactive == true then - - for i,event in ipairs(control.event) do - EventProxy.RegisterCallback(widgetcontrol, event.eventname, function(_, evt) - - if( event.action ~= nil and #event.action > 0 and workerTable[control.tag..event.eventname] == nil) then - runActionList(event.action, control.tag..event.eventname, "interact",false,"nothing",true) - end - - evt:Handle() - end) - end - - end - - if(control.type ~= "scrollarea" and control.type ~= "button" ) then - CName.add(control.tag) - widgetcontrol:SetName(CName(control.tag)) - widgetcontrol:SetFitToContent(control.fittocontent) - widgetcontrol:SetTintColor(textcolor) - widgetcontrol:SetSize(Vector2.new({ X = width, Y = height })) - widgetcontrol:SetScale(Vector2.new({ X = scalewidth, Y = scaleheight })) - widgetcontrol:SetInteractive(control.interactive) - widgetcontrol:SetMargin(inkMargin.new(control.margin)) - widgetcontrol:SetAnchor(control.anchor) - widgetcontrol:SetAnchorPoint(Vector2.new({ X = 0, Y = 0 })) - widgetcontrol:SetOpacity(control.opacity) - widgetcontrol:SetRotation(control.rotation) - widgetcontrol:SetVisible(control.visible) - widgetcontrol:SetTranslation(Vector2.new({ X = translationwidth, Y = translationheight })) - widgetcontrol:SetPadding(inkMargin.new(control.padding)) - widgetcontrol:SetRenderTransformPivot(Vector2.new({ X = transformwidth, Y = transformheight })) - widgetcontrol:SetState("default") - - else - - -- widgetcontrol.root:SetName(CName.new(control.tag)) - widgetcontrol.root:SetFitToContent(control.fittocontent) - -- widgetcontrol.root:SetTintColor(textcolor) - widgetcontrol.root:SetSize(Vector2.new({ X = width, Y = height })) - -- widgetcontrol.root:SetScale(Vector2.new({ X = scalewidth, Y = scaleheight })) - -- widgetcontrol.root:SetInteractive(control.interactive) - widgetcontrol.root:SetMargin(inkMargin.new(control.margin)) - widgetcontrol.root:SetAnchor(control.anchor) - -- widgetcontrol.root:SetAnchorPoint(Vector2.new({ X = 0, Y = 0 })) - -- widgetcontrol.root:SetOpacity(control.opacity) - -- widgetcontrol.root:SetRotation(control.rotation) - -- widgetcontrol.root:SetVisible(control.visible) - -- widgetcontrol.root:SetTranslation(Vector2.new({ X = translationwidth, Y = translationheight })) - -- widgetcontrol.root:SetPadding(inkMargin.new(control.padding)) - -- widgetcontrol.root:SetRenderTransformPivot(Vector2.new({ X = transformwidth, Y = transformheight })) - -- widgetcontrol.root:SetState("default") - if(control.type == "scrollarea") then - --widgetcontrol:GetWidgetByIndex(0):SetSize(Vector2.new({ X = width, Y = height })) - end - if(control.type == "shape") then - - for i,v in ipairs(widgetcontrol.vertexList) do - - - - - end - - end - end - - - - obj.ink = widgetcontrol - - - table.insert(currentInterfaceWidget[interface.tag].controls,obj) - - end - end) - - - if status == false then - - logme(1,control.tag) - logme(1,result) - logme(1,dump(control)) - - - end - end - - - - + + local rootWidget = parentroot + + + currentevt = {} + currentscroll = {} + + + + + local leftmargin = 540 + local topmargin = -uimargintop + local labelcount = 0 + local havebutton = false + local buttoncount = 0 + local havetext = false + local fontsize = uifont + local width = 400 + local height = 100 + local scalewidth = 0.5 + local scaleheight = 0.5 + local translationheight = 0 + local translationwidth = 0 + local transformheight = 0 + local transformwidth = 0 + local horizontalalign = 1 + local verticalalign = 1 + + if(interface.onload_action ~= nil and #interface.onload_action > 0) then + + runActionList(interface.onload_action, interface.tag, "interact",false,"nothing",true) + + end + currentInterfaceWidgetTest = {} + currentInterfaceWidget[interface.tag] = {} + currentInterfaceWidget[interface.tag].controls = {} + currentInterfaceWidget[interface.tag].parent = parentroot + + + for i,control in ipairs(interface.controls) do + local status, result = pcall( function() + if(checkTriggerRequirement(control["requirement"],control["trigger"])) then + + checkContext(control) + local bgcolor = HDRColor.new({ Red = 0.054902, Green = 0.054902, Blue = 0.090196, Alpha = 1.0 }) + + local textcolor = HDRColor.new({ Red = 1.1761, Green = 0.3809, Blue = 0.3476, Alpha = 1.0 }) + + + if control.margin == nil then control.margin = {} end + if control.childmargin == nil then control.childmargin = {} end + if control.padding == nil then control.padding = {} end + if control.style == nil then control.style = {} end + if control.size == nil then control.size = {} end + if control.scale == nil then control.scale = {} end + if control.translation == nil then control.translation = {} end + if control.transform == nil then control.transform = {} end + + if(control.bgcolor ~= nil and control.bgcolor.red ~= nil ) then bgcolor = gamecolorStyle(control.bgcolor) end + if(control.textcolor ~= nil and control.textcolor.red ~= nil ) then textcolor = gamecolorStyle(control.textcolor) end + + if(control.fittocontent == nil) then control.fittocontent = true end + if(control.opacity == nil) then control.opacity = 1 end + if(control.rotation == nil) then control.rotation = 0 end + if(control.interactive == nil) then control.interactive = false end + + if(control.event == nil) then control.event = {} end + + + if(control.horizontalalign == nil) then control.horizontalalign = 1 end + if(control.anchor == nil) then control.anchor = 15 end + if(control.verticalalign == nil) then control.verticalalign = 1 end + if(control.style.fontsize ~= nil and control.style.fontsize ~= "") then fontsize = control.style.fontsize end + if(control.size.width ~= nil and control.size.width ~= "") then width = control.size.width end + if(control.size.height ~= nil and control.size.height ~= "") then height = control.size.height end + if(control.scale.height ~= nil and control.scale.height ~= "") then scaleheight = control.scale.height end + if(control.scale.width ~= nil and control.scale.width ~= "") then scalewidth = control.scale.width end + + if(control.translation.height ~= nil and control.translation.height ~= "") then translationheight = control.translation.height end + if(control.translation.width ~= nil and control.translation.width ~= "") then translationwidth = control.translation.width end + + if(control.transform.height ~= nil and control.transform.height ~= "") then transformheight = control.transform.height end + if(control.transform.width ~= nil and control.transform.width ~= "") then transformwidth= control.transform.width end + + + if(control.visible == nil) then control.visible = true end + if(control.scrollspeed and (control.scrolldelay == nil or control.autoscroll == nil)) then control.scrolldelay = 30 control.autoscroll = true end + + local obj = {} + + obj.tag = control.tag + obj.data = control + obj.type = control.type + + + + local widgetcontrol = nil + + + + + + + + if(control.type == "label" or control.type == "textinput") then + + + + labelcount = labelcount +1 + topmargin = topmargin+uimargintop + local texttoDisplay = "" + + if(control.type == "textinput") then + widgetcontrol = inkTextInput.new() + + else + widgetcontrol = inkText.new() + + end + + if(control.split and control.split > 0) then + + local desctab = splitByChunk(getLang(control.text), control.split) + local descc = desctab + + + widgetcontrol:SetText(descc) + else + widgetcontrol:SetText(getLang(control.text)) + end + + widgetcontrol:SetFontFamily('base\\gameplay\\gui\\fonts\\raj\\raj.inkfontfamily') + widgetcontrol:SetFontStyle('Medium') + widgetcontrol:SetFontSize(fontsize) + widgetcontrol:SetHorizontalAlignment(control.horizontalalign) + widgetcontrol:SetVerticalAlignment(control.verticalalign) + + + if(control.scrollspeed and control.scrollspeed > 0) then + + widgetcontrol:SetScrollTextSpeed(control.scrollspeed) + widgetcontrol.scrollDelay = control.scrolldelay + widgetcontrol:EnableAutoScroll(control.autoscroll) + + end + + + + end + + + + if(control.type == "image") then + widgetcontrol = inkImage.new() + widgetcontrol:SetAtlasResource(ResRef.FromName(control.tweak)) + widgetcontrol:SetTexturePart(control.texture) + -- local stickerTweakId = control.tweak + -- local stickerRecord = TDB.GetPhotoModeStickerRecord(stickerTweakId) + -- if(stickerRecord ~= nil) then + -- widgetcontrol:SetAtlasResource(stickerRecord:AtlasName()) + -- widgetcontrol:SetTexturePart(stickerRecord:ImagePartName()) + + -- end + end + + if(control.type == "button") then + control.interactive = true + + + local buttonData = { + name = StringToName(control.tag), + text = control.title, + value = i, + tag = control.tag, + action = control.action + } + local fontsize = uifont + widgetcontrol = UIButton.Create(buttonData.name, buttonData.text,fontsize, control.size.width, control.size.height,control.margin,bgcolor,textcolor) + + widgetcontrol:RegisterCallback('OnRelease', function(button, evt) + + + runActionList(control.action, control.tag, "interact",false,"nothing",false) + + evt:Handle() + + end) + widgetcontrol:RegisterCallback('OnEnter', function(_, evt) + + if(control.onenter_action ~= nil and #control.onenter_action > 0) then + runActionList(control.onenter_action, control.tag.."_onenter", "interact",false,"nothing",false) + end + + evt:Handle() + end) + widgetcontrol:RegisterCallback('OnLeave', function(_, evt) + + if(control.onleave_action ~= nil and #control.onleave_action > 0) then + runActionList(control.onleave_action, control.tag.."_onleave", "interact",false,"nothing",false) + end + + evt:Handle() + end) + + --logme(2,"button") + end + + if(control.type == "scrollarea") then + + + + widgetcontrol = UIScroller.Create(control.tag) + + + + + + + + Cron.NextTick(function() + widgetcontrol:UpdateContent(true) + end) + + end + + if(control.type == "area") then + widgetcontrol = inkCanvas.new() + + end + + if(control.type == "vertical_area") then + widgetcontrol = inkVerticalPanelWidget.new() + + + widgetcontrol:SetChildMargin(inkMargin.new(control.childmargin)) + + end + + if(control.type == "horizontal_area") then + widgetcontrol = inkHorizontalPanelWidget.new() + + widgetcontrol:SetChildMargin(inkMargin.new(control.childmargin)) + + end + + if(control.type == "rectangle") then + widgetcontrol = inkRectangleWidget.new() + + end + + if(control.type == "circle") then + widgetcontrol = inkCirclewWidget.new() + + end + + + if(control.type == "shape") then + + widgetcontrol = inkShapeWidget.new() + widgetcontrol.shapeVariant = Enum.new('inkEShapeVariant', control.shapevariant) + widgetcontrol.lineThickness = control.linethickness + widgetcontrol.endCapStyle = Enum.new('inkEEndCapStyle', control.endcapstyle) + widgetcontrol.borderColor = gamecolorStyle(control.textcolor) + + widgetcontrol.nineSliceScale = inkMargin.new({}) + local vertextt = {} + for i,vertex in ipairs(control.vertex) do + + local vector = Vector2.new({X=vertex.x,Y=vertex.y}) + table.insert(vertextt,vector) + + + + end + widgetcontrol.vertexList = vertextt + + + + widgetcontrol.useNineSlice = true + + + end + + + if(control.type == "scrollarea") then + if(control.parent == nil or control.parent == "")then + widgetcontrol:GetRootWidget():Reparent(parentroot, -1) + else + local parentv = getInkWidgetControl(interface.tag,control.parent) + if(parentv ~= nil ) then + widgetcontrol:GetRootWidget():Reparent(parentv.ink, -1) + + else + widgetcontrol:Reparent(parentroot, -1) + + end + end + + else + if(control.parent == nil or control.parent == "")then + widgetcontrol:Reparent(parentroot, -1) + + else + local parentv = getInkWidgetControl(interface.tag,control.parent) + + if(parentv ~= nil ) then + + + + if(parentv.type ~= nil and parentv.type == "scrollarea") then + + local scrollContent = parentv.ink:GetContentWidget() + widgetcontrol:Reparent(scrollContent, -1) + + else + + + widgetcontrol:Reparent(parentv.ink, -1) + + end + else + widgetcontrol:Reparent(parentroot, -1) + + end + end + + end + + + + if control.interactive == true then + + for i,event in ipairs(control.event) do + EventProxy.RegisterCallback(widgetcontrol, event.eventname, function(_, evt) + + if( event.action ~= nil and #event.action > 0 and workerTable[control.tag..event.eventname] == nil) then + runActionList(event.action, control.tag..event.eventname, "interact",false,"nothing",true) + end + + evt:Handle() + end) + end + + end + + if(control.type ~= "scrollarea" and control.type ~= "button" ) then + CName.add(control.tag) + widgetcontrol:SetName(CName(control.tag)) + widgetcontrol:SetFitToContent(control.fittocontent) + widgetcontrol:SetTintColor(textcolor) + widgetcontrol:SetSize(Vector2.new({ X = width, Y = height })) + widgetcontrol:SetScale(Vector2.new({ X = scalewidth, Y = scaleheight })) + widgetcontrol:SetInteractive(control.interactive) + widgetcontrol:SetMargin(inkMargin.new(control.margin)) + widgetcontrol:SetAnchor(control.anchor) + widgetcontrol:SetAnchorPoint(Vector2.new({ X = 0, Y = 0 })) + widgetcontrol:SetOpacity(control.opacity) + widgetcontrol:SetRotation(control.rotation) + widgetcontrol:SetVisible(control.visible) + widgetcontrol:SetTranslation(Vector2.new({ X = translationwidth, Y = translationheight })) + widgetcontrol:SetPadding(inkMargin.new(control.padding)) + widgetcontrol:SetRenderTransformPivot(Vector2.new({ X = transformwidth, Y = transformheight })) + widgetcontrol:SetState("default") + + else + + -- widgetcontrol.root:SetName(CName.new(control.tag)) + widgetcontrol.root:SetFitToContent(control.fittocontent) + -- widgetcontrol.root:SetTintColor(textcolor) + widgetcontrol.root:SetSize(Vector2.new({ X = width, Y = height })) + -- widgetcontrol.root:SetScale(Vector2.new({ X = scalewidth, Y = scaleheight })) + -- widgetcontrol.root:SetInteractive(control.interactive) + widgetcontrol.root:SetMargin(inkMargin.new(control.margin)) + widgetcontrol.root:SetAnchor(control.anchor) + -- widgetcontrol.root:SetAnchorPoint(Vector2.new({ X = 0, Y = 0 })) + -- widgetcontrol.root:SetOpacity(control.opacity) + -- widgetcontrol.root:SetRotation(control.rotation) + -- widgetcontrol.root:SetVisible(control.visible) + -- widgetcontrol.root:SetTranslation(Vector2.new({ X = translationwidth, Y = translationheight })) + -- widgetcontrol.root:SetPadding(inkMargin.new(control.padding)) + -- widgetcontrol.root:SetRenderTransformPivot(Vector2.new({ X = transformwidth, Y = transformheight })) + -- widgetcontrol.root:SetState("default") + if(control.type == "scrollarea") then + --widgetcontrol:GetWidgetByIndex(0):SetSize(Vector2.new({ X = width, Y = height })) + end + if(control.type == "shape") then + + for i,v in ipairs(widgetcontrol.vertexList) do + + + + + end + + end + end + + + + obj.ink = widgetcontrol + + + table.insert(currentInterfaceWidget[interface.tag].controls,obj) + + end + end) + + + if status == false then + + logme(1,control.tag) + logme(1,result) + logme(1,dump(control)) + + + end + end + + + + end function openanpage(page) - irpmenu.main = false - irpmenu.contact = false - irpmenu.fixer = false - irpmenu.service = false - irpmenu.social = false - irpmenu.address = false - irpmenu.radio = false - irpmenu.tools = false - irpmenu.multi = false - irpmenu.editor = false - irpmenu[page] = true + irpmenu.main = false + irpmenu.contact = false + irpmenu.fixer = false + irpmenu.service = false + irpmenu.social = false + irpmenu.address = false + irpmenu.radio = false + irpmenu.tools = false + irpmenu.multi = false + irpmenu.editor = false + irpmenu[page] = true end function buildnativesetting() - if(nativeSettings.pathExists("CSKEYBIND/InfoController")) then - --update current controller label - nativeSettings["CSKEYBIND"].subcategories["InfoController"].label = "Current controller configuration : "..currentControllerName - end - - - - - - -- Add our mods tab (path, label) - if(isEmpty(cyberscript.cache["setting"]) == false) then - - local tabledone = {} - - --delete existing then redo - for k,v in pairs(cyberscript.cache["setting"]) do - - local cat = "/CSCUSTOM_"..v.datapack:gsub("%s+", "_") - if nativeSettings[cat] ~= nil then - - nativeSettings[cat] = nil - - end - end - - - for k,v in pairs(cyberscript.cache["setting"]) do - - - local setting = v.data - local cat = "/CSCUSTOM_"..v.datapack:gsub("%s+", "_") - local subcat = cat.."/"..k - - - - if tabledone[v.datapack] == nil then - - nativeSettings.addTab(cat, v.datapack) -- Add our mods tab (path, label) - nativeSettings.addSubcategory(cat.."/InfoController", "This mod is powered by CyberScript.".." Current controller configuration : "..currentControllerName) -- Optional: Add a subcategory (path, label), you can add as many as you want - - - tabledone[v.datapack]={} - - end - if not nativeSettings.pathExists(cat.."/"..k) then - local label = setting.tag - if(setting.label ~= nil ) then - label = getLang(setting.label) - end - - nativeSettings.addSubcategory(subcat, label) -- Optional: Add a subcategory (path, label), you can add as many as you want - - end - - - if setting.type == "button" then - nativeSettings.addButton(subcat, getLang(setting.label), getLang(setting.description),getLang(setting.buttonlabel), setting.textsize, function() - runActionList(setting.action, setting.tag, "interact",false,"nothing",true) - - end) - end - - if setting.type == "toggle" then - - nativeSettings.addSwitch(subcat, getLang(setting.label), getLang(setting.description), getVariableKeyWithDefault(setting.variable.tag,setting.variable.key,setting.defaultvalue), setting.defaultvalue, function(value) - setVariable(setting.variable.tag,setting.variable.key,value) - - runActionList(setting.action, setting.tag, "interact",false,"nothing",true) - - end) - end - - if setting.type == "sliderInt" then - - nativeSettings.addRangeInt(subcat, getLang(setting.label), getLang(setting.description), setting.min, setting.max, setting.step, getScoreKeyWithDefault(setting.variable.tag,setting.variable.key,setting.defaultvalue), setting.defaultvalue, function(value) - - setScore(setting.target.tag,setting.target.key,value) - runActionList(setting.action, setting.tag, "interact",false,"nothing",true) - - end) - - end - - - if setting.type == "sliderFloat" then - nativeSettings.addRangeFloat(subcat, getLang(setting.label), getLang(setting.description), setting.min, setting.max, setting.step,"%.2f", getScoreKeyWithDefault(setting.variable.tag,setting.variable.key,setting.defaultvalue), setting.defaultvalue, function(value) - - setScore(setting.target.tag,setting.target.key,value) - runActionList(setting.action, setting.tag, "interact",false,"nothing",true) - - end) - end - - if setting.type == "sliderText" then - nativeSettings.addSelectorString(subcat, getLang(setting.label), getLang(setting.description), getScoreKeyWithDefault(setting.variable.tag,setting.variable.key,setting.variable.defaultvalue), setting.defaultvalue, function(value) - - setScore(setting.target.tag,setting.target.key,getScoreKeyWithDefault(setting.variable.tag,setting.variable.key,setting.variable.defaultvalue)[value]) - runActionList(setting.action, setting.tag, "interact",false,"nothing",true) - - end) - end - - if setting.type == "input" then - local info = inputManager.createBindingInfo() -- Create an info table that holds information for a binding, makes it easier to reuse later - info.keybindLabel = getLang(setting.label) -- Label of each key, will be followed by the key number, e.g. "Key 1" - info.keybindDescription = getLang(setting.description) -- Description that'll be displayed for all the bindings keys - info.supportsHold = true -- Whether to show the hold switches for this bindings keys - info.isHoldLabel = getLang("setting_hold_key") - info.isHoldDescription = getLang("setting_hold_key_desc") - info.id = setting.tag -- Unique id for the binding, used for the savedOptions/defaultOptions tables and the saveCallback. See above for more details - info.maxKeys = 3 -- Maximum amount of keys for this binding, shows a slider if it is bigger than 1 - info.maxKeysLabel = getLang("setting_max_key") -- Label for the binding's key amount slider - info.maxKeysDescription = getLang("setting_max_key_desc") - info.nativeSettingsPath = subcat -- Native settings path for where to add the bindigs options, if it is a multikey binding it has to be a seperate subcategory - info.defaultOptions = createdefaultOption(setting.tag,setting.maxkeys) -- Table containing the default options - info.repeatable = setting.repeatable or false - if(arrayUserInput[info.id] ~= nil) then - info.savedOptions = {} - info.savedOptions[info.id] = {} - info.savedOptions[info.id] = arrayUserInput[info.id] - info.savedOptions[info.id] = arrayUserInput[info.id]-- Table containing the current options - else - - arrayUserInput[info.id] =info.defaultOptions[info.id] - end - info.forceHold = false - info.saveCallback = function(name, value) -- Callback for when anything about the binding gets changed, gets the changed variable's generated name + the value - -- Store changed value - - saveUserInput(info.id,name,value) - - - - end - info.callback = function() -- Callback for when the binding has been activated - runActionList(setting.action, setting.tag, "interact",false,"nothing",true) - workerTable[setting.targetevent] = nil - if(cyberscript.cache["event"][setting.targetevent] ~= nil) then - local event = cyberscript.cache["event"][setting.targetevent].data - checkContext(event) - - - if(event.way == "input" and checkTriggerRequirement(event.requirement,event.trigger) and workerTable[setting.targetevent] == nil)then - - runActionList(event.action,setting.targetevent,"event",false,"nothing") - - end - - end - end - inputManager.addNativeSettingsBinding(info) - - end - - -- logme(1,"result : "..exportDatapackArray(nativeSettings.data),true) - end - - - end - - - - + -- Guard: if nativeSettings mod isn't loaded yet (or initCore hasn't run), + -- skip gracefully instead of crashing the refresh loop every frame. + if nativeSettings == nil then + return + end + if(nativeSettings.pathExists("CSKEYBIND/InfoController")) then + --update current controller label + nativeSettings["CSKEYBIND"].subcategories["InfoController"].label = "Current controller configuration : "..currentControllerName + end + + + + + + -- Add our mods tab (path, label) + if(isEmpty(cyberscript.cache["setting"]) == false) then + + local tabledone = {} + + --delete existing then redo + for k,v in pairs(cyberscript.cache["setting"]) do + + local cat = "/CSCUSTOM_"..v.datapack:gsub("%s+", "_") + if nativeSettings[cat] ~= nil then + + nativeSettings[cat] = nil + + end + end + + + for k,v in pairs(cyberscript.cache["setting"]) do + + + local setting = v.data + local cat = "/CSCUSTOM_"..v.datapack:gsub("%s+", "_") + local subcat = cat.."/"..k + + + + if tabledone[v.datapack] == nil then + + nativeSettings.addTab(cat, v.datapack) -- Add our mods tab (path, label) + nativeSettings.addSubcategory(cat.."/InfoController", "This mod is powered by CyberScript.".." Current controller configuration : "..currentControllerName) -- Optional: Add a subcategory (path, label), you can add as many as you want + + + tabledone[v.datapack]={} + + end + if not nativeSettings.pathExists(cat.."/"..k) then + local label = setting.tag + if(setting.label ~= nil ) then + label = getLang(setting.label) + end + + nativeSettings.addSubcategory(subcat, label) -- Optional: Add a subcategory (path, label), you can add as many as you want + + end + + + if setting.type == "button" then + nativeSettings.addButton(subcat, getLang(setting.label), getLang(setting.description),getLang(setting.buttonlabel), setting.textsize, function() + runActionList(setting.action, setting.tag, "interact",false,"nothing",true) + + end) + end + + if setting.type == "toggle" then + + nativeSettings.addSwitch(subcat, getLang(setting.label), getLang(setting.description), getVariableKeyWithDefault(setting.variable.tag,setting.variable.key,setting.defaultvalue), setting.defaultvalue, function(value) + setVariable(setting.variable.tag,setting.variable.key,value) + + runActionList(setting.action, setting.tag, "interact",false,"nothing",true) + + end) + end + + if setting.type == "sliderInt" then + + nativeSettings.addRangeInt(subcat, getLang(setting.label), getLang(setting.description), setting.min, setting.max, setting.step, getScoreKeyWithDefault(setting.variable.tag,setting.variable.key,setting.defaultvalue), setting.defaultvalue, function(value) + + setScore(setting.target.tag,setting.target.key,value) + runActionList(setting.action, setting.tag, "interact",false,"nothing",true) + + end) + + end + + + if setting.type == "sliderFloat" then + nativeSettings.addRangeFloat(subcat, getLang(setting.label), getLang(setting.description), setting.min, setting.max, setting.step,"%.2f", getScoreKeyWithDefault(setting.variable.tag,setting.variable.key,setting.defaultvalue), setting.defaultvalue, function(value) + + setScore(setting.target.tag,setting.target.key,value) + runActionList(setting.action, setting.tag, "interact",false,"nothing",true) + + end) + end + + if setting.type == "sliderText" then + nativeSettings.addSelectorString(subcat, getLang(setting.label), getLang(setting.description), getScoreKeyWithDefault(setting.variable.tag,setting.variable.key,setting.variable.defaultvalue), setting.defaultvalue, function(value) + + setScore(setting.target.tag,setting.target.key,getScoreKeyWithDefault(setting.variable.tag,setting.variable.key,setting.variable.defaultvalue)[value]) + runActionList(setting.action, setting.tag, "interact",false,"nothing",true) + + end) + end + + if setting.type == "input" then + local info = inputManager.createBindingInfo() -- Create an info table that holds information for a binding, makes it easier to reuse later + info.keybindLabel = getLang(setting.label) -- Label of each key, will be followed by the key number, e.g. "Key 1" + info.keybindDescription = getLang(setting.description) -- Description that'll be displayed for all the bindings keys + info.supportsHold = true -- Whether to show the hold switches for this bindings keys + info.isHoldLabel = getLang("setting_hold_key") + info.isHoldDescription = getLang("setting_hold_key_desc") + info.id = setting.tag -- Unique id for the binding, used for the savedOptions/defaultOptions tables and the saveCallback. See above for more details + info.maxKeys = 3 -- Maximum amount of keys for this binding, shows a slider if it is bigger than 1 + info.maxKeysLabel = getLang("setting_max_key") -- Label for the binding's key amount slider + info.maxKeysDescription = getLang("setting_max_key_desc") + info.nativeSettingsPath = subcat -- Native settings path for where to add the bindigs options, if it is a multikey binding it has to be a seperate subcategory + info.defaultOptions = createdefaultOption(setting.tag,setting.maxkeys) -- Table containing the default options + info.repeatable = setting.repeatable or false + if(arrayUserInput[info.id] ~= nil) then + info.savedOptions = {} + info.savedOptions[info.id] = {} + info.savedOptions[info.id] = arrayUserInput[info.id] + info.savedOptions[info.id] = arrayUserInput[info.id]-- Table containing the current options + else + + arrayUserInput[info.id] =info.defaultOptions[info.id] + end + info.forceHold = false + info.saveCallback = function(name, value) -- Callback for when anything about the binding gets changed, gets the changed variable's generated name + the value + -- Store changed value + + saveUserInput(info.id,name,value) + + + + end + info.callback = function() -- Callback for when the binding has been activated + runActionList(setting.action, setting.tag, "interact",false,"nothing",true) + workerTable[setting.targetevent] = nil + if(cyberscript.cache["event"][setting.targetevent] ~= nil) then + local event = cyberscript.cache["event"][setting.targetevent].data + checkContext(event) + + + if(event.way == "input" and checkTriggerRequirement(event.requirement,event.trigger) and workerTable[setting.targetevent] == nil)then + + runActionList(event.action,setting.targetevent,"event",false,"nothing") + + end + + end + end + inputManager.addNativeSettingsBinding(info) + + end + + -- logme(1,"result : "..exportDatapackArray(nativeSettings.data),true) + end + + + end + + + + end function makefavoritesetting() - if(nativeSettings.pathExists("CSKEYBIND/favorite")) then - nativeSettings["CSKEYBIND"].subcategories["favorite"] = nil - end - - arrayDatapackIndex = {} - myarrayDatapackIndex = 1 - - for k,v in pairs(arrayDatapack) do - table.insert(arrayDatapackIndex,k) - - - end - - for i,k in ipairs(arrayDatapackIndex) do - - if(k == favoriteInteractGroup) then - myarrayDatapackIndex = i - end - - - end - nativeSettings.addSubcategory("/CSKEYBIND/favorite", getLang("setting_fav_menu_cat")) - nativeSettings.addSelectorString("/CSKEYBIND/favorite", getLang("setting_fav_menu_cat"), "Description", arrayDatapackIndex, myarrayDatapackIndex, 1, function(value) - myarrayDatapackIndex = value - print(value) - print(arrayDatapackIndex[value]) - favoriteInteractGroup = arrayDatapackIndex[value] - updateUserSetting("favoriteInteractGroup", arrayDatapackIndex[value]) - -- Add any logic you need in here, such as saving the changes to file / database - end) - - local info = inputManager.createBindingInfo() -- Create an info table that holds information for a binding, makes it easier to reuse later - info.keybindLabel = getLang("setting_fav_menu_cat") -- Label of each key, will be followed by the key number, e.g. "Key 1" - info.keybindDescription = getLang("setting_fav_menu_cat") -- Description that'll be displayed for all the bindings keys - info.supportsHold = true -- Whether to show the hold switches for this bindings keys - info.isHoldLabel = getLang("setting_hold_key") - info.isHoldDescription = getLang("setting_hold_key_desc") - info.id ="cyberscriptOpenFavorite"-- Unique id for the binding, used for the savedOptions/defaultOptions tables and the saveCallback. See above for more details - info.maxKeys = 3 -- Maximum amount of keys for this binding, shows a slider if it is bigger than 1 - info.maxKeysLabel = getLang("setting_max_key") -- Label for the binding's key amount slider - info.maxKeysDescription = getLang("setting_max_key_desc") - info.nativeSettingsPath = "/CSKEYBIND/favorite" -- Native settings path for where to add the bindigs options, if it is a multikey binding it has to be a seperate subcategory - info.repeatable = false - -- Table containing the default options - local defaultinput = {} - defaultinput["cyberscriptOpenFavorite"] = {} - defaultinput["cyberscriptOpenFavorite"]["keyboard"] = {} - defaultinput["cyberscriptOpenFavorite"]["gamepad"] = {} - for i=1,3 do - - defaultinput["cyberscriptOpenFavorite"]["keyboard"]["key_"..i] = "IK_PageUp" - defaultinput["cyberscriptOpenFavorite"]["keyboard"]["hold_"..i] = false - defaultinput["cyberscriptOpenFavorite"]["gamepad"]["key_"..i] = "IK_PageUp" - defaultinput["cyberscriptOpenFavorite"]["gamepad"]["hold_"..i] = false - - end - - defaultinput["cyberscriptOpenFavorite"]["keyboard"]["keys"] = 1 - defaultinput["cyberscriptOpenFavorite"]["gamepad"]["keys"] = 1 - - info.defaultOptions = defaultinput - - if(arrayUserInput[info.id] ~= nil) then - info.savedOptions = {} - info.savedOptions[info.id] = {} - info.savedOptions[info.id] = arrayUserInput[info.id]-- Table containing the current options - else - arrayUserInput[info.id] =info.defaultOptions[info.id] - end - info.forceHold = false - info.saveCallback = function(name, value) -- Callback for when anything about the binding gets changed, gets the changed variable's generated name + the value - -- Store changed value - - saveUserInput(info.id,name,value) - - - end - info.callback = function() -- Callback for when the binding has been activated - cycleInteractFavorite() - end - inputManager.addNativeSettingsBinding(info) + -- B-25 fix: skip if arrayDatapack is empty (first load, before + -- ImportDataPack/LoadDataPackCache populate it). The dropdown will + -- be built by the second call from LoadDataPackCache once data is + -- available. Without this guard, the first call builds an empty + -- dropdown and selecting an item sets favoriteInteractGroup to nil. + local hasDatapacks = false + if arrayDatapack then + for _ in pairs(arrayDatapack) do + hasDatapacks = true + break + end + end + if not hasDatapacks then + return + end + if(nativeSettings.pathExists("CSKEYBIND/favorite")) then + nativeSettings["CSKEYBIND"].subcategories["favorite"] = nil + end + + arrayDatapackIndex = {} + myarrayDatapackIndex = 1 + + for k,v in pairs(arrayDatapack) do + table.insert(arrayDatapackIndex,k) + + + end + + for i,k in ipairs(arrayDatapackIndex) do + + if(k == favoriteInteractGroup) then + myarrayDatapackIndex = i + end + + + end + nativeSettings.addSubcategory("/CSKEYBIND/favorite", getLang("setting_fav_menu_cat")) + nativeSettings.addSelectorString("/CSKEYBIND/favorite", getLang("setting_fav_menu_cat"), "Description", arrayDatapackIndex, myarrayDatapackIndex, 1, function(value) + myarrayDatapackIndex = value + print(value) + print(arrayDatapackIndex[value]) + favoriteInteractGroup = arrayDatapackIndex[value] + updateUserSetting("favoriteInteractGroup", arrayDatapackIndex[value]) + -- Add any logic you need in here, such as saving the changes to file / database + end) + + local info = inputManager.createBindingInfo() -- Create an info table that holds information for a binding, makes it easier to reuse later + info.keybindLabel = getLang("setting_fav_menu_cat") -- Label of each key, will be followed by the key number, e.g. "Key 1" + info.keybindDescription = getLang("setting_fav_menu_cat") -- Description that'll be displayed for all the bindings keys + info.supportsHold = true -- Whether to show the hold switches for this bindings keys + info.isHoldLabel = getLang("setting_hold_key") + info.isHoldDescription = getLang("setting_hold_key_desc") + info.id ="cyberscriptOpenFavorite"-- Unique id for the binding, used for the savedOptions/defaultOptions tables and the saveCallback. See above for more details + info.maxKeys = 3 -- Maximum amount of keys for this binding, shows a slider if it is bigger than 1 + info.maxKeysLabel = getLang("setting_max_key") -- Label for the binding's key amount slider + info.maxKeysDescription = getLang("setting_max_key_desc") + info.nativeSettingsPath = "/CSKEYBIND/favorite" -- Native settings path for where to add the bindigs options, if it is a multikey binding it has to be a seperate subcategory + info.repeatable = false + -- Table containing the default options + local defaultinput = {} + defaultinput["cyberscriptOpenFavorite"] = {} + defaultinput["cyberscriptOpenFavorite"]["keyboard"] = {} + defaultinput["cyberscriptOpenFavorite"]["gamepad"] = {} + for i=1,3 do + + defaultinput["cyberscriptOpenFavorite"]["keyboard"]["key_"..i] = "IK_PageUp" + defaultinput["cyberscriptOpenFavorite"]["keyboard"]["hold_"..i] = false + defaultinput["cyberscriptOpenFavorite"]["gamepad"]["key_"..i] = "IK_PageUp" + defaultinput["cyberscriptOpenFavorite"]["gamepad"]["hold_"..i] = false + + end + + defaultinput["cyberscriptOpenFavorite"]["keyboard"]["keys"] = 1 + defaultinput["cyberscriptOpenFavorite"]["gamepad"]["keys"] = 1 + + info.defaultOptions = defaultinput + + if(arrayUserInput[info.id] ~= nil) then + info.savedOptions = {} + info.savedOptions[info.id] = {} + info.savedOptions[info.id] = arrayUserInput[info.id]-- Table containing the current options + else + arrayUserInput[info.id] =info.defaultOptions[info.id] + end + info.forceHold = false + info.saveCallback = function(name, value) -- Callback for when anything about the binding gets changed, gets the changed variable's generated name + the value + -- Store changed value + + saveUserInput(info.id,name,value) + + + end + info.callback = function() -- Callback for when the binding has been activated + cycleInteractFavorite() + end + inputManager.addNativeSettingsBinding(info) end function saveUserInput(id,name,value) - - arrayUserInput[id][currentControllerid][name] = value + + arrayUserInput[id][currentControllerid][name] = value end function getcurrentpage() - - local page = "main" - for k,v in pairs(irpmenu) do - - if v then - page = k - end - end - return page + + local page = "main" + for k,v in pairs(irpmenu) do + + if v then + page = k + end + end + return page end function loadUIsetting() - - local scr_w, scr_h = GetDisplayResolution() - locationWindowsX = locationWindowsX or getUserSetting("locationWindowsX") - locationWindowsY = locationWindowsY or getUserSetting("locationWindowsY") - - if locationWindowsX > scr_w or locationWindowsY > scr_h then - locationWindowsX = 35 - locationWindowsY = 355 - end + + local scr_w, scr_h = GetDisplayResolution() + locationWindowsX = locationWindowsX or getUserSetting("locationWindowsX") + locationWindowsY = locationWindowsY or getUserSetting("locationWindowsY") + + if locationWindowsX > scr_w or locationWindowsY > scr_h then + locationWindowsX = 35 + locationWindowsY = 355 + end end function makeNativeSettings() - - nativeSettings.addTab("/CM", getLang("ui_setting_main")) -- Add our mods tab (path, label) - if (ScriptedEntityAffinity == nil or - AutoAmbush == nil or - AmbushEnabled== nil or - AmbushMin== nil or - - - Player_Sprint_Multiplier==nil or - Player_Run_Multiplier==nil or - Jump_Height==nil or - Double_Jump_Height==nil - ) then - local obj = {} - - obj.AutoAmbush = tostring(AutoAmbush) - obj.AmbushEnabled = tostring(AutoAmbush) - obj.ScriptedEntityAffinity = tostring(ScriptedEntityAffinity) - - obj.Player_Sprint_Multiplier = tostring(Player_Sprint_Multiplier) - obj.Player_Run_Multiplier = tostring(Player_Run_Multiplier) - obj.Jump_Height = tostring(Jump_Height) - obj.Double_Jump_Height = tostring(Double_Jump_Height) - - - - - - else - local status, result = pcall(function() - - nativeSettings.addSubcategory("/CM/general", getLang("General")) -- Optional: Add a subcategory (path, label), you can add as many as you want - - - nativeSettings.addSwitch("/CM/general", getLang("Disable CyberScript"), getLang("Disable CyberScript"), moddisabled, false, function(state) -- path, label, desc, currentValue, defaultValue, callback - moddisabled = state - updateUserSetting ("moddisabled", moddisabled) - end) - - - - - - - - - nativeSettings.addSubcategory("/CM/script", "Script Settings") - - - nativeSettings.addRangeInt("/CM/script", getLang("SetAmbushMinTime"), getLang("SetAmbushMinTime"), 1, 120, 1, AmbushMin, 5, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback - AmbushMin = value - updateUserSetting("AmbushMin", value) - end) - - - nativeSettings.addRangeInt("/CM/script", getLang("Point of Interest Detection Range"), getLang("Automatic Point of Interest Detection Range"), 1, 100, 1, CurrentPOIDetectionRange, 10, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback - CurrentPOIDetectionRange = value - updateUserSetting("CurrentPOIDetectionRange", value) - end) - - - - nativeSettings.addSwitch("/CM/script", getLang("Enable Logging"), getLang("Enable Logging (can impact performance)"), debugLog, false, function(state) -- path, label, desc, currentValue, defaultValue, callback - debugLog = state - updateUserSetting("debugLog", state) - end) - - - - - nativeSettings.addSubcategory("/CM/hud",getLang("ui_setting_display")) - - - - - - - - - nativeSettings.addSwitch("/CM/hud", getLang("Show Cyberscript Fixer on Map"), getLang("Show Cyberscript Fixer on Map"), showcyberscriptfixeronmap, true, function(state) -- path, label, desc, currentValue, defaultValue, callback - showcyberscriptfixeronmap = state - updateUserSetting("showcyberscriptfixeronmap", state) - if(state) then - setNewFixersPoint() - else - removeFixersPoint() - end - end) - - - - - nativeSettings.addSubcategory("/CM/quests",getLang("Quest setting")) - - - - nativeSettings.addSwitch("/CM/quests", getLang("Enable Custom Quest"), getLang("Enable Custom Quest"), enableCustomQuest, true, function(state) -- path, label, desc, currentValue, defaultValue, callback - enableCustomQuest = state - updateUserSetting("enableCustomQuest", enableCustomQuest) - end) - - nativeSettings.addButton("/CM/quests", getLang("ui_setting_actions_resetquest"), getLang("ui_setting_actions_resetquest"), "Reset CS Quest", 45, function() - if currentQuest then - resetQuest() - end - - end) - - - - - - - - nativeSettings.addSubcategory("/CM/affinity",getLang("Affinity setting")) - - nativeSettings.addButton("/CM/affinity", getLang("ui_setting_actions_recalculateaffinity"), getLang("ui_setting_actions_recalculateaffinity_msg"),"Recalculate", 45, function() - - - for k,v in pairs(cyberscript.cache["faction"]) do - setScore(k, "Score", 0) - end - - - for k,v in pairs(cyberscript.entitieshash) do - - setScore(v.entity_name, "Score", 0) - - - end - - - GangAffinityCalculator() - initGangRelation() - initGangDistrictScore() - - end) - - nativeSettings.addButton("/CM/affinity", getLang("ui_setting_actions_cleareaffinity"), getLang("ui_setting_actions_recalculateaffinity_msg"),"Clear", 45, function() - for k,v in pairs(cyberscript.cache["faction"]) do - setScore("Affinity",k, 0) - end - for k,v in pairs(cyberscript.entitieshash) do - - setScore(v.entity_name, "Score", 0) - - - end - - - end) - - - nativeSettings.addSubcategory("/CM/modsetting",getLang("Mod setting")) - - - - nativeSettings.addSwitch("/CM/modsetting", getLang("Auto Refresh Mods When Pause Menu"), getLang("Auto Refresh Mods When Pause Menu"), AutoRefreshDatapack, false, function(state) -- path, label, desc, currentValue, defaultValue, callback - AutoRefreshDatapack = state - updateUserSetting("AutoRefreshDatapack", AutoRefreshDatapack) - end) - - nativeSettings.addButton("/CM/modsetting", getLang("ui_setting_actions_refresh"), getLang("ui_setting_actions_refresh"), "Refresh", 45, function() - - LoadDataPackCache() - logme(2,"CyberScript : Datapack Cache refreshed") - - end) - - nativeSettings.addButton("/CM/modsetting", getLang("ui_setting_actions_cleanthemess"), getLang("ui_setting_actions_cleanthemess"), "Clean the mess", 45, function() - - despawnAll() - workerTable = {} - - end) - - nativeSettings.addButton("/CM/modsetting", "Reload Cyberscript mods", "Reload Cyberscript mods", "Reload Cyberscript mods", 45, function() - - ImportDataPack() - LoadDataPackCache() - logme(2,"CyberScript : Datapack Cache reload") - - end) - - - - nativeSettings.addButton("/CM/modsetting", "!!! Reset the mod !!! ", "WARNING : Will totaly delete downloaded Mods, cache and session", "Reset the mod", 45, function() - - if file_exists("user/sessions/latest.txt") then - os.remove("user/sessions/latest.txt") - end - - - local reader = dir("user/sessions") - - - for i=1, #reader do - if(tostring(reader[i].type) ~= "directory" and reader[i].name ~= "placeholder") then - - os.remove('user/sessions/'..reader[i].name) - - - - - end - end - - local reader = dir("user/settings") - - - for i=1, #reader do - if(tostring(reader[i].type) ~= "directory" and reader[i].name ~= "placeholder") then - - os.remove('user/settings/'..reader[i].name) - - - - - end - end - - - - - - local reader = dir("user/editor_output") - for i=1, #reader do - if(tostring(reader[i].type) ~= "directory" and reader[i].name ~= "placeholder") then - - os.remove('user/editor_output/'..reader[i].name) - - - - - end - end - - - ImportDataPack() - LoadDataPackCache() - logme(2, getLang("ui_setting_actions_rebuild_done")) - - end) - - - - nativeSettings.addTab("/CMCHEAT", getLang("ui_setting_cheat")) -- Add our mods tab (path, label) - - nativeSettings.addSubcategory("/CMCHEAT/player", getLang("ui_setting_cheat")) -- Optional: Add a subcategory (path, label), you can add as many as you want - - - - - - - nativeSettings.addSwitch("/CMCHEAT/player", getLang("Immortal"), getLang("Immortal"), Immortal, false, function(state) -- path, label, desc, currentValue, defaultValue, callback - Immortal = state - updateUserSetting("Immortal", Immortal) - - if (Immortal) then - - Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Invulnerable", CName.new("SecondHeart")) - if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then - local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - if veh then - Game.GetGodModeSystem():AddGodMode(veh:GetEntityID(), "Invulnerable", CName.new("Default")) - end - end - else - local hasSecondHeart = false - local ssc = Game.GetScriptableSystemsContainer() - local es = ssc:Get(CName.new('EquipmentSystem')) - local espd = es:GetPlayerData(Game.GetPlayer()) - espd['GetItemInEquipSlot2'] = espd['GetItemInEquipSlot;gamedataEquipmentAreaInt32'] - for i=0,2 do - if espd:GetItemInEquipSlot2("CardiovascularSystemCW", i).tdbid.hash == 3619482064 then - hasSecondHeart = true - end - end - if hasSecondHeart then - Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Immortal", CName.new("SecondHeart")) - else - Game.GetGodModeSystem():DisableOverride(Game.GetPlayer():GetEntityID(), CName.new("SecondHeart")) - end - if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then - local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) - if veh then - Game.GetGodModeSystem():ClearGodMode(veh:GetEntityID(), CName.new("Default")) - end - end - - end - - end) - -- Parameters: path, label, desc, currentValue, defaultValue, callback, optionalIndex - nativeSettings.addSwitch("/CMCHEAT/player", getLang("Infinite Stamina"), getLang("Infinite Stamina"), InfiniteStaminas, false, function(state) -- path, label, desc, currentValue, defaultValue, callback - InfiniteStaminas = state - updateUserSetting("InfiniteStaminas", InfiniteStaminas) - - InfiniteStamina(InfiniteStaminas) - end) - - - - - - - - - - nativeSettings.addSubcategory("/CMCHEAT/reload",getLang("Theses cheats need that you save after enable them then reload")) - - nativeSettings.addRangeFloat("/CMCHEAT/reload", getLang("ui_setting_cheat_player_sprint"), getLang("ui_setting_cheat_player_sprint"), 1, 10, 0.1, "%.1f", Player_Sprint_Multiplier, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback - pcall(function() - Player_Sprint_Multiplier = tonumber(string.format("%.1f", value)) - updateUserSetting("Player_Sprint_Multiplier", Player_Sprint_Multiplier) - TweakDB:SetFlat("PlayerLocomotion.player_locomotion_data_Sprint_inline1.value", 6.5 * Player_Sprint_Multiplier) - TweakDB:Update("PlayerLocomotion.player_locomotion_data_Sprint_inline1.value") - - -- local newMod = gameConstantStatModifierData.new() - -- newMod.statType = 619 - -- newMod.modifierType = 2 - -- newMod.value = Player_Sprint_Multiplier - - -- Game.GetStatsSystem():AddModifier(Game.GetPlayer():GetEntityID(),newmod) - - end) - end) - - nativeSettings.addRangeFloat("/CMCHEAT/reload", getLang("ui_setting_cheat_player_run"), getLang("ui_setting_cheat_player_run"), 1, 10, 0.1, "%.1f", Player_Run_Multiplier, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback - pcall(function() - Player_Run_Multiplier = tonumber(string.format("%.1f", value)) - updateUserSetting("Player_Run_Multiplier", Player_Run_Multiplier) - TweakDB:SetFlat("PlayerLocomotion.player_locomotion_data_Stand_inline1.value", 3.5 * Player_Run_Multiplier) - TweakDB:Update("PlayerLocomotion.player_locomotion_data_Stand_inline1.value") - - -- local newMod = gameConstantStatModifierData.new() - -- newMod.statType = 619 - -- newMod.modifierType = 2 - -- newMod.value = Player_Run_Multiplier - - -- Game.GetStatsSystem():AddModifier(Game.GetPlayer():GetEntityID(),newmod) - end) - end) - - - nativeSettings.addRangeFloat("/CMCHEAT/reload", getLang("ui_setting_cheat_jump_height"), getLang("ui_setting_cheat_jump_height"), 1, 10, 0.1, "%.1f", Jump_Height, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback - pcall(function() - Jump_Height = tonumber(string.format("%.1f", value)) - updateUserSetting("Jump_Height", Jump_Height) - TweakDB:SetFlat("PlayerLocomotion.JumpJumpHeightModifier.value", 1 * Jump_Height) - TweakDB:Update("PlayerLocomotion.JumpJumpHeightModifier.value") - - -- local newMod = gameConstantStatModifierData.new() - -- newMod.statType = 596 - -- newMod.modifierType = 2 - -- newMod.value = Jump_Height - - -- Game.GetStatsSystem():AddModifier(Game.GetPlayer():GetEntityID(),newmod) - - end) - end) - - nativeSettings.addRangeFloat("/CMCHEAT/reload", getLang("ui_setting_cheat_doublejump_height"), getLang("ui_setting_cheat_doublejump_height"), 1, 10, 0.1, "%.1f", Double_Jump_Height, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback - pcall(function() - Double_Jump_Height = tonumber(string.format("%.1f", value)) - updateUserSetting("Double_Jump_Height", Double_Jump_Height) - TweakDB:SetFlat("PlayerLocomotion.DoubleJumpJumpHeightModifier.value", 2.6 * Double_Jump_Height) - TweakDB:Update("PlayerLocomotion.DoubleJumpJumpHeightModifier.value") - - -- local newMod = gameConstantStatModifierData.new() - -- newMod.statType = 596 - -- newMod.modifierType = 2 - -- newMod.value = Jump_Height - - -- Game.GetStatsSystem():AddModifier(Game.GetPlayer():GetEntityID(),newmod) - end) - end) - - - - - nativeSettings.addSwitch("/CMCHEAT/reload", getLang("ui_setting_cheat_player_ram"), getLang("ui_setting_cheat_player_ram"), RamUpgrade, false, function(state) -- path, label, desc, currentValue, defaultValue, callback - RamUpgrade = state - updateUserSetting("RamUpgrade", RamUpgrade) - - TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline1.value", 1000) - TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline4.value", 25) - - TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline2.floatValues", {1000}) - TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline5.floatValues", {25}) - - end) - - nativeSettings.addSwitch("/CMCHEAT/reload", getLang("Overpowered Optical Camo"), getLang("ui_setting_cheat_player_ram"), RamUpgrade, false, function(state) -- path, label, desc, currentValue, defaultValue, callback - OpticalCamo = state - updateUserSetting("OpticalCamo", OpticalCamo) - - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffLegendary_inline1.value", 9999) - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffEpic_inline1.value", 9999) - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffRare_inline1.value", 9999) - - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoLegendaryCooldown_inline1.value", 1) - TweakDB:SetFlat("BaseStatusEffect.OpticalCamoCooldown_inline1.value",1) - - TweakDB:SetFlat("Items.OpticalCamoLegendary_inline2.intValues", 1) - TweakDB:SetFlat("Items.OpticalCamoEpic_inline2.intValues", 9999) - TweakDB:SetFlat("Items.OpticalCamoRare_inline2.intValues", 9999) - - end) - - - - - - nativeSettings.addTab("/CSKEYBIND", getLang("Cyberscript KeyBinding")) -- Add our mods tab (path, label) - - nativeSettings.addSubcategory("/CSKEYBIND/InfoController","Current controller configuration : "..currentControllerName) -- Optional: Add a subcategory (path, label), you can add as many as you want - nativeSettings.addSubcategory("/CSKEYBIND/InfoKeybind", "Every Keybinding change need a reload") -- Optional: Add a subcategory (path, label), you can add as many as you want - nativeSettings.addSubcategory("/CSKEYBIND/keybindConfig", getLang("Keybind Configuration")) - - nativeSettings.addSwitch("/CSKEYBIND/keybindConfig", getLang("ui_setting_gameplay_controller"), getLang("ui_setting_gameplay_controller"), currentController, false, function(state) -- path, label, desc, currentValue, defaultValue, callback - currentController = state - updateUserSetting("currentController", state) - - currentControllerName = "Keyboard" - currentControllerid = "keyboard" - - if(currentController == true)then - currentControllerName = "Gamepad" - currentControllerid = "gamepad" - end - - - - - end) - - nativeSettings.addSubcategory("/CSKEYBIND/gameplay", getLang("setting_open_menu_cat")) - - local info = inputManager.createBindingInfo() -- Create an info table that holds information for a binding, makes it easier to reuse later - info.keybindLabel = getLang("setting_open_menu") -- Label of each key, will be followed by the key number, e.g. "Key 1" - info.keybindDescription = getLang("setting_open_menu_desc") -- Description that'll be displayed for all the bindings keys - info.supportsHold = true -- Whether to show the hold switches for this bindings keys - info.isHoldLabel = getLang("setting_hold_key") - info.isHoldDescription = getLang("setting_hold_key_desc") - info.id ="cyberscriptOpenGroup"-- Unique id for the binding, used for the savedOptions/defaultOptions tables and the saveCallback. See above for more details - info.maxKeys = 3 -- Maximum amount of keys for this binding, shows a slider if it is bigger than 1 - info.maxKeysLabel = getLang("setting_max_key") -- Label for the binding's key amount slider - info.maxKeysDescription = getLang("setting_max_key_desc") - info.repeatable = false - info.nativeSettingsPath = "/CSKEYBIND/gameplay" -- Native settings path for where to add the bindigs options, if it is a multikey binding it has to be a seperate subcategory - -- Table containing the default options - local defaultinput = {} - defaultinput["cyberscriptOpenGroup"] = {} - defaultinput["cyberscriptOpenGroup"]["keyboard"] = {} - defaultinput["cyberscriptOpenGroup"]["gamepad"] = {} - for i=1,3 do - - defaultinput["cyberscriptOpenGroup"]["keyboard"]["key_"..i] = "IK_PageDown" - defaultinput["cyberscriptOpenGroup"]["keyboard"]["hold_"..i] = false - defaultinput["cyberscriptOpenGroup"]["gamepad"]["key_"..i] = "IK_PageDown" - defaultinput["cyberscriptOpenGroup"]["gamepad"]["hold_"..i] = false - - end - - defaultinput["cyberscriptOpenGroup"]["keyboard"]["keys"] = 1 - defaultinput["cyberscriptOpenGroup"]["gamepad"]["keys"] = 1 - - info.defaultOptions = defaultinput - - if(arrayUserInput[info.id] ~= nil) then - info.savedOptions = {} - info.savedOptions[info.id] = {} - info.savedOptions[info.id] = arrayUserInput[info.id]-- Table containing the current options - else - arrayUserInput[info.id] =info.defaultOptions[info.id] - end - info.forceHold = false - info.saveCallback = function(name, value) -- Callback for when anything about the binding gets changed, gets the changed variable's generated name + the value - -- Store changed value - - saveUserInput(info.id,name,value) - - - end - info.callback = function() -- Callback for when the binding has been activated - cycleInteract2() - end - inputManager.addNativeSettingsBinding(info) - - - - - nativeSettings.addSubcategory("/CSKEYBIND/holdTime", "Keybinding behavior") - nativeSettings.addRangeFloat("/CSKEYBIND/holdTime", "Keybinding Hold Time", "How long in second you need to hold the combo/key", 0.5, 100, 0.10, "%.2f", holdTime, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback - holdTime = value - updateUserSetting("holdTime", value) - end) - - - - - - end) - - if status == false then - - - - nativeSettings.addSubcategory("/CM/gameplay00", "sssOoops there is an error in CyberScript Setting !") - nativeSettings.addSubcategory("/CM/gameplay01", "Try rebuild the cache and reload the mod/save/game !") - nativeSettings.addSubcategory("/CM/gameplay02", "Send quest_mod.log to discord Admin on Cyberscript Discord !") - - - - - - nativeSettings.addButton("/CM/gameplay02", "!!! Reset the mod !!! ", "WARNING : Will totaly delete downloaded datapack, cache and session", "Reset the mod", 45, function() - - if file_exists("user/sessions/latest.txt") then - os.remove("user/sessions/latest.txt") - end - - - local reader = dir("sessions") - - - for i=1, #reader do - if(tostring(reader[i].type) ~= "directory" and reader[i].name ~= "placeholder") then - - os.remove('user/sessions/'..reader[i].name) - - - - - end - end - - - - - - ImportDataPack() - LoadDataPackCache() - logme(2, getLang("ui_setting_actions_rebuild_done")) - - end) - end - - - end + + -- Diagnostic: force-log so we can verify makeNativeSettings actually ran. + -- This uses force=true so it appears in cyberscript.log even with debugLog off. + logme(1, "[Cyberscript Init] makeNativeSettings() called — building settings tabs", true) + + nativeSettings.addTab("/CM", getLang("ui_setting_main")) -- Add our mods tab (path, label) + if (ScriptedEntityAffinity == nil or + AutoAmbush == nil or + AmbushEnabled== nil or + AmbushMin== nil or + + + Player_Sprint_Multiplier==nil or + Player_Run_Multiplier==nil or + Jump_Height==nil or + Double_Jump_Height==nil + ) then + local obj = {} + + obj.AutoAmbush = tostring(AutoAmbush) + obj.AmbushEnabled = tostring(AutoAmbush) + obj.ScriptedEntityAffinity = tostring(ScriptedEntityAffinity) + + obj.Player_Sprint_Multiplier = tostring(Player_Sprint_Multiplier) + obj.Player_Run_Multiplier = tostring(Player_Run_Multiplier) + obj.Jump_Height = tostring(Jump_Height) + obj.Double_Jump_Height = tostring(Double_Jump_Height) + + + + + + else + local status, result = pcall(function() + + nativeSettings.addSubcategory("/CM/general", getLang("General")) -- Optional: Add a subcategory (path, label), you can add as many as you want + + + nativeSettings.addSwitch("/CM/general", getLang("Disable CyberScript"), getLang("Disable CyberScript"), moddisabled, false, function(state) -- path, label, desc, currentValue, defaultValue, callback + moddisabled = state + updateUserSetting ("moddisabled", moddisabled) + end) + + + + + + + + + nativeSettings.addSubcategory("/CM/script", "Script Settings") + + + nativeSettings.addRangeInt("/CM/script", getLang("SetAmbushMinTime"), getLang("SetAmbushMinTime"), 1, 120, 1, AmbushMin, 5, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback + AmbushMin = value + updateUserSetting("AmbushMin", value) + end) + + + nativeSettings.addRangeInt("/CM/script", getLang("Point of Interest Detection Range"), getLang("Automatic Point of Interest Detection Range"), 1, 100, 1, CurrentPOIDetectionRange, 10, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback + CurrentPOIDetectionRange = value + updateUserSetting("CurrentPOIDetectionRange", value) + end) + + + + nativeSettings.addSwitch("/CM/script", getLang("Enable Logging"), getLang("Enable Logging (can impact performance)"), debugLog, false, function(state) -- path, label, desc, currentValue, defaultValue, callback + debugLog = state + updateUserSetting("debugLog", state) + end) + + -- B-23 fix: separate debug toggle for entity/group lookup diagnostics. + -- Mod authors: enable this to see every nil/skipped entity reference in cyberscript.log. + -- Off by default to keep the log clean for end users. + nativeSettings.addSwitch("/CM/script", "Debug Entity Lookups", "Log every nil/skipped entity reference (for mod authors debugging missing entities). Can impact performance.", debugEntityLookups, false, function(state) + debugEntityLookups = state + updateUserSetting("debugEntityLookups", state) + end) + + + + + nativeSettings.addSubcategory("/CM/hud",getLang("ui_setting_display")) + + + + + + + + + nativeSettings.addSwitch("/CM/hud", getLang("Show Cyberscript Fixer on Map"), getLang("Show Cyberscript Fixer on Map"), showcyberscriptfixeronmap, true, function(state) -- path, label, desc, currentValue, defaultValue, callback + showcyberscriptfixeronmap = state + updateUserSetting("showcyberscriptfixeronmap", state) + if(state) then + setNewFixersPoint() + else + removeFixersPoint() + end + end) + + -- B-26 fix: separate toggle for spawning fixer NPCs on the street. + -- The "on Map" toggle above only controls map markers; this one + -- controls whether the actual NPC traders spawn in the world. + -- Default: true (preserves existing behavior). + nativeSettings.addSwitch("/CM/hud", "Show Cyberscript Fixer on Street", "Spawn the Cyberscript fixer NPCs (traders) in the world. Turn off to remove them from the streets (map markers are controlled separately).", showcyberscriptfixeronstreet, true, function(state) + showcyberscriptfixeronstreet = state + updateUserSetting("showcyberscriptfixeronstreet", state) + -- If turned off, despawn any currently-spawned fixers so the + -- change takes effect immediately without requiring a reload. + if not state then + pcall(function() + if cyberscript and cyberscript.cache and cyberscript.cache["fixer"] then + for k, v in pairs(cyberscript.cache["fixer"]) do + local fixer = v.data + if fixer and fixer.tag and cyberscript.EntityManager[fixer.tag] ~= nil then + despawnEntity(fixer.tag) + logme(2, "Cyberscript : Despawned fixer (street toggle off): " .. fixer.tag) + end + end + end + end) + end + end) + + + + + nativeSettings.addSubcategory("/CM/quests",getLang("Quest setting")) + + + + nativeSettings.addSwitch("/CM/quests", getLang("Enable Custom Quest"), getLang("Enable Custom Quest"), enableCustomQuest, true, function(state) -- path, label, desc, currentValue, defaultValue, callback + enableCustomQuest = state + updateUserSetting("enableCustomQuest", enableCustomQuest) + end) + + nativeSettings.addButton("/CM/quests", getLang("ui_setting_actions_resetquest"), getLang("ui_setting_actions_resetquest"), "Reset CS Quest", 45, function() + if currentQuest then + resetQuest() + end + + end) + + + + + + + + nativeSettings.addSubcategory("/CM/affinity",getLang("Affinity setting")) + + nativeSettings.addButton("/CM/affinity", getLang("ui_setting_actions_recalculateaffinity"), getLang("ui_setting_actions_recalculateaffinity_msg"),"Recalculate", 45, function() + + + for k,v in pairs(cyberscript.cache["faction"]) do + setScore(k, "Score", 0) + end + + + for k,v in pairs(cyberscript.entitieshash) do + + setScore(v.entity_name, "Score", 0) + + + end + + + GangAffinityCalculator() + initGangRelation() + initGangDistrictScore() + + end) + + nativeSettings.addButton("/CM/affinity", getLang("ui_setting_actions_cleareaffinity"), getLang("ui_setting_actions_recalculateaffinity_msg"),"Clear", 45, function() + for k,v in pairs(cyberscript.cache["faction"]) do + setScore("Affinity",k, 0) + end + for k,v in pairs(cyberscript.entitieshash) do + + setScore(v.entity_name, "Score", 0) + + + end + + + end) + + + nativeSettings.addSubcategory("/CM/modsetting",getLang("Mod setting")) + + + + nativeSettings.addSwitch("/CM/modsetting", getLang("Auto Refresh Mods When Pause Menu"), getLang("Auto Refresh Mods When Pause Menu"), AutoRefreshDatapack, false, function(state) -- path, label, desc, currentValue, defaultValue, callback + AutoRefreshDatapack = state + updateUserSetting("AutoRefreshDatapack", AutoRefreshDatapack) + end) + + nativeSettings.addButton("/CM/modsetting", getLang("ui_setting_actions_refresh"), getLang("ui_setting_actions_refresh"), "Refresh", 45, function() + + LoadDataPackCache() + logme(2,"CyberScript : Datapack Cache refreshed") + + end) + + nativeSettings.addButton("/CM/modsetting", getLang("ui_setting_actions_cleanthemess"), getLang("ui_setting_actions_cleanthemess"), "Clean the mess", 45, function() + + despawnAll() + workerTable = {} + + end) + + nativeSettings.addButton("/CM/modsetting", "Reload Cyberscript mods", "Reload Cyberscript mods", "Reload Cyberscript mods", 45, function() + + ImportDataPack() + LoadDataPackCache() + logme(2,"CyberScript : Datapack Cache reload") + + end) + + + + nativeSettings.addButton("/CM/modsetting", "!!! Reset the mod !!! ", "WARNING : Will totaly delete downloaded Mods, cache and session", "Reset the mod", 45, function() + + if file_exists("user/sessions/latest.txt") then + os.remove("user/sessions/latest.txt") + end + + + local reader = dir("user/sessions") + + + for i=1, #reader do + if(tostring(reader[i].type) ~= "directory" and reader[i].name ~= "placeholder") then + + os.remove('user/sessions/'..reader[i].name) + + + + + end + end + + local reader = dir("user/settings") + + + for i=1, #reader do + if(tostring(reader[i].type) ~= "directory" and reader[i].name ~= "placeholder") then + + os.remove('user/settings/'..reader[i].name) + + + + + end + end + + + + + + local reader = dir("user/editor_output") + for i=1, #reader do + if(tostring(reader[i].type) ~= "directory" and reader[i].name ~= "placeholder") then + + os.remove('user/editor_output/'..reader[i].name) + + + + + end + end + + + ImportDataPack() + LoadDataPackCache() + logme(2, getLang("ui_setting_actions_rebuild_done")) + + end) + + + + nativeSettings.addTab("/CMCHEAT", getLang("ui_setting_cheat")) -- Add our mods tab (path, label) + + nativeSettings.addSubcategory("/CMCHEAT/player", getLang("ui_setting_cheat")) -- Optional: Add a subcategory (path, label), you can add as many as you want + + + + + + + nativeSettings.addSwitch("/CMCHEAT/player", getLang("Immortal"), getLang("Immortal"), Immortal, false, function(state) -- path, label, desc, currentValue, defaultValue, callback + Immortal = state + updateUserSetting("Immortal", Immortal) + + if (Immortal) then + + Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Invulnerable", CName.new("SecondHeart")) + if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then + local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + if veh then + Game.GetGodModeSystem():AddGodMode(veh:GetEntityID(), "Invulnerable", CName.new("Default")) + end + end + else + local hasSecondHeart = false + local ssc = Game.GetScriptableSystemsContainer() + local es = ssc:Get(CName.new('EquipmentSystem')) + local espd = es:GetPlayerData(Game.GetPlayer()) + espd['GetItemInEquipSlot2'] = espd['GetItemInEquipSlot;gamedataEquipmentAreaInt32'] + for i=0,2 do + if espd:GetItemInEquipSlot2("CardiovascularSystemCW", i).tdbid.hash == 3619482064 then + hasSecondHeart = true + end + end + if hasSecondHeart then + Game.GetGodModeSystem():EnableOverride(Game.GetPlayer():GetEntityID(), "Immortal", CName.new("SecondHeart")) + else + Game.GetGodModeSystem():DisableOverride(Game.GetPlayer():GetEntityID(), CName.new("SecondHeart")) + end + if Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) then + local veh = Game['GetMountedVehicle;GameObject'](Game.GetPlayer()) + if veh then + Game.GetGodModeSystem():ClearGodMode(veh:GetEntityID(), CName.new("Default")) + end + end + + end + + end) + -- Parameters: path, label, desc, currentValue, defaultValue, callback, optionalIndex + nativeSettings.addSwitch("/CMCHEAT/player", getLang("Infinite Stamina"), getLang("Infinite Stamina"), InfiniteStaminas, false, function(state) -- path, label, desc, currentValue, defaultValue, callback + InfiniteStaminas = state + updateUserSetting("InfiniteStaminas", InfiniteStaminas) + + InfiniteStamina(InfiniteStaminas) + end) + + + + + + + + + + nativeSettings.addSubcategory("/CMCHEAT/reload",getLang("Theses cheats need that you save after enable them then reload")) + + nativeSettings.addRangeFloat("/CMCHEAT/reload", getLang("ui_setting_cheat_player_sprint"), getLang("ui_setting_cheat_player_sprint"), 1, 10, 0.1, "%.1f", Player_Sprint_Multiplier, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback + pcall(function() + Player_Sprint_Multiplier = tonumber(string.format("%.1f", value)) + updateUserSetting("Player_Sprint_Multiplier", Player_Sprint_Multiplier) + TweakDB:SetFlat("PlayerLocomotion.player_locomotion_data_Sprint_inline1.value", 6.5 * Player_Sprint_Multiplier) + TweakDB:Update("PlayerLocomotion.player_locomotion_data_Sprint_inline1.value") + + -- local newMod = gameConstantStatModifierData.new() + -- newMod.statType = 619 + -- newMod.modifierType = 2 + -- newMod.value = Player_Sprint_Multiplier + + -- Game.GetStatsSystem():AddModifier(Game.GetPlayer():GetEntityID(),newmod) + + end) + end) + + nativeSettings.addRangeFloat("/CMCHEAT/reload", getLang("ui_setting_cheat_player_run"), getLang("ui_setting_cheat_player_run"), 1, 10, 0.1, "%.1f", Player_Run_Multiplier, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback + pcall(function() + Player_Run_Multiplier = tonumber(string.format("%.1f", value)) + updateUserSetting("Player_Run_Multiplier", Player_Run_Multiplier) + TweakDB:SetFlat("PlayerLocomotion.player_locomotion_data_Stand_inline1.value", 3.5 * Player_Run_Multiplier) + TweakDB:Update("PlayerLocomotion.player_locomotion_data_Stand_inline1.value") + + -- local newMod = gameConstantStatModifierData.new() + -- newMod.statType = 619 + -- newMod.modifierType = 2 + -- newMod.value = Player_Run_Multiplier + + -- Game.GetStatsSystem():AddModifier(Game.GetPlayer():GetEntityID(),newmod) + end) + end) + + + nativeSettings.addRangeFloat("/CMCHEAT/reload", getLang("ui_setting_cheat_jump_height"), getLang("ui_setting_cheat_jump_height"), 1, 10, 0.1, "%.1f", Jump_Height, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback + pcall(function() + Jump_Height = tonumber(string.format("%.1f", value)) + updateUserSetting("Jump_Height", Jump_Height) + TweakDB:SetFlat("PlayerLocomotion.JumpJumpHeightModifier.value", 1 * Jump_Height) + TweakDB:Update("PlayerLocomotion.JumpJumpHeightModifier.value") + + -- local newMod = gameConstantStatModifierData.new() + -- newMod.statType = 596 + -- newMod.modifierType = 2 + -- newMod.value = Jump_Height + + -- Game.GetStatsSystem():AddModifier(Game.GetPlayer():GetEntityID(),newmod) + + end) + end) + + nativeSettings.addRangeFloat("/CMCHEAT/reload", getLang("ui_setting_cheat_doublejump_height"), getLang("ui_setting_cheat_doublejump_height"), 1, 10, 0.1, "%.1f", Double_Jump_Height, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback + pcall(function() + Double_Jump_Height = tonumber(string.format("%.1f", value)) + updateUserSetting("Double_Jump_Height", Double_Jump_Height) + TweakDB:SetFlat("PlayerLocomotion.DoubleJumpJumpHeightModifier.value", 2.6 * Double_Jump_Height) + TweakDB:Update("PlayerLocomotion.DoubleJumpJumpHeightModifier.value") + + -- local newMod = gameConstantStatModifierData.new() + -- newMod.statType = 596 + -- newMod.modifierType = 2 + -- newMod.value = Jump_Height + + -- Game.GetStatsSystem():AddModifier(Game.GetPlayer():GetEntityID(),newmod) + end) + end) + + + + + nativeSettings.addSwitch("/CMCHEAT/reload", getLang("ui_setting_cheat_player_ram"), getLang("ui_setting_cheat_player_ram"), RamUpgrade, false, function(state) -- path, label, desc, currentValue, defaultValue, callback + RamUpgrade = state + updateUserSetting("RamUpgrade", RamUpgrade) + + TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline1.value", 1000) + TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline4.value", 25) + + TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline2.floatValues", {1000}) + TweakDB:SetFlat("Items.AdvancedRamUpgradeLegendaryPlusPlus_inline5.floatValues", {25}) + + end) + + nativeSettings.addSwitch("/CMCHEAT/reload", getLang("Overpowered Optical Camo"), getLang("ui_setting_cheat_player_ram"), RamUpgrade, false, function(state) -- path, label, desc, currentValue, defaultValue, callback + OpticalCamo = state + updateUserSetting("OpticalCamo", OpticalCamo) + + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffLegendary_inline1.value", 9999) + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffEpic_inline1.value", 9999) + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoPlayerBuffRare_inline1.value", 9999) + + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoLegendaryCooldown_inline1.value", 1) + TweakDB:SetFlat("BaseStatusEffect.OpticalCamoCooldown_inline1.value",1) + + TweakDB:SetFlat("Items.OpticalCamoLegendary_inline2.intValues", 1) + TweakDB:SetFlat("Items.OpticalCamoEpic_inline2.intValues", 9999) + TweakDB:SetFlat("Items.OpticalCamoRare_inline2.intValues", 9999) + + end) + + + + + + nativeSettings.addTab("/CSKEYBIND", getLang("Cyberscript KeyBinding")) -- Add our mods tab (path, label) + + nativeSettings.addSubcategory("/CSKEYBIND/InfoController","Current controller configuration : "..currentControllerName) -- Optional: Add a subcategory (path, label), you can add as many as you want + nativeSettings.addSubcategory("/CSKEYBIND/InfoKeybind", "Every Keybinding change need a reload") -- Optional: Add a subcategory (path, label), you can add as many as you want + nativeSettings.addSubcategory("/CSKEYBIND/keybindConfig", getLang("Keybind Configuration")) + + nativeSettings.addSwitch("/CSKEYBIND/keybindConfig", getLang("ui_setting_gameplay_controller"), getLang("ui_setting_gameplay_controller"), currentController, false, function(state) -- path, label, desc, currentValue, defaultValue, callback + currentController = state + updateUserSetting("currentController", state) + + currentControllerName = "Keyboard" + currentControllerid = "keyboard" + + if(currentController == true)then + currentControllerName = "Gamepad" + currentControllerid = "gamepad" + end + + + + + end) + + nativeSettings.addSubcategory("/CSKEYBIND/gameplay", getLang("setting_open_menu_cat")) + + local info = inputManager.createBindingInfo() -- Create an info table that holds information for a binding, makes it easier to reuse later + info.keybindLabel = getLang("setting_open_menu") -- Label of each key, will be followed by the key number, e.g. "Key 1" + info.keybindDescription = getLang("setting_open_menu_desc") -- Description that'll be displayed for all the bindings keys + info.supportsHold = true -- Whether to show the hold switches for this bindings keys + info.isHoldLabel = getLang("setting_hold_key") + info.isHoldDescription = getLang("setting_hold_key_desc") + info.id ="cyberscriptOpenGroup"-- Unique id for the binding, used for the savedOptions/defaultOptions tables and the saveCallback. See above for more details + info.maxKeys = 3 -- Maximum amount of keys for this binding, shows a slider if it is bigger than 1 + info.maxKeysLabel = getLang("setting_max_key") -- Label for the binding's key amount slider + info.maxKeysDescription = getLang("setting_max_key_desc") + info.repeatable = false + info.nativeSettingsPath = "/CSKEYBIND/gameplay" -- Native settings path for where to add the bindigs options, if it is a multikey binding it has to be a seperate subcategory + -- Table containing the default options + local defaultinput = {} + defaultinput["cyberscriptOpenGroup"] = {} + defaultinput["cyberscriptOpenGroup"]["keyboard"] = {} + defaultinput["cyberscriptOpenGroup"]["gamepad"] = {} + for i=1,3 do + + defaultinput["cyberscriptOpenGroup"]["keyboard"]["key_"..i] = "IK_PageDown" + defaultinput["cyberscriptOpenGroup"]["keyboard"]["hold_"..i] = false + defaultinput["cyberscriptOpenGroup"]["gamepad"]["key_"..i] = "IK_PageDown" + defaultinput["cyberscriptOpenGroup"]["gamepad"]["hold_"..i] = false + + end + + defaultinput["cyberscriptOpenGroup"]["keyboard"]["keys"] = 1 + defaultinput["cyberscriptOpenGroup"]["gamepad"]["keys"] = 1 + + info.defaultOptions = defaultinput + + if(arrayUserInput[info.id] ~= nil) then + info.savedOptions = {} + info.savedOptions[info.id] = {} + info.savedOptions[info.id] = arrayUserInput[info.id]-- Table containing the current options + else + arrayUserInput[info.id] =info.defaultOptions[info.id] + end + info.forceHold = false + info.saveCallback = function(name, value) -- Callback for when anything about the binding gets changed, gets the changed variable's generated name + the value + -- Store changed value + + saveUserInput(info.id,name,value) + + + end + info.callback = function() -- Callback for when the binding has been activated + cycleInteract2() + end + inputManager.addNativeSettingsBinding(info) + + + + + nativeSettings.addSubcategory("/CSKEYBIND/holdTime", "Keybinding behavior") + nativeSettings.addRangeFloat("/CSKEYBIND/holdTime", "Keybinding Hold Time", "How long in second you need to hold the combo/key", 0.5, 100, 0.10, "%.2f", holdTime, 1, function(value) -- path, label, desc, min, max, step, currentValue, defaultValue, callback + holdTime = value + updateUserSetting("holdTime", value) + end) + + + + + + end) + + if status == false then + + + + nativeSettings.addSubcategory("/CM/gameplay00", "sssOoops there is an error in CyberScript Setting !") + nativeSettings.addSubcategory("/CM/gameplay01", "Try rebuild the cache and reload the mod/save/game !") + nativeSettings.addSubcategory("/CM/gameplay02", "Send quest_mod.log to discord Admin on Cyberscript Discord !") + + + + + + nativeSettings.addButton("/CM/gameplay02", "!!! Reset the mod !!! ", "WARNING : Will totaly delete downloaded datapack, cache and session", "Reset the mod", 45, function() + + if file_exists("user/sessions/latest.txt") then + os.remove("user/sessions/latest.txt") + end + + + local reader = dir("sessions") + + + for i=1, #reader do + if(tostring(reader[i].type) ~= "directory" and reader[i].name ~= "placeholder") then + + os.remove('user/sessions/'..reader[i].name) + + + + + end + end + + + + + + ImportDataPack() + LoadDataPackCache() + logme(2, getLang("ui_setting_actions_rebuild_done")) + + end) + end + + + end end @@ -1739,1509 +1795,1509 @@ end function loadHUD() - - - - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "container") then - displayHUD[k] = inkCanvas.new() - displayHUD[k]:SetName(CName.new(hud.tag)) - displayHUD[k]:SetAnchor(inkEAnchor.Fill) - displayHUD[k]:Reparent(rootContainer, -1) - logme(1,"create "..hud.tag) - - end - end - - - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "container") then - if(hud.container == nil or hud.container == "default" or hud.container == "") then - displayHUD[k]:Reparent(rootContainer, -1) - else - displayHUD[k]:Reparent(displayHUD[hud.container], -1) - end - - - end - end - - for k,v in pairs(cyberscript.cache["hud"]) do - local hud = v.data - if(hud.type == "widget") then - displayHUD[k] = inkText.new() - displayHUD[k]:SetName(CName.new(hud.tag)) - displayHUD[k]:SetMargin(inkMargin.new({ top = hud.margin.top, left = hud.margin.left})) - displayHUD[k]:SetFontFamily(hud.fontfamily) - displayHUD[k]:SetFontStyle(hud.fontstyle) - displayHUD[k]:SetFontSize(hud.fontsize) - displayHUD[k]:SetTintColor(gamecolor(hud.color.red,hud.color.green,hud.color.blue,1)) - displayHUD[k]:SetVisible(hud.visible) - displayHUD[k]:SetHorizontalAlignment(textHorizontalAlignment.Center) - displayHUD[k]:SetVerticalAlignment(textVerticalAlignment.Center) - - if(hud.container == nil or hud.container == "default" or hud.container == "") then - displayHUD[k]:Reparent(container, -1) - else - displayHUD[k]:Reparent(displayHUD[hud.container], -1) - end - logme(1,"create "..hud.tag) - end - - end - + + + + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "container") then + displayHUD[k] = inkCanvas.new() + displayHUD[k]:SetName(CName.new(hud.tag)) + displayHUD[k]:SetAnchor(inkEAnchor.Fill) + displayHUD[k]:Reparent(rootContainer, -1) + logme(1,"create "..hud.tag) + + end + end + + + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "container") then + if(hud.container == nil or hud.container == "default" or hud.container == "") then + displayHUD[k]:Reparent(rootContainer, -1) + else + displayHUD[k]:Reparent(displayHUD[hud.container], -1) + end + + + end + end + + for k,v in pairs(cyberscript.cache["hud"]) do + local hud = v.data + if(hud.type == "widget") then + displayHUD[k] = inkText.new() + displayHUD[k]:SetName(CName.new(hud.tag)) + displayHUD[k]:SetMargin(inkMargin.new({ top = hud.margin.top, left = hud.margin.left})) + displayHUD[k]:SetFontFamily(hud.fontfamily) + displayHUD[k]:SetFontStyle(hud.fontstyle) + displayHUD[k]:SetFontSize(hud.fontsize) + displayHUD[k]:SetTintColor(gamecolor(hud.color.red,hud.color.green,hud.color.blue,1)) + displayHUD[k]:SetVisible(hud.visible) + displayHUD[k]:SetHorizontalAlignment(textHorizontalAlignment.Center) + displayHUD[k]:SetVerticalAlignment(textVerticalAlignment.Center) + + if(hud.container == nil or hud.container == "default" or hud.container == "") then + displayHUD[k]:Reparent(container, -1) + else + displayHUD[k]:Reparent(displayHUD[hud.container], -1) + end + logme(1,"create "..hud.tag) + end + + end + end function ImageFrame() - - for k,v in pairs(currentLoadedTexture) do - - ImGui.SetWindowFontScale(2) - CPS.colorBegin("WindowBg", {v.bgcolor , v.bgopacity}) - CPS.colorBegin("Text", {v.titlecolor , v.titleopacity}) - CPS.colorBegin("Border", {v.bordercolor , v.borderopacity}) - - CPS.colorBegin("TextDisabled", {"000000" , 0}) - CPS.colorBegin("FrameBg", {"000000" , 0}) - CPS.colorBegin("TitleBg", {"000000" , 0}) - - CPS.colorBegin("TitleBgActive", {"000000" , 0}) - CPS.colorBegin("Header", {"000000" , 0}) - CPS.colorBegin("ScrollbarBg", {"000000" , 0}) - - CPS.colorBegin("ScrollbarGrab", {"000000" , 0}) - CPS.colorBegin("ScrollbarGrabHovered", {"000000" , 0}) - CPS.colorBegin("ScrollbarGrabActive", {"000000" , 0}) - - if ImGui.Begin(v.title) then - - local windowWidth = 220 - local screenWidth, screenHeight = GetDisplayResolution() - local screenRatioX, screenRatioY = screenWidth / 1920, screenHeight / 1200 - - - local posx = v.size.x +v.position.x - ImGui.SetWindowSize(v.size.x, v.size.y) - - ImGui.SetWindowPos( v.position.x * screenRatioX, v.position.y * screenRatioY) - - print(v.texture) - ImGui.Image(v.texture) - - - - end - ImGui.End() - ImGui.SetWindowFontScale(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - - end - + + for k,v in pairs(currentLoadedTexture) do + + ImGui.SetWindowFontScale(2) + CPS.colorBegin("WindowBg", {v.bgcolor , v.bgopacity}) + CPS.colorBegin("Text", {v.titlecolor , v.titleopacity}) + CPS.colorBegin("Border", {v.bordercolor , v.borderopacity}) + + CPS.colorBegin("TextDisabled", {"000000" , 0}) + CPS.colorBegin("FrameBg", {"000000" , 0}) + CPS.colorBegin("TitleBg", {"000000" , 0}) + + CPS.colorBegin("TitleBgActive", {"000000" , 0}) + CPS.colorBegin("Header", {"000000" , 0}) + CPS.colorBegin("ScrollbarBg", {"000000" , 0}) + + CPS.colorBegin("ScrollbarGrab", {"000000" , 0}) + CPS.colorBegin("ScrollbarGrabHovered", {"000000" , 0}) + CPS.colorBegin("ScrollbarGrabActive", {"000000" , 0}) + + if ImGui.Begin(v.title) then + + local windowWidth = 220 + local screenWidth, screenHeight = GetDisplayResolution() + local screenRatioX, screenRatioY = screenWidth / 1920, screenHeight / 1200 + + + local posx = v.size.x +v.position.x + ImGui.SetWindowSize(v.size.x, v.size.y) + + ImGui.SetWindowPos( v.position.x * screenRatioX, v.position.y * screenRatioY) + + print(v.texture) + ImGui.Image(v.texture) + + + + end + ImGui.End() + ImGui.SetWindowFontScale(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + + end + end function fadeinwindows() - - local screenWidth, screenHeight = GetDisplayResolution() - CPS.colorBegin("WindowBg", {"000000" , opacity}) - CPS.colorBegin("FrameBg", {"000000" , opacity}) - CPS.colorBegin("MenuBarBg", {"000000" , opacity}) - CPS.colorBegin("TitleBg", {"000000" , opacity}) - CPS.colorBegin("Header", {"000000" , opacity}) - CPS.colorBegin("Border", {"000000" , opacity}) - CPS.colorBegin("PopupBg", {"000000" , opacity}) - CPS.colorBegin("HeaderActive", {"000000" , opacity}) - CPS.colorBegin("TitleBgActive", {"000000" , opacity}) - CPS.colorBegin("Text", {"000000" , opacity}) - - if ImGui.Begin(fademessage) then - ImGui.SetNextWindowSize(screenWidth, screenHeight, ImGuiCond.Appearing) -- set window size w, h - ImGui.SetWindowSize(screenWidth+5, screenHeight+5) - ImGui.SetWindowPos(-5, -5) - ImGui.End() - end - - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - CPS.colorEnd(1) - + + local screenWidth, screenHeight = GetDisplayResolution() + CPS.colorBegin("WindowBg", {"000000" , opacity}) + CPS.colorBegin("FrameBg", {"000000" , opacity}) + CPS.colorBegin("MenuBarBg", {"000000" , opacity}) + CPS.colorBegin("TitleBg", {"000000" , opacity}) + CPS.colorBegin("Header", {"000000" , opacity}) + CPS.colorBegin("Border", {"000000" , opacity}) + CPS.colorBegin("PopupBg", {"000000" , opacity}) + CPS.colorBegin("HeaderActive", {"000000" , opacity}) + CPS.colorBegin("TitleBgActive", {"000000" , opacity}) + CPS.colorBegin("Text", {"000000" , opacity}) + + if ImGui.Begin(fademessage) then + ImGui.SetNextWindowSize(screenWidth, screenHeight, ImGuiCond.Appearing) -- set window size w, h + ImGui.SetWindowSize(screenWidth+5, screenHeight+5) + ImGui.SetWindowPos(-5, -5) + ImGui.End() + end + + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + CPS.colorEnd(1) + end function displaySetting(setting, libelle) - - if setting == 1 then - colorclass = IRPtheme.EnabledColor - state = lang.Enabled - else - colorclass = IRPtheme.DisabledColor - state = lang.Disabled - end - CPS.colorBegin("Text", colorclass) - ImGui.TextWrapped(libelle.." : "..state) - CPS.colorEnd(1) + + if setting == 1 then + colorclass = IRPtheme.EnabledColor + state = lang.Enabled + else + colorclass = IRPtheme.DisabledColor + state = lang.Disabled + end + CPS.colorBegin("Text", colorclass) + ImGui.TextWrapped(libelle.." : "..state) + CPS.colorEnd(1) end ---Native UI--- function BuyedItemsUI() - currentInterface = nil - - local ui = {} - ui.title = getLang("ui_buyed_items") - ui.tag = "buyed_items_ui" - ui.controls = {} - - local area = {} - area.type = "scrollarea" - area.tag = "buyed_items_ui_scroll" - area.trigger = {} - area.trigger.auto = {} - area.trigger.auto.name = "auto" - area.requirement = {} - - local requirement = {} - table.insert(requirement,"auto") - table.insert(area.requirement,requirement) - area.action = {} - area.margin = {} - area.style = {} - area.margin.top = 15 - area.style.fontsize = 30 - area.style.width = 1500 - area.style.height = 700 - table.insert(ui.controls,area) - area = {} - area.type = "vertical_area" - area.tag = "buyed_items_ui_varea" - area.trigger = {} - area.trigger.auto = {} - area.trigger.auto.name = "auto" - area.requirement = {} - - local requirement = {} - table.insert(requirement,"auto") - table.insert(area.requirement,requirement) - area.action = {} - area.margin = {} - area.style = {} - area.margin.top = 15 - area.parent = "buyed_items_ui_scroll" - area.style.fontsize = 30 - area.style.width = 1500 - area.style.height = 350 - table.insert(ui.controls,area) - - if(#currentSave.arrayPlayerItems > 0 ) then - for i = 1, #currentSave.arrayPlayerItems do - - local mitems = currentSave.arrayPlayerItems[i] - - if(mitems.Quantity > 0) then - - local buttons = {} - buttons.type = "button" - buttons.title = "Place "..mitems.Title.." Here ("..mitems.Quantity..")" - buttons.tag =mitems.Tag.."_button_"..i - buttons.width = 1000 - buttons.trigger = {} - buttons.trigger.auto = {} - buttons.trigger.auto.name = "auto" - buttons.margin = {} - buttons.style = {} - buttons.margin.top = 15 - buttons.style.fontsize = 35 - buttons.style.width = 1450 - buttons.style.height = 100 - buttons.parent = "buyed_items_ui_varea" - buttons.requirement = {} - - local requirement = {} - table.insert(requirement,"auto") - table.insert(buttons.requirement,requirement) - buttons.action = {} - - local spawn_item = {} - spawn_item.name = "spawn_buyed_item" - spawn_item.tag = mitems.Tag - table.insert(buttons.action,spawn_item) - spawn_item = {} - spawn_item.name = "grab_select_item" - table.insert(buttons.action,spawn_item) - - local close_action = {} - close_action.name = "close_interface" - table.insert(buttons.action,close_action) - table.insert(ui.controls,buttons) - end - end - currentInterface = ui - - if UIPopupsManager.IsReady() then - - local notificationData = ShardReadPopupData.new() - notificationData.notificationName = 'base\\gameplay\\gui\\widgets\\notifications\\shard_notification.inkwidget' - notificationData.queueName = 'modal_popup' - notificationData.isBlocking = true - notificationData.useCursor = true - UIPopupsManager.ShowPopup(notificationData) - else - Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") - end - end + currentInterface = nil + + local ui = {} + ui.title = getLang("ui_buyed_items") + ui.tag = "buyed_items_ui" + ui.controls = {} + + local area = {} + area.type = "scrollarea" + area.tag = "buyed_items_ui_scroll" + area.trigger = {} + area.trigger.auto = {} + area.trigger.auto.name = "auto" + area.requirement = {} + + local requirement = {} + table.insert(requirement,"auto") + table.insert(area.requirement,requirement) + area.action = {} + area.margin = {} + area.style = {} + area.margin.top = 15 + area.style.fontsize = 30 + area.style.width = 1500 + area.style.height = 700 + table.insert(ui.controls,area) + area = {} + area.type = "vertical_area" + area.tag = "buyed_items_ui_varea" + area.trigger = {} + area.trigger.auto = {} + area.trigger.auto.name = "auto" + area.requirement = {} + + local requirement = {} + table.insert(requirement,"auto") + table.insert(area.requirement,requirement) + area.action = {} + area.margin = {} + area.style = {} + area.margin.top = 15 + area.parent = "buyed_items_ui_scroll" + area.style.fontsize = 30 + area.style.width = 1500 + area.style.height = 350 + table.insert(ui.controls,area) + + if(#currentSave.arrayPlayerItems > 0 ) then + for i = 1, #currentSave.arrayPlayerItems do + + local mitems = currentSave.arrayPlayerItems[i] + + if(mitems.Quantity > 0) then + + local buttons = {} + buttons.type = "button" + buttons.title = "Place "..mitems.Title.." Here ("..mitems.Quantity..")" + buttons.tag =mitems.Tag.."_button_"..i + buttons.width = 1000 + buttons.trigger = {} + buttons.trigger.auto = {} + buttons.trigger.auto.name = "auto" + buttons.margin = {} + buttons.style = {} + buttons.margin.top = 15 + buttons.style.fontsize = 35 + buttons.style.width = 1450 + buttons.style.height = 100 + buttons.parent = "buyed_items_ui_varea" + buttons.requirement = {} + + local requirement = {} + table.insert(requirement,"auto") + table.insert(buttons.requirement,requirement) + buttons.action = {} + + local spawn_item = {} + spawn_item.name = "spawn_buyed_item" + spawn_item.tag = mitems.Tag + table.insert(buttons.action,spawn_item) + spawn_item = {} + spawn_item.name = "grab_select_item" + table.insert(buttons.action,spawn_item) + + local close_action = {} + close_action.name = "close_interface" + table.insert(buttons.action,close_action) + table.insert(ui.controls,buttons) + end + end + currentInterface = ui + + if UIPopupsManager.IsReady() then + + local notificationData = ShardReadPopupData.new() + notificationData.notificationName = 'base\\gameplay\\gui\\widgets\\notifications\\shard_notification.inkwidget' + notificationData.queueName = 'modal_popup' + notificationData.isBlocking = true + notificationData.useCursor = true + UIPopupsManager.ShowPopup(notificationData) + else + Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") + end + end end function ActivatedGroup2() - local dialog = {} - - dialog.trigger = {} - dialog.requirement = {} - dialog.desc = "" - dialog.tag = "ActivatedGroup2" - dialog.speaker = "Choose a mod " - dialog.context = {} - dialog.options = {} - - - - if(#currentInteractGroup > 0 ) then - - - - - - for i = 1, #currentInteractGroup do - - - local options = {} - options.requirement = nil - options.trigger = nil - options.description = currentInteractGroup[i] - options.action = {} - - local spawn_item = {} - spawn_item.name = "set_datapack_group_index" - spawn_item.value = i - table.insert(options.action,spawn_item) - - table.insert(dialog.options,options) - end - - - createDialog(dialog) - end - - + local dialog = {} + + dialog.trigger = {} + dialog.requirement = {} + dialog.desc = "" + dialog.tag = "ActivatedGroup2" + dialog.speaker = "Choose a mod " + dialog.context = {} + dialog.options = {} + + + + if(#currentInteractGroup > 0 ) then + + + + + + for i = 1, #currentInteractGroup do + + + local options = {} + options.requirement = nil + options.trigger = nil + options.description = currentInteractGroup[i] + options.action = {} + + local spawn_item = {} + spawn_item.name = "set_datapack_group_index" + spawn_item.value = i + table.insert(options.action,spawn_item) + + table.insert(dialog.options,options) + end + + + createDialog(dialog) + end + + end function cycleInteract2() - getTriggeredActions() - currentInteractGroupIndex = currentInteractGroupIndex or 1 - getTriggeredActionsDisplay() - local dialog = {} - - dialog.trigger = {} - dialog.requirement = {} - dialog.desc = "" - dialog.tag = "cycleInteract2" - dialog.speaker = currentInteractGroup[currentInteractGroupIndex] - dialog.context = {} - dialog.options = {} - - - - for key,value in pairs(cyberscript.cache["interact"]) do --actualcode - - local interact = cyberscript.cache["interact"][key].data - checkContext(interact) - --testTriggerRequirement(interact2.requirement,interact2.trigger) - if(checkTriggerRequirement(interact.requirement,interact.trigger)) and - (interact.group == currentInteractGroup[currentInteractGroupIndex] and key ~= "default_open_datapack_group_ui") then - - if((interact.type == nil or interact.type == "interact") and (interact.display == nil or interact.display == "event_interact")) then - - local options = {} - options.requirement = interact.requirement - options.trigger = interact.trigger - options.description = getLang(interact.name) - options.action = interact.action - - options.icon = interact.icon - options.style = {} - if interact.style ~= nil and interact.style.textcolor ~= nil then - options.style.color = interact.style.textcolor - - end - options.tag = interact.tag - - - - - table.insert(dialog.options,options) - - else - if((interact.type == nil or interact.type == "hint")) then - - showInputHint(interact.key, getLang(interact.name), 1, interact.hold, interact.tag) - end - end - else - if(#currentInputHintList > 0) then - - for i = 1, #currentInputHintList do - - if(currentInputHintList[i]~= nil and currentInputHintList[i].tag == interact.tag) then - hideCustomHints(interact.tag) - - currentInputHintList[i] = nil - end - - - end - - - end - end - - - - - end - - local interact = cyberscript.cache["interact"]["default_open_datapack_group_ui"].data - local options = {} - options.requirement = interact.requirement - options.trigger = interact.trigger - options.description = interact.name - - options.action = {} - options.action[1] = {} - options.action[1].name = "open_datapack_group_ui2" - - options.icon = interact.icon - options.style = {} - if interact.style ~= nil and interact.style.textcolor ~= nil then - options.style.color = interact.style.textcolor - - end - options.tag = interact.tag - - - - - table.insert(dialog.options,options) - - - - local options = {} - options.requirement = nil - options.trigger = nil - options.description = "Exit" - options.action = {} - - - options.action[1] = {} - options.action[1].name = "nothing" - - - - - - table.insert(dialog.options,options) - --print("mark2") - createDialog(dialog) - - + getTriggeredActions() + currentInteractGroupIndex = currentInteractGroupIndex or 1 + getTriggeredActionsDisplay() + local dialog = {} + + dialog.trigger = {} + dialog.requirement = {} + dialog.desc = "" + dialog.tag = "cycleInteract2" + dialog.speaker = currentInteractGroup[currentInteractGroupIndex] + dialog.context = {} + dialog.options = {} + + + + for key,value in pairs(cyberscript.cache["interact"]) do --actualcode + + local interact = cyberscript.cache["interact"][key].data + checkContext(interact) + --testTriggerRequirement(interact2.requirement,interact2.trigger) + if(checkTriggerRequirement(interact.requirement,interact.trigger)) and + (interact.group == currentInteractGroup[currentInteractGroupIndex] and key ~= "default_open_datapack_group_ui") then + + if((interact.type == nil or interact.type == "interact") and (interact.display == nil or interact.display == "event_interact")) then + + local options = {} + options.requirement = interact.requirement + options.trigger = interact.trigger + options.description = getLang(interact.name) + options.action = interact.action + + options.icon = interact.icon + options.style = {} + if interact.style ~= nil and interact.style.textcolor ~= nil then + options.style.color = interact.style.textcolor + + end + options.tag = interact.tag + + + + + table.insert(dialog.options,options) + + else + if((interact.type == nil or interact.type == "hint")) then + + showInputHint(interact.key, getLang(interact.name), 1, interact.hold, interact.tag) + end + end + else + if(#currentInputHintList > 0) then + + for i = 1, #currentInputHintList do + + if(currentInputHintList[i]~= nil and currentInputHintList[i].tag == interact.tag) then + hideCustomHints(interact.tag) + + currentInputHintList[i] = nil + end + + + end + + + end + end + + + + + end + + local interact = cyberscript.cache["interact"]["default_open_datapack_group_ui"].data + local options = {} + options.requirement = interact.requirement + options.trigger = interact.trigger + options.description = interact.name + + options.action = {} + options.action[1] = {} + options.action[1].name = "open_datapack_group_ui2" + + options.icon = interact.icon + options.style = {} + if interact.style ~= nil and interact.style.textcolor ~= nil then + options.style.color = interact.style.textcolor + + end + options.tag = interact.tag + + + + + table.insert(dialog.options,options) + + + + local options = {} + options.requirement = nil + options.trigger = nil + options.description = "Exit" + options.action = {} + + + options.action[1] = {} + options.action[1].name = "nothing" + + + + + + table.insert(dialog.options,options) + --print("mark2") + createDialog(dialog) + + end function cycleInteractFavorite() - getTriggeredActions() - - getTriggeredActionsDisplay() - local dialog = {} - - dialog.trigger = {} - dialog.requirement = {} - dialog.desc = "" - dialog.tag = "cycleInteractFavorite" - dialog.speaker = favoriteInteractGroup - dialog.context = {} - dialog.options = {} - - - - for key,value in pairs(cyberscript.cache["interact"]) do --actualcode - - local interact = cyberscript.cache["interact"][key].data - checkContext(interact) - --testTriggerRequirement(interact2.requirement,interact2.trigger) - if(checkTriggerRequirement(interact.requirement,interact.trigger)) and - (interact.group == favoriteInteractGroup and key ~= "default_open_datapack_group_ui") then - - if((interact.type == nil or interact.type == "interact") and (interact.display == nil or interact.display == "event_interact")) then - - local options = {} - options.requirement = interact.requirement - options.trigger = interact.trigger - options.description = getLang(interact.name) - print(interact.name) - options.action = interact.action - - options.icon = interact.icon - options.style = {} - if interact.style ~= nil and interact.style.textcolor ~= nil then - options.style.color = interact.style.textcolor - - end - options.tag = interact.tag - - - - - table.insert(dialog.options,options) - - else - if((interact.type == nil or interact.type == "hint")) then - - showInputHint(interact.key, getLang(interact.name), 1, interact.hold, interact.tag) - end - end - - end - - - - - end - - - - - - local options = {} - options.requirement = nil - options.trigger = nil - options.description = "Exit" - options.action = {} - - - options.action[1] = {} - options.action[1].name = "nothing" - - - - - - table.insert(dialog.options,options) - --print("mark2") - createDialog(dialog) - - + getTriggeredActions() + + getTriggeredActionsDisplay() + local dialog = {} + + dialog.trigger = {} + dialog.requirement = {} + dialog.desc = "" + dialog.tag = "cycleInteractFavorite" + dialog.speaker = favoriteInteractGroup + dialog.context = {} + dialog.options = {} + + + + for key,value in pairs(cyberscript.cache["interact"]) do --actualcode + + local interact = cyberscript.cache["interact"][key].data + checkContext(interact) + --testTriggerRequirement(interact2.requirement,interact2.trigger) + if(checkTriggerRequirement(interact.requirement,interact.trigger)) and + (interact.group == favoriteInteractGroup and key ~= "default_open_datapack_group_ui") then + + if((interact.type == nil or interact.type == "interact") and (interact.display == nil or interact.display == "event_interact")) then + + local options = {} + options.requirement = interact.requirement + options.trigger = interact.trigger + options.description = getLang(interact.name) + print(interact.name) + options.action = interact.action + + options.icon = interact.icon + options.style = {} + if interact.style ~= nil and interact.style.textcolor ~= nil then + options.style.color = interact.style.textcolor + + end + options.tag = interact.tag + + + + + table.insert(dialog.options,options) + + else + if((interact.type == nil or interact.type == "hint")) then + + showInputHint(interact.key, getLang(interact.name), 1, interact.hold, interact.tag) + end + end + + end + + + + + end + + + + + + local options = {} + options.requirement = nil + options.trigger = nil + options.description = "Exit" + options.action = {} + + + options.action[1] = {} + options.action[1].name = "nothing" + + + + + + table.insert(dialog.options,options) + --print("mark2") + createDialog(dialog) + + end function Activatedshard(shard) - currentInterface = nil - ----print(dump(shard)) - local ui = {} - ui.title = shard.title - ui.tag = "ui_custom_shard" - ui.controls = {} - - - - - - local area = {} - area.type = "area" - area.tag = "main_area" - area.rotation = 0 - area.anchor = 15 - area.fittocontent = true - area.trigger = {} - area.trigger.auto = {} - area.trigger.auto.name = "auto" - area.requirement = {} - local requirement = {} - table.insert(requirement,"auto") - table.insert(area.requirement,requirement) - area.margin = {} - area.margin.top = 0 - area.margin.left = 0 - area.size = {} - area.size.width = 1000 - area.size.height = 1000 - area.scale = {} - area.scale.width = 1 - area.scale.height = 1 - table.insert(ui.controls,area) - - local area = {} - area.type = "area" - area.tag = "container" - area.parent = "main_area" - area.rotation = 0 - area.anchor = 0 - area.opacity = 1 - area.visible = true - area.fittocontent = true - area.trigger = {} - area.trigger.auto = {} - area.trigger.auto.name = "auto" - area.requirement = {} - local requirement = {} - table.insert(requirement,"auto") - table.insert(area.requirement,requirement) - area.margin = {} - area.margin.top = 0 - area.margin.left = 0 - area.size = {} - area.size.width = 1000 - area.size.height = 1000 - area.scale = {} - area.scale.width = 1 - area.scale.height = 1 - table.insert(ui.controls,area) - - - local label = {} - label.type = "label" - label.tag ="selected_group_lbl" - label.trigger = {} - label.trigger.auto = {} - label.trigger.auto.name = "auto" - label.parent = "container" - label.margin = {} - label.style = {} - label.anchor = 0 - label.margin.top = 5 - label.style.fontsize = 55 - label.requirement = {} - label.textcolor = {} - label.textcolor.red = 0 - label.textcolor.green = 255 - label.textcolor.blue = 247 - - - local requirement = {} - table.insert(requirement,"auto") - table.insert(label.requirement,requirement) - - label.text = shard.description - table.insert(ui.controls,label) - - - - currentInterface = ui - - if UIPopupsManager.IsReady() then - - local notificationData = ShardReadPopupData.new() - notificationData.notificationName = 'base\\gameplay\\gui\\widgets\\notifications\\shard_notification.inkwidget' - notificationData.queueName = 'modal_popup' - notificationData.isBlocking = true - notificationData.useCursor = true - UIPopupsManager.ShowPopup(notificationData) - - else - Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") - end - + currentInterface = nil + ----print(dump(shard)) + local ui = {} + ui.title = shard.title + ui.tag = "ui_custom_shard" + ui.controls = {} + + + + + + local area = {} + area.type = "area" + area.tag = "main_area" + area.rotation = 0 + area.anchor = 15 + area.fittocontent = true + area.trigger = {} + area.trigger.auto = {} + area.trigger.auto.name = "auto" + area.requirement = {} + local requirement = {} + table.insert(requirement,"auto") + table.insert(area.requirement,requirement) + area.margin = {} + area.margin.top = 0 + area.margin.left = 0 + area.size = {} + area.size.width = 1000 + area.size.height = 1000 + area.scale = {} + area.scale.width = 1 + area.scale.height = 1 + table.insert(ui.controls,area) + + local area = {} + area.type = "area" + area.tag = "container" + area.parent = "main_area" + area.rotation = 0 + area.anchor = 0 + area.opacity = 1 + area.visible = true + area.fittocontent = true + area.trigger = {} + area.trigger.auto = {} + area.trigger.auto.name = "auto" + area.requirement = {} + local requirement = {} + table.insert(requirement,"auto") + table.insert(area.requirement,requirement) + area.margin = {} + area.margin.top = 0 + area.margin.left = 0 + area.size = {} + area.size.width = 1000 + area.size.height = 1000 + area.scale = {} + area.scale.width = 1 + area.scale.height = 1 + table.insert(ui.controls,area) + + + local label = {} + label.type = "label" + label.tag ="selected_group_lbl" + label.trigger = {} + label.trigger.auto = {} + label.trigger.auto.name = "auto" + label.parent = "container" + label.margin = {} + label.style = {} + label.anchor = 0 + label.margin.top = 5 + label.style.fontsize = 55 + label.requirement = {} + label.textcolor = {} + label.textcolor.red = 0 + label.textcolor.green = 255 + label.textcolor.blue = 247 + + + local requirement = {} + table.insert(requirement,"auto") + table.insert(label.requirement,requirement) + + label.text = shard.description + table.insert(ui.controls,label) + + + + currentInterface = ui + + if UIPopupsManager.IsReady() then + + local notificationData = ShardReadPopupData.new() + notificationData.notificationName = 'base\\gameplay\\gui\\widgets\\notifications\\shard_notification.inkwidget' + notificationData.queueName = 'modal_popup' + notificationData.isBlocking = true + notificationData.useCursor = true + UIPopupsManager.ShowPopup(notificationData) + + else + Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") + end + end function PlacedItemsUI() - currentInterface = nil - - local ui = {} - ui.title = getLang("ui_manage_placed_item") - ui.tag = "placed_items_ui" - ui.controls = {} - - local area = {} - area.type = "scrollarea" - area.tag = "placed_items_ui_scroll" - area.trigger = {} - area.trigger.auto = {} - area.trigger.auto.name = "auto" - area.requirement = {} - - local requirement = {} - table.insert(requirement,"auto") - table.insert(area.requirement,requirement) - area.action = {} - area.margin = {} - area.style = {} - area.margin.top = 15 - area.style.fontsize = 30 - area.style.width = 1500 - area.style.height = 700 - table.insert(ui.controls,area) - area = {} - area.type = "vertical_area" - area.tag = "placed_items_ui_varea" - area.trigger = {} - area.trigger.auto = {} - area.trigger.auto.name = "auto" - area.requirement = {} - - local requirement = {} - table.insert(requirement,"auto") - table.insert(area.requirement,requirement) - area.action = {} - area.margin = {} - area.style = {} - area.margin.top = 15 - area.parent = "placed_items_ui_scroll" - area.style.fontsize = 30 - area.style.width = 1500 - area.style.height = 350 - table.insert(ui.controls,area) - - if(#currentItemSpawned > 0 ) then - - if selectedItem ~= nil then - - local label = {} - label.type = "label" - label.tag ="selected_item_lbl" - label.trigger = {} - label.trigger.auto = {} - label.trigger.auto.name = "auto" - label.margin = {} - label.style = {} - label.margin.top = 15 - label.style.fontsize = 35 - label.requirement = {} - - local requirement = {} - table.insert(requirement,"auto") - table.insert(label.requirement,requirement) - label.value = {} - label.value.type = "text" - label.value.value = "Selected : "..selectedItem.Title.."("..selectedItem.Id..")" - table.insert(ui.controls,label) - end - for i = 1, #currentItemSpawned do - - local mitems = currentItemSpawned[i] - - local buttons = {} - buttons.type = "button" - buttons.title = "Select "..mitems.Title.."("..mitems.Id..")" - buttons.tag =mitems.Tag.."_button_"..i - buttons.margin = {} - buttons.style = {} - buttons.margin.top = 15 - buttons.style.fontsize = 35 - buttons.style.width = 1000 - buttons.style.height = 100 - buttons.trigger = {} - buttons.trigger.auto = {} - buttons.trigger.auto.name = "auto" - buttons.requirement = {} - - local requirement = {} - table.insert(requirement,"auto") - table.insert(buttons.requirement,requirement) - buttons.action = {} - - local spawn_item = {} - spawn_item.name = "select_item" - spawn_item.value = mitems.Id - table.insert(buttons.action,spawn_item) - - local close_action = {} - close_action.name = "close_interface" - table.insert(buttons.action,close_action) - table.insert(ui.controls,buttons) - end - - local buttons = {} - buttons.type = "button" - buttons.title = "Unselect item" - buttons.tag ="unselect_button" - buttons.trigger = {} - buttons.trigger.auto = {} - buttons.trigger.auto.name = "auto" - buttons.margin = {} - buttons.style = {} - buttons.parent = "placed_items_ui_varea" - buttons.style.fontsize = 35 - buttons.style.width = 1450 - buttons.style.height = 100 - buttons.requirement = {} - - local requirement = {} - table.insert(requirement,"auto") - table.insert(buttons.requirement,requirement) - buttons.action = {} - - local spawn_item = {} - spawn_item.name = "unselect_item" - table.insert(buttons.action,spawn_item) - - local close_action = {} - close_action.name = "close_interface" - table.insert(buttons.action,close_action) - table.insert(ui.controls,buttons) - currentInterface = ui - - if UIPopupsManager.IsReady() then - - local notificationData = ShardReadPopupData.new() - notificationData.notificationName = 'base\\gameplay\\gui\\widgets\\notifications\\shard_notification.inkwidget' - notificationData.queueName = 'modal_popup' - notificationData.isBlocking = true - notificationData.useCursor = true - UIPopupsManager.ShowPopup(notificationData) - else - Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") - end - end + currentInterface = nil + + local ui = {} + ui.title = getLang("ui_manage_placed_item") + ui.tag = "placed_items_ui" + ui.controls = {} + + local area = {} + area.type = "scrollarea" + area.tag = "placed_items_ui_scroll" + area.trigger = {} + area.trigger.auto = {} + area.trigger.auto.name = "auto" + area.requirement = {} + + local requirement = {} + table.insert(requirement,"auto") + table.insert(area.requirement,requirement) + area.action = {} + area.margin = {} + area.style = {} + area.margin.top = 15 + area.style.fontsize = 30 + area.style.width = 1500 + area.style.height = 700 + table.insert(ui.controls,area) + area = {} + area.type = "vertical_area" + area.tag = "placed_items_ui_varea" + area.trigger = {} + area.trigger.auto = {} + area.trigger.auto.name = "auto" + area.requirement = {} + + local requirement = {} + table.insert(requirement,"auto") + table.insert(area.requirement,requirement) + area.action = {} + area.margin = {} + area.style = {} + area.margin.top = 15 + area.parent = "placed_items_ui_scroll" + area.style.fontsize = 30 + area.style.width = 1500 + area.style.height = 350 + table.insert(ui.controls,area) + + if(#currentItemSpawned > 0 ) then + + if selectedItem ~= nil then + + local label = {} + label.type = "label" + label.tag ="selected_item_lbl" + label.trigger = {} + label.trigger.auto = {} + label.trigger.auto.name = "auto" + label.margin = {} + label.style = {} + label.margin.top = 15 + label.style.fontsize = 35 + label.requirement = {} + + local requirement = {} + table.insert(requirement,"auto") + table.insert(label.requirement,requirement) + label.value = {} + label.value.type = "text" + label.value.value = "Selected : "..selectedItem.Title.."("..selectedItem.Id..")" + table.insert(ui.controls,label) + end + for i = 1, #currentItemSpawned do + + local mitems = currentItemSpawned[i] + + local buttons = {} + buttons.type = "button" + buttons.title = "Select "..mitems.Title.."("..mitems.Id..")" + buttons.tag =mitems.Tag.."_button_"..i + buttons.margin = {} + buttons.style = {} + buttons.margin.top = 15 + buttons.style.fontsize = 35 + buttons.style.width = 1000 + buttons.style.height = 100 + buttons.trigger = {} + buttons.trigger.auto = {} + buttons.trigger.auto.name = "auto" + buttons.requirement = {} + + local requirement = {} + table.insert(requirement,"auto") + table.insert(buttons.requirement,requirement) + buttons.action = {} + + local spawn_item = {} + spawn_item.name = "select_item" + spawn_item.value = mitems.Id + table.insert(buttons.action,spawn_item) + + local close_action = {} + close_action.name = "close_interface" + table.insert(buttons.action,close_action) + table.insert(ui.controls,buttons) + end + + local buttons = {} + buttons.type = "button" + buttons.title = "Unselect item" + buttons.tag ="unselect_button" + buttons.trigger = {} + buttons.trigger.auto = {} + buttons.trigger.auto.name = "auto" + buttons.margin = {} + buttons.style = {} + buttons.parent = "placed_items_ui_varea" + buttons.style.fontsize = 35 + buttons.style.width = 1450 + buttons.style.height = 100 + buttons.requirement = {} + + local requirement = {} + table.insert(requirement,"auto") + table.insert(buttons.requirement,requirement) + buttons.action = {} + + local spawn_item = {} + spawn_item.name = "unselect_item" + table.insert(buttons.action,spawn_item) + + local close_action = {} + close_action.name = "close_interface" + table.insert(buttons.action,close_action) + table.insert(ui.controls,buttons) + currentInterface = ui + + if UIPopupsManager.IsReady() then + + local notificationData = ShardReadPopupData.new() + notificationData.notificationName = 'base\\gameplay\\gui\\widgets\\notifications\\shard_notification.inkwidget' + notificationData.queueName = 'modal_popup' + notificationData.isBlocking = true + notificationData.useCursor = true + UIPopupsManager.ShowPopup(notificationData) + else + Game.GetPlayer():SetWarningMessage("Open and close Main menu before call an popup.") + end + end end --interact-- function cycleInteract() - --inputcount = inputcount +1 - getTriggeredActions() - currentInteractGroupIndex = currentInteractGroupIndex or 1 - inputInAction = false - - candisplayInteract = true - if currentPossibleInteractChunkIndex == 0 then - -- currentPossibleInteractChunkIndex = 1 - candisplayInteract = true - end - - if candisplayInteract then - currentPossibleInteractChunkIndex = currentPossibleInteractChunkIndex + 1 - - getTriggeredActionsDisplay() - - --logme(1,"000") - createInteraction(true) - end - - if currentPossibleInteractChunkIndex > #possibleInteractDisplay then - -- currentInteractGroupIndex = currentInteractGroupIndex + 1 - currentPossibleInteractChunkIndex = 0 - - -- if(currentInteractGroupIndex > #currentInteractGroup) then - -- currentInteractGroupIndex = 1 - -- end - - --Game.GetPlayer():SetWarningMessage(getLang("current_interact_group")..currentInteractGroup[currentInteractGroupIndex]) - end - - -- if GameController["interactionWidgetGameController"].currentOptions then - -- if GameController["interactionWidgetGameController"].id < 1 then - -- if currentDialogHub then - -- -- createInteraction(false) - -- createDialog(currentDialogHub.dial) - -- isdialogactivehub = true - -- end - -- else - -- --createInteraction(true) - -- isdialogactivehub = false - -- --logme(6,"tyu") - -- end - -- else - -- createInteraction(true) - -- isdialogactivehub = false - -- --logme(6,"tyuss") - -- end - - + --inputcount = inputcount +1 + getTriggeredActions() + currentInteractGroupIndex = currentInteractGroupIndex or 1 + inputInAction = false + + candisplayInteract = true + if currentPossibleInteractChunkIndex == 0 then + -- currentPossibleInteractChunkIndex = 1 + candisplayInteract = true + end + + if candisplayInteract then + currentPossibleInteractChunkIndex = currentPossibleInteractChunkIndex + 1 + + getTriggeredActionsDisplay() + + --logme(1,"000") + createInteraction(true) + end + + if currentPossibleInteractChunkIndex > #possibleInteractDisplay then + -- currentInteractGroupIndex = currentInteractGroupIndex + 1 + currentPossibleInteractChunkIndex = 0 + + -- if(currentInteractGroupIndex > #currentInteractGroup) then + -- currentInteractGroupIndex = 1 + -- end + + --Game.GetPlayer():SetWarningMessage(getLang("current_interact_group")..currentInteractGroup[currentInteractGroupIndex]) + end + + -- if GameController["interactionWidgetGameController"].currentOptions then + -- if GameController["interactionWidgetGameController"].id < 1 then + -- if currentDialogHub then + -- -- createInteraction(false) + -- createDialog(currentDialogHub.dial) + -- isdialogactivehub = true + -- end + -- else + -- --createInteraction(true) + -- isdialogactivehub = false + -- --logme(6,"tyu") + -- end + -- else + -- createInteraction(true) + -- isdialogactivehub = false + -- --logme(6,"tyuss") + -- end + + end function cycleInteractgroup() - inputcount = inputcount +1 - - logme(6,"possibleInteractDisplay"..#possibleInteractDisplay) - -- logme(6,actionValue) - - if currentPossibleInteractChunkIndex == 0 then - -- currentPossibleInteractChunkIndex = 1 - candisplayInteract = true - end - - if candisplayInteract then - currentPossibleInteractChunkIndex = currentPossibleInteractChunkIndex + 1 - - getTriggeredActionsDisplay() - - createInteraction(true) - end - - if currentPossibleInteractChunkIndex > #possibleInteractDisplay then - currentPossibleInteractChunkIndex = 0 - - if currentInteractGroupIndex > #currentInteractGroup then - currentInteractGroupIndex = 1 - end - - Game.GetPlayer():SetWarningMessage(getLang("current_interact_group")..currentInteractGroup[currentInteractGroupIndex]) - end - - if GameController["interactionWidgetGameController"].currentOptions ~= nil then - if GameController["interactionWidgetGameController"].id < 1 then - if currentDialogHub then - -- createInteraction(false) - createDialog(currentDialogHub.dial) - isdialogactivehub = true - end - else - --createInteraction(true) - isdialogactivehub = false - end - else - createInteraction(true) - isdialogactivehub = false - end + inputcount = inputcount +1 + + logme(6,"possibleInteractDisplay"..#possibleInteractDisplay) + -- logme(6,actionValue) + + if currentPossibleInteractChunkIndex == 0 then + -- currentPossibleInteractChunkIndex = 1 + candisplayInteract = true + end + + if candisplayInteract then + currentPossibleInteractChunkIndex = currentPossibleInteractChunkIndex + 1 + + getTriggeredActionsDisplay() + + createInteraction(true) + end + + if currentPossibleInteractChunkIndex > #possibleInteractDisplay then + currentPossibleInteractChunkIndex = 0 + + if currentInteractGroupIndex > #currentInteractGroup then + currentInteractGroupIndex = 1 + end + + Game.GetPlayer():SetWarningMessage(getLang("current_interact_group")..currentInteractGroup[currentInteractGroupIndex]) + end + + if GameController["interactionWidgetGameController"].currentOptions ~= nil then + if GameController["interactionWidgetGameController"].id < 1 then + if currentDialogHub then + -- createInteraction(false) + createDialog(currentDialogHub.dial) + isdialogactivehub = true + end + else + --createInteraction(true) + isdialogactivehub = false + end + else + createInteraction(true) + isdialogactivehub = false + end end function hideInteract() - - - interactionUI.hideHub() - + + + interactionUI.hideHub() + end ---Radio--- function playRadio() - - if(currentRadio ~= nil and currentRadio.data ~= nil) then - - if currentRadio.data.tracks ~= nil and #currentRadio.data.tracks > 0 then - - local canplay = true - - if(currentRadio.data.only_in_car == true) then - canplay = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - else - canplay = true - - end - - if(currentRadio.playedmusic == nil or (currentRadio.playedmusic ~= nil and (cyberscript.soundmanager[currentRadio.playedmusic.name] == nil or cyberscript.soundmanager[currentRadio.playedmusic.name].isplaying == false))) then - - if(currentRadio.playedmusic ~= nil) then - currentRadio.lastplayedmusic = currentRadio.playedmusic - - end - - currentRadio.isplaying = false - currentRadio.playedmusic = nil - - - end - - if(canplay and (currentRadio.playedmusic == nil))then - - local index = math.random(1,#currentRadio.data.tracks) - - local song = currentRadio.data.tracks[index] - - if(currentRadio.lastplayedmusic ~= nil) then - while(song.name == currentRadio.lastplayedmusic) do - - index = math.random(1,#currentRadio.data.tracks) - - song = currentRadio.data.tracks[index] - end - - - end - - currentRadio.isplaying = true - currentRadio.playedmusic = song - - - local actionlist = {} - - local action = {} - action = {} - action.name = "play_custom_sound" - action.value = song.name - action.isradio = true - - table.insert(actionlist,action) - runActionList(actionlist, "play_radio_radio_"..currentRadio.data.tag, "interact",false,"nothing",true) - else - - if(currentRadio.data.only_in_car == true) then - - local iscar = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - - if(iscar == false and (currentRadio.playedmusic ~= "" and currentRadio.playedmusic ~= nil)) then - - Stop(currentRadio.playedmusic.name) - currentRadio.isplaying = false - currentRadio.playedmusic = nil - end - - end - - - - end - end - end + + if(currentRadio ~= nil and currentRadio.data ~= nil) then + + if currentRadio.data.tracks ~= nil and #currentRadio.data.tracks > 0 then + + local canplay = true + + if(currentRadio.data.only_in_car == true) then + canplay = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + else + canplay = true + + end + + if(currentRadio.playedmusic == nil or (currentRadio.playedmusic ~= nil and (cyberscript.soundmanager[currentRadio.playedmusic.name] == nil or cyberscript.soundmanager[currentRadio.playedmusic.name].isplaying == false))) then + + if(currentRadio.playedmusic ~= nil) then + currentRadio.lastplayedmusic = currentRadio.playedmusic + + end + + currentRadio.isplaying = false + currentRadio.playedmusic = nil + + + end + + if(canplay and (currentRadio.playedmusic == nil))then + + local index = math.random(1,#currentRadio.data.tracks) + + local song = currentRadio.data.tracks[index] + + if(currentRadio.lastplayedmusic ~= nil) then + while(song.name == currentRadio.lastplayedmusic) do + + index = math.random(1,#currentRadio.data.tracks) + + song = currentRadio.data.tracks[index] + end + + + end + + currentRadio.isplaying = true + currentRadio.playedmusic = song + + + local actionlist = {} + + local action = {} + action = {} + action.name = "play_custom_sound" + action.value = song.name + action.isradio = true + + table.insert(actionlist,action) + runActionList(actionlist, "play_radio_radio_"..currentRadio.data.tag, "interact",false,"nothing",true) + else + + if(currentRadio.data.only_in_car == true) then + + local iscar = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + + if(iscar == false and (currentRadio.playedmusic ~= "" and currentRadio.playedmusic ~= nil)) then + + Stop(currentRadio.playedmusic.name) + currentRadio.isplaying = false + currentRadio.playedmusic = nil + end + + end + + + + end + end + end end function openRadio() - if GameController["PopupsManager"] and not popupActive then - popupActive = true - GameController["PopupsManager"]:SpawnVehicleRadioPopup() - end + if GameController["PopupsManager"] and not popupActive then + popupActive = true + GameController["PopupsManager"]:SpawnVehicleRadioPopup() + end end function playRandomfromRadio() - - if currentRadio.tracks ~= nil and #currentRadio.tracks > 0 then - - if(IsPlaying("music") == false) then - - local canplay = true - - if(autoplayincar) then - canplay = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - end - - if(canplay)then - - local index = math.random(1,#currentRadio.tracks) - - local song = currentRadio.tracks[index] - - if(shuffleall) then - local numitems = 0 -- find the size of the table - - for k,v in pairs(cyberscript.cache["radio"]) do - numitems = numitems + 1 - end - - local randval = math.random(1, numitems) -- get a random point - - local randentry - local count = 0 - - for k,v in pairs(cyberscript.cache["radio"]) do - count = count + 1 - if(count == randentry) then - currentRadio = v.data - break - end - end - - index = math.random(1,#currentRadio.tracks) - song = currentRadio.tracks[index] - end - - local sound = getSoundByNameNamespace(song.file,currentRadio.namespace) - - if(sound ~= nil) then - - local path = cyberscript.soundpath..sound.path - logme(6,path..sound.name) - PlaySound(sound.name,path,"music",currentRadioVolume) - - local message = SimpleScreenMessage.new() - message.message = "Currently Playing : "..sound.name.." From Radio "..currentRadio.name - message.isShown = true - - local blackboardDefs = Game.GetAllBlackboardDefs() - - local blackboardUI = Game.GetBlackboardSystem():Get(blackboardDefs.UI_Notifications) - blackboardUI:SetVariant( - blackboardDefs.UI_Notifications.OnscreenMessage, - ToVariant(message), - true - ) - end - end - else - - if(autoplayincar) then - - local iscar = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) - - if(iscar == false) then - logme(6,"stop music") - Stop("music") - end - end - end - end + + if currentRadio.tracks ~= nil and #currentRadio.tracks > 0 then + + if(IsPlaying("music") == false) then + + local canplay = true + + if(autoplayincar) then + canplay = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + end + + if(canplay)then + + local index = math.random(1,#currentRadio.tracks) + + local song = currentRadio.tracks[index] + + if(shuffleall) then + local numitems = 0 -- find the size of the table + + for k,v in pairs(cyberscript.cache["radio"]) do + numitems = numitems + 1 + end + + local randval = math.random(1, numitems) -- get a random point + + local randentry + local count = 0 + + for k,v in pairs(cyberscript.cache["radio"]) do + count = count + 1 + if(count == randentry) then + currentRadio = v.data + break + end + end + + index = math.random(1,#currentRadio.tracks) + song = currentRadio.tracks[index] + end + + local sound = getSoundByNameNamespace(song.file,currentRadio.namespace) + + if(sound ~= nil) then + + local path = cyberscript.soundpath..sound.path + logme(6,path..sound.name) + PlaySound(sound.name,path,"music",currentRadioVolume) + + local message = SimpleScreenMessage.new() + message.message = "Currently Playing : "..sound.name.." From Radio "..currentRadio.name + message.isShown = true + + local blackboardDefs = Game.GetAllBlackboardDefs() + + local blackboardUI = Game.GetBlackboardSystem():Get(blackboardDefs.UI_Notifications) + blackboardUI:SetVariant( + blackboardDefs.UI_Notifications.OnscreenMessage, + ToVariant(message), + true + ) + end + end + else + + if(autoplayincar) then + + local iscar = Game.GetWorkspotSystem():IsActorInWorkspot(Game.GetPlayer()) + + if(iscar == false) then + logme(6,"stop music") + Stop("music") + end + end + end + end end ---UI factory--- function WindowsItem() - - if(currentInterface["values"] == nil) then - currentInterface["values"] = {} - end - - if ImGui.Begin(currentInterface.title) then - ImGui.SetNextWindowPos(currentInterface.x, currentInterface.y, ImGuiCond.Appearing) -- set window position x, y - ImGui.SetNextWindowPos(currentInterface.x, currentInterface.y, ImGuiCond.FirstUseEver) -- set window position x, y - ImGui.SetNextWindowSize(currentInterface.width, currentInterface.heigh, ImGuiCond.Appearing) -- set window size w, h - ImGui.SetWindowSize(currentInterface.width, currentInterface.heigh) - - if ImGui.Button(lang.Close) then - openInterface = false - end - ImGui.Spacing() - ImGui.Spacing() - ImGui.Spacing() - windowsFactory() - ImGui.End() - end + + if(currentInterface["values"] == nil) then + currentInterface["values"] = {} + end + + if ImGui.Begin(currentInterface.title) then + ImGui.SetNextWindowPos(currentInterface.x, currentInterface.y, ImGuiCond.Appearing) -- set window position x, y + ImGui.SetNextWindowPos(currentInterface.x, currentInterface.y, ImGuiCond.FirstUseEver) -- set window position x, y + ImGui.SetNextWindowSize(currentInterface.width, currentInterface.heigh, ImGuiCond.Appearing) -- set window size w, h + ImGui.SetWindowSize(currentInterface.width, currentInterface.heigh) + + if ImGui.Button(lang.Close) then + openInterface = false + end + ImGui.Spacing() + ImGui.Spacing() + ImGui.Spacing() + windowsFactory() + ImGui.End() + end end function windowsFactory() - for i=1,#currentInterface.controls do - - if(currentInterface.controls[i].type == "sameline") then - ImGui.SameLine() - end - - if(currentInterface.controls[i].type == "linebreak") then - ImGui.Separator() - end - - if(currentInterface.controls[i].type ~= "sameline" and currentInterface.controls[i].type ~= "linebreak") then - - if(checkTriggerRequirement(currentInterface.controls[i]["requirement"],currentInterface.controls[i]["trigger"])) then - - if(currentInterface.controls[i].type == "text") then - - if(currentInterface.controls[i].value.type == "text") then - currentInterface["values"][currentInterface.controls[i].tag] = ImGui.InputText(currentInterface.controls[i].title, currentInterface["values"][currentInterface.controls[i].tag], 100, ImGuiInputTextFlags.AutoSelectAll) - elseif(currentInterface.controls[i].value.type == "variable") then - - local variable = getVariableKey(currentInterface.controls[i].value.tag,currentInterface.controls[i].value.key) - - if(variable== nil) then - variable = "" - end - currentInterface["values"][currentInterface.controls[i].tag] = ImGui.InputText(currentInterface.controls[i].title, variable, 100, ImGuiInputTextFlags.AutoSelectAll) - end - end - - if(currentInterface.controls[i].type == "label") then - - if(currentInterface.controls[i].value.type == "text") then - ImGui.TextWrapped(currentInterface.controls[i].value.value) - elseif(currentInterface.controls[i].value.type == "score") then - - local score = getScoreKey(currentInterface.controls[i].value.tag,currentInterface.controls[i].value.key) - - if(score== nil) then - score = 0 - end - ImGui.TextWrapped(score) - elseif(currentInterface.controls[i].value.type == "variable") then - - local variable = getVariableKey(currentInterface.controls[i].value.tag,currentInterface.controls[i].value.key) - - if(variable== nil) then - variable = "" - end - ImGui.TextWrapped(variable) - end - end - - if(currentInterface.controls[i].type == "number") then - - if(currentInterface.controls[i].value.type == "text") then - currentInterface["values"][currentInterface.controls[i].tag] = ImGui.InputFloat(currentInterface.controls[i].title, currentInterface.controls[i].value, 1, 10, "%.1f", ImGuiInputTextFlags.None) - elseif(currentInterface.controls[i].value.type == "score") then - - local score = getScoreKey(currentInterface.controls[i].value.tag,currentInterface.controls[i].value.key) - - if(score== nil) then - score = 0 - end - currentInterface["values"][currentInterface.controls[i].tag] = ImGui.InputFloat(currentInterface.controls[i].title, score, 1, 10, "%.1f", ImGuiInputTextFlags.None) - end - end - - if(currentInterface.controls[i].type == "button") then - - if ImGui.Button(currentInterface.controls[i].title) then - end - end - end - end - end + for i=1,#currentInterface.controls do + + if(currentInterface.controls[i].type == "sameline") then + ImGui.SameLine() + end + + if(currentInterface.controls[i].type == "linebreak") then + ImGui.Separator() + end + + if(currentInterface.controls[i].type ~= "sameline" and currentInterface.controls[i].type ~= "linebreak") then + + if(checkTriggerRequirement(currentInterface.controls[i]["requirement"],currentInterface.controls[i]["trigger"])) then + + if(currentInterface.controls[i].type == "text") then + + if(currentInterface.controls[i].value.type == "text") then + currentInterface["values"][currentInterface.controls[i].tag] = ImGui.InputText(currentInterface.controls[i].title, currentInterface["values"][currentInterface.controls[i].tag], 100, ImGuiInputTextFlags.AutoSelectAll) + elseif(currentInterface.controls[i].value.type == "variable") then + + local variable = getVariableKey(currentInterface.controls[i].value.tag,currentInterface.controls[i].value.key) + + if(variable== nil) then + variable = "" + end + currentInterface["values"][currentInterface.controls[i].tag] = ImGui.InputText(currentInterface.controls[i].title, variable, 100, ImGuiInputTextFlags.AutoSelectAll) + end + end + + if(currentInterface.controls[i].type == "label") then + + if(currentInterface.controls[i].value.type == "text") then + ImGui.TextWrapped(currentInterface.controls[i].value.value) + elseif(currentInterface.controls[i].value.type == "score") then + + local score = getScoreKey(currentInterface.controls[i].value.tag,currentInterface.controls[i].value.key) + + if(score== nil) then + score = 0 + end + ImGui.TextWrapped(score) + elseif(currentInterface.controls[i].value.type == "variable") then + + local variable = getVariableKey(currentInterface.controls[i].value.tag,currentInterface.controls[i].value.key) + + if(variable== nil) then + variable = "" + end + ImGui.TextWrapped(variable) + end + end + + if(currentInterface.controls[i].type == "number") then + + if(currentInterface.controls[i].value.type == "text") then + currentInterface["values"][currentInterface.controls[i].tag] = ImGui.InputFloat(currentInterface.controls[i].title, currentInterface.controls[i].value, 1, 10, "%.1f", ImGuiInputTextFlags.None) + elseif(currentInterface.controls[i].value.type == "score") then + + local score = getScoreKey(currentInterface.controls[i].value.tag,currentInterface.controls[i].value.key) + + if(score== nil) then + score = 0 + end + currentInterface["values"][currentInterface.controls[i].tag] = ImGui.InputFloat(currentInterface.controls[i].title, score, 1, 10, "%.1f", ImGuiInputTextFlags.None) + end + end + + if(currentInterface.controls[i].type == "button") then + + if ImGui.Button(currentInterface.controls[i].title) then + end + end + end + end + end end function createButton(name, text, fontsize,width,height) - - local button = inkCanvas.new() - button:SetName(name) - button:SetSize(width, height) - button:SetAnchorPoint(Vector2.new({ X = 0.5, Y = 0.5 })) - button:SetInteractive(true) - - local bg = inkImage.new() - bg:SetName('bg') - bg:SetAtlasResource(ResRef.FromName('base\\gameplay\\gui\\common\\shapes\\atlas_shapes_sync.inkatlas')) - bg:SetTexturePart('cell_bg') - bg:SetTintColor(HDRColor.new({ Red = 0.054902, Green = 0.054902, Blue = 0.090196, Alpha = 1.0 })) - bg:SetOpacity(0.8) - bg:SetAnchor(inkEAnchor.Fill) - bg.useNineSliceScale = true - bg.nineSliceScale = inkMargin.new({ left = 0.0, top = 0.0, right = 10.0, bottom = 0.0 }) - bg:Reparent(button, -1) - - local fill = inkImage.new() - fill:SetName('fill') - fill:SetAtlasResource(ResRef.FromName('base\\gameplay\\gui\\common\\shapes\\atlas_shapes_sync.inkatlas')) - fill:SetTexturePart('cell_bg') - fill:SetTintColor(HDRColor.new({ Red = 1.1761, Green = 0.3809, Blue = 0.3476, Alpha = 1.0 })) - fill:SetOpacity(0.0) - fill:SetAnchor(inkEAnchor.Fill) - fill.useNineSliceScale = true - fill.nineSliceScale = inkMargin.new({ left = 0.0, top = 0.0, right = 10.0, bottom = 0.0 }) - fill:Reparent(button, -1) - - local frame = inkImage.new() - frame:SetName('frame') - frame:SetAtlasResource(ResRef.FromName('base\\gameplay\\gui\\common\\shapes\\atlas_shapes_sync.inkatlas')) - frame:SetTexturePart('cell_fg') - frame:SetTintColor(HDRColor.new({ Red = 0.368627, Green = 0.964706, Blue = 1.0, Alpha = 1.0 })) - frame:SetOpacity(0.3) - frame:SetAnchor(inkEAnchor.Fill) - frame.useNineSliceScale = true - frame.nineSliceScale = inkMargin.new({ left = 0.0, top = 0.0, right = 10.0, bottom = 0.0 }) - frame:Reparent(button, -1) - - local label = inkText.new() - label:SetName('label') - label:SetFontFamily('base\\gameplay\\gui\\fonts\\raj\\raj.inkfontfamily') - label:SetFontStyle('Medium') - label:SetFontSize(fontsize) - label:SetLetterCase(textLetterCase.UpperCase) - label:SetTintColor(HDRColor.new({ Red = 1.1761, Green = 0.3809, Blue = 0.3476, Alpha = 1.0 })) - label:SetAnchor(inkEAnchor.Fill) - label:SetHorizontalAlignment(textHorizontalAlignment.Center) - label:SetVerticalAlignment(textVerticalAlignment.Center) - label:SetText(text) - label:Reparent(button, -1) - return button + + local button = inkCanvas.new() + button:SetName(name) + button:SetSize(width, height) + button:SetAnchorPoint(Vector2.new({ X = 0.5, Y = 0.5 })) + button:SetInteractive(true) + + local bg = inkImage.new() + bg:SetName('bg') + bg:SetAtlasResource(ResRef.FromName('base\\gameplay\\gui\\common\\shapes\\atlas_shapes_sync.inkatlas')) + bg:SetTexturePart('cell_bg') + bg:SetTintColor(HDRColor.new({ Red = 0.054902, Green = 0.054902, Blue = 0.090196, Alpha = 1.0 })) + bg:SetOpacity(0.8) + bg:SetAnchor(inkEAnchor.Fill) + bg.useNineSliceScale = true + bg.nineSliceScale = inkMargin.new({ left = 0.0, top = 0.0, right = 10.0, bottom = 0.0 }) + bg:Reparent(button, -1) + + local fill = inkImage.new() + fill:SetName('fill') + fill:SetAtlasResource(ResRef.FromName('base\\gameplay\\gui\\common\\shapes\\atlas_shapes_sync.inkatlas')) + fill:SetTexturePart('cell_bg') + fill:SetTintColor(HDRColor.new({ Red = 1.1761, Green = 0.3809, Blue = 0.3476, Alpha = 1.0 })) + fill:SetOpacity(0.0) + fill:SetAnchor(inkEAnchor.Fill) + fill.useNineSliceScale = true + fill.nineSliceScale = inkMargin.new({ left = 0.0, top = 0.0, right = 10.0, bottom = 0.0 }) + fill:Reparent(button, -1) + + local frame = inkImage.new() + frame:SetName('frame') + frame:SetAtlasResource(ResRef.FromName('base\\gameplay\\gui\\common\\shapes\\atlas_shapes_sync.inkatlas')) + frame:SetTexturePart('cell_fg') + frame:SetTintColor(HDRColor.new({ Red = 0.368627, Green = 0.964706, Blue = 1.0, Alpha = 1.0 })) + frame:SetOpacity(0.3) + frame:SetAnchor(inkEAnchor.Fill) + frame.useNineSliceScale = true + frame.nineSliceScale = inkMargin.new({ left = 0.0, top = 0.0, right = 10.0, bottom = 0.0 }) + frame:Reparent(button, -1) + + local label = inkText.new() + label:SetName('label') + label:SetFontFamily('base\\gameplay\\gui\\fonts\\raj\\raj.inkfontfamily') + label:SetFontStyle('Medium') + label:SetFontSize(fontsize) + label:SetLetterCase(textLetterCase.UpperCase) + label:SetTintColor(HDRColor.new({ Red = 1.1761, Green = 0.3809, Blue = 0.3476, Alpha = 1.0 })) + label:SetAnchor(inkEAnchor.Fill) + label:SetHorizontalAlignment(textHorizontalAlignment.Center) + label:SetVerticalAlignment(textVerticalAlignment.Center) + label:SetText(text) + label:Reparent(button, -1) + return button end ---Native Interaction--- function createInteractionChoice(action, title,icon,displaytype) - - local choiceData = InteractionChoiceData.new() - choiceData.localizedName = title - choiceData.inputAction = action - - if icon ~= nil then - - local iconrecord = TweakDBInterface.GetChoiceCaptionIconPartRecord("ChoiceCaptionParts."..icon) + + local choiceData = InteractionChoiceData.new() + choiceData.localizedName = title + choiceData.inputAction = action + + if icon ~= nil then + + local iconrecord = TweakDBInterface.GetChoiceCaptionIconPartRecord("ChoiceCaptionParts."..icon) local part = gameinteractionsChoiceCaption.new() part:AddPartFromRecord(iconrecord) choiceData.captionParts = part - end - - - - local choiceType = ChoiceTypeWrapper.new() - choiceData.type = choiceType - - - if displaytype ~= nil then + end + + + + local choiceType = ChoiceTypeWrapper.new() + choiceData.type = choiceType + + + if displaytype ~= nil then local choiceType = gameinteractionsChoiceTypeWrapper.new() choiceType:SetType(displaytype) - choiceData.type = choiceType - end - - - return choiceData + choiceData.type = choiceType + end + + + return choiceData end function createInteractionHub(active) - - if(choiceHubData == nil) then - choiceHubData = gameinteractionsvisInteractionChoiceHubData.new() - choiceHubData.active =true - choiceHubData.flags = EVisualizerDefinitionFlags.Undefined - choiceHubData.title = "possibleInteractList" --'Test Interaction Hub' - end - choiceHubData.active = active - - local choices = {} - possibleInteractdisplayUI = {} - -- table.insert(choices, createInteraction('Choice1', 'Blow up the sky')) - - if(active == true) then - - if(#loadInteract > 0) then - for z=1,#loadInteract do - local interact = cyberscript.cache["interact"][loadInteract[z]].data - if(interact.type == nil or interact.type == "interact") then - - checkContext(interact) - - - - - table.insert(choices, createInteractionChoice('Choice'..z, interact.tag,interact.icon,interact.displaytype)) - end - end - else - - if possibleInteractDisplay ~= nil and currentPossibleInteractChunkIndex ~= nil and #possibleInteractDisplay > 0 and possibleInteractDisplay[currentPossibleInteractChunkIndex] ~= nil then - for z=1,#possibleInteractDisplay[currentPossibleInteractChunkIndex] do - - local interact = possibleInteractDisplay[currentPossibleInteractChunkIndex][z] - checkContext(interact) - - - if(interact.type == nil or interact.type == "interact") then - interact.input = z - table.insert(choices, createInteractionChoice('Choice'..z, interact.tag,interact.icon,interact.displaytype)) - else - showInputHint(interact.key, getLang(interact.name), 1, interact.hold, interact.tag) - end - end - - end - end - else - choiceHubData.id = 0 - math.random(50,1000) - end - choiceHubData.choices = choices + + if(choiceHubData == nil) then + choiceHubData = gameinteractionsvisInteractionChoiceHubData.new() + choiceHubData.active =true + choiceHubData.flags = EVisualizerDefinitionFlags.Undefined + choiceHubData.title = "possibleInteractList" --'Test Interaction Hub' + end + choiceHubData.active = active + + local choices = {} + possibleInteractdisplayUI = {} + -- table.insert(choices, createInteraction('Choice1', 'Blow up the sky')) + + if(active == true) then + + if(#loadInteract > 0) then + for z=1,#loadInteract do + local interact = cyberscript.cache["interact"][loadInteract[z]].data + if(interact.type == nil or interact.type == "interact") then + + checkContext(interact) + + + + + table.insert(choices, createInteractionChoice('Choice'..z, interact.tag,interact.icon,interact.displaytype)) + end + end + else + + if possibleInteractDisplay ~= nil and currentPossibleInteractChunkIndex ~= nil and #possibleInteractDisplay > 0 and possibleInteractDisplay[currentPossibleInteractChunkIndex] ~= nil then + for z=1,#possibleInteractDisplay[currentPossibleInteractChunkIndex] do + + local interact = possibleInteractDisplay[currentPossibleInteractChunkIndex][z] + checkContext(interact) + + + if(interact.type == nil or interact.type == "interact") then + interact.input = z + table.insert(choices, createInteractionChoice('Choice'..z, interact.tag,interact.icon,interact.displaytype)) + else + showInputHint(interact.key, getLang(interact.name), 1, interact.hold, interact.tag) + end + end + + end + end + else + choiceHubData.id = 0 - math.random(50,1000) + end + choiceHubData.choices = choices end function prepareVisualizersInfo(hub) - - local visualizersInfo = VisualizersInfo.new() - visualizersInfo.activeVisId = hub.id - visualizersInfo.visIds = { hub.id } - return visualizersInfo + + local visualizersInfo = VisualizersInfo.new() + visualizersInfo.activeVisId = hub.id + visualizersInfo.visIds = { hub.id } + return visualizersInfo end function createInteraction(active) - - local blackboardDefs = Game.GetAllBlackboardDefs() - - local interactionBB = Game.GetBlackboardSystem():Get(blackboardDefs.UIInteractions) - - local value = FromVariant(interactionBB:GetVariant(blackboardDefs.UIInteractions.InteractionChoiceHub)) - createInteractionHub(active) - - local interactionHub = choiceHubData - - local visualizersInfo = prepareVisualizersInfo(interactionHub) - interactionBB:SetVariant(blackboardDefs.UIInteractions.InteractionChoiceHub, ToVariant(interactionHub), true) - interactionBB:SetVariant(blackboardDefs.UIInteractions.VisualizersInfo, ToVariant(visualizersInfo), true) + + local blackboardDefs = Game.GetAllBlackboardDefs() + + local interactionBB = Game.GetBlackboardSystem():Get(blackboardDefs.UIInteractions) + + local value = FromVariant(interactionBB:GetVariant(blackboardDefs.UIInteractions.InteractionChoiceHub)) + createInteractionHub(active) + + local interactionHub = choiceHubData + + local visualizersInfo = prepareVisualizersInfo(interactionHub) + interactionBB:SetVariant(blackboardDefs.UIInteractions.InteractionChoiceHub, ToVariant(interactionHub), true) + interactionBB:SetVariant(blackboardDefs.UIInteractions.VisualizersInfo, ToVariant(visualizersInfo), true) end ---Native Dialog--- function createDialog(dialog) - isdialogactivehub = true - candisplayInteract = false - --createInteraction(false) - - - currentDialogHub = {} - currentDialogHub.hub= {} - currentDialogHub.dial = {} - currentDialogHub.index = 1 - - currentDialogHub.dial = dialog - - local choicelist = {} - - for i = 1, #dialog.options do - - local option = dialog.options[i] - - local icon = nil - if option.icon ~= nil then - icon = TweakDBInterface.GetChoiceCaptionIconPartRecord("ChoiceCaptionParts."..option.icon) - end - - local choice1 = interactionUI.createChoice(getLang(option.description), icon , gameinteractionsChoiceType.Selected) -- Icon and choiceType are optional - table.insert(choicelist,choice1) - end - - - + isdialogactivehub = true + candisplayInteract = false + --createInteraction(false) + + + currentDialogHub = {} + currentDialogHub.hub= {} + currentDialogHub.dial = {} + currentDialogHub.index = 1 + + currentDialogHub.dial = dialog + + local choicelist = {} + + for i = 1, #dialog.options do + + local option = dialog.options[i] + + local icon = nil + if option.icon ~= nil then + icon = TweakDBInterface.GetChoiceCaptionIconPartRecord("ChoiceCaptionParts."..option.icon) + end + + local choice1 = interactionUI.createChoice(getLang(option.description), icon , gameinteractionsChoiceType.Selected) -- Icon and choiceType are optional + table.insert(choicelist,choice1) + end + + + -- Setup, set and show hub local hub = interactionUI.createHub(getDialogOwner(dialog.speaker), choicelist,id) -- Create hub and give it the list of choices - - interactionUI.setupHub(hub) -- Set the hub - + + interactionUI.setupHub(hub) -- Set the hub + interactionUI.showHub() -- Show the previously set hub - currentDialogHub.hub = hub + currentDialogHub.hub = hub -- Setup callbacks - - for i = 1, #dialog.options do - - --print(i) - interactionUI.callbacks[i] = function() - local option = dialog.options[i] - if(option.requirement == nil or checkTriggerRequirement(option.requirement,option.trigger))then - - ClickOnDialog(option,dialog.speaker,"speak") - - interactionUI.hideHub() - - end - end - - end - - - - if(playerisstopped == false) then - StatusEffectHelper.ApplyStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") - playerisstopped = true - end + + for i = 1, #dialog.options do + + --print(i) + interactionUI.callbacks[i] = function() + local option = dialog.options[i] + if(option.requirement == nil or checkTriggerRequirement(option.requirement,option.trigger))then + + ClickOnDialog(option,dialog.speaker,"speak") + + interactionUI.hideHub() + + end + end + + end + + + + if(playerisstopped == false) then + StatusEffectHelper.ApplyStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoCombat") + playerisstopped = true + end end function createDialogHub(dialogIIRP,active) - - local choiceHubDataDial = gameinteractionsvisDialogChoiceHubs.new() - - local choiceHubs = {} - - if(active == true) then - table.insert(choiceHubs ,createDialogTitle(dialogIIRP,active)) - end - choiceHubDataDial.choiceHubs = choiceHubs - return choiceHubDataDial + + local choiceHubDataDial = gameinteractionsvisDialogChoiceHubs.new() + + local choiceHubs = {} + + if(active == true) then + table.insert(choiceHubs ,createDialogTitle(dialogIIRP,active)) + end + choiceHubDataDial.choiceHubs = choiceHubs + return choiceHubDataDial end function createDialogTitle(dialogIIRP,active) - - local dialog = gameinteractionsvisListChoiceHubData.new() - dialog.id = 0 - math.random(50,1000) - - if(active == true) then - dialog.activityState =Enum.new('gameinteractionsvisEVisualizerActivityState', 'Active') - else - dialog.activityState =Enum.new('gameinteractionsvisEVisualizerActivityState', 'None') - end - - dialog.flags = Enum.new('gameinteractionsvisEVisualizerDefinitionFlags', 'HeadlineSelection') - dialog.isPhoneLockActive = true - dialog.title = getDialogOwner(dialogIIRP.speaker) - dialog.hubPriority = 0 - dialog.activityState = Enum.new('gameinteractionsvisEVisualizerActivityState', 'Active') - - local choices = {} - for i = 1, #dialogIIRP.options do - - local option = dialogIIRP.options[i] - dialogIIRP.options[i].input = i - table.insert(choices, creatDialogChoice('Choice'..i, getLang(option.description),option.icon,option.choicetype)) - end - dialog.choices = choices - return dialog + + local dialog = gameinteractionsvisListChoiceHubData.new() + dialog.id = 0 - math.random(50,1000) + + if(active == true) then + dialog.activityState =Enum.new('gameinteractionsvisEVisualizerActivityState', 'Active') + else + dialog.activityState =Enum.new('gameinteractionsvisEVisualizerActivityState', 'None') + end + + dialog.flags = Enum.new('gameinteractionsvisEVisualizerDefinitionFlags', 'HeadlineSelection') + dialog.isPhoneLockActive = true + dialog.title = getDialogOwner(dialogIIRP.speaker) + dialog.hubPriority = 0 + dialog.activityState = Enum.new('gameinteractionsvisEVisualizerActivityState', 'Active') + + local choices = {} + for i = 1, #dialogIIRP.options do + + local option = dialogIIRP.options[i] + dialogIIRP.options[i].input = i + table.insert(choices, creatDialogChoice('Choice'..i, getLang(option.description),option.icon,option.choicetype)) + end + dialog.choices = choices + return dialog end function getDialogOwner(speaker) - - local result = getLang(speaker) - - if(speaker == "any") then - if(currentNPC ~= nil) then - result = currentNPC.Names - elseif(currentStar ~= nil) then - result = currentStar.Names - else - result = getLang(speaker) - end - end - - return result - + + local result = getLang(speaker) + + if(speaker == "any") then + if(currentNPC ~= nil) then + result = currentNPC.Names + elseif(currentStar ~= nil) then + result = currentStar.Names + else + result = getLang(speaker) + end + end + + return result + end function creatDialogChoice(action, title, icon, optionchoice) - - local choiceData = gameinteractionsvisListChoiceData.new() - choiceData.localizedName = getLang(title) - choiceData.inputAction = action - - local choiceType = gameinteractionsChoiceTypeWrapper.new() - choiceType:SetType(choiceType,Enum.new('gameinteractionsChoiceType', 'Inactive')) - - if icon ~= nil and icon ~= "" then - local iconrecord = TweakDBInterface.GetChoiceCaptionIconPartRecord("ChoiceCaptionParts."..icon) + + local choiceData = gameinteractionsvisListChoiceData.new() + choiceData.localizedName = getLang(title) + choiceData.inputAction = action + + local choiceType = gameinteractionsChoiceTypeWrapper.new() + choiceType:SetType(choiceType,Enum.new('gameinteractionsChoiceType', 'Inactive')) + + if icon ~= nil and icon ~= "" then + local iconrecord = TweakDBInterface.GetChoiceCaptionIconPartRecord("ChoiceCaptionParts."..icon) local part = gameinteractionsChoiceCaption.new() part:AddPartFromRecord(iconrecord) choiceData.captionParts = part - end - - - if optionchoice ~= nil then + end + + + if optionchoice ~= nil then local choiceType = gameinteractionsChoiceTypeWrapper.new() choiceType:SetType(optionchoice) - choiceData.type = choiceType - end - - choiceData.type = choiceType - return choiceData + choiceData.type = choiceType + end + + choiceData.type = choiceType + return choiceData end function removeDialog() - - local blackboardDefs = Game.GetAllBlackboardDefs() - - local interactionBB = Game.GetBlackboardSystem():Get(blackboardDefs.UIInteractions) - interactionBB:SetVariant(blackboardDefs.UIInteractions.DialogChoiceHubs, ToVariant(gameinteractionsvisDialogChoiceHubs.new()), true) - - if(playerisstopped == true) then - StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.FistFight") - playerisstopped = false - end + + local blackboardDefs = Game.GetAllBlackboardDefs() + + local interactionBB = Game.GetBlackboardSystem():Get(blackboardDefs.UIInteractions) + interactionBB:SetVariant(blackboardDefs.UIInteractions.DialogChoiceHubs, ToVariant(gameinteractionsvisDialogChoiceHubs.new()), true) + + if(playerisstopped == true) then + StatusEffectHelper.RemoveStatusEffect(Game.GetPlayer(), "GameplayRestriction.FistFight") + playerisstopped = false + end end diff --git a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/var.lua b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/var.lua index 0fbabeb..32e1cb1 100644 --- a/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/var.lua +++ b/bin/x64/plugins/cyber_engine_tweaks/mods/cyberscript/mod/modules/var.lua @@ -5,59 +5,59 @@ cyberscript.module = cyberscript.module +1 --functions function dump(o) - if type(o) == 'table' then - local s = '{ ' - for k,v in pairs(o) do - if type(k) ~= 'number' then k = '"'..k..'"' end - s = s .. '['..k..'] = ' .. dump(v) .. ',' - end - return s .. '} ' - else - return tostring(o) - end + if type(o) == 'table' then + local s = '{ ' + for k,v in pairs(o) do + if type(k) ~= 'number' then k = '"'..k..'"' end + s = s .. '['..k..'] = ' .. dump(v) .. ',' + end + return s .. '} ' + else + return tostring(o) + end end function catch(what) - return what[1] + return what[1] end function try(what) - status, result = pcall(what[1]) - if not status then - what[2](result) - end - return result + status, result = pcall(what[1]) + if not status then + what[2](result) + end + return result end function trydecodeJSOn(text, file,path) - local jsontext = nil - if(path == nil) then - path = "Unknown" - end - try { - function() - jsontext = json.decode(text) - - end, - catch { - function(error) - - logme(1,'Error decoding JSON : '..error.." ( path : "..path,true) - file:close() - end - } - } - return jsontext + local jsontext = nil + if(path == nil) then + path = "Unknown" + end + try { + function() + jsontext = json.decode(text) + + end, + catch { + function(error) + + logme(1,'Error decoding JSON : '..error.." ( path : "..path,true) + file:close() + end + } + } + return jsontext end function Enume(t) - local e = { enums = t } - return setmetatable(e, enummt) + local e = { enums = t } + return setmetatable(e, enummt) end function isSameInstance(a, b) - return Game['OperatorEqual;IScriptableIScriptable;Bool'](a, b) + return Game['OperatorEqual;IScriptableIScriptable;Bool'](a, b) end @@ -65,33 +65,33 @@ function spairs(t, order) -- collect the keys local keys = {} for k in pairs(t) do keys[#keys+1] = k end - + -- if order function given, sort by it by passing the table and keys a, b, -- otherwise just sort the keys if order then table.sort(keys, function(a,b) return order(t, a, b) end) - else + else --table.sort(keys) - end - + end + -- return the iterator function local i = 0 return function() i = i + 1 if keys[i] then return keys[i], t[keys[i]] - end - end + end + end end function getMainStash() - - local stashId = NewObject('entEntityID') - stashId.hash = "" - - return Game.FindEntityByID(stashId) - - + + local stashId = NewObject('entEntityID') + stashId.hash = "" + + return Game.FindEntityByID(stashId) + + end function Delta(from, to) @@ -99,7 +99,7 @@ function Delta(from, to) end function Vector4Add(a, b) - return Vector4.new(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w) + return Vector4.new(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w) end @@ -109,919 +109,919 @@ end function resetVar() - - - cyberscript.soundmanager={} - - - - editorAnimName = "add__stand__2h_front__01__dynamic" - editorAnimRepo = "man_base" - editorAnimTag = "lookatnpc" - editorEntName = "base\\amm_workspots\\entity\\workspot_anim.ent" - editorWKName = "amm_workspot_custom_base" - editorAnimx = 0 - editorAnimy = 0 - editorAnimz = 0 - - animsearch = "" - forcecrashSEE = false - recordRotationOnlypos = {} - - recordRotationOnlypos.x = 0 - recordRotationOnlypos.y = 0 - recordRotationOnlypos.z = 0 - - hotreload = false - ScrollSpeed = 0.020 - ScriptedEntityAffinity = false - AmbushMin = 5 - AmbushMax = 10 - AmbushEnabled = true - AutoAmbush = true - GangWarsEnabled = true - AutoRefreshDatapack = true + + + cyberscript.soundmanager={} + + + + editorAnimName = "add__stand__2h_front__01__dynamic" + editorAnimRepo = "man_base" + editorAnimTag = "lookatnpc" + editorEntName = "base\\amm_workspots\\entity\\workspot_anim.ent" + editorWKName = "amm_workspot_custom_base" + editorAnimx = 0 + editorAnimy = 0 + editorAnimz = 0 + + animsearch = "" + forcecrashSEE = false + recordRotationOnlypos = {} + + recordRotationOnlypos.x = 0 + recordRotationOnlypos.y = 0 + recordRotationOnlypos.z = 0 + + hotreload = false + ScrollSpeed = 0.020 + ScriptedEntityAffinity = false + AmbushMin = 5 + AmbushMax = 10 + AmbushEnabled = true + AutoAmbush = true + GangWarsEnabled = true + AutoRefreshDatapack = true - playerNoticed = false - playerTargeted = false - entityTargetPlayer = {} - displayHUD = {} - CurrentPOIDetectionRange = 10 - AutoCheckPOI = true - editorCurrentVariableSearch = "" - editorCurrentVariableKeySearch = "" - PlayerisHitten = false - spawntablecount = {} - moddisabled = false - cachedespawn = {} - - poi_district = {} - poi_subdistrict = {} - poi_type = {} - poi_tag = {} - - - anim_rigs_list = {} - - - currentObjectiveId = 0 - - - - - local reader = dir("mod/data/anims/workspot") - if(reader ~= nil) then - for i=1, #reader do - if(tostring(reader[i].type) == "file" and string.match(tostring(reader[i].name), ".json")) then - local f = assert(io.open("mod/data/anims/workspot/"..reader[i].name)) - - lines = f:read("*a") - - encdo = lines - f:close() - - - local mytable = trydecodeJSOn(encdo, f ,"mod/data/anims/workspot/"..reader[i].name) - anim_rigs_list[reader[i].name:gsub(".json", "")] = mytable - - - end - end - end - - - - - datapackObjectType = { - "character", - "circuit", - "codex", - "corpo", - "choice", - "event", - "faction", - "fixer", - "functions", - "help", - "housing", - "housing_template", - "hud", - "interact", - "interfaces", - "lang", - "mission", - "node", - "npc", - "path", - "phone_dialog", - "place", - "poi", - "radio", - "scene", - "setting", - "shard", - "sound", - "texture", - "webpage", - "email", - "quickhack", - "garage", - "ai", - "aitemplate", + playerNoticed = false + playerTargeted = false + entityTargetPlayer = {} + displayHUD = {} + CurrentPOIDetectionRange = 10 + AutoCheckPOI = true + editorCurrentVariableSearch = "" + editorCurrentVariableKeySearch = "" + PlayerisHitten = false + spawntablecount = {} + moddisabled = false + cachedespawn = {} + + poi_district = {} + poi_subdistrict = {} + poi_type = {} + poi_tag = {} + + + anim_rigs_list = {} + + + currentObjectiveId = 0 + + + + + local reader = dir("mod/data/anims/workspot") + if(reader ~= nil) then + for i=1, #reader do + if(tostring(reader[i].type) == "file" and string.match(tostring(reader[i].name), ".json")) then + local f = assert(io.open("mod/data/anims/workspot/"..reader[i].name)) + + lines = f:read("*a") + + encdo = lines + f:close() + + + local mytable = trydecodeJSOn(encdo, f ,"mod/data/anims/workspot/"..reader[i].name) + anim_rigs_list[reader[i].name:gsub(".json", "")] = mytable + + + end + end + end + + + + + datapackObjectType = { + "character", + "circuit", + "codex", + "corpo", + "choice", + "event", + "faction", + "fixer", + "functions", + "help", + "housing", + "housing_template", + "hud", + "interact", + "interfaces", + "lang", + "mission", + "node", + "npc", + "path", + "phone_dialog", + "place", + "poi", + "radio", + "scene", + "setting", + "shard", + "sound", + "texture", + "webpage", + "email", + "quickhack", + "garage", + "ai", + "aitemplate", "tweakflat", "animpack" - - } + + } cyberscript.datapackObjectType = datapackObjectType - cacheupdate = false - passwordView =ImGuiInputTextFlags.Password - menuName = "CyberScript" - debugPrintLevel = 5 - showLog = false - onlineInstanceCreation = false - onlineGuildCreation = false - onlineInstanceUpdate = false - onlineGuildUpdate = false - togglehousing = true - onlineInstancePlaceCreation = false - onlineShootMessage = false - CreateInstance={} - CreateGuild={} - CreateInstancePlace={} - UpdateInstance={} - UpdateGuild={} - instancePrivacy ={ "Public", "Private", "Secret (Private with password)"} - CurrentFriendTag ="" - selectedUser = {} - selectedGuild = {} - selectedGuildUser = {} - selectedUser.data = {} - currentPlaceTag = {} - selectedFriend = {} - selectedFriend.data = {} - settingsTables = {} - pox = 0 - poy = 0 - JackFlightJackFlight = false - poz = 0 - sliderPathTarget = 1 - recorderEntity = "player" - recorderPlayerCamera = false - recorderEntityList ={ "player", "mounted_vehicle","player_entity","player_camera" } - pathPlayerEntityList ={ "player", "mounted_vehicle","editor_cam","lookat" } - scenepov ={ "free", "entity" } - scenepovtype = "free" - editorcam = false - loadInteract = {} - moveX=0 - moveY=0 - moveZ=0 - debugOptions= false - currentInterfaceWidget= {} - - arrayItems = {} - arrayPnjDb = {} - arrayPhoneNPC = {} - - - arrayBoundedEntity = {} - logrecordlevel =3 - currentScannerItem = nil - currentScannerEntity = nil - - - - contractTypeLevel = 3 -- gameJournalQuestType.Contract - maxNestedLevel = 7 - - fetcheddata = nil - npcpreventionlimit = 99999 - - editHousingTemplateX = 0 - editHousingTemplateY = 0 - editHousingTemplateZ = 0 - - editHousingTemplateYaw = 0 - editHousingTemplatePitch = 0 - editHousingTemplateRoll = 0 - - editPOIlocation = "" - - editorCurrentScore = "" - editorCurrentScoreKey = "" - editorCurrentScoreValue = 0 - - - editorCurrentVariable = "" - editorCurrentVariableKey = "" - editorCurrentVariableValue = "" - - pathOffsetX = 0 - pathOffsetY = 0 - pathOffsetZ = 0 - enableCustomQuest = true - - Immortal = false - InfiniteStaminas = false - - RamUpgrade = false - + cacheupdate = false + passwordView =ImGuiInputTextFlags.Password + menuName = "CyberScript" + debugPrintLevel = 5 + showLog = false + onlineInstanceCreation = false + onlineGuildCreation = false + onlineInstanceUpdate = false + onlineGuildUpdate = false + togglehousing = true + onlineInstancePlaceCreation = false + onlineShootMessage = false + CreateInstance={} + CreateGuild={} + CreateInstancePlace={} + UpdateInstance={} + UpdateGuild={} + instancePrivacy ={ "Public", "Private", "Secret (Private with password)"} + CurrentFriendTag ="" + selectedUser = {} + selectedGuild = {} + selectedGuildUser = {} + selectedUser.data = {} + currentPlaceTag = {} + selectedFriend = {} + selectedFriend.data = {} + settingsTables = {} + pox = 0 + poy = 0 + JackFlightJackFlight = false + poz = 0 + sliderPathTarget = 1 + recorderEntity = "player" + recorderPlayerCamera = false + recorderEntityList ={ "player", "mounted_vehicle","player_entity","player_camera" } + pathPlayerEntityList ={ "player", "mounted_vehicle","editor_cam","lookat" } + scenepov ={ "free", "entity" } + scenepovtype = "free" + editorcam = false + loadInteract = {} + moveX=0 + moveY=0 + moveZ=0 + debugOptions= false + currentInterfaceWidget= {} + + arrayItems = {} + arrayPnjDb = {} + arrayPhoneNPC = {} + + + arrayBoundedEntity = {} + logrecordlevel =3 + currentScannerItem = nil + currentScannerEntity = nil + + + + contractTypeLevel = 3 -- gameJournalQuestType.Contract + maxNestedLevel = 7 + + fetcheddata = nil + npcpreventionlimit = 99999 + + editHousingTemplateX = 0 + editHousingTemplateY = 0 + editHousingTemplateZ = 0 + + editHousingTemplateYaw = 0 + editHousingTemplatePitch = 0 + editHousingTemplateRoll = 0 + + editPOIlocation = "" + + editorCurrentScore = "" + editorCurrentScoreKey = "" + editorCurrentScoreValue = 0 + + + editorCurrentVariable = "" + editorCurrentVariableKey = "" + editorCurrentVariableValue = "" + + pathOffsetX = 0 + pathOffsetY = 0 + pathOffsetZ = 0 + enableCustomQuest = true + + Immortal = false + InfiniteStaminas = false + + RamUpgrade = false + - Player_Sprint_Multiplier = 1 --Default is 1 IMPORTANT as of 1.3, movement speed is capped somewhere. - Player_Run_Multiplier = 1 --Default 1 - Jump_Height = 1 --Default 1 - Double_Jump_Height = 1 --Default 1 - - CurrentStock = nil - moveRoll=0 - movePitch=0 - moveYaw=0 - - currentScene = nil - tempdatapack = nil - playerisstopped = false - id = false - enabled = false - grabbed = false - objPush = false - objPull = false - target = nil - grabbedTarget = nil - testObject = nil - playerOldPos = nil - objectDist = 0 - interactautohide = true - reloadCET = false - ambush_limit_min = 15000 -- 5min15 - ambush_limit_max = 30000 -- 10min30 - AutoRefreshDatapack = false - updateinprogress = false - updatefinished = false - currentInputHintList = {} - needupdate = false + Player_Sprint_Multiplier = 1 --Default is 1 IMPORTANT as of 1.3, movement speed is capped somewhere. + Player_Run_Multiplier = 1 --Default 1 + Jump_Height = 1 --Default 1 + Double_Jump_Height = 1 --Default 1 + + CurrentStock = nil + moveRoll=0 + movePitch=0 + moveYaw=0 + + currentScene = nil + tempdatapack = nil + playerisstopped = false + id = false + enabled = false + grabbed = false + objPush = false + objPull = false + target = nil + grabbedTarget = nil + testObject = nil + playerOldPos = nil + objectDist = 0 + interactautohide = true + reloadCET = false + ambush_limit_min = 15000 -- 5min15 + ambush_limit_max = 30000 -- 10min30 + AutoRefreshDatapack = false + updateinprogress = false + updatefinished = false + currentInputHintList = {} + needupdate = false - arrayroom = {} - arrayNPCInteract ={} - cyberscript.customHouse = true - initFinished = false - saveLocationEnabled = false - locationWindowsIsVisible = true - fixerIsSpawn = false - isFadeIn = false - canwaitend = false - ExecPauseMenu = false - testTag = "" - isReady = false - currentTime = {} - phonedFixer = false - currentreason = 4 - isdead = false - inMenu = false - ActiveMenu = nil - ActiveSubMenu = nil - inScanner = false - targetObject = nil - currentPhoneCall = nil - activeMetroDisplay = false - freezeCamera = false - TakeAIVehicule = false - objLook = nil - objLookIsVehicule = false - interactKey = false - cetkeyused = false - nextkey = false - multiName = "" - editorView = {} - editorView.x = 0 - editorView.y = 0 - editorView.z = 0 - editorView.roll = 0 - editorView.pitch = 0 - editorView.yaw = 0 - editorFreeze = false - pitch = 0 - yaw = 0 - AlwaysShowDefaultWindows = 1 - SoundManager = nil - fademessage = "Never Fade Away..." - opacity = 1 - next_ambush = 0 - isGameLoaded = false - nopes = {} - nope = {} - ModIsLoaded = true - SaveisLoaded = false - cyberscript.soundpath = "json\\datapack\\" - cyberscript.autoload = false - tick = 0 - ticktimer = 0 - cetVer = 1.12 - pcWasOpen = false - LastChoiceActionName = nil - inputInAction = false - ActivecustomMappin = nil - ActiveFastTravelMappin = nil - SelectedMappinHouse = nil - SelectedMappinMetro = nil - SelectedScriptMappin = nil - isdialogactivehub = false - candisplayInteract = true - forcedialog = false - myobs = {} - myDialogHubLogicController = {} - lastHubId = 0 - nativeSettings = nil - nativesettingEnabled = false - Keystone_currentSelectedDatapack = nil - recordingMode = false - BrowserCustomPlace = nil - mpvehicletick = 0 - BraindanceGameController = nil - locationWindowsX = 35 - locationWindowsY = 355 - - currentHouseCenter = nil - newHousingTemplateTag = "" - newHousingTemplateName = "" - newHousingTemplatePrice = 0 - newHousingTemplateDescription = "" - newHousingTemplateTarget = "" - - menuWindowsX = 400 - menuWindowsY = 200 - currentHousingTemplate = nil - currentHousingTemplatetag = "" - currentHousing = nil - currentHousingtag="" - menuFrameX = 400 - menuFrameY = 200 - - menuBTNX = 180 - menuBTNY = 150 - - menuRowX = menuFrameX - menuRowY = 150 - - menufont= 1.5 - currentselectedItemIndex = 1 - currentInterface = nil - - choiceHubData = nil - - currentpoi = nil - - onlineReceiver = nil - onlineMessageContent = "" - onlineMessagePopup = false - onlineWhisperPopup = false - onlineMessagePopupFirstUse = true - - - gameStatModifierType = {"Additive","AdditiveMultiplier","Multiplier"} - - - currentLoadedTexture = {} - - currentHelp = nil - currentHelpIndex = 1 - local phonewaitmessage = "Connecting to 10.5.6.189.." - local animcounter = 0 - local tranpsarency = 0 - openHelpMenu = false - openHelp = false - openJournalMenu = false - inputquest = "joytoy_quest_radiant" - inputscore = "myscore" - inputvariable = "myvariable" - inputkey = "mykey" - openInterface = false - defaultIsOpen = true - currentDialogHub = nil - currentInteractionHub = nil - currentPossibleInteractChunkIndex = 1 - possibleInteractdisplay = {} - isGodMod = false - lastTargetKilled = nil - irpmenu = {} - possibleinteractchunk = {} - irpmenu.main = true - - irpmenu.contact = false - irpmenu.fixer = false - irpmenu.service = false - - irpmenu.social = false - irpmenu.address = false - irpmenu.radio = false - - irpmenu.tools = false - irpmenu.multi = false - irpmenu.editor = false - - canLoadDtpckMenu = true - - waiting = false - mainwait = false - firstload = true - - firstloadMission = true - firstloadMarket = true - initfinish = false - ItemsCart = {} - CartPrice = 0 - - query = "" - querycat = "" - - netontracthub = {} - netontracthub.login = true - netontracthub.register = false - netontracthub.main = false - RememberMe = false - - - AvatarList = {} - currentRole = "" - currentbranch = "" - currentFaction = "" - currentFactionRank = "" - possiblebranch = {} - VBodyComponents = {"l0_003_pwa_pants__leggins7303", "l1_004_pma_pants__sweatpants8832", "l1_004_pwa_pants__sweatpants1663", "l1_006_pma_pants__stoop_king8208", "l1_006_pwa_pants__stoop_king6174", "l1_008_pma_shorts__long8821", "l1_008_pwa_shorts__long6811", "l1_011_pma_skirt__tight1732", "l1_044_pma_pants__panties", "l1_011_pwa_skirt__tight0028", "l1_096_pwa_shorts__micro_thong", "l1_012_pma_pants__jeans_tight4118", "l1_012_pwa_pants__jeans_above_ankle8405", "l1_012_pwa_pants__jeans_tight7860", "l1_013_pma_shorts__small4307", "l1_013_pwa_shorts__small0548", "l1_021_pma_pants__cargo_computer", "l1_021_pwa_pants__cargo_computer7114", "l1_021_pwa_pants__cargo_computer", "l1_022_pma_pants__suit_belt5255", "l1_025_pma_pants__leather3476", "l1_034_pma_pants__scavenger6036", "l1_034_pwa_pants__scavenger4728", "l1_045_pma_pants__suit0076", "l1_045_pwa_pants__suit2855", "l1_047_pwa_shorts__panties7731", "l1_049_pma_shorts__boxers6361", "l1_052_pma_pants__suit_paulnight8641", "l1_054_pma_shorts__latino8283", "l1_054_pwa_shorts__latino4138", "l1_061_pma_pants__chaps_farmer5718", "l1_061_pwa_pants__chaps_farmer6443", "l1_062_pma_pants__jeans6487", "l1_063_pwa_pants__leather3162", "l1_065_pma_pants__pockets6523", "l1_065_pwa_pants__pockets7734", "l1_066_pwa_pants__rogue7706", "l1_068_pma_pants__racing_right7166", "l1_068_pma_pants__racing_right_harness_074", "l1_068_pma_pants__racing_right_012_01", "l1_068_pwa_pants__racing_right_012_01", "l1_068_pwa_pants__racing_right_harness_074", "l1_068_pwa_pants__racing", "l1_069_pma_shorts__torn_shorts3371", "l1_069_pwa_shorts__torn_shorts5467", "l1_070_pma_pants__loose 1305", "l1_070_pwa_pants__loose 5137", "l1_077_pma_pants__trauma_small0585", "l1_077_pwa_pants__trauma_small5157", "l1_078_pma_pants__militech5364", "l1_078_pwa_pants__militech6668", "l1_081_pwa_pants__suit8188", "l1_084_pma_skirt__misty8388", "l1_084_pwa_skirt__misty6640", "l1_087_pma_pants__ninja6302", "l1_087_pwa_pants__ninja2367", "l1_088_pma_pants__sergeant1676", "l1_088_pwa_pants__sergeant3237", "l1_091_pma_pants__silverhand5016", "l1_091_pwa_pants__silverhand3762", "a0_005_ma__strongarms_int_r", "a0_005_ma__strongarms_r", "a0_005_ma__strongarms_cyberware_r", "a0_005_ma__strongarms_cyberware_l", "a0_005_ma__strongarms_int_l", "a0_005_ma__strongarms_l", "a0_005_wa__strongarms_cyberware_l", "a0_005_wa__strongarms_l", "a0_005_wa__strongarms_int_l", "a0_005_wa__strongarms_cyberware_r", "a0_005_wa__strongarms_r", "a0_005_wa__strongarms_int_r", "a0_005_wa__strongarms_holstered_personal_link_dec_l3001", "a0_005_wa__strongarms_personal_link_dec_l4456", "a0_001_wa__personal_link_port", "a0_001_ma__personal_link", "a0_001_ma__personal_link_default6377", "a0_001_pma_cyber__silverhand_overlay", "a0_001_wa__personal_link_prototype", "a0_001_wa__personal_link_port_decal1800", "a0_002_ma__monowire_whip_l", "a0_002_ma__monowire_whip_r", "a0_002_wa__monowire_whip_l_cableless", "a0_002_wa__monowire_whip_r_cableless", "a0_002_wa__monowire_left_arm_prototype", "a0_002_wa__monowire_left_whip_prototype", "a0_002_wa__monowire_right_arm_prototype", "a0_002_wa__monowire_right_whip_prototype", "a0_003_ma__mantisblade_left", "a0_003_ma__mantisblade_right", "a0_003_ma__mantisblades_right", "a0_003_ma__mantisblades_left", "SkinnedMesh8480", "SkinnedMesh3815", "a0_004__weapon_grip_device0226", "a0_004__weapon_grip_decal_01", "a0_005_ma__strongarms_holstered_cyberware_r", "a0_005_ma__strongarms_holstered_r", "a0_005_ma__strongarms_holstered_cyberware_l", "a0_005_ma__strongarms_holstered_l", "a0_005_wa__strongarms_holstered_r", "a0_005_wa__strongarms_holstered_cyberware_r", "a0_005_wa__strongarms_holstered_l", "a0_005_wa__strongarms_holstered_cyberware_l", "a0_005_wa__strongarms_photo_mode_r", "a0_005_wa__strongarms_photo_mode_cyberware_r", "a0_005_wa__strongarms_photo_mode_cyberware_l", "a0_005_wa__strongarms_photo_mode_l", "a0_006_launcher_arm_cables", "a0_006_launcher_arm_forearm_bottom_plate_a", "a0_006_launcher_arm_forearm_plate_a", "a0_006_launcher_arm_forearm_plate_b", "a0_006_launcher_arm_forearm_upper_plate_a", "a0_006_launcher_arm_guts_b", "a0_006_launcher_arm_guts_c", "a0_006_launcher_arm_guts_d", "a0_006_launcher_arm_muscle_a", "a0_006_launcher_arm_muscle_b", "a0_006_launcher_arm_muscle_c", "a0_006_launcher_arm_plate_a", "a0_006_launcher_arm_plate_b", "a0_006_launcher_arm_plate_c", "a0_006_launcher_arm_side_plate_a", "a0_006_launcher_arm_side_plate_b", "a0_006_launcher_arm_skin", "a0_006_launcher_arm_wrist_plate_a", "a0_006_launcher_arm_wrist_plate_b", "a0_006_launcher_arm_wrist_plate_c", "a0_006_launcher_arm_wrist_plate_d", "a0_006_launcher_arm_guts_a", "a0_006_launcher_projectile_a", "a0_010_ma__soft_token5036", "a0_010_wa__soft_token2203", "a0_010_ma__soft_token7310", "a0_002_ma__monowire_whip_l_cableless", "a0_002_ma__monowire_whip_r_cableless", "a0_002_ma__monowire_whip_personal_link_dec_l", "a0_000_ma_base__nails_l", "a0_000_ma_base__nails_r", "a0_002_wa__monowire_whip_whip1_l", "a0_002_wa__monowire_whip_whip1_r", "a0_003_ma__mantisblade_upperarm_left", "a0_003_ma__mantisblade_upperarm_right", "a0_003_ma__mantisblade_left", "a0_003_ma__mantisblade_left_blade", "a0_003_ma__mantisblade_left_mechanisms", "a0_003_ma__mantisblade_right_mechanisms", "a0_003_ma__mantisblade_right_blade", "a0_003_wa__mantisblade_right_blade", "a0_003_wa__mantisblade_left_blade", "a0_003_ma__mantisblade_holstered_left6562", "a0_003_ma__mantisblade_holstered_right", "a0_003_ma__mantisblade_holstered_upperarm_left", "a0_003_ma__mantisblade_holstered_upperarm_right", "a0_003_wa__mantisblade_holstered_right", "a0_003_wa__mantisblade_holstered_upperarm_right", "a0_003_wa__mantisblade_holstered_upperarm_left", "a0_003_wa__mantisblade_holstered_left", "a0_003_wa__mantisblade_photomode_left2804", "a0_003_wa__mantisblade_photomode_right", "a0_003_wa__mantisblade_photomode_upperarm_left", "a0_003_wa__mantisblade_photomode_upperarm_right", "a0_003_wa__mantisblade_upperarm_left", "a0_003_wa__mantisblade_upperarm_right", "a0_003_wa__mantisblade_right", "a0_003_wa__mantisblade_left", "a0_006_ma__launcher_upperarm", "a0_006_ma__launcher_upperarm_right", "a0_006_ma__launcher_ammo_fire2714", "a0_006_ma__launcher_shells1525", "a0_006_ma__launcher_fragment_fire4806", "a0_006_ma__launcher_holstered1283", "a0_006_ma__launcher_holstered_upperarm", "a0_006_ma__launcher_holstered_upperarm_right", "a0_006_ma__launcher_mechanisms", "a0_006_ma__launcher_muscles", "a0_006_wa__launcher_upperarm", "a0_006_wa__launcher_holstered_right", "a0_006_wa__launcher_ammo_fire2326", "a0_006_wa__launcher_shells8722", "a0_006_wa__launcher_fragment_fire6227", "a0_006_wa__launcher_holstered4156", "a0_006_wa__launcher_holstered_upperarm", "a0_006_wa__launcher_holstered_photo_mode8630", "a0_006_wa__launcher_upperarm_photo_mode", "a0_006_wa__launcher_holstered_photo_mode_right", "a0_006_wa__launcher_muscles", "a0_006_wa__launcher_mechanisms", "a0_006_wa__launcher_nails_l", "a0_006_wa__launcher_nails_r", "monowire_arm", "monowire_hooks", "monowire_wire", "a0_001_wa__personal_link_prototype1385", "a0_006_launcher_arm_projectile", "t0_005_pma_body__t_bug5280", "t0_005_pma_body__t_bug_cuff", "t0_005_pwa_body__t_bug7718", "t0_005_pwa_body__t_bug_cuff", "t0_006_pma_full__queen2164", "t0_006_pma_full__queen_cuff", "t0_006_pwa_full__queen6424", "t0_006_pwa_full__queen_cuff", "t1_001_pma_shirt__militech_agent", "t1_001_pma_shirt__militech_agent_cuffs", "t1_001_pwa_shirt__militech_agent", "t1_001_pwa_shirt__militech_agent_cuffs", "t1_004_pma_tshirt__longsleeve5383", "t1_004_pma_tshirt__longsleeve_cuff", "t1_007_pma_shirt__lumberjack4112", "t2_pma_shirt__lumberjack", "t1_007_pwa_shirt__lumberjack3803", "t1_011_pwa_tank__plain3516", "t1_011_pwa_tank__plain_dec_sticker", "t1_012_pwa_tank__open_sides7518", "t1_018_pma_full__body0281", "t1_018_pma_full__body_cuffs", "t1_018_pwa_full__body1277", "t1_018_pwa_full__body_cuffs", "t2_pma_jacket__sleeves_shadow", "t1_024_pma_tshirt__sweater_cuffs", "t1_024_pma_tshirt__sweater0253", "t1_024_pwa_tshirt__sweater_cuffs", "t1_024_pwa_tshirt__sweater1258", "t1_035_pwa_shirt__suit6540", "t1_035_pwa_shirt__suit_cuff", "t1_041_pma_tshirt__sleeveless6413", "t1_045_pma_shirt__cowboy3770", "t1_045_pma_shirt__cowboy_suff", "t1_047_pma_tank__pushup8854", "t1_047_pwa_tank__pushup8543", "t1_048_pma_tank__plastic_bag4601", "t1_057_pwa_tank__bra0730", "t1_060_pma_tank__corset3513", "t1_061_pma_shirt__holster_belts5680", "t1_068_pwa_tank__long_rogue3063", "t1_070_pma_full__hanako2543", "t1_070_pma_full__hanako_cuff", "t1_070_pwa_full__hanako4412", "t1_070_pwa_full__hanako_cuff", "t1_071_pma_tank__basic4518", "t1_071_wa_tank__basic7841", "t1_073_pma_shirt__torn_shirt0687", "t1_073_pwa_shirt__torn_shirt8278", "t1_074_pma_shirt__torn_shirt4011", "t1_074_pwa_shirt__torn_shirt7362", "t1_079_pma_tshirt__casual2303", "t1_079_pma_tshirt__casual_dec_witcher", "t1_079_ma_tshirt__casual_dec_samurai", "t1_079_pma_tshirt__casual_dec_galaxy", "sq_white_vote_peralez", "t1_079_pma_tshirt__casual_dec_vote_peralez", "t1_079_pwa_tshirt__casual6346", "t1_079_pwa_tshirt__casual_dec_samurai", "t1_079_pwa_tshirt__casual_dec_witcher", "t1_079_pwa_tshirt__casual_dec_galaxy", "t1_079_pwa_tshirt__casual_dec_vote_peralez", "t1_080_pwa_tank__judy6160", "t1_082_pwa_tank__casual0270", "t1_087_pma_shirt__high_collar2852", "t1_087_pwa_shirt__high_collar3543", "t1_088_pma_shirt__kimono0082", "t1_088_pwa_shirt__kimono3315", "t1_089_pwa_tank__short_torn4743", "t1_090_pma_tank__johnny4617", "t1_090_pwa_tank__johnny1030", "t1_091_pma_full__jumpsuit7248", "t1_091_pma_full__jumpsuit_cuff", "t1_041_pma_tshirt__sleeveless", "t1_091_pwa_full__jumpsuit3810", "t1_091_pwa_full__jumpsuit_cuff", "t1_071_pwa_tank__basic", "t1_093_pwa_shirt__denny_corset8405", "t1_094_pma_shirt__scientist7816", "t1_094_pma_shirt__scientist_cuff", "t1_094_pwa_shirt__scientist3763", "t1_094_pwa_shirt__scientist_cuff", "t1_097_pma_tank__corset_doll_prostitute", "t1_097_pwa_tank__corset_doll_prostitute3055", "t1_102_pma_shirt__vest4307", "t1_102_pwa_shirt__vest5844", "t1_105_pma_tank__bandage1160", "t2_002_pma_vest__puffy1434", "t2_002_pwa_vest__puffy2302", "t2_014_pma_dress__chic3813", "t2_014_pma_dress__chic_cuff", "t2_014_pwa_dress__chic4878", "t2_014_pwa_dress__chic_cuff", "t2_021_pma_vest__denim5608", "black_leather", "t2_021_pma_vest__denim_patch", "t2_021_pma_vest__denim_patch_torn", "t2_021_pwa_vest__denim6405", "t2_021_pwa_vest__denim_patch", "t2_021_pwa_vest__denim_patch_torn", "t2_023_pma_full__uniform8588", "t2_023_pma_full__uniform_badge", "t2_023_pma_full__uniform_screen", "t2_023_pwa_full__uniform0884", "t2_023_pwa_full__uniform_badge", "t2_023_pwa_full__uniform_screen", "t2_031_pma_full__hazmat_no_hood7674", "t2_031_pma_full__hazmat_no_hood_cuff", "t2_031_pma_full__hazmat_no_hood_dec_stickers", "t2_031_pwa_full__hazmat_no_hood2811", "t2_031_pwa_full__hazmat_no_hood_cuff", "t2_031_pwa_full__hazmat_no_hood_dec_stickers", "t2_033_pwa_jacket__suspenders3145", "t2_033_pwa_jacket__suspenders_cuffs", "t2_036_pma_jacket__suit_open_elegant4133", "t2_036_pma_jacket__suit_open_elegant_cuff", "t2_039_pwa_jacket__suit_closed5581", "t2_039_pwa_jacket__suit_closed_shirt", "t2_039_pwa_jacket__suit_closed_cuff", "t2_041_pma_jacket__spiked2584", "t2_041_pwa_jacket__spiked3028", "t2_047_pma_jacket__bolero0308", "t2_047_pwa_jacket__bolero5123", "t2_050_pma_jacket__scavenger6531", "t2_050_pma_jacket__scavenger_cuffs", "t2_061_pma_vest__tactical1201", "t2_061_pma_vest__tactical_dec_corpo", "t2_061_pwa_vest__tactical6683", "t2_061_pwa_vest__tactical_dec_corpo", "t2_063_pwa_jacket__silver3022", "t2_063_pwa_jacket__silver_cuffs", "l0_003_pwa_pants__leggins", "t2_064_pma_jacket__t2_player_heavy2048", "t2_064_pma_jacket__t2_player_heavy_cuff", "t2_064_pma_jacket__t2_player_heavy_collar2277", "t2_064_pma_jacket__t2_player_heavy_collar_folded", "t2_064_pma_jacket__t2_player_heavy_folded", "t2_064_pwa_jacket__t2_player_heavy3241", "t2_064_pwa_jacket__t2_player_heavy_cuff", "t2_064_pwa_jacket__t2_player_heavy_collar3310", "t2_068_pma_jacket__formal_suit7461", "t2_068_pma_jacket__formal_suit_cuff", "t2_068_pma_jacket__formal_suit_elegant4353", "t2_070_pma_jacket__suit_paulnight5857", "t2_070_pma_jacket__suit_paulnight_cuff", "t2_072_pma_vest__tactic_collar6428", "t2_072_pma_vest__tactic_collar_dec_corpo", "t2_072_pwa_vest__tactic_collar0062", "t2_072_pwa_vest__tactic_collar_dec_corpo", "t2_073_pma_vest__tactic_collar27052", "t2_073_pma_vest__tactic_collar2_dec_corpo", "t2_073_pwa_vest__tactic_collar20561", "t2_073_pwa_vest__tactic_collar2_dec_corpo", "t2_075_pwa_jacket__tied6223", "t2_076_pma_vest__armor_short1544", "t2_076_pma_vest__armor_short_dec_corpo", "t2_076_pwa_vest__armor_short4166", "t2_076_pwa_vest__armor_short_dec_corpo", "t2_077_pma_vest__armor_short6286", "t2_077_pma_vest__armor_short_dec_corpo", "t2_077_pwa_vest__armor_short7777", "t2_077_pwa_vest__armor_short_dec_corpo", "t2_080_pma_jacket__prince1302", "t2_080_pma_jacket__prince_cuffs", "t2_080_pwa_jacket__prince4284", "t2_080_pwa_jacket__prince_cuffs", "t2_082_pma_vest__hoodie6131", "t2_082_pwa_vest__hoodie2631", "t2_083_pwa_vest__denim4704", "t2_084_pma__short_sleeves5437", "t2_084_pma_jacket__short_sleeves_hanging2284", "t2_084_pma_jacket__short_sleeves_decal_hanging", "t2_084_pwa__short_sleeves3780", "t2_087_pma_jacket__river_short5470", "t2_087_pma_jacket__river_short_cuff", "t2_087_pwa_jacket__river_short_cuff", "t2_087_pwa_jacket__river_short", "t2_088_pwa_jacket__rogue6184", "t2_088_pwa_jacket__rogue_dec_gang", "t2_088_pwa_jacket__rogue_dec_corpo", "t2_090_pma_vest__harness1084", "t2_090_pwa_vest__harness1081", "t2_091_pma_jacket__racing0841", "t2_091_pma_jacket__racing_cuffs", "t2_091_pma_jacket__racing_dec_sticker", "t2_091_pwa_jacket__racing4672", "t2_091_pwa_jacket__racing_cuffs", "t2_091_pwa_jacket__racing_dec_sticker", "t2_093_pwa_jacket__collar0600", "t2_093_pwa_jacket__collar_collar", "t2_094_pma_full__racing_suit2847", "t2_094_pma_full__racing_suit_cuff", "t2_094_pma_full__racing_suit_stephenson_dec_sticker", "t2_094_pwa_full__racing_suit6578", "t2_094_pwa_full__racing_suit_cuff", "prisoner_orange", "t2_094_pwa_full__racing_suit_stephenson_dec_sticker", "t2_097_pma_jacket__holmes_coat8230", "t2_097_pwa_jacket__holmes_coat1745", "t2_098_pwa_jacket__bomber_jacket1140", "t1_pma_formal__shirt_shadow", "t2_099_pma_jacket__military", "t2_100_pma_vest__military1561", "t2_100_pma_vest__military_dec_corpo", "t2_100_pwa_vest__military3323", "t2_100_pwa_vest__military_dec_corpo", "t2_102_pma_vest__tight3467", "t2_103_pwa_jacket__agent2013", "t2_103_pwa_jacket__agent_cuff", "t2_106_pma_jacket__trauma_small2653", "t2_106_pma_jacket__trauma_small_cuffs_cuffs", "t2_106_ma_jacket__trauma_small_dec_logo", "t2_106_pma_jacket__trauma_small_dec_cable", "t2_106_pwa_jacket__trauma_small4411", "t2_106_pwa_jacket__trauma_small_cuffs", "t2_106_pwa_jacket__trauma_small_dec_cable", "t2_106_wa_jacket__trauma_small_dec_logo", "t2_109_pma_jacket__puffy_vest0887", "t2_109_pwa_jacket__puffy_vest6740", "t2_110_pma_vest__high_collar4286", "t2_110_pwa_vest__high_collar4710", "t2_111_pma_jacket__bodyguard_dex4063", "t2_111_pma_jacket__bodyguard_dex_cuffs", "t2_111_pwa_jacket__bodyguard_dex1833", "t2_111_pwa_jacket__bodyguard_dex_cuffs", "t2_114_pma_vest__hi_vis5306", "t2_114_pma_vest__hi_vis_dec_corpo", "t2_114_pwa_vest__hi_vis1141", "t2_114_pwa_vest__hi_vis_dec_corpo", "t2_115_pma_jacket__military3431", "t2_115_pma_jacket__military_dec_sticker", "t2_115_pma_jacket__military", "t2_115_pwa_jacket__military1114", "t2_115_pwa_jacket__military_dec_sticker", "t2_119_pma_jacket__suit_cuff", "t2_119_pma_jacket__suit8131", "t2_120_pwa_jacket__suit_01", "t2_120_pwa_jacket__suit_sleeves_01", "t2_120_pwa_jacket__suit_sleeves_04", "t2_120_pwa_jacket__suit_sleeves_02_cuff", "t2_120_pwa_jacket__suit_022017", "t2_120_pwa_jacket__suit_03", "t2_122_pma_jacket__biker0023", "t2_122_pma_jacket__biker_cuffs", "t2_122_pwa_jacket__bike", "t2_122_pwa_jacket__biker_cuffs", "t2_123_pma_full__space_suit4181", "t2_123_pma_full__space_suit_dec_sticker", "t2_123_pma_full__space_suit_trauma_pack", "t2_123_pma_full__space_suit_helmet3538", "t2_123_pwa_full__space_suit0210", "t2_123_pwa_full__space_suit_trauma_pack", "t2_123_pwa_full__space_suit_dec_sticker", "t2_123_pwa_full__space_suit_helmet7518", "t2_126_pma_jacket__hood5142", "t2_126_pma_jacket__hood_cuffs", "t2_127_pwa_jacket__evelyn3568", "t2_128_pma_jacket__takemura8622", "t2_128_pma_jacket__takemura_cuff", "t2_131_pma_vest__kerry4682", "t2_131_pma_vest__kerry_dec_gang", "t2_131_pwa_vest__kerry2131", "t2_131_pwa_vest__kerry_dec_gang", "t2_132_pma_jacket__wilson7816", "t2_132_pma_jacket__wilson_dec_corpo", "t2_132_pma_jacket__wilson_dec_gang", "t2_132_pma_jacket__wilson_cuff", "t2_140_pma_jacket__leather7543", "t2_140_pma_jacket__leather_cuff", "t2_140_pwa_jacket__leather3281", "t2_140_pwa_jacket__leather_cuff", "t2_142_pma_jacket__witcher0688", "t2_142_pma_jacket__witcher_cuffs", "leather_black", "t2_142_pwa_jacket__witcher0655", "t2_142_pwa_jacket__witcher_cuffs", "s1_001_pma_shoe__swim_fins4245", "s1_001_pwa_shoe__swim_fins7734", "s1_004_pma_shoe__sneakers_high5153", "s1_005_pma_shoe__sport_high5041", "s1_010_pma_shoe__elegant3230", "s1_011_pwa_boot__heel_sneakers5643", "s1_013_pma_boot__snow_shoes2172", "s1_013_pwa_boot__snow_shoes1576", "s1_026_pma_boot__heavy4104", "s1_026_pwa_boot__heavy7835", "s1_027_pwa_shoe__heel_pointy1510", "s1_039_pma_boot__knee_high1352", "s1_051_pwa_shoe__latino1302", "s1_052_pma_boot__cowboy3283", "s1_052_pwa_boot__cowboy", "s1_053_pma_boot__military3700", "s1_053_pwa_boot__military2302", "s1_055_pma_shoe__converse5711", "s1_055_pwa_shoe__converse6558", "s1_056_pma_boot__biker5465", "s1_056_pwa_boot__biker0668", "s1_057_pma_shoe__racing6821", "s1_057_pwa_shoe__racing4635", "s1_059_pwa_shoe__judy7548", "s1_061_pma_shoe__clair6674", "s1_061_pwa_shoe__clair7540", "s1_063_pma_shoe__mexican7186", "s1_063_pma_shoe__mexican_harness", "s1_063_pwa_shoe__mexican2571", "s1_063_pwa_shoe__mexican_harness", "s1_065_pma_shoe__ankle6553", "s1_065_pwa_shoe__ankle0855", "s1_066_pma_boot__bovver3318", "s1_066_pma_boot__bovver_laces_01", "s1_066_pma_boot__bovver_metal_tip_01", "s1_066_pwa_boot__bovver4748", "s1_066_pwa_boot__bovver_laces_01", "s1_066_pwa_boot__bovver_metal_tip_01", "s1_067_pma_shoe__river3450", "s1_068_pma_shoe__sneakers1043", "s1_068_pwa_shoe__sneakers7640", "s1_073_pwa_shoe__high_heels", "s1_075_pma_shoe__yorinobu2284", "s1_076_pwa_boot__misty5375", "s1_077_pma_boot__blackwater8588", "s1_077_pwa_boot__blackwater7310", "s1_078_pma_boot__wilson6368", "s1_078_pwa_boot__wilson", "s1_079_pwa_shoe__hanako3883", "s1_084_pma_boot__thrusters", "s1_084_pma_boot__thrusters_dec_corpo", "s1_084_pwa_boot__thrusters", "s1_084_pwa_boot__thrusters_dec_corpo", "left_arm", "right_arm", "a0_000_pwa_fpp__nails_l", "a0_000_pwa_fpp__nails_r", "a0_001__personal_link_default_holstered", "MorphTargetSkinnedMesh0531", "l0_000_pwa_base__cs_flat", "t0_000_pwa_fpp__torso", "n0_000_pwa_fpp__neck0160", "t0_000_pma_base__full", "n0_000_pma_fpp__neck2814", "i0_000_pma_base__nipple", "a0_000_pma_base__nails_r", "a0_000_pma_base__nails_l", "a0_000_ma_base__full_ag_hq1491", "a0_000_ma_base__full_ag_hq6168", "g1_012_pma_gloves__trauma_no_protection4340", "i1_002_pwa_slot__diving_bottle7786", "i1_003_pma_neck__bullet_pendant1068", "i1_114_pwa_neck__dogtag_johnny1520", "i1_020_pma_neck__goggles7616", "i1_020_pwa_neck__goggles1368", "i1_050_pma_neck__bolo_tie5567", "i1_074_pma_full__harness_racing", "i1_074_pwa_full__harness_racing", "i1_106_wa_neck__doll7414", "i1_114_pma_neck__dogtag_johnny6127", "i1_122_ma_full__devices", "i1_122_ma_full__devices_dec_sticker", "i1_122_pwa_full__devices4716", "i1_122_pwa_full__devices_dec_sticker", "h1_001_pma_mask__swim_mask2764", "h1_001_pwa_mask__swim_mask0307", "h1_002_pma_hat__headcap4652", "h1_002_pwa_hat__headcap2675", "h1_003_pma_hat__beanie7181", "h1_003_pwa_hat__beanie8268", "h1_007_pma_specs__aviators1285", "h1_007_pwa_specs__aviators2376", "h1_011_pma_hat__baseball7254", "h1_011_pma_hat__baseball_back8080", "h1_011_pwa_hat__baseball7030", "h1_011_pwa_hat__baseball_back4262", "h1_012_pma_hat__googles3226", "h1_012_pwa_hat__googles3001", "h1_015_pma_specs__visor_holo0421", "h1_015_pwa_specs__visor_holo7440", "h1_021_pma_hat__cowboy_sheriff6747", "h1_021_pwa_hat__cowboy_sheriff2327", "h1_024_pma_hat__scavenger5026", "h1_024_pwa_hat__scavenger8308", "h1_032_pma_hat__asian6840", "h1_032_pwa_hat__asian0587", "h1_033_pma_specs__braindance0241", "h1_033_pwa_specs__braindance4636", "h1_036_pma_hat__elegant2825", "h1_036_pwa_hat__elegant7660", "h1_037_pma_hat__hijab0370", "h1_037_pwa_hat__hijab1547", "h1_038_pma_specs__classic6586", "h1_038_pwa_specs__classic3436", "h1_045_pma_hat__farmer0115", "h1_045_pwa_hat__farmer2402", "h1_051_pma_mask__headkerchief_lower0382", "h1_051_pwa_mask__headkerchief_lower7323", "h1_052_pma_specs__tactical_017720", "h1_052_pma_specs__tactical_026748", "h1_052_pma_specs__tactical_035180", "h1_052_pma_specs__tactical_047786", "h1_052_pwa_specs__tactical_018516", "h1_052_pwa_specs__tactical_023262", "h1_052_pwa_specs__tactical_031711", "h1_052_pwa_specs__tactical_048724", "h1_055_pma_specs__googles6020", "h1_055_pwa_specs__googles4313", "h1_056_pma_mask__samurai4161", "h1_056_pwa_mask__samurai0763", "h1_058_pma_mask__skull1350", "h1_058_pma_mask__skull_mask_cover", "h1_058_pma_mask__skull_mask_cover02", "h1_058_pma_mask__skull_small_cover03", "h1_058_pwa_mask__skull5430", "h1_058_pwa_mask__skull_mask_cover", "h1_058_pwa_mask__skull_mask_cover02", "h1_058_pwa_mask__skull_small_cover03", "h1_060_pma_hat__bandana_kerry8710", "h1_060_pwa_hat__bandana_kerry0240", "h1_063_pma_hat__military5372", "h1_063_pwa_hat__military1528", "h1_064_pma_specs__sunglasses_011714", "h1_064_pma_specs__sunglasses_025032", "h1_064_pwa_specs__sunglasses_011343", "h1_064_pwa_specs__sunglasses_026676", "h1_065_pma_hat__guard1224", "h1_065_pwa_hat__guard8765", "h1_070_pma_mask__glasses_l1313", "h1_070_pwa_mask__glasses", "h1_082_pma_hat__bandage1421", "h2_005_pma_helmet__construction0817", "h2_005_pwa_helmet__construction6140", "h2_009_pma_helmet__samurai8040", "h2_009_pwa_helmet__samurai5837", "h2_011_pma_helmet__riot3158", "h2_011_pwa_helmet__riot0243", "h2_015_pma_helmet__motorcycle0431", "h2_015_pwa_helmet__motorcycle1627", "h2_016_pma_helmet__max_tac7723", "h2_016_pwa_helmet__max_tac0037", "i1_020_pma_neck__goggles6842", "i1_020_pwa_neck__goggles0113", "a0_008_ma__fpp_right_q001_injection_mark", "a0_008_wa__fpp_right_q001_injection_mark", "a0_004__weapon_grip_decal_02", "a0_004__weapon_grip_device", "a0_000_nomad_base_fists", "t0_000_pwa_base__full", "hh_000_ma__prototype3047", "hh_000_mb__prototype", "hh_000_wa__prototype", "hh_006_ma__demo3633", "hh_006_mb__demo", "hh_006_wa__demo", "hh_007_ma__demo1210", "hh_007_mb__demo", "hh_007_wa__demo", "hh_008_ma__demo0028", "hh_008_mb__demo", "hh_008_wa__demo", "hh_009_ma__demo3404", "hh_009_mb__demo", "hh_009_wa__demo4473", "hh_011_ma__demo3010", "hh_011_wa__demo7364", "hh_011_waf__demo1381", "hh_020_ma__mullet7683", "hh_020_wa__mullet", "hh_021_ma__player", "hh_021_mb__player013337", "hh_021_wa__player012513", "hh_022_ma__chrome_celeb", "hh_022_mb__chrome_celeb", "hh_022_wa__chrome_celeb", "hh_023_ma__short_messy5102", "hh_023_mb__short_messy", "hh_023_wa__short_messy", "hh_024_wa__underwater_dancer1446", "hh_025_ma__pompadour", "hh_025_mb__pompadour0053", "hh_025_mba__pompadour3258", "hh_025_wa__pompadour2838", "hh_025_wba__pompadour6412", "hh_026_ma__rat_tail", "hh_026_mb__rat_tail7140", "hh_026_mba__rat_tail4380", "hh_026_mc__rat_tail8050", "hh_026_wa__rat_tail6062", "hh_026_wba__rat_tail6150", "hh_027_ma__scavenger", "hh_027_mb__scavenger", "hh_027_mc__scavenger8838", "hh_027_wa__scavenger0663", "hh_028_ma__corpo_bun3807", "hh_028_wa__corpo_bun", "hh_029_wa__misty", "hh_029_wa__misty6688", "hh_030_ma__punk_idol", "hh_030_mb__punk_idol", "hh_030_mc__punk_idol_short5114", "hh_030_wa__punk_idol", "hh_031_ma__morgan_blackhand", "hh_032_ma__ripper_doc_common", "hh_032_mb__ripper_doc_common2200", "hh_032_mf__ripper_doc_common7107", "hh_033_ma__player", "hh_033_wa__player", "hh_034_wa__militech_agent", "hh_034_wa__militech_agent7131", "hh_035_ma__mohawk_tall", "hh_035_mb__mohawk_tall", "hh_035_wa__mohawk_tall", "hh_036_ma__high_tight4653", "hh_036_mb__high_tight3688", "hh_036_mba__high_tight8062", "hh_036_mc__high_tight2408", "hh_036_mf__high_tight7000", "hh_036_wa__high_tight3672", "hh_036_waf__high_tight6778", "hh_036_wba__high_tight1646", "hh_037_ma__gungho3158", "hh_037_mb__gungho7340", "hh_037_mba__gungho8170", "hh_037_mc__gungho5665", "hh_037_mf__gungho4245", "hh_037_wa__gungho5574", "hh_037_waf__gungho8031", "hh_037_wba__gungho7046", "hh_039_ma__punk_shaved7577", "hh_039_mb__punk_shaved7460", "hh_039_mba__punk_shaved6716", "hh_039_mc__punk_shaved8275", "hh_039_mf__punk_shaved0306", "hh_039_wa__punk_shaved", "hh_039_waf__punk_shaved0178", "hh_039_wba__punk_shaved1308", "hh_040_ma__pixie_bob0822", "hh_040_mb__pixie_bob7356", "hh_040_mc__pixie_bob3384", "hh_040_wa__pixie_bob", "hh_040_waf__pixie_bob6887", "hh_040_wba__pixie_bob4233", "hh_041_ma__valentino8404", "hh_041_wa__valentino", "hh_042_ma__topknots6552", "hh_042_mb__topknots1558", "hh_042_mba__topknots2542", "hh_042_mc__topknots3560", "hh_042_mf__topknots0633", "hh_042_wa__topknots", "hh_042_wa__topknots_band", "hh_042_mf__topknots_band", "hh_042_mc__topknots_band", "hh_042_mba__topknots_band", "hh_042_mb__topknots_band", "hh_042_ma__topknots_band", "hh_042_wba__topknots_band", "hh_042_wba__topknots1411", "hh_043_wa__modern_bob6743", "hh_044_ma__classic4517", "hh_044_wa__classic7063", "hh_045_ma__short_spiked8708", "hh_045_mb__short_spiked6105", "hh_045_mba__short_spiked7177", "hh_045_mc__short_spiked1850", "hh_045_mf__short_spiked4442", "hh_045_wa__short_spiked2173", "hh_045_wba__short_spiked7343", "hh_046_ma__saburo_arasaka3348", "hh_047_ma__swirl_pomp5410", "hh_047_wa__swirl_pomp1544", "hh_048_ma__dual_braids8777", "hh_048_mb__dual_braids8661", "hh_048_wa__dual_braids6587", "hh_049_ma__thiago6065", "hh_049_ma__thiago_common6367", "hh_049_mb__thiago_common4480", "hh_049_mba__thiago_common1414", "hh_049_mc__thiago_common8054", "hh_049_mf__thiago_common5240", "hh_049_wa__thiago_common6388", "hh_049_waf__thiago_common7105", "hh_049_wba__thiago_common2817", "hh_050_ma__johnny_silverhand", "hh_051_ma__judy_common7437", "hh_051_wa__judy", "hh_051_wa__judy_common1632", "hh_052_mc__clair6255", "hh_052_wa__clair2245", "hh_053_ma__kerry_eurodyne5786", "hh_053_ma__kerry_eurodyne_common4302", "hh_053_ma__yorinobu3860", "hh_053_wa__kerry_eurodyne_common3268", "hh_054_wa__michiko6576", "hh_054_wa__rogue_young5787", "hh_054_wa__rogue_young_common8076", "hh_055_mb_placide", "hh_055_mba_placide_common3028", "hh_056_wa__rogue_old4448", "hh_057_ma__kerry_eurodyne_young1370", "hh_058_ma__voodoo_013726", "hh_058_mb__voodoo_017001", "hh_058_mba__voodoo_012844", "hh_058_mc__voodoo_016270", "hh_058_wa__voodoo_011875", "hh_058_wba__voodoo_018748", "hh_059_ma__voodoo_027611", "hh_059_mb__voodoo_028265", "hh_059_mba__voodoo_020116", "hh_059_mc__voodoo_028010", "hh_059_mf__voodoo_020552", "hh_059_wa__voodoo_024201", "hh_059_waf__voodoo_020436", "hh_059_wba__voodoo_027872", "hh_060_ma__voodoo_034083", "hh_060_mb__voodoo_037007", "hh_060_mba__voodoo_034235", "hh_060_mc__voodoo_037705", "hh_060_wa__voodoo_036583", "hh_060_wba__voodoo_034725", "hh_061_ma__midlength_wavy2365", "hh_061_mb__midlength_wavy", "hh_061_mba__midlength_wavy", "hh_061_mc__midlength_girly0457", "hh_061_mc__midlength_wavy2788", "hh_061_wa__midlength_wavy8134", "hh_062_ma__slick_back1308", "hh_062_mb__slick_back4121", "hh_062_mba__slick_back4575", "hh_062_wa__slick_back2407", "hh_063_ma__messy_bob0304", "hh_063_mc__messy_bob6182", "hh_063_wa__messy_bob3723", "hh_063_wa__messy_bob_us_cracks8748", "hh_063_wba__messy_bob0017", "hh_064_mc__bob_fringe4183", "hh_064_wa__bob_fringe8438", "hh_064_waf__bob_fringe6800", "hh_064_wba__bob_fringe7150", "hh_065_ma__afro_knots8114", "hh_065_mb__afro_knots4580", "hh_065_mba__afro_knots0164", "hh_065_mc__afro_knots2484", "hh_065_wa__afro_knots5387", "hh_065_waf__afro_knots3741", "hh_065_wba__afro_knots4883", "hh_066_mba__animals_011153", "hh_067_mba__animals_027836", "hh_068_ma__animals_032316", "hh_068_ma__animals_03_band", "hh_068_mb__animals_032001", "hh_068_mb__animals_03_band", "hh_068_mba__animals_03_band", "hh_068_mba__animals_030814", "hh_068_mc__animals_030804", "hh_068_mc__animals_band", "hh_068_wa__animals_band", "hh_068_wa__animals_038526", "hh_068_waf__animals_band", "hh_068_waf__animals_033647", "hh_068_wba__animals_band", "hh_068_wba__animals_038362", "hh_999_wba__buzz_cap5647", "hh_999_waf__buzz_cap3810", "hh_999_wa__buzz_dorset_cap4185", "hh_999_wa__buzz_cap", "hh_999_mf__buzz_cap6774", "hh_999_mc__buzz_cap7112", "hh_999_mba__buzz_cap0763", "hh_999_mb__buzz_cap", "hh_999_ma__buzz_cap", "hh_151_waf__judy_variation02_common3001", "hh_151_wa__judy_v02_shadow_npc", "hh_151_wa__judy_variation02_common4843", "hh_151_wa__judy_variation022886", "hh_151_ma__judy_variation02_common5775", "hh_145_ma__v_short5237", "hh_140_wba__short_afro1353", "hh_140_wa__short_afro8843", "hh_140_mf__short_afro1273", "hh_140_mc__short_afro0562", "hh_140_mba__short_afro1001", "hh_140_mb__short_afro3783", "hh_140_ma__short_afro8223", "hh_133_wa_cyberware_spikes_03", "hh_133_mb_cyberware_spikes_03", "hh_133_ma_cyberware_spikes_03", "hh_132_wa_cyberware_spikes_02", "hh_131_wa_cyberware_spikes_01_cap", "hh_132_ma_cyberware_spikes_02", "hh_131_ma_cyberware_spikes_01_cap", "hh_131_wa_cyberware_spikes_01", "hh_131_wa_cyberware_spikes_01_cap", "hh_131_ma_cyberware_spikes_01", "hh_122_ma__roy5656", "hh_121_wba__t_bug_common2037", "hh_121_waf__t_bug_common0674", "hh_121_wa__t_bug_common5334", "hh_121_wa__t_bug5630", "hh_121_mc__t_bug_common4202", "hh_121_ma__t_bug_common2560", "hh_120_ma__arasaka_bun_knot_04", "hh_120_ma__arasaka_bun_knot_04_band", "hh_120_ma__arasaka_bun_common_04", "hh_082_ma__afro_bun_shadow_npc", "hh_120_ma__arasaka_bun_knot_05", "hh_120_ma__arasaka_bun_knot_03", "hh_120_ma__arasaka_bun_knot_03_band", "hh_120_ma__arasaka_bun_knot_06", "hh_120_ma__arasaka_bun_knot_06_sticks", "hh_120_ma__arasaka_bun_common_03", "hh_120_ma__arasaka_bun_knot_02", "hh_120_ma__arasaka_bun_knot_05_band", "hh_120_ma__arasaka_bun_knot_01", "hh_120_ma__arasaka_bun_common_02", "hh_120_ma__arasaka_bun_knot_02_band", "hh_120_ma__arasaka_bun_common_01", "hh_120_ma__arasaka_bun_046120", "hh_120_ma__arasaka_bun_031001", "hh_120_ma__arasaka_bun_027010", "hh_120_ma__arasaka_bun_016145", "hh_119_ma__kojima0247", "hh_118_wa__gillean8283", "hh_118_ma__gillean4256", "hh_117_wa__nina8038", "hh_116_mb__jesse1353", "hh_115_wa__alanah_common3135", "hh_115_wa__alanah2374", "hh_115_mc__alanah_common1307", "hh_114_ma__cohh4631", "hh_113_ma__iwinski_common2284", "hh_113_ma__iwinski2288", "hh_112_ma__kicinski_player3800", "hh_112_ma__kicinski_common2475", "hh_112_ma__kicinski8536", "hh_110_wa__wizzy2244", "hh_105_wa__us_cracks_020823", "hh_105_wa__us_cracks_02_bands", "hh_104_wa__braids5870", "hh_104_mb__braids8634", "hh_104_ma__braids1237", "hh_103_wa__common_spikes6864", "hh_103_ma__maelstrom_spikes5116", "hh_103_ma__common_spikes4318", "hh_102_ma__maelstrom_mohawk4657", "hh_101_ma__maelstrom_ugly5430", "hh_100_wa__wakako2015", "hh_100_wa__wakako_bun", "hh_100_wa__wakako_bun_chopsticks_bun_sticks", "hh_099_ma__holt_common7842", "hh_099_ma__holt2555", "hh_098_wa__top_bun4103", "hh_097_ma__perez8713", "hh_096_mba__saburo_arasaka_old_common7544", "hh_096_ma__saburo_arasaka_old_common5672", "hh_096_ma__saburo_arasaka_old4265", "hh_095_wa__panam5886", "hh_094_ma__saul_common5252", "hh_050_ma__johnny_silverhand_npc", "hh_094_ma__saul1807", "hh_093_wa__sumo_knot", "hh_093_wa__sumo_knot_band", "hh_085_ma__takemura_shadow_npc", "hh_093_mba__sumo_bodyguard6354", "hh_093_mba__sumo_knot", "hh_093_mba__sumo1528", "hh_093_ma__sumo4200", "hh_093_ma__sumo_knot", "hh_093_ma__sumo_band", "hh_092_wa__hanako7083", "hh_092_wa__hanako_bun", "hh_092_wa__hanako_clip", "hh_091_wa__dakota6784", "hh_091_wa__dakota_braid", "hh_091_wa__dakota_braid_band", "hh_090_wa__alt_sex_scene_023561", "hh_090_wa__alt_sex_scene", "hh_090_wa__alt_player2038", "hh_090_wa__alt5644", "hh_089_wba__thompson_common2040", "hh_089_waf__thompson_common4031", "hh_089_wa__thompson_common3557", "hh_089_mf__thompson3472", "hh_089_mba__thompson_common1478", "hh_089_mb__thompson_common4242", "hh_089_ma__thompson_common3557", "hh_089_ma__thompson_common7847", "hh_089_ma__thompson7678", "hh_088_waf__corpo_bob6527", "hh_088_wa__corpo_bob7280", "hh_087_ma__balding_ponytail7888", "hh_086_ma__balding_short_mitch6837", "hh_086_ma__balding_short0330", "hh_085_wba__takemura_common3666", "hh_085_waf__takemura_common2728", "hh_085_wa__takemura_common3377", "hh_085_mf__takemura_common4838", "hh_085_mc__takemura_common5134", "hh_085_mba__takemura_common4845", "hh_085_mb__takemura_common0623", "hh_085_ma__takemura_common1240", "hh_085_ma__takemura2044", "hh_084_wa__bun_chopsticks6071", "hh_084_wa__bun_chopsticks_bun", "hh_084_wa__bun_chopsticks_bun_sticks", "hh_084_ma__bun_chopsticks7617", "hh_084_ma__bun_chopsticks_bun", "hh_084_ma__bun_chopsticks_bun_sticks", "hh_083_wa__ponytail_straight_016481", "hh_083_wa__ponytail_base_01", "hh_083_wa__ponytail_straight_01_band", "hh_083_wa__ponytail_bulb_013744", "hh_083_wa__ponytail_bulb_01_band", "hh_083_wa__ponytail_braid_011002", "hh_083_wa__ponytail_braid_01_band", "hh_083_ma__ponytail_straight_013188", "hh_083_ma__ponytail_base_01", "hh_083_ma__ponytail_straight_01_band", "hh_083_ma__ponytail_bulb_012124", "hh_083_ma__ponytail_bulb_01_band", "hh_083_ma__ponytail_braid_012023", "hh_083_ma__ponytail_braid_01_band", "hh_082_wba__afro_bun7800", "hh_082_wba__afro_bun_bun", "hh_082_waf__afro_bun8315", "hh_082_waf__afro_bun_bun", "hh_082_wa__afro_bun3836", "hh_082_wa__afro_bun_bun", "hh_082_mf__afro_bun3424", "hh_082_mf__afro_bun_bun", "hh_082_mc__afro_bun5755", "hh_082_mc__afro_bun_bun", "hh_082_mba__afro_bun6161", "hh_082_mba__afro_bun_bun", "hh_082_mb__afro_bun6138", "hh_082_mb__afro_bun_bun", "hh_082_ma__afro_bun3687", "hh_082_ma__afro_bun_bun", "hh_081_wa__buns_02_us_cracks5582", "hh_080_wa__buns_01_shadow_npc", "hh_081_wa__buns_022704", "hh_080_waf__buns_017644", "hh_080_wa__buns_01_us_cracks0305", "hh_080_wa__buns_016838", "hh_079_wa__denny0258", "hh_078_wa__evelyn_common3385", "hh_078_wa__evelyn7467", "hh_077_wa__nomad_024358", "hh_077_ma__nomad_028327", "hh_076_mb__ozob4641", "hh_075_wa__peralez_common7071", "hh_075_mf__peralez_common7050", "hh_075_mba__peralez_common7148", "hh_075_mb__peralez_common3232", "hh_075_ma__peralez_common1541", "hh_075_ma__peralez4688", "hh_074_ma__henry8434", "hh_073_wa__nomad_012568", "hh_073_mba__nomad_011212", "hh_073_mb__nomad_017781", "hh_073_ma__nomad_018123", "hh_072_wa__maman_brigitte5557", "hh_071_ma__netwatch_agent1637", "hh_070_mm__animals_boss1635", "hh_070_mm__animals_boss_bangs", "hh_069_wba__animals_044800", "a0_000_pwa_base_nails_l", "a0_000_pwa_base_nails_r", "a0_000_pma_base__injection_r", "a0_000_pwa_base__injection_r", "a0_000_pwa_fpp__injection_r", "a0_000_pma_fpp__injection_r", "t0_000_pwa_base__full_seamfix", "t0_000_pma_base__full_seamfix", "ht_000_pwa_c__basehead", "hx_000_pwa_c__basehead_cyberware_01", "heb_000_pwa_c__basehead", "he_000_pwa_c__basehead", "h0_000_pwa_c__basehead", "hh_033_pwa__player_cyberware_01", "hx_000_pwa_c__basehead_personal_slot_dec", "h0_000_pma_c__basehead", "ht_000_pma_c__basehead", "he_000_pma_c__basehead", "i1_000_pma_c__basehead_earring_01", "hb_000_pma_c__basehead_shadowbase_01", "hb_000_pma_c__basehead", "heb_000_pma_c__basehead", "hh_045_pma__short_spiked_cyberware_01", "hh_045_ma__short_spiked_shadow", "hx_000_pma_c__basehead_cyberware_01", "hx_000_pma_c__basehead_personal_slot_dec", "a0_001__personal_link_tpp4537", "personal_link_female", "MorphTargetSkinnedMesh3637", "MorphTargetSkinnedMesh7243", "i1_000_pwa__morphs_earring_01", "i1_000_pwa__morphs_earring_02", "i1_000_pwa__morphs_earring_03", "i1_000_pwa__morphs_earring_04", "i1_000_pma__morphs_earring_01", "i1_000_pma__morphs_earring_02", "i1_000_pma__morphs_earring_03", "i1_000_pma__morphs_earring_04", "MorphTargetSkinnedMesh1265", "hx_000_pwa__basehead_makeup_lips_01", "hx_000_pwa__basehead_makeup_eyes_01", "hx_000_pma__basehead_makeup_eyes_01", "ht_000_pwa__basehead", "ht_000_pma__basehead", "heb_000_pwa__basehead", "heb_000_pma__basehead", "he_000_pma__basehead", "he_000_pwa__basehead", "t2_122_pwa_jacket__biker6317"} - - possibleFaction = { "Arasaka", "Militech", "KangTao", "Nomad"} - - npcsource = { "npc", "current_star", "faction","faction_random_list", "current_district_leader", "current_subdistrict_leader", "district_leader", "subdistrict_leader", "random","from_list","district_rival","subdistrict_rival","current_district_rival","current_subdistrict_rival"} - npcposition = { - "at", - "relative_to_entity", - "node", - "player_look_at", - "poi", - "mappin", - "fasttravel", - "custom_place", - "custom_room", - "manager" - } - - mappinsource = { - "at", - "relative_to_entity", - "node", - "player_look_at", - "poi", - "mappin", - "fasttravel", - "custom_place", - "custom_room", - "on_entity", - "on_group", - "manager" - } - npcpositionway = { "normal", "behind", "forward","forward_relative"} - npcpositionhouseway = { "default", "enter", "exit"} - - poitype={ "All", "Hostile", "Friendly","Special"} - editorCurrentPOIType = "All" - - vehiclesource = { "vehicle", "faction", "current_district_leader", "current_subdistrict_leader", "district_leader", "subdistrict_leader", "random","from_list","district_rival","subdistrict_rival","current_district_rival","current_subdistrict_rival"} - vehiclespawnsystem = {"From Garage", "Beta", "Prevention","Codeware"} - vehiclespawnsystemeditordefault = "From Garage" - - local f = assert(io.open("mod/data/effects.json")) - - lines = f:read("*a") - - encdo = lines - f:close() - effectslistJson = trydecodeJSOn(encdo, f ,"mod/data/effects.json") - - - listFX = {"blackout", "fast_travel_glitch_long", "fast_travel_glitch", "terrain_scan", "trail", "transition_glitch_loop_braindance", "transition_glitch_loop", "fx_candles_lightup", "weakspot_explode", "weakspot_overload", "weakspot_compensating", "weakspot_destroyed", "weakspot_indicator", "weakspot_broken", "weakspot_hit", "light_on_destr", "mine_laser_green", "mine_laser_red", "light_cone_dust", "fx_empty", "deflection", "swimming_surface_stroke", "swimming_diving", "swimming_diving_stroke", "swimming_diving_stroke_fast", "fx_checked", "fx_damage_high", "fx_damage_medium", "fx_damage_low", "human_shield", "fx_health_low", "muzzle_flash_photo_mode", "fx_oxygen_critical", "stealth_mode", "detonation_warning", "ignition", "focus_mode", "screen_scanning_loop", "screen_scanning_red_loop", "transition_glitch_loop", "scan", "fx_distraction", "broken", "active", "friendly", "status_tired", "blood_onscreen", "fish_eye", "camera_transition_effect_start", "camera_transition_effect_stop", "camera_mask", "imp_concrete", "disabling_connectivity_glitch", "zoom", "fire", "thrusters", "underwater_bubbles", "explosion", "crystal_dome_instant_on", "crystal_dome_start", "crystal_dome_stop", "damage_engine_stage1", "damage_engine_stage2", "damage_engine_stage3", "cooler_destro_fx", "crystal_dome_fl_b", "crystal_dome_fl_f", "crystal_dome_fr_b", "crystal_dome_fr_f", "crystal_dome_ml", "crystal_dome_mr", "crystal_dome_ol", "crystal_dome_or", "overheating", "police_sign_combat", "charge", "police_sign_default", - "blink_fast", - "blink_slow", - "eyes_closing_fast", - "eyes_closing_slow_3s", - "eyes_closing_slow", - "eyes_closing", - "fish_eye", - "focus_mode", - "reboot_glitch", - "sunglasses", - "status_drugged_low", - "status_drugged_medium", - "status_drugged_heavy"} - - npcFX = {"human_shield"} - - carFX={"fire", "thrusters", "underwater_bubbles", "explosion", "damage_engine_stage1", "damage_engine_stage2", "damage_engine_stage3"} - transistionFX ={"blackout", - "fast_travel_glitch_long", - "fast_travel_glitch", - "transition_glitch_loop_braindance", - "transition_glitch_loop", - "fx_health_low", - "focus_mode", - "screen_scanning_loop", - "screen_scanning_red_loop", - "transition_glitch_loop", - "scan", - "blood_onscreen", - "fish_eye", - "camera_transition_effect_start", - "camera_transition_effect_stop", - "camera_mask", - "disabling_connectivity_glitch", - "zoom", - "blink_fast", - "blink_slow", - "eyes_closing_fast", - "eyes_closing_slow_3s", - "eyes_closing_slow", - "eyes_closing", - "fish_eye", - "focus_mode", - "reboot_glitch", - "sunglasses", - "status_drugged_low", - "status_drugged_medium", - "status_drugged_heavy" - - } - - - - - affiliationTweakList = { - - "AfterlifeMercs", - "Aldecaldos", - "Animals", - "Arasaka", - "Biotechnica", - "CityCouncil", - "Civilian", - "KangTao", - "Maelstrom", - "Militech", - "NCPD", - "NetWatch", - "News54", - "RecordingAgency", - "Scavengers", - "SixthStreet", - "SouthCalifornia", - "SSI", - "TheMox", - "TraumaTeam", - "TygerClaws", - "Unaffiliated", - "UnaffiliatedCorpo", - "Unknown", - "Valentinos", - "VoodooBoys", - "Wraiths" - - } - - transgressionsTweakList = {"AidingAI", - "Assault", - "AssaultByMob", - "AssaultCop", - "AssaultCorpo", - "AssaultPublicOfficial", - "AttemptedMurder", - "Battery", - "BatteryCop", - "BatteryCorpo", - "BatteryPublicOfficial", - "Blackmail", - "BlackmailCorpo", - "BlackwallViolation", - "BodilyHarm", - "BodySnatching", - "Classified", - "Confinement", - "CopyrightInfringement", - "CorporateSlander", - "CorpoSlander", - "DataDestruction", - "DataVandal", - "DefilingHumanRemains", - "DrugDealing", - "DrugPossession", - "ElectronicallyStolenGoods", - "EmancipationAI", - "EspionageCorpo", - "FatalHitAndRun", - "ForcedImplantProcedures", - "GeneticAlteration", - "GeneticAlterationPerform", - "GrandLarceny", - "HostageTaking", - "HumanTrafficking", - "IllegalCorrespondance", - "IllegalOrganicFood", - "ImpersonationCorpo", - "KidnappingCorpo", - "KidnappingForRansom", - "LarcenyCorpo", - "ManufactureSubstances", - "MilitaryHardware", - "MultipleHomocide", - "Murder", - "Murder02", - "MurderCop", - "MurderCorpo", - "NetFraud", - "NetMayhem", - "Occupation", - "Pimping", - "ProhibitedNet", - "q110_pizza_easter_egg", - "Racketeering", - "ReverseEngineering", - "SabotagingLifeSavingImplants", - "SellingStolenImplants", - "SexualAssault", - "SIDForgery", - "SIDTheft", - "StealingLifeSavingImplants", - "TradingXBD", - "Trespassing", - "UnlawfulDataAcquisition", - "UnpaidDebt", - "VandalCorp"} - - - defaultFXlist="player" - defaukltFX = "blackout" - Fxobjectlist = {"player","npc","car","all"} - - - - - - arraySubDistrict = - { - "ArasakaWaterfront", - "ArasakaWaterfront_AbandonedWarehouse", - "ArasakaWaterfront_KonpekiPlaza", - "Arroyo", - "Arroyo_Arasaka_Warehouse", - "Arroyo_ClairesGarage", - "Arroyo_CytechFactory", - "Arroyo_Kendachi", - "Arroyo_KenmoreCafe", - "Arroyo_LasPalapas", - "Arroyo_Red_Dirt", - "Arroyo_TireEmpire", - - "Badlands_BiotechnicaFlats", - "Badlands_DryCreek", - "Badlands_JacksonPlains", - "Badlands_LagunaBend", - "Badlands_LasPalapas", - "Badlands_NorthSunriseOilField", - "Badlands_RattlesnakeCreek", - "Badlands_RedPeaks", - "Badlands_RockyRidge", - "Badlands_SantaClara", - "Badlands_SierraSonora", - "Badlands_SoCalBorderCrossing", - "Badlands_VasquezPass", - "Badlands_Yucca", - "Badlands_YuccaGarage", - "Badlands_YuccaRadioTower", - - "CharterHill_PowerPlant", - - "Coastview", - "Coastview_BattysHotel", - "Coastview_ButcherShop", - "Coastview_GrandImperialMall", - "Coastview_RundownApartment", - "Coastview_VDBChapel", - "Coastview_VDBMaglev", - "Coastview_q110Cyberspace", - "CorpoPlaza", - "CorpoPlaza_ArasakaTowerAtrium", - "CorpoPlaza_ArasakaTowerCEOFloor", - "CorpoPlaza_ArasakaTowerJenkins", - "CorpoPlaza_ArasakaTowerJungle", - "CorpoPlaza_ArasakaTowerLobby", - "CorpoPlaza_ArasakaTowerNest", - "CorpoPlaza_ArasakaTowerSaburoOffice", - "CorpoPlaza_ArasakaTowerUnlistedFloors", - "CorpoPlaza_ArasakaTowerUpperAtrium", - "CorpoPlaza_q201Cyberspace", - "Downtown", - "Downtown_Jinguji", - "Downtown_TheHammer", - "Glen", - "Glen_Embers", - "Glen_MusicStore", - "Glen_NCPDLab", - "Glen_WichedTires", - - "JapanTown", - "JapanTown_Clouds", - "JapanTown_DarkMatter", - "JapanTown_Fingers", - "JapanTown_FourthWallBdStudio", - "JapanTown_HiromisApartment", - "JapanTown_MegabuildingH8", - "JapanTown_VR_Tutorial", - "JapanTown_Wakakos_Pachinko_Parlor", - "Kabuki", - "Kabuki_JudysApartment", - "Kabuki_LizziesBar", - "Kabuki_NoTellMotel", - "LagunaBend_LakeHut", - "LittleChina", - "LittleChina_Afterlife", - "LittleChina_MistysShop", - "LittleChina_Q101Cyberspace", - "LittleChina_RiotClub", - "LittleChina_TomsDiner", - "LittleChina_VApartment", - "LittleChina_VictorsClinic", - "NorthBadlands", - "NorthOaks", - "NorthOaks_Arasaka_Estate", - "NorthOaks_Columbarium", - "NorthOaks_Denny_Estate", - "NorthOaks_Kerry_Estate", - "Northside", - "Northside_All_Foods", - "Northside_CleanCut", - "Northside_Totentaz", - "Northside_WNS", - - "RanchoCoronado", - "RanchoCoronado_Caliente", - "RanchoCoronado_GunORama", - "RanchoCoronado_Piez", - "RanchoCoronado_Softsys", - "RanchoCoronado_Stylishly", - - "SouthBadlands", - "SouthBadlands_EdgewoodFarm", - "SouthBadlands_PoppyFarm", - "SouthBadlands_TrailerPark", - "SouthBadlands_q201SpaceStation", - "VistaDelRey", - "Vista_del_Rey_Delamain", - "Vista_del_Rey_LaCatrina", - "Vista_del_rey_Abandoned_Apartment_Building", - "Vista_del_rey_ElCoyoteCojo", - - "Wellsprings", - "WestWindEstate" - - - } - - mappinTypeEnum = { - - - "ActionDealDamageVariant", - "ActionFastSoloVariant", - "ActionGenericInteractionVariant", - "ActionNetrunnerAccessPointVariant", - "ActionNetrunnerVariant", - "ActionScanVariant", - "ActionSoloVariant", - "ActionTechieVariant", - "AimVariant", - "AllowVariant", - "ApartmentVariant", - "ArrowVariant", - "BackOutVariant", - "BountyHuntVariant", - "CallVariant", - "ChangeToFriendlyVariant", - "ClientInDistressVariant", - "ConversationVariant", - "ConvoyVariant", - "CoolVariant", - "CourierVariant", - "CustomPositionVariant", - "CyberspaceNPC", - "CyberspaceObject", - "DefaultInteractionVariant", - "DefaultQuestVariant", - "DefaultVariant", - "DistractVariant", - "DropboxVariant", - "DynamicEventVariant", - "EffectAlarmVariant", - "EffectControlNetworkVariant", - "EffectControlOtherDeviceVariant", - "EffectControlSelfVariant", - "EffectCutPowerVariant", - "EffectDistractVariant", - "EffectDropPointVariant", - "EffectExplodeLethalVariant", - "EffectExplodeNonLethalVariant", - "EffectFallVariant", - "EffectGrantInformationVariant", - "EffectHideBodyVariant", - "EffectLootVariant", - "EffectOpenPathVariant", - "EffectPushVariant", - "EffectServicePointVariant", - "EffectShootVariant", - "EffectSpreadGasVariant", - "EffectStoreItemsVariant", - "ExclamationMarkVariant", - "FailedCrossingVariant", - "FastTravelVariant", - "FixerVariant", - "FocusClueVariant", - "GPSForcedPathVariant", - "GPSPortalVariant", - "GangWatchVariant", - "GenericRoleVariant", - "GetInVariant", - "GetUpVariant", - "GrenadeVariant", - "GunSuicideVariant", - "HandVariant", - "HazardWarningVariant", - "HiddenStashVariant", - "HitVariant", - "HuntForPsychoVariant", - "ImportantInteractionVariant", - "InvalidVariant", - "JackInVariant", - "JamWeaponVariant", - "LifepathCorpoVariant", - "LifepathNomadVariant", - "LifepathStreetKidVariant", - "LootVariant", - "MinorActivityVariant", - "NPCVariant", - "NetrunnerAccessPointVariant", - "NetrunnerSoloTechieVariant", - "NetrunnerSoloVariant", - "NetrunnerTechieVariant", - "NetrunnerVariant", - "NonLethalTakedownVariant", - "OffVariant", - "OpenVendorVariant", - "OutpostVariant", - "PhoneCallVariant", - "QuestGiverVariant", - "QuestionMarkVariant", - "QuickHackVariant", - "ReflexesVariant", - "ResourceVariant", - "RetrievingVariant", - "SOSsignalVariant", - "SabotageVariant", - "ServicePointBarVariant", - "ServicePointClothesVariant", - "ServicePointCyberwareVariant", - "ServicePointDropPointVariant", - "ServicePointFoodVariant", - "ServicePointGunsVariant", - "ServicePointJunkVariant", - "ServicePointMedsVariant", - "ServicePointMeleeTrainerVariant", - "ServicePointNetTrainerVariant", - "ServicePointProstituteVariant", - "ServicePointRipperdocVariant", - "ServicePointTechVariant", - "SitVariant", - "SmugglersDenVariant", - "SoloTechieVariant", - "SoloVariant", - "SpeechVariant", - "TakeControlVariant", - "TakeDownVariant", - "TarotVariant", - "TechieVariant", - "ThieveryVariant", - "UseVariant", - "VehicleVariant", - "WanderingMerchantVariant", - "Zzz01_CarForPurchaseVariant", - "Zzz02_MotorcycleForPurchaseVariant", - "Zzz03_MotorcycleVariant", - "CPO_PingDoorVariant", - "CPO_PingGoHereVariant", - "CPO_PingLootVariant", - "CPO_RemotePlayerVariant", - "Count", - "Invalid" - } - - - statutEffect = { - "AdamSmasher.AdamSmasherOverload", + arrayroom = {} + arrayNPCInteract ={} + cyberscript.customHouse = true + initFinished = false + saveLocationEnabled = false + locationWindowsIsVisible = true + fixerIsSpawn = false + isFadeIn = false + canwaitend = false + ExecPauseMenu = false + testTag = "" + isReady = false + currentTime = {} + phonedFixer = false + currentreason = 4 + isdead = false + inMenu = false + ActiveMenu = nil + ActiveSubMenu = nil + inScanner = false + targetObject = nil + currentPhoneCall = nil + activeMetroDisplay = false + freezeCamera = false + TakeAIVehicule = false + objLook = nil + objLookIsVehicule = false + interactKey = false + cetkeyused = false + nextkey = false + multiName = "" + editorView = {} + editorView.x = 0 + editorView.y = 0 + editorView.z = 0 + editorView.roll = 0 + editorView.pitch = 0 + editorView.yaw = 0 + editorFreeze = false + pitch = 0 + yaw = 0 + AlwaysShowDefaultWindows = 1 + SoundManager = nil + fademessage = "Never Fade Away..." + opacity = 1 + next_ambush = 0 + isGameLoaded = false + nopes = {} + nope = {} + ModIsLoaded = true + SaveisLoaded = false + cyberscript.soundpath = "json\\datapack\\" + cyberscript.autoload = false + tick = 0 + ticktimer = 0 + cetVer = 1.12 + pcWasOpen = false + LastChoiceActionName = nil + inputInAction = false + ActivecustomMappin = nil + ActiveFastTravelMappin = nil + SelectedMappinHouse = nil + SelectedMappinMetro = nil + SelectedScriptMappin = nil + isdialogactivehub = false + candisplayInteract = true + forcedialog = false + myobs = {} + myDialogHubLogicController = {} + lastHubId = 0 + nativeSettings = nil + nativesettingEnabled = false + Keystone_currentSelectedDatapack = nil + recordingMode = false + BrowserCustomPlace = nil + mpvehicletick = 0 + BraindanceGameController = nil + locationWindowsX = 35 + locationWindowsY = 355 + + currentHouseCenter = nil + newHousingTemplateTag = "" + newHousingTemplateName = "" + newHousingTemplatePrice = 0 + newHousingTemplateDescription = "" + newHousingTemplateTarget = "" + + menuWindowsX = 400 + menuWindowsY = 200 + currentHousingTemplate = nil + currentHousingTemplatetag = "" + currentHousing = nil + currentHousingtag="" + menuFrameX = 400 + menuFrameY = 200 + + menuBTNX = 180 + menuBTNY = 150 + + menuRowX = menuFrameX + menuRowY = 150 + + menufont= 1.5 + currentselectedItemIndex = 1 + currentInterface = nil + + choiceHubData = nil + + currentpoi = nil + + onlineReceiver = nil + onlineMessageContent = "" + onlineMessagePopup = false + onlineWhisperPopup = false + onlineMessagePopupFirstUse = true + + + gameStatModifierType = {"Additive","AdditiveMultiplier","Multiplier"} + + + currentLoadedTexture = {} + + currentHelp = nil + currentHelpIndex = 1 + local phonewaitmessage = "Connecting to 10.5.6.189.." + local animcounter = 0 + local tranpsarency = 0 + openHelpMenu = false + openHelp = false + openJournalMenu = false + inputquest = "joytoy_quest_radiant" + inputscore = "myscore" + inputvariable = "myvariable" + inputkey = "mykey" + openInterface = false + defaultIsOpen = true + currentDialogHub = nil + currentInteractionHub = nil + currentPossibleInteractChunkIndex = 1 + possibleInteractdisplay = {} + isGodMod = false + lastTargetKilled = nil + irpmenu = {} + possibleinteractchunk = {} + irpmenu.main = true + + irpmenu.contact = false + irpmenu.fixer = false + irpmenu.service = false + + irpmenu.social = false + irpmenu.address = false + irpmenu.radio = false + + irpmenu.tools = false + irpmenu.multi = false + irpmenu.editor = false + + canLoadDtpckMenu = true + + waiting = false + mainwait = false + firstload = true + + firstloadMission = true + firstloadMarket = true + initfinish = false + ItemsCart = {} + CartPrice = 0 + + query = "" + querycat = "" + + netontracthub = {} + netontracthub.login = true + netontracthub.register = false + netontracthub.main = false + RememberMe = false + + + AvatarList = {} + currentRole = "" + currentbranch = "" + currentFaction = "" + currentFactionRank = "" + possiblebranch = {} + VBodyComponents = {"l0_003_pwa_pants__leggins7303", "l1_004_pma_pants__sweatpants8832", "l1_004_pwa_pants__sweatpants1663", "l1_006_pma_pants__stoop_king8208", "l1_006_pwa_pants__stoop_king6174", "l1_008_pma_shorts__long8821", "l1_008_pwa_shorts__long6811", "l1_011_pma_skirt__tight1732", "l1_044_pma_pants__panties", "l1_011_pwa_skirt__tight0028", "l1_096_pwa_shorts__micro_thong", "l1_012_pma_pants__jeans_tight4118", "l1_012_pwa_pants__jeans_above_ankle8405", "l1_012_pwa_pants__jeans_tight7860", "l1_013_pma_shorts__small4307", "l1_013_pwa_shorts__small0548", "l1_021_pma_pants__cargo_computer", "l1_021_pwa_pants__cargo_computer7114", "l1_021_pwa_pants__cargo_computer", "l1_022_pma_pants__suit_belt5255", "l1_025_pma_pants__leather3476", "l1_034_pma_pants__scavenger6036", "l1_034_pwa_pants__scavenger4728", "l1_045_pma_pants__suit0076", "l1_045_pwa_pants__suit2855", "l1_047_pwa_shorts__panties7731", "l1_049_pma_shorts__boxers6361", "l1_052_pma_pants__suit_paulnight8641", "l1_054_pma_shorts__latino8283", "l1_054_pwa_shorts__latino4138", "l1_061_pma_pants__chaps_farmer5718", "l1_061_pwa_pants__chaps_farmer6443", "l1_062_pma_pants__jeans6487", "l1_063_pwa_pants__leather3162", "l1_065_pma_pants__pockets6523", "l1_065_pwa_pants__pockets7734", "l1_066_pwa_pants__rogue7706", "l1_068_pma_pants__racing_right7166", "l1_068_pma_pants__racing_right_harness_074", "l1_068_pma_pants__racing_right_012_01", "l1_068_pwa_pants__racing_right_012_01", "l1_068_pwa_pants__racing_right_harness_074", "l1_068_pwa_pants__racing", "l1_069_pma_shorts__torn_shorts3371", "l1_069_pwa_shorts__torn_shorts5467", "l1_070_pma_pants__loose 1305", "l1_070_pwa_pants__loose 5137", "l1_077_pma_pants__trauma_small0585", "l1_077_pwa_pants__trauma_small5157", "l1_078_pma_pants__militech5364", "l1_078_pwa_pants__militech6668", "l1_081_pwa_pants__suit8188", "l1_084_pma_skirt__misty8388", "l1_084_pwa_skirt__misty6640", "l1_087_pma_pants__ninja6302", "l1_087_pwa_pants__ninja2367", "l1_088_pma_pants__sergeant1676", "l1_088_pwa_pants__sergeant3237", "l1_091_pma_pants__silverhand5016", "l1_091_pwa_pants__silverhand3762", "a0_005_ma__strongarms_int_r", "a0_005_ma__strongarms_r", "a0_005_ma__strongarms_cyberware_r", "a0_005_ma__strongarms_cyberware_l", "a0_005_ma__strongarms_int_l", "a0_005_ma__strongarms_l", "a0_005_wa__strongarms_cyberware_l", "a0_005_wa__strongarms_l", "a0_005_wa__strongarms_int_l", "a0_005_wa__strongarms_cyberware_r", "a0_005_wa__strongarms_r", "a0_005_wa__strongarms_int_r", "a0_005_wa__strongarms_holstered_personal_link_dec_l3001", "a0_005_wa__strongarms_personal_link_dec_l4456", "a0_001_wa__personal_link_port", "a0_001_ma__personal_link", "a0_001_ma__personal_link_default6377", "a0_001_pma_cyber__silverhand_overlay", "a0_001_wa__personal_link_prototype", "a0_001_wa__personal_link_port_decal1800", "a0_002_ma__monowire_whip_l", "a0_002_ma__monowire_whip_r", "a0_002_wa__monowire_whip_l_cableless", "a0_002_wa__monowire_whip_r_cableless", "a0_002_wa__monowire_left_arm_prototype", "a0_002_wa__monowire_left_whip_prototype", "a0_002_wa__monowire_right_arm_prototype", "a0_002_wa__monowire_right_whip_prototype", "a0_003_ma__mantisblade_left", "a0_003_ma__mantisblade_right", "a0_003_ma__mantisblades_right", "a0_003_ma__mantisblades_left", "SkinnedMesh8480", "SkinnedMesh3815", "a0_004__weapon_grip_device0226", "a0_004__weapon_grip_decal_01", "a0_005_ma__strongarms_holstered_cyberware_r", "a0_005_ma__strongarms_holstered_r", "a0_005_ma__strongarms_holstered_cyberware_l", "a0_005_ma__strongarms_holstered_l", "a0_005_wa__strongarms_holstered_r", "a0_005_wa__strongarms_holstered_cyberware_r", "a0_005_wa__strongarms_holstered_l", "a0_005_wa__strongarms_holstered_cyberware_l", "a0_005_wa__strongarms_photo_mode_r", "a0_005_wa__strongarms_photo_mode_cyberware_r", "a0_005_wa__strongarms_photo_mode_cyberware_l", "a0_005_wa__strongarms_photo_mode_l", "a0_006_launcher_arm_cables", "a0_006_launcher_arm_forearm_bottom_plate_a", "a0_006_launcher_arm_forearm_plate_a", "a0_006_launcher_arm_forearm_plate_b", "a0_006_launcher_arm_forearm_upper_plate_a", "a0_006_launcher_arm_guts_b", "a0_006_launcher_arm_guts_c", "a0_006_launcher_arm_guts_d", "a0_006_launcher_arm_muscle_a", "a0_006_launcher_arm_muscle_b", "a0_006_launcher_arm_muscle_c", "a0_006_launcher_arm_plate_a", "a0_006_launcher_arm_plate_b", "a0_006_launcher_arm_plate_c", "a0_006_launcher_arm_side_plate_a", "a0_006_launcher_arm_side_plate_b", "a0_006_launcher_arm_skin", "a0_006_launcher_arm_wrist_plate_a", "a0_006_launcher_arm_wrist_plate_b", "a0_006_launcher_arm_wrist_plate_c", "a0_006_launcher_arm_wrist_plate_d", "a0_006_launcher_arm_guts_a", "a0_006_launcher_projectile_a", "a0_010_ma__soft_token5036", "a0_010_wa__soft_token2203", "a0_010_ma__soft_token7310", "a0_002_ma__monowire_whip_l_cableless", "a0_002_ma__monowire_whip_r_cableless", "a0_002_ma__monowire_whip_personal_link_dec_l", "a0_000_ma_base__nails_l", "a0_000_ma_base__nails_r", "a0_002_wa__monowire_whip_whip1_l", "a0_002_wa__monowire_whip_whip1_r", "a0_003_ma__mantisblade_upperarm_left", "a0_003_ma__mantisblade_upperarm_right", "a0_003_ma__mantisblade_left", "a0_003_ma__mantisblade_left_blade", "a0_003_ma__mantisblade_left_mechanisms", "a0_003_ma__mantisblade_right_mechanisms", "a0_003_ma__mantisblade_right_blade", "a0_003_wa__mantisblade_right_blade", "a0_003_wa__mantisblade_left_blade", "a0_003_ma__mantisblade_holstered_left6562", "a0_003_ma__mantisblade_holstered_right", "a0_003_ma__mantisblade_holstered_upperarm_left", "a0_003_ma__mantisblade_holstered_upperarm_right", "a0_003_wa__mantisblade_holstered_right", "a0_003_wa__mantisblade_holstered_upperarm_right", "a0_003_wa__mantisblade_holstered_upperarm_left", "a0_003_wa__mantisblade_holstered_left", "a0_003_wa__mantisblade_photomode_left2804", "a0_003_wa__mantisblade_photomode_right", "a0_003_wa__mantisblade_photomode_upperarm_left", "a0_003_wa__mantisblade_photomode_upperarm_right", "a0_003_wa__mantisblade_upperarm_left", "a0_003_wa__mantisblade_upperarm_right", "a0_003_wa__mantisblade_right", "a0_003_wa__mantisblade_left", "a0_006_ma__launcher_upperarm", "a0_006_ma__launcher_upperarm_right", "a0_006_ma__launcher_ammo_fire2714", "a0_006_ma__launcher_shells1525", "a0_006_ma__launcher_fragment_fire4806", "a0_006_ma__launcher_holstered1283", "a0_006_ma__launcher_holstered_upperarm", "a0_006_ma__launcher_holstered_upperarm_right", "a0_006_ma__launcher_mechanisms", "a0_006_ma__launcher_muscles", "a0_006_wa__launcher_upperarm", "a0_006_wa__launcher_holstered_right", "a0_006_wa__launcher_ammo_fire2326", "a0_006_wa__launcher_shells8722", "a0_006_wa__launcher_fragment_fire6227", "a0_006_wa__launcher_holstered4156", "a0_006_wa__launcher_holstered_upperarm", "a0_006_wa__launcher_holstered_photo_mode8630", "a0_006_wa__launcher_upperarm_photo_mode", "a0_006_wa__launcher_holstered_photo_mode_right", "a0_006_wa__launcher_muscles", "a0_006_wa__launcher_mechanisms", "a0_006_wa__launcher_nails_l", "a0_006_wa__launcher_nails_r", "monowire_arm", "monowire_hooks", "monowire_wire", "a0_001_wa__personal_link_prototype1385", "a0_006_launcher_arm_projectile", "t0_005_pma_body__t_bug5280", "t0_005_pma_body__t_bug_cuff", "t0_005_pwa_body__t_bug7718", "t0_005_pwa_body__t_bug_cuff", "t0_006_pma_full__queen2164", "t0_006_pma_full__queen_cuff", "t0_006_pwa_full__queen6424", "t0_006_pwa_full__queen_cuff", "t1_001_pma_shirt__militech_agent", "t1_001_pma_shirt__militech_agent_cuffs", "t1_001_pwa_shirt__militech_agent", "t1_001_pwa_shirt__militech_agent_cuffs", "t1_004_pma_tshirt__longsleeve5383", "t1_004_pma_tshirt__longsleeve_cuff", "t1_007_pma_shirt__lumberjack4112", "t2_pma_shirt__lumberjack", "t1_007_pwa_shirt__lumberjack3803", "t1_011_pwa_tank__plain3516", "t1_011_pwa_tank__plain_dec_sticker", "t1_012_pwa_tank__open_sides7518", "t1_018_pma_full__body0281", "t1_018_pma_full__body_cuffs", "t1_018_pwa_full__body1277", "t1_018_pwa_full__body_cuffs", "t2_pma_jacket__sleeves_shadow", "t1_024_pma_tshirt__sweater_cuffs", "t1_024_pma_tshirt__sweater0253", "t1_024_pwa_tshirt__sweater_cuffs", "t1_024_pwa_tshirt__sweater1258", "t1_035_pwa_shirt__suit6540", "t1_035_pwa_shirt__suit_cuff", "t1_041_pma_tshirt__sleeveless6413", "t1_045_pma_shirt__cowboy3770", "t1_045_pma_shirt__cowboy_suff", "t1_047_pma_tank__pushup8854", "t1_047_pwa_tank__pushup8543", "t1_048_pma_tank__plastic_bag4601", "t1_057_pwa_tank__bra0730", "t1_060_pma_tank__corset3513", "t1_061_pma_shirt__holster_belts5680", "t1_068_pwa_tank__long_rogue3063", "t1_070_pma_full__hanako2543", "t1_070_pma_full__hanako_cuff", "t1_070_pwa_full__hanako4412", "t1_070_pwa_full__hanako_cuff", "t1_071_pma_tank__basic4518", "t1_071_wa_tank__basic7841", "t1_073_pma_shirt__torn_shirt0687", "t1_073_pwa_shirt__torn_shirt8278", "t1_074_pma_shirt__torn_shirt4011", "t1_074_pwa_shirt__torn_shirt7362", "t1_079_pma_tshirt__casual2303", "t1_079_pma_tshirt__casual_dec_witcher", "t1_079_ma_tshirt__casual_dec_samurai", "t1_079_pma_tshirt__casual_dec_galaxy", "sq_white_vote_peralez", "t1_079_pma_tshirt__casual_dec_vote_peralez", "t1_079_pwa_tshirt__casual6346", "t1_079_pwa_tshirt__casual_dec_samurai", "t1_079_pwa_tshirt__casual_dec_witcher", "t1_079_pwa_tshirt__casual_dec_galaxy", "t1_079_pwa_tshirt__casual_dec_vote_peralez", "t1_080_pwa_tank__judy6160", "t1_082_pwa_tank__casual0270", "t1_087_pma_shirt__high_collar2852", "t1_087_pwa_shirt__high_collar3543", "t1_088_pma_shirt__kimono0082", "t1_088_pwa_shirt__kimono3315", "t1_089_pwa_tank__short_torn4743", "t1_090_pma_tank__johnny4617", "t1_090_pwa_tank__johnny1030", "t1_091_pma_full__jumpsuit7248", "t1_091_pma_full__jumpsuit_cuff", "t1_041_pma_tshirt__sleeveless", "t1_091_pwa_full__jumpsuit3810", "t1_091_pwa_full__jumpsuit_cuff", "t1_071_pwa_tank__basic", "t1_093_pwa_shirt__denny_corset8405", "t1_094_pma_shirt__scientist7816", "t1_094_pma_shirt__scientist_cuff", "t1_094_pwa_shirt__scientist3763", "t1_094_pwa_shirt__scientist_cuff", "t1_097_pma_tank__corset_doll_prostitute", "t1_097_pwa_tank__corset_doll_prostitute3055", "t1_102_pma_shirt__vest4307", "t1_102_pwa_shirt__vest5844", "t1_105_pma_tank__bandage1160", "t2_002_pma_vest__puffy1434", "t2_002_pwa_vest__puffy2302", "t2_014_pma_dress__chic3813", "t2_014_pma_dress__chic_cuff", "t2_014_pwa_dress__chic4878", "t2_014_pwa_dress__chic_cuff", "t2_021_pma_vest__denim5608", "black_leather", "t2_021_pma_vest__denim_patch", "t2_021_pma_vest__denim_patch_torn", "t2_021_pwa_vest__denim6405", "t2_021_pwa_vest__denim_patch", "t2_021_pwa_vest__denim_patch_torn", "t2_023_pma_full__uniform8588", "t2_023_pma_full__uniform_badge", "t2_023_pma_full__uniform_screen", "t2_023_pwa_full__uniform0884", "t2_023_pwa_full__uniform_badge", "t2_023_pwa_full__uniform_screen", "t2_031_pma_full__hazmat_no_hood7674", "t2_031_pma_full__hazmat_no_hood_cuff", "t2_031_pma_full__hazmat_no_hood_dec_stickers", "t2_031_pwa_full__hazmat_no_hood2811", "t2_031_pwa_full__hazmat_no_hood_cuff", "t2_031_pwa_full__hazmat_no_hood_dec_stickers", "t2_033_pwa_jacket__suspenders3145", "t2_033_pwa_jacket__suspenders_cuffs", "t2_036_pma_jacket__suit_open_elegant4133", "t2_036_pma_jacket__suit_open_elegant_cuff", "t2_039_pwa_jacket__suit_closed5581", "t2_039_pwa_jacket__suit_closed_shirt", "t2_039_pwa_jacket__suit_closed_cuff", "t2_041_pma_jacket__spiked2584", "t2_041_pwa_jacket__spiked3028", "t2_047_pma_jacket__bolero0308", "t2_047_pwa_jacket__bolero5123", "t2_050_pma_jacket__scavenger6531", "t2_050_pma_jacket__scavenger_cuffs", "t2_061_pma_vest__tactical1201", "t2_061_pma_vest__tactical_dec_corpo", "t2_061_pwa_vest__tactical6683", "t2_061_pwa_vest__tactical_dec_corpo", "t2_063_pwa_jacket__silver3022", "t2_063_pwa_jacket__silver_cuffs", "l0_003_pwa_pants__leggins", "t2_064_pma_jacket__t2_player_heavy2048", "t2_064_pma_jacket__t2_player_heavy_cuff", "t2_064_pma_jacket__t2_player_heavy_collar2277", "t2_064_pma_jacket__t2_player_heavy_collar_folded", "t2_064_pma_jacket__t2_player_heavy_folded", "t2_064_pwa_jacket__t2_player_heavy3241", "t2_064_pwa_jacket__t2_player_heavy_cuff", "t2_064_pwa_jacket__t2_player_heavy_collar3310", "t2_068_pma_jacket__formal_suit7461", "t2_068_pma_jacket__formal_suit_cuff", "t2_068_pma_jacket__formal_suit_elegant4353", "t2_070_pma_jacket__suit_paulnight5857", "t2_070_pma_jacket__suit_paulnight_cuff", "t2_072_pma_vest__tactic_collar6428", "t2_072_pma_vest__tactic_collar_dec_corpo", "t2_072_pwa_vest__tactic_collar0062", "t2_072_pwa_vest__tactic_collar_dec_corpo", "t2_073_pma_vest__tactic_collar27052", "t2_073_pma_vest__tactic_collar2_dec_corpo", "t2_073_pwa_vest__tactic_collar20561", "t2_073_pwa_vest__tactic_collar2_dec_corpo", "t2_075_pwa_jacket__tied6223", "t2_076_pma_vest__armor_short1544", "t2_076_pma_vest__armor_short_dec_corpo", "t2_076_pwa_vest__armor_short4166", "t2_076_pwa_vest__armor_short_dec_corpo", "t2_077_pma_vest__armor_short6286", "t2_077_pma_vest__armor_short_dec_corpo", "t2_077_pwa_vest__armor_short7777", "t2_077_pwa_vest__armor_short_dec_corpo", "t2_080_pma_jacket__prince1302", "t2_080_pma_jacket__prince_cuffs", "t2_080_pwa_jacket__prince4284", "t2_080_pwa_jacket__prince_cuffs", "t2_082_pma_vest__hoodie6131", "t2_082_pwa_vest__hoodie2631", "t2_083_pwa_vest__denim4704", "t2_084_pma__short_sleeves5437", "t2_084_pma_jacket__short_sleeves_hanging2284", "t2_084_pma_jacket__short_sleeves_decal_hanging", "t2_084_pwa__short_sleeves3780", "t2_087_pma_jacket__river_short5470", "t2_087_pma_jacket__river_short_cuff", "t2_087_pwa_jacket__river_short_cuff", "t2_087_pwa_jacket__river_short", "t2_088_pwa_jacket__rogue6184", "t2_088_pwa_jacket__rogue_dec_gang", "t2_088_pwa_jacket__rogue_dec_corpo", "t2_090_pma_vest__harness1084", "t2_090_pwa_vest__harness1081", "t2_091_pma_jacket__racing0841", "t2_091_pma_jacket__racing_cuffs", "t2_091_pma_jacket__racing_dec_sticker", "t2_091_pwa_jacket__racing4672", "t2_091_pwa_jacket__racing_cuffs", "t2_091_pwa_jacket__racing_dec_sticker", "t2_093_pwa_jacket__collar0600", "t2_093_pwa_jacket__collar_collar", "t2_094_pma_full__racing_suit2847", "t2_094_pma_full__racing_suit_cuff", "t2_094_pma_full__racing_suit_stephenson_dec_sticker", "t2_094_pwa_full__racing_suit6578", "t2_094_pwa_full__racing_suit_cuff", "prisoner_orange", "t2_094_pwa_full__racing_suit_stephenson_dec_sticker", "t2_097_pma_jacket__holmes_coat8230", "t2_097_pwa_jacket__holmes_coat1745", "t2_098_pwa_jacket__bomber_jacket1140", "t1_pma_formal__shirt_shadow", "t2_099_pma_jacket__military", "t2_100_pma_vest__military1561", "t2_100_pma_vest__military_dec_corpo", "t2_100_pwa_vest__military3323", "t2_100_pwa_vest__military_dec_corpo", "t2_102_pma_vest__tight3467", "t2_103_pwa_jacket__agent2013", "t2_103_pwa_jacket__agent_cuff", "t2_106_pma_jacket__trauma_small2653", "t2_106_pma_jacket__trauma_small_cuffs_cuffs", "t2_106_ma_jacket__trauma_small_dec_logo", "t2_106_pma_jacket__trauma_small_dec_cable", "t2_106_pwa_jacket__trauma_small4411", "t2_106_pwa_jacket__trauma_small_cuffs", "t2_106_pwa_jacket__trauma_small_dec_cable", "t2_106_wa_jacket__trauma_small_dec_logo", "t2_109_pma_jacket__puffy_vest0887", "t2_109_pwa_jacket__puffy_vest6740", "t2_110_pma_vest__high_collar4286", "t2_110_pwa_vest__high_collar4710", "t2_111_pma_jacket__bodyguard_dex4063", "t2_111_pma_jacket__bodyguard_dex_cuffs", "t2_111_pwa_jacket__bodyguard_dex1833", "t2_111_pwa_jacket__bodyguard_dex_cuffs", "t2_114_pma_vest__hi_vis5306", "t2_114_pma_vest__hi_vis_dec_corpo", "t2_114_pwa_vest__hi_vis1141", "t2_114_pwa_vest__hi_vis_dec_corpo", "t2_115_pma_jacket__military3431", "t2_115_pma_jacket__military_dec_sticker", "t2_115_pma_jacket__military", "t2_115_pwa_jacket__military1114", "t2_115_pwa_jacket__military_dec_sticker", "t2_119_pma_jacket__suit_cuff", "t2_119_pma_jacket__suit8131", "t2_120_pwa_jacket__suit_01", "t2_120_pwa_jacket__suit_sleeves_01", "t2_120_pwa_jacket__suit_sleeves_04", "t2_120_pwa_jacket__suit_sleeves_02_cuff", "t2_120_pwa_jacket__suit_022017", "t2_120_pwa_jacket__suit_03", "t2_122_pma_jacket__biker0023", "t2_122_pma_jacket__biker_cuffs", "t2_122_pwa_jacket__bike", "t2_122_pwa_jacket__biker_cuffs", "t2_123_pma_full__space_suit4181", "t2_123_pma_full__space_suit_dec_sticker", "t2_123_pma_full__space_suit_trauma_pack", "t2_123_pma_full__space_suit_helmet3538", "t2_123_pwa_full__space_suit0210", "t2_123_pwa_full__space_suit_trauma_pack", "t2_123_pwa_full__space_suit_dec_sticker", "t2_123_pwa_full__space_suit_helmet7518", "t2_126_pma_jacket__hood5142", "t2_126_pma_jacket__hood_cuffs", "t2_127_pwa_jacket__evelyn3568", "t2_128_pma_jacket__takemura8622", "t2_128_pma_jacket__takemura_cuff", "t2_131_pma_vest__kerry4682", "t2_131_pma_vest__kerry_dec_gang", "t2_131_pwa_vest__kerry2131", "t2_131_pwa_vest__kerry_dec_gang", "t2_132_pma_jacket__wilson7816", "t2_132_pma_jacket__wilson_dec_corpo", "t2_132_pma_jacket__wilson_dec_gang", "t2_132_pma_jacket__wilson_cuff", "t2_140_pma_jacket__leather7543", "t2_140_pma_jacket__leather_cuff", "t2_140_pwa_jacket__leather3281", "t2_140_pwa_jacket__leather_cuff", "t2_142_pma_jacket__witcher0688", "t2_142_pma_jacket__witcher_cuffs", "leather_black", "t2_142_pwa_jacket__witcher0655", "t2_142_pwa_jacket__witcher_cuffs", "s1_001_pma_shoe__swim_fins4245", "s1_001_pwa_shoe__swim_fins7734", "s1_004_pma_shoe__sneakers_high5153", "s1_005_pma_shoe__sport_high5041", "s1_010_pma_shoe__elegant3230", "s1_011_pwa_boot__heel_sneakers5643", "s1_013_pma_boot__snow_shoes2172", "s1_013_pwa_boot__snow_shoes1576", "s1_026_pma_boot__heavy4104", "s1_026_pwa_boot__heavy7835", "s1_027_pwa_shoe__heel_pointy1510", "s1_039_pma_boot__knee_high1352", "s1_051_pwa_shoe__latino1302", "s1_052_pma_boot__cowboy3283", "s1_052_pwa_boot__cowboy", "s1_053_pma_boot__military3700", "s1_053_pwa_boot__military2302", "s1_055_pma_shoe__converse5711", "s1_055_pwa_shoe__converse6558", "s1_056_pma_boot__biker5465", "s1_056_pwa_boot__biker0668", "s1_057_pma_shoe__racing6821", "s1_057_pwa_shoe__racing4635", "s1_059_pwa_shoe__judy7548", "s1_061_pma_shoe__clair6674", "s1_061_pwa_shoe__clair7540", "s1_063_pma_shoe__mexican7186", "s1_063_pma_shoe__mexican_harness", "s1_063_pwa_shoe__mexican2571", "s1_063_pwa_shoe__mexican_harness", "s1_065_pma_shoe__ankle6553", "s1_065_pwa_shoe__ankle0855", "s1_066_pma_boot__bovver3318", "s1_066_pma_boot__bovver_laces_01", "s1_066_pma_boot__bovver_metal_tip_01", "s1_066_pwa_boot__bovver4748", "s1_066_pwa_boot__bovver_laces_01", "s1_066_pwa_boot__bovver_metal_tip_01", "s1_067_pma_shoe__river3450", "s1_068_pma_shoe__sneakers1043", "s1_068_pwa_shoe__sneakers7640", "s1_073_pwa_shoe__high_heels", "s1_075_pma_shoe__yorinobu2284", "s1_076_pwa_boot__misty5375", "s1_077_pma_boot__blackwater8588", "s1_077_pwa_boot__blackwater7310", "s1_078_pma_boot__wilson6368", "s1_078_pwa_boot__wilson", "s1_079_pwa_shoe__hanako3883", "s1_084_pma_boot__thrusters", "s1_084_pma_boot__thrusters_dec_corpo", "s1_084_pwa_boot__thrusters", "s1_084_pwa_boot__thrusters_dec_corpo", "left_arm", "right_arm", "a0_000_pwa_fpp__nails_l", "a0_000_pwa_fpp__nails_r", "a0_001__personal_link_default_holstered", "MorphTargetSkinnedMesh0531", "l0_000_pwa_base__cs_flat", "t0_000_pwa_fpp__torso", "n0_000_pwa_fpp__neck0160", "t0_000_pma_base__full", "n0_000_pma_fpp__neck2814", "i0_000_pma_base__nipple", "a0_000_pma_base__nails_r", "a0_000_pma_base__nails_l", "a0_000_ma_base__full_ag_hq1491", "a0_000_ma_base__full_ag_hq6168", "g1_012_pma_gloves__trauma_no_protection4340", "i1_002_pwa_slot__diving_bottle7786", "i1_003_pma_neck__bullet_pendant1068", "i1_114_pwa_neck__dogtag_johnny1520", "i1_020_pma_neck__goggles7616", "i1_020_pwa_neck__goggles1368", "i1_050_pma_neck__bolo_tie5567", "i1_074_pma_full__harness_racing", "i1_074_pwa_full__harness_racing", "i1_106_wa_neck__doll7414", "i1_114_pma_neck__dogtag_johnny6127", "i1_122_ma_full__devices", "i1_122_ma_full__devices_dec_sticker", "i1_122_pwa_full__devices4716", "i1_122_pwa_full__devices_dec_sticker", "h1_001_pma_mask__swim_mask2764", "h1_001_pwa_mask__swim_mask0307", "h1_002_pma_hat__headcap4652", "h1_002_pwa_hat__headcap2675", "h1_003_pma_hat__beanie7181", "h1_003_pwa_hat__beanie8268", "h1_007_pma_specs__aviators1285", "h1_007_pwa_specs__aviators2376", "h1_011_pma_hat__baseball7254", "h1_011_pma_hat__baseball_back8080", "h1_011_pwa_hat__baseball7030", "h1_011_pwa_hat__baseball_back4262", "h1_012_pma_hat__googles3226", "h1_012_pwa_hat__googles3001", "h1_015_pma_specs__visor_holo0421", "h1_015_pwa_specs__visor_holo7440", "h1_021_pma_hat__cowboy_sheriff6747", "h1_021_pwa_hat__cowboy_sheriff2327", "h1_024_pma_hat__scavenger5026", "h1_024_pwa_hat__scavenger8308", "h1_032_pma_hat__asian6840", "h1_032_pwa_hat__asian0587", "h1_033_pma_specs__braindance0241", "h1_033_pwa_specs__braindance4636", "h1_036_pma_hat__elegant2825", "h1_036_pwa_hat__elegant7660", "h1_037_pma_hat__hijab0370", "h1_037_pwa_hat__hijab1547", "h1_038_pma_specs__classic6586", "h1_038_pwa_specs__classic3436", "h1_045_pma_hat__farmer0115", "h1_045_pwa_hat__farmer2402", "h1_051_pma_mask__headkerchief_lower0382", "h1_051_pwa_mask__headkerchief_lower7323", "h1_052_pma_specs__tactical_017720", "h1_052_pma_specs__tactical_026748", "h1_052_pma_specs__tactical_035180", "h1_052_pma_specs__tactical_047786", "h1_052_pwa_specs__tactical_018516", "h1_052_pwa_specs__tactical_023262", "h1_052_pwa_specs__tactical_031711", "h1_052_pwa_specs__tactical_048724", "h1_055_pma_specs__googles6020", "h1_055_pwa_specs__googles4313", "h1_056_pma_mask__samurai4161", "h1_056_pwa_mask__samurai0763", "h1_058_pma_mask__skull1350", "h1_058_pma_mask__skull_mask_cover", "h1_058_pma_mask__skull_mask_cover02", "h1_058_pma_mask__skull_small_cover03", "h1_058_pwa_mask__skull5430", "h1_058_pwa_mask__skull_mask_cover", "h1_058_pwa_mask__skull_mask_cover02", "h1_058_pwa_mask__skull_small_cover03", "h1_060_pma_hat__bandana_kerry8710", "h1_060_pwa_hat__bandana_kerry0240", "h1_063_pma_hat__military5372", "h1_063_pwa_hat__military1528", "h1_064_pma_specs__sunglasses_011714", "h1_064_pma_specs__sunglasses_025032", "h1_064_pwa_specs__sunglasses_011343", "h1_064_pwa_specs__sunglasses_026676", "h1_065_pma_hat__guard1224", "h1_065_pwa_hat__guard8765", "h1_070_pma_mask__glasses_l1313", "h1_070_pwa_mask__glasses", "h1_082_pma_hat__bandage1421", "h2_005_pma_helmet__construction0817", "h2_005_pwa_helmet__construction6140", "h2_009_pma_helmet__samurai8040", "h2_009_pwa_helmet__samurai5837", "h2_011_pma_helmet__riot3158", "h2_011_pwa_helmet__riot0243", "h2_015_pma_helmet__motorcycle0431", "h2_015_pwa_helmet__motorcycle1627", "h2_016_pma_helmet__max_tac7723", "h2_016_pwa_helmet__max_tac0037", "i1_020_pma_neck__goggles6842", "i1_020_pwa_neck__goggles0113", "a0_008_ma__fpp_right_q001_injection_mark", "a0_008_wa__fpp_right_q001_injection_mark", "a0_004__weapon_grip_decal_02", "a0_004__weapon_grip_device", "a0_000_nomad_base_fists", "t0_000_pwa_base__full", "hh_000_ma__prototype3047", "hh_000_mb__prototype", "hh_000_wa__prototype", "hh_006_ma__demo3633", "hh_006_mb__demo", "hh_006_wa__demo", "hh_007_ma__demo1210", "hh_007_mb__demo", "hh_007_wa__demo", "hh_008_ma__demo0028", "hh_008_mb__demo", "hh_008_wa__demo", "hh_009_ma__demo3404", "hh_009_mb__demo", "hh_009_wa__demo4473", "hh_011_ma__demo3010", "hh_011_wa__demo7364", "hh_011_waf__demo1381", "hh_020_ma__mullet7683", "hh_020_wa__mullet", "hh_021_ma__player", "hh_021_mb__player013337", "hh_021_wa__player012513", "hh_022_ma__chrome_celeb", "hh_022_mb__chrome_celeb", "hh_022_wa__chrome_celeb", "hh_023_ma__short_messy5102", "hh_023_mb__short_messy", "hh_023_wa__short_messy", "hh_024_wa__underwater_dancer1446", "hh_025_ma__pompadour", "hh_025_mb__pompadour0053", "hh_025_mba__pompadour3258", "hh_025_wa__pompadour2838", "hh_025_wba__pompadour6412", "hh_026_ma__rat_tail", "hh_026_mb__rat_tail7140", "hh_026_mba__rat_tail4380", "hh_026_mc__rat_tail8050", "hh_026_wa__rat_tail6062", "hh_026_wba__rat_tail6150", "hh_027_ma__scavenger", "hh_027_mb__scavenger", "hh_027_mc__scavenger8838", "hh_027_wa__scavenger0663", "hh_028_ma__corpo_bun3807", "hh_028_wa__corpo_bun", "hh_029_wa__misty", "hh_029_wa__misty6688", "hh_030_ma__punk_idol", "hh_030_mb__punk_idol", "hh_030_mc__punk_idol_short5114", "hh_030_wa__punk_idol", "hh_031_ma__morgan_blackhand", "hh_032_ma__ripper_doc_common", "hh_032_mb__ripper_doc_common2200", "hh_032_mf__ripper_doc_common7107", "hh_033_ma__player", "hh_033_wa__player", "hh_034_wa__militech_agent", "hh_034_wa__militech_agent7131", "hh_035_ma__mohawk_tall", "hh_035_mb__mohawk_tall", "hh_035_wa__mohawk_tall", "hh_036_ma__high_tight4653", "hh_036_mb__high_tight3688", "hh_036_mba__high_tight8062", "hh_036_mc__high_tight2408", "hh_036_mf__high_tight7000", "hh_036_wa__high_tight3672", "hh_036_waf__high_tight6778", "hh_036_wba__high_tight1646", "hh_037_ma__gungho3158", "hh_037_mb__gungho7340", "hh_037_mba__gungho8170", "hh_037_mc__gungho5665", "hh_037_mf__gungho4245", "hh_037_wa__gungho5574", "hh_037_waf__gungho8031", "hh_037_wba__gungho7046", "hh_039_ma__punk_shaved7577", "hh_039_mb__punk_shaved7460", "hh_039_mba__punk_shaved6716", "hh_039_mc__punk_shaved8275", "hh_039_mf__punk_shaved0306", "hh_039_wa__punk_shaved", "hh_039_waf__punk_shaved0178", "hh_039_wba__punk_shaved1308", "hh_040_ma__pixie_bob0822", "hh_040_mb__pixie_bob7356", "hh_040_mc__pixie_bob3384", "hh_040_wa__pixie_bob", "hh_040_waf__pixie_bob6887", "hh_040_wba__pixie_bob4233", "hh_041_ma__valentino8404", "hh_041_wa__valentino", "hh_042_ma__topknots6552", "hh_042_mb__topknots1558", "hh_042_mba__topknots2542", "hh_042_mc__topknots3560", "hh_042_mf__topknots0633", "hh_042_wa__topknots", "hh_042_wa__topknots_band", "hh_042_mf__topknots_band", "hh_042_mc__topknots_band", "hh_042_mba__topknots_band", "hh_042_mb__topknots_band", "hh_042_ma__topknots_band", "hh_042_wba__topknots_band", "hh_042_wba__topknots1411", "hh_043_wa__modern_bob6743", "hh_044_ma__classic4517", "hh_044_wa__classic7063", "hh_045_ma__short_spiked8708", "hh_045_mb__short_spiked6105", "hh_045_mba__short_spiked7177", "hh_045_mc__short_spiked1850", "hh_045_mf__short_spiked4442", "hh_045_wa__short_spiked2173", "hh_045_wba__short_spiked7343", "hh_046_ma__saburo_arasaka3348", "hh_047_ma__swirl_pomp5410", "hh_047_wa__swirl_pomp1544", "hh_048_ma__dual_braids8777", "hh_048_mb__dual_braids8661", "hh_048_wa__dual_braids6587", "hh_049_ma__thiago6065", "hh_049_ma__thiago_common6367", "hh_049_mb__thiago_common4480", "hh_049_mba__thiago_common1414", "hh_049_mc__thiago_common8054", "hh_049_mf__thiago_common5240", "hh_049_wa__thiago_common6388", "hh_049_waf__thiago_common7105", "hh_049_wba__thiago_common2817", "hh_050_ma__johnny_silverhand", "hh_051_ma__judy_common7437", "hh_051_wa__judy", "hh_051_wa__judy_common1632", "hh_052_mc__clair6255", "hh_052_wa__clair2245", "hh_053_ma__kerry_eurodyne5786", "hh_053_ma__kerry_eurodyne_common4302", "hh_053_ma__yorinobu3860", "hh_053_wa__kerry_eurodyne_common3268", "hh_054_wa__michiko6576", "hh_054_wa__rogue_young5787", "hh_054_wa__rogue_young_common8076", "hh_055_mb_placide", "hh_055_mba_placide_common3028", "hh_056_wa__rogue_old4448", "hh_057_ma__kerry_eurodyne_young1370", "hh_058_ma__voodoo_013726", "hh_058_mb__voodoo_017001", "hh_058_mba__voodoo_012844", "hh_058_mc__voodoo_016270", "hh_058_wa__voodoo_011875", "hh_058_wba__voodoo_018748", "hh_059_ma__voodoo_027611", "hh_059_mb__voodoo_028265", "hh_059_mba__voodoo_020116", "hh_059_mc__voodoo_028010", "hh_059_mf__voodoo_020552", "hh_059_wa__voodoo_024201", "hh_059_waf__voodoo_020436", "hh_059_wba__voodoo_027872", "hh_060_ma__voodoo_034083", "hh_060_mb__voodoo_037007", "hh_060_mba__voodoo_034235", "hh_060_mc__voodoo_037705", "hh_060_wa__voodoo_036583", "hh_060_wba__voodoo_034725", "hh_061_ma__midlength_wavy2365", "hh_061_mb__midlength_wavy", "hh_061_mba__midlength_wavy", "hh_061_mc__midlength_girly0457", "hh_061_mc__midlength_wavy2788", "hh_061_wa__midlength_wavy8134", "hh_062_ma__slick_back1308", "hh_062_mb__slick_back4121", "hh_062_mba__slick_back4575", "hh_062_wa__slick_back2407", "hh_063_ma__messy_bob0304", "hh_063_mc__messy_bob6182", "hh_063_wa__messy_bob3723", "hh_063_wa__messy_bob_us_cracks8748", "hh_063_wba__messy_bob0017", "hh_064_mc__bob_fringe4183", "hh_064_wa__bob_fringe8438", "hh_064_waf__bob_fringe6800", "hh_064_wba__bob_fringe7150", "hh_065_ma__afro_knots8114", "hh_065_mb__afro_knots4580", "hh_065_mba__afro_knots0164", "hh_065_mc__afro_knots2484", "hh_065_wa__afro_knots5387", "hh_065_waf__afro_knots3741", "hh_065_wba__afro_knots4883", "hh_066_mba__animals_011153", "hh_067_mba__animals_027836", "hh_068_ma__animals_032316", "hh_068_ma__animals_03_band", "hh_068_mb__animals_032001", "hh_068_mb__animals_03_band", "hh_068_mba__animals_03_band", "hh_068_mba__animals_030814", "hh_068_mc__animals_030804", "hh_068_mc__animals_band", "hh_068_wa__animals_band", "hh_068_wa__animals_038526", "hh_068_waf__animals_band", "hh_068_waf__animals_033647", "hh_068_wba__animals_band", "hh_068_wba__animals_038362", "hh_999_wba__buzz_cap5647", "hh_999_waf__buzz_cap3810", "hh_999_wa__buzz_dorset_cap4185", "hh_999_wa__buzz_cap", "hh_999_mf__buzz_cap6774", "hh_999_mc__buzz_cap7112", "hh_999_mba__buzz_cap0763", "hh_999_mb__buzz_cap", "hh_999_ma__buzz_cap", "hh_151_waf__judy_variation02_common3001", "hh_151_wa__judy_v02_shadow_npc", "hh_151_wa__judy_variation02_common4843", "hh_151_wa__judy_variation022886", "hh_151_ma__judy_variation02_common5775", "hh_145_ma__v_short5237", "hh_140_wba__short_afro1353", "hh_140_wa__short_afro8843", "hh_140_mf__short_afro1273", "hh_140_mc__short_afro0562", "hh_140_mba__short_afro1001", "hh_140_mb__short_afro3783", "hh_140_ma__short_afro8223", "hh_133_wa_cyberware_spikes_03", "hh_133_mb_cyberware_spikes_03", "hh_133_ma_cyberware_spikes_03", "hh_132_wa_cyberware_spikes_02", "hh_131_wa_cyberware_spikes_01_cap", "hh_132_ma_cyberware_spikes_02", "hh_131_ma_cyberware_spikes_01_cap", "hh_131_wa_cyberware_spikes_01", "hh_131_wa_cyberware_spikes_01_cap", "hh_131_ma_cyberware_spikes_01", "hh_122_ma__roy5656", "hh_121_wba__t_bug_common2037", "hh_121_waf__t_bug_common0674", "hh_121_wa__t_bug_common5334", "hh_121_wa__t_bug5630", "hh_121_mc__t_bug_common4202", "hh_121_ma__t_bug_common2560", "hh_120_ma__arasaka_bun_knot_04", "hh_120_ma__arasaka_bun_knot_04_band", "hh_120_ma__arasaka_bun_common_04", "hh_082_ma__afro_bun_shadow_npc", "hh_120_ma__arasaka_bun_knot_05", "hh_120_ma__arasaka_bun_knot_03", "hh_120_ma__arasaka_bun_knot_03_band", "hh_120_ma__arasaka_bun_knot_06", "hh_120_ma__arasaka_bun_knot_06_sticks", "hh_120_ma__arasaka_bun_common_03", "hh_120_ma__arasaka_bun_knot_02", "hh_120_ma__arasaka_bun_knot_05_band", "hh_120_ma__arasaka_bun_knot_01", "hh_120_ma__arasaka_bun_common_02", "hh_120_ma__arasaka_bun_knot_02_band", "hh_120_ma__arasaka_bun_common_01", "hh_120_ma__arasaka_bun_046120", "hh_120_ma__arasaka_bun_031001", "hh_120_ma__arasaka_bun_027010", "hh_120_ma__arasaka_bun_016145", "hh_119_ma__kojima0247", "hh_118_wa__gillean8283", "hh_118_ma__gillean4256", "hh_117_wa__nina8038", "hh_116_mb__jesse1353", "hh_115_wa__alanah_common3135", "hh_115_wa__alanah2374", "hh_115_mc__alanah_common1307", "hh_114_ma__cohh4631", "hh_113_ma__iwinski_common2284", "hh_113_ma__iwinski2288", "hh_112_ma__kicinski_player3800", "hh_112_ma__kicinski_common2475", "hh_112_ma__kicinski8536", "hh_110_wa__wizzy2244", "hh_105_wa__us_cracks_020823", "hh_105_wa__us_cracks_02_bands", "hh_104_wa__braids5870", "hh_104_mb__braids8634", "hh_104_ma__braids1237", "hh_103_wa__common_spikes6864", "hh_103_ma__maelstrom_spikes5116", "hh_103_ma__common_spikes4318", "hh_102_ma__maelstrom_mohawk4657", "hh_101_ma__maelstrom_ugly5430", "hh_100_wa__wakako2015", "hh_100_wa__wakako_bun", "hh_100_wa__wakako_bun_chopsticks_bun_sticks", "hh_099_ma__holt_common7842", "hh_099_ma__holt2555", "hh_098_wa__top_bun4103", "hh_097_ma__perez8713", "hh_096_mba__saburo_arasaka_old_common7544", "hh_096_ma__saburo_arasaka_old_common5672", "hh_096_ma__saburo_arasaka_old4265", "hh_095_wa__panam5886", "hh_094_ma__saul_common5252", "hh_050_ma__johnny_silverhand_npc", "hh_094_ma__saul1807", "hh_093_wa__sumo_knot", "hh_093_wa__sumo_knot_band", "hh_085_ma__takemura_shadow_npc", "hh_093_mba__sumo_bodyguard6354", "hh_093_mba__sumo_knot", "hh_093_mba__sumo1528", "hh_093_ma__sumo4200", "hh_093_ma__sumo_knot", "hh_093_ma__sumo_band", "hh_092_wa__hanako7083", "hh_092_wa__hanako_bun", "hh_092_wa__hanako_clip", "hh_091_wa__dakota6784", "hh_091_wa__dakota_braid", "hh_091_wa__dakota_braid_band", "hh_090_wa__alt_sex_scene_023561", "hh_090_wa__alt_sex_scene", "hh_090_wa__alt_player2038", "hh_090_wa__alt5644", "hh_089_wba__thompson_common2040", "hh_089_waf__thompson_common4031", "hh_089_wa__thompson_common3557", "hh_089_mf__thompson3472", "hh_089_mba__thompson_common1478", "hh_089_mb__thompson_common4242", "hh_089_ma__thompson_common3557", "hh_089_ma__thompson_common7847", "hh_089_ma__thompson7678", "hh_088_waf__corpo_bob6527", "hh_088_wa__corpo_bob7280", "hh_087_ma__balding_ponytail7888", "hh_086_ma__balding_short_mitch6837", "hh_086_ma__balding_short0330", "hh_085_wba__takemura_common3666", "hh_085_waf__takemura_common2728", "hh_085_wa__takemura_common3377", "hh_085_mf__takemura_common4838", "hh_085_mc__takemura_common5134", "hh_085_mba__takemura_common4845", "hh_085_mb__takemura_common0623", "hh_085_ma__takemura_common1240", "hh_085_ma__takemura2044", "hh_084_wa__bun_chopsticks6071", "hh_084_wa__bun_chopsticks_bun", "hh_084_wa__bun_chopsticks_bun_sticks", "hh_084_ma__bun_chopsticks7617", "hh_084_ma__bun_chopsticks_bun", "hh_084_ma__bun_chopsticks_bun_sticks", "hh_083_wa__ponytail_straight_016481", "hh_083_wa__ponytail_base_01", "hh_083_wa__ponytail_straight_01_band", "hh_083_wa__ponytail_bulb_013744", "hh_083_wa__ponytail_bulb_01_band", "hh_083_wa__ponytail_braid_011002", "hh_083_wa__ponytail_braid_01_band", "hh_083_ma__ponytail_straight_013188", "hh_083_ma__ponytail_base_01", "hh_083_ma__ponytail_straight_01_band", "hh_083_ma__ponytail_bulb_012124", "hh_083_ma__ponytail_bulb_01_band", "hh_083_ma__ponytail_braid_012023", "hh_083_ma__ponytail_braid_01_band", "hh_082_wba__afro_bun7800", "hh_082_wba__afro_bun_bun", "hh_082_waf__afro_bun8315", "hh_082_waf__afro_bun_bun", "hh_082_wa__afro_bun3836", "hh_082_wa__afro_bun_bun", "hh_082_mf__afro_bun3424", "hh_082_mf__afro_bun_bun", "hh_082_mc__afro_bun5755", "hh_082_mc__afro_bun_bun", "hh_082_mba__afro_bun6161", "hh_082_mba__afro_bun_bun", "hh_082_mb__afro_bun6138", "hh_082_mb__afro_bun_bun", "hh_082_ma__afro_bun3687", "hh_082_ma__afro_bun_bun", "hh_081_wa__buns_02_us_cracks5582", "hh_080_wa__buns_01_shadow_npc", "hh_081_wa__buns_022704", "hh_080_waf__buns_017644", "hh_080_wa__buns_01_us_cracks0305", "hh_080_wa__buns_016838", "hh_079_wa__denny0258", "hh_078_wa__evelyn_common3385", "hh_078_wa__evelyn7467", "hh_077_wa__nomad_024358", "hh_077_ma__nomad_028327", "hh_076_mb__ozob4641", "hh_075_wa__peralez_common7071", "hh_075_mf__peralez_common7050", "hh_075_mba__peralez_common7148", "hh_075_mb__peralez_common3232", "hh_075_ma__peralez_common1541", "hh_075_ma__peralez4688", "hh_074_ma__henry8434", "hh_073_wa__nomad_012568", "hh_073_mba__nomad_011212", "hh_073_mb__nomad_017781", "hh_073_ma__nomad_018123", "hh_072_wa__maman_brigitte5557", "hh_071_ma__netwatch_agent1637", "hh_070_mm__animals_boss1635", "hh_070_mm__animals_boss_bangs", "hh_069_wba__animals_044800", "a0_000_pwa_base_nails_l", "a0_000_pwa_base_nails_r", "a0_000_pma_base__injection_r", "a0_000_pwa_base__injection_r", "a0_000_pwa_fpp__injection_r", "a0_000_pma_fpp__injection_r", "t0_000_pwa_base__full_seamfix", "t0_000_pma_base__full_seamfix", "ht_000_pwa_c__basehead", "hx_000_pwa_c__basehead_cyberware_01", "heb_000_pwa_c__basehead", "he_000_pwa_c__basehead", "h0_000_pwa_c__basehead", "hh_033_pwa__player_cyberware_01", "hx_000_pwa_c__basehead_personal_slot_dec", "h0_000_pma_c__basehead", "ht_000_pma_c__basehead", "he_000_pma_c__basehead", "i1_000_pma_c__basehead_earring_01", "hb_000_pma_c__basehead_shadowbase_01", "hb_000_pma_c__basehead", "heb_000_pma_c__basehead", "hh_045_pma__short_spiked_cyberware_01", "hh_045_ma__short_spiked_shadow", "hx_000_pma_c__basehead_cyberware_01", "hx_000_pma_c__basehead_personal_slot_dec", "a0_001__personal_link_tpp4537", "personal_link_female", "MorphTargetSkinnedMesh3637", "MorphTargetSkinnedMesh7243", "i1_000_pwa__morphs_earring_01", "i1_000_pwa__morphs_earring_02", "i1_000_pwa__morphs_earring_03", "i1_000_pwa__morphs_earring_04", "i1_000_pma__morphs_earring_01", "i1_000_pma__morphs_earring_02", "i1_000_pma__morphs_earring_03", "i1_000_pma__morphs_earring_04", "MorphTargetSkinnedMesh1265", "hx_000_pwa__basehead_makeup_lips_01", "hx_000_pwa__basehead_makeup_eyes_01", "hx_000_pma__basehead_makeup_eyes_01", "ht_000_pwa__basehead", "ht_000_pma__basehead", "heb_000_pwa__basehead", "heb_000_pma__basehead", "he_000_pma__basehead", "he_000_pwa__basehead", "t2_122_pwa_jacket__biker6317"} + + possibleFaction = { "Arasaka", "Militech", "KangTao", "Nomad"} + + npcsource = { "npc", "current_star", "faction","faction_random_list", "current_district_leader", "current_subdistrict_leader", "district_leader", "subdistrict_leader", "random","from_list","district_rival","subdistrict_rival","current_district_rival","current_subdistrict_rival"} + npcposition = { + "at", + "relative_to_entity", + "node", + "player_look_at", + "poi", + "mappin", + "fasttravel", + "custom_place", + "custom_room", + "manager" + } + + mappinsource = { + "at", + "relative_to_entity", + "node", + "player_look_at", + "poi", + "mappin", + "fasttravel", + "custom_place", + "custom_room", + "on_entity", + "on_group", + "manager" + } + npcpositionway = { "normal", "behind", "forward","forward_relative"} + npcpositionhouseway = { "default", "enter", "exit"} + + poitype={ "All", "Hostile", "Friendly","Special"} + editorCurrentPOIType = "All" + + vehiclesource = { "vehicle", "faction", "current_district_leader", "current_subdistrict_leader", "district_leader", "subdistrict_leader", "random","from_list","district_rival","subdistrict_rival","current_district_rival","current_subdistrict_rival"} + vehiclespawnsystem = {"From Garage", "Beta", "Prevention","Codeware"} + vehiclespawnsystemeditordefault = "From Garage" + + local f = assert(io.open("mod/data/effects.json")) + + lines = f:read("*a") + + encdo = lines + f:close() + effectslistJson = trydecodeJSOn(encdo, f ,"mod/data/effects.json") + + + listFX = {"blackout", "fast_travel_glitch_long", "fast_travel_glitch", "terrain_scan", "trail", "transition_glitch_loop_braindance", "transition_glitch_loop", "fx_candles_lightup", "weakspot_explode", "weakspot_overload", "weakspot_compensating", "weakspot_destroyed", "weakspot_indicator", "weakspot_broken", "weakspot_hit", "light_on_destr", "mine_laser_green", "mine_laser_red", "light_cone_dust", "fx_empty", "deflection", "swimming_surface_stroke", "swimming_diving", "swimming_diving_stroke", "swimming_diving_stroke_fast", "fx_checked", "fx_damage_high", "fx_damage_medium", "fx_damage_low", "human_shield", "fx_health_low", "muzzle_flash_photo_mode", "fx_oxygen_critical", "stealth_mode", "detonation_warning", "ignition", "focus_mode", "screen_scanning_loop", "screen_scanning_red_loop", "transition_glitch_loop", "scan", "fx_distraction", "broken", "active", "friendly", "status_tired", "blood_onscreen", "fish_eye", "camera_transition_effect_start", "camera_transition_effect_stop", "camera_mask", "imp_concrete", "disabling_connectivity_glitch", "zoom", "fire", "thrusters", "underwater_bubbles", "explosion", "crystal_dome_instant_on", "crystal_dome_start", "crystal_dome_stop", "damage_engine_stage1", "damage_engine_stage2", "damage_engine_stage3", "cooler_destro_fx", "crystal_dome_fl_b", "crystal_dome_fl_f", "crystal_dome_fr_b", "crystal_dome_fr_f", "crystal_dome_ml", "crystal_dome_mr", "crystal_dome_ol", "crystal_dome_or", "overheating", "police_sign_combat", "charge", "police_sign_default", + "blink_fast", + "blink_slow", + "eyes_closing_fast", + "eyes_closing_slow_3s", + "eyes_closing_slow", + "eyes_closing", + "fish_eye", + "focus_mode", + "reboot_glitch", + "sunglasses", + "status_drugged_low", + "status_drugged_medium", + "status_drugged_heavy"} + + npcFX = {"human_shield"} + + carFX={"fire", "thrusters", "underwater_bubbles", "explosion", "damage_engine_stage1", "damage_engine_stage2", "damage_engine_stage3"} + transistionFX ={"blackout", + "fast_travel_glitch_long", + "fast_travel_glitch", + "transition_glitch_loop_braindance", + "transition_glitch_loop", + "fx_health_low", + "focus_mode", + "screen_scanning_loop", + "screen_scanning_red_loop", + "transition_glitch_loop", + "scan", + "blood_onscreen", + "fish_eye", + "camera_transition_effect_start", + "camera_transition_effect_stop", + "camera_mask", + "disabling_connectivity_glitch", + "zoom", + "blink_fast", + "blink_slow", + "eyes_closing_fast", + "eyes_closing_slow_3s", + "eyes_closing_slow", + "eyes_closing", + "fish_eye", + "focus_mode", + "reboot_glitch", + "sunglasses", + "status_drugged_low", + "status_drugged_medium", + "status_drugged_heavy" + + } + + + + + affiliationTweakList = { + + "AfterlifeMercs", + "Aldecaldos", + "Animals", + "Arasaka", + "Biotechnica", + "CityCouncil", + "Civilian", + "KangTao", + "Maelstrom", + "Militech", + "NCPD", + "NetWatch", + "News54", + "RecordingAgency", + "Scavengers", + "SixthStreet", + "SouthCalifornia", + "SSI", + "TheMox", + "TraumaTeam", + "TygerClaws", + "Unaffiliated", + "UnaffiliatedCorpo", + "Unknown", + "Valentinos", + "VoodooBoys", + "Wraiths" + + } + + transgressionsTweakList = {"AidingAI", + "Assault", + "AssaultByMob", + "AssaultCop", + "AssaultCorpo", + "AssaultPublicOfficial", + "AttemptedMurder", + "Battery", + "BatteryCop", + "BatteryCorpo", + "BatteryPublicOfficial", + "Blackmail", + "BlackmailCorpo", + "BlackwallViolation", + "BodilyHarm", + "BodySnatching", + "Classified", + "Confinement", + "CopyrightInfringement", + "CorporateSlander", + "CorpoSlander", + "DataDestruction", + "DataVandal", + "DefilingHumanRemains", + "DrugDealing", + "DrugPossession", + "ElectronicallyStolenGoods", + "EmancipationAI", + "EspionageCorpo", + "FatalHitAndRun", + "ForcedImplantProcedures", + "GeneticAlteration", + "GeneticAlterationPerform", + "GrandLarceny", + "HostageTaking", + "HumanTrafficking", + "IllegalCorrespondance", + "IllegalOrganicFood", + "ImpersonationCorpo", + "KidnappingCorpo", + "KidnappingForRansom", + "LarcenyCorpo", + "ManufactureSubstances", + "MilitaryHardware", + "MultipleHomocide", + "Murder", + "Murder02", + "MurderCop", + "MurderCorpo", + "NetFraud", + "NetMayhem", + "Occupation", + "Pimping", + "ProhibitedNet", + "q110_pizza_easter_egg", + "Racketeering", + "ReverseEngineering", + "SabotagingLifeSavingImplants", + "SellingStolenImplants", + "SexualAssault", + "SIDForgery", + "SIDTheft", + "StealingLifeSavingImplants", + "TradingXBD", + "Trespassing", + "UnlawfulDataAcquisition", + "UnpaidDebt", + "VandalCorp"} + + + defaultFXlist="player" + defaukltFX = "blackout" + Fxobjectlist = {"player","npc","car","all"} + + + + + + arraySubDistrict = + { + "ArasakaWaterfront", + "ArasakaWaterfront_AbandonedWarehouse", + "ArasakaWaterfront_KonpekiPlaza", + "Arroyo", + "Arroyo_Arasaka_Warehouse", + "Arroyo_ClairesGarage", + "Arroyo_CytechFactory", + "Arroyo_Kendachi", + "Arroyo_KenmoreCafe", + "Arroyo_LasPalapas", + "Arroyo_Red_Dirt", + "Arroyo_TireEmpire", + + "Badlands_BiotechnicaFlats", + "Badlands_DryCreek", + "Badlands_JacksonPlains", + "Badlands_LagunaBend", + "Badlands_LasPalapas", + "Badlands_NorthSunriseOilField", + "Badlands_RattlesnakeCreek", + "Badlands_RedPeaks", + "Badlands_RockyRidge", + "Badlands_SantaClara", + "Badlands_SierraSonora", + "Badlands_SoCalBorderCrossing", + "Badlands_VasquezPass", + "Badlands_Yucca", + "Badlands_YuccaGarage", + "Badlands_YuccaRadioTower", + + "CharterHill_PowerPlant", + + "Coastview", + "Coastview_BattysHotel", + "Coastview_ButcherShop", + "Coastview_GrandImperialMall", + "Coastview_RundownApartment", + "Coastview_VDBChapel", + "Coastview_VDBMaglev", + "Coastview_q110Cyberspace", + "CorpoPlaza", + "CorpoPlaza_ArasakaTowerAtrium", + "CorpoPlaza_ArasakaTowerCEOFloor", + "CorpoPlaza_ArasakaTowerJenkins", + "CorpoPlaza_ArasakaTowerJungle", + "CorpoPlaza_ArasakaTowerLobby", + "CorpoPlaza_ArasakaTowerNest", + "CorpoPlaza_ArasakaTowerSaburoOffice", + "CorpoPlaza_ArasakaTowerUnlistedFloors", + "CorpoPlaza_ArasakaTowerUpperAtrium", + "CorpoPlaza_q201Cyberspace", + "Downtown", + "Downtown_Jinguji", + "Downtown_TheHammer", + "Glen", + "Glen_Embers", + "Glen_MusicStore", + "Glen_NCPDLab", + "Glen_WichedTires", + + "JapanTown", + "JapanTown_Clouds", + "JapanTown_DarkMatter", + "JapanTown_Fingers", + "JapanTown_FourthWallBdStudio", + "JapanTown_HiromisApartment", + "JapanTown_MegabuildingH8", + "JapanTown_VR_Tutorial", + "JapanTown_Wakakos_Pachinko_Parlor", + "Kabuki", + "Kabuki_JudysApartment", + "Kabuki_LizziesBar", + "Kabuki_NoTellMotel", + "LagunaBend_LakeHut", + "LittleChina", + "LittleChina_Afterlife", + "LittleChina_MistysShop", + "LittleChina_Q101Cyberspace", + "LittleChina_RiotClub", + "LittleChina_TomsDiner", + "LittleChina_VApartment", + "LittleChina_VictorsClinic", + "NorthBadlands", + "NorthOaks", + "NorthOaks_Arasaka_Estate", + "NorthOaks_Columbarium", + "NorthOaks_Denny_Estate", + "NorthOaks_Kerry_Estate", + "Northside", + "Northside_All_Foods", + "Northside_CleanCut", + "Northside_Totentaz", + "Northside_WNS", + + "RanchoCoronado", + "RanchoCoronado_Caliente", + "RanchoCoronado_GunORama", + "RanchoCoronado_Piez", + "RanchoCoronado_Softsys", + "RanchoCoronado_Stylishly", + + "SouthBadlands", + "SouthBadlands_EdgewoodFarm", + "SouthBadlands_PoppyFarm", + "SouthBadlands_TrailerPark", + "SouthBadlands_q201SpaceStation", + "VistaDelRey", + "Vista_del_Rey_Delamain", + "Vista_del_Rey_LaCatrina", + "Vista_del_rey_Abandoned_Apartment_Building", + "Vista_del_rey_ElCoyoteCojo", + + "Wellsprings", + "WestWindEstate" + + + } + + mappinTypeEnum = { + + + "ActionDealDamageVariant", + "ActionFastSoloVariant", + "ActionGenericInteractionVariant", + "ActionNetrunnerAccessPointVariant", + "ActionNetrunnerVariant", + "ActionScanVariant", + "ActionSoloVariant", + "ActionTechieVariant", + "AimVariant", + "AllowVariant", + "ApartmentVariant", + "ArrowVariant", + "BackOutVariant", + "BountyHuntVariant", + "CallVariant", + "ChangeToFriendlyVariant", + "ClientInDistressVariant", + "ConversationVariant", + "ConvoyVariant", + "CoolVariant", + "CourierVariant", + "CustomPositionVariant", + "CyberspaceNPC", + "CyberspaceObject", + "DefaultInteractionVariant", + "DefaultQuestVariant", + "DefaultVariant", + "DistractVariant", + "DropboxVariant", + "DynamicEventVariant", + "EffectAlarmVariant", + "EffectControlNetworkVariant", + "EffectControlOtherDeviceVariant", + "EffectControlSelfVariant", + "EffectCutPowerVariant", + "EffectDistractVariant", + "EffectDropPointVariant", + "EffectExplodeLethalVariant", + "EffectExplodeNonLethalVariant", + "EffectFallVariant", + "EffectGrantInformationVariant", + "EffectHideBodyVariant", + "EffectLootVariant", + "EffectOpenPathVariant", + "EffectPushVariant", + "EffectServicePointVariant", + "EffectShootVariant", + "EffectSpreadGasVariant", + "EffectStoreItemsVariant", + "ExclamationMarkVariant", + "FailedCrossingVariant", + "FastTravelVariant", + "FixerVariant", + "FocusClueVariant", + "GPSForcedPathVariant", + "GPSPortalVariant", + "GangWatchVariant", + "GenericRoleVariant", + "GetInVariant", + "GetUpVariant", + "GrenadeVariant", + "GunSuicideVariant", + "HandVariant", + "HazardWarningVariant", + "HiddenStashVariant", + "HitVariant", + "HuntForPsychoVariant", + "ImportantInteractionVariant", + "InvalidVariant", + "JackInVariant", + "JamWeaponVariant", + "LifepathCorpoVariant", + "LifepathNomadVariant", + "LifepathStreetKidVariant", + "LootVariant", + "MinorActivityVariant", + "NPCVariant", + "NetrunnerAccessPointVariant", + "NetrunnerSoloTechieVariant", + "NetrunnerSoloVariant", + "NetrunnerTechieVariant", + "NetrunnerVariant", + "NonLethalTakedownVariant", + "OffVariant", + "OpenVendorVariant", + "OutpostVariant", + "PhoneCallVariant", + "QuestGiverVariant", + "QuestionMarkVariant", + "QuickHackVariant", + "ReflexesVariant", + "ResourceVariant", + "RetrievingVariant", + "SOSsignalVariant", + "SabotageVariant", + "ServicePointBarVariant", + "ServicePointClothesVariant", + "ServicePointCyberwareVariant", + "ServicePointDropPointVariant", + "ServicePointFoodVariant", + "ServicePointGunsVariant", + "ServicePointJunkVariant", + "ServicePointMedsVariant", + "ServicePointMeleeTrainerVariant", + "ServicePointNetTrainerVariant", + "ServicePointProstituteVariant", + "ServicePointRipperdocVariant", + "ServicePointTechVariant", + "SitVariant", + "SmugglersDenVariant", + "SoloTechieVariant", + "SoloVariant", + "SpeechVariant", + "TakeControlVariant", + "TakeDownVariant", + "TarotVariant", + "TechieVariant", + "ThieveryVariant", + "UseVariant", + "VehicleVariant", + "WanderingMerchantVariant", + "Zzz01_CarForPurchaseVariant", + "Zzz02_MotorcycleForPurchaseVariant", + "Zzz03_MotorcycleVariant", + "CPO_PingDoorVariant", + "CPO_PingGoHereVariant", + "CPO_PingLootVariant", + "CPO_RemotePlayerVariant", + "Count", + "Invalid" + } + + + statutEffect = { + "AdamSmasher.AdamSmasherOverload", "AdamSmasher.AdamSmasherStatus", "AdamSmasher.AdamSmasherStealthDot", "AdamSmasher.AdamSmasherStealthDotDamage", @@ -2909,10 +2909,10 @@ function resetVar() "WorkspotStatus.SwimTube", "WorkspotStatus.SyncAnimation", "WorkspotStatus.Unconscious" - - } - reactionlist = { - {name = "Neutral", idle = 2, category = 2}, + + } + reactionlist = { + {name = "Neutral", idle = 2, category = 2}, {name = "Joy", idle = 5, category = 3}, {name = "Smile", idle = 6, category = 3}, {name = "Sad", idle = 3, category = 3}, @@ -2931,621 +2931,621 @@ function resetVar() {name = "Sleepy", idle = 5, category = 1}, {name = "Unconscious", idle = 4, category = 1}, {name = "Dead", idle = 1, category = 2} - } - reactionNameList = {"Neutral","Joy","Smile","Sad","Surprise","Aggressive","Anger","Interested","Disinterested","Disappointed","Disgust","Exertion","Nervous","Fear","Terrified","Pain","Sleepy","Unconscious","Dead"} - --Thanks AMM - - editor_check_trigger_test = false - editor_check_action_test = false - editor_check_trigger_test_visble = false - - editor_json = "" - editor_json_tag = "" - editor_json_view = false - editor_json_malformatted = false - editor_json_malformatted_error = "" - editor_json_obj = nil - editor_json_obj_name = "" - - possiblecategory = {} - corpoNews = {} - - - arrayDatapack3 = {} - arrayMyDatapack = {} - - arrayMission = {} - arrayMymissions = {} - editorPathTarget = nil - arrayMarket = {} - recordRotation = false - recordRotationOnly = false - recordRelative = false - recordInitialPosition = {} - arrayMarketItem = {} - lookatEntity = nil - currentpack = "" - - CurrentServerModVersion = {} - CurrentServerModVersion.version = cyberscript.version - - NetServiceOn = true - MultiplayerOn = false - - - canSpawn = true - selectedInstance = 1 - selectedInstancePassword = "none" - - myTag = "" - currentSave.myAvatar = "Character.Judy" - - Avatarindex = 1 - tweakdbtable = {} - - myFriendTag = "" - myPassword = "" - - tokenisvalid = false - myFaction ="Arasaka" - previousConnectedPlayersList = {} - ActualPlayersList = {} - - multiWindowsOpen = false - errormessage = "" - AlreadyLogin = false - friendIsSpaned = false - friendIsReady = false - friendMove = false - - to_spawn = {} - - KillStats = { - totalKills = 0, - totalKillsByGroup = {}, - lastKillLocation = nil, - lastKillTimestamp = nil, - } - - - seats = {"seat_front_left","seat_front_right","seat_back_right","seat_back_left"} - - - - -- - calledfromgarage = true - - - channel = 1 - - currentMultiHouse = {} - ItemOfHouseMultiSpawned = false - isInMultiHouse = false - selectedItemMulti = nil - selectedItemMultiBackup = nil - - - currentHouse = {} - isInHouse = false - ItemOfHouseSpawned = false - worldprocessing = false - messageprocessing = false - selectedItem = nil - SalaryIsPossible = true - --enum type house - - - potentialQuest = {} - possibleQuest = {} - takenQuest = {} - openQuestWindows = false - currentQuest = nil - AIhandler = {} - currentQuestStarted = false - currentQuestFailed = false - - - cancheckmission = false - currentQuestFinished = false - - - canDoTriggerAction = false - canDoStartAction = false - canDoEndAction = false - canDoFailAction = false - - canDoResetAction = false - - DoedTriggerAction = false - DoedStartAction = false - DoedEndAction = false - DoedFailAction = false - AIconversation = {} - DoedResetAction = false - - actionistaken = false - worker = false - currentActionIndex=0 - - currentActionList = nil - currentActionVerb = nil - currentwaitTimer = nil - currentTimer = nil - - displayRemaningTimer = false - displayConsumingTimer = false - displayTimerMessage = "" - - enabledTrack = {} - - - currentTarget={} - currentTargetIsFromNPC = false - currentTargetIsFromFriend = false - - - selectedEntity = false - - enableEntitySelection = false - entitySelectionIsVehicule = false - - - openQuestDialogWindow = false - openPhoneDialogWindow = false - openSpeakDialogWindow = false - openEventDialogWindow = false - openPhone = false - startSpeak = false - currentPhoneDialog = nil - currentPhoneDialogPopup = nil - Phoned = nil - phoneAnim = false - phoneAnimFixer = false - - autoplayRadio = false - autoplayincar = false - shuffleall = false - currentRadio = {} - currentRadioVolume = 100 - pausemusic = false - - - - possibleInteract = {} - possibleInteractDisplay = {} - - currentInteractGroupIndex = 1 - currentInteractGroup = {} - - - - workerTable={} - workerTableKey={} - directWorkerTable = {} - directActionsWorkerTable = {} - toremove = {} - selectTarget = nil - autoScript = true - - goIndex = 0 - - cachedActionResult = false - - mappinManager = {} - currentDistricts2 = { - visible = true, - districtId = nil, - districtLabels = nil, - districtCaption = nil, - factionLabels = nil, - customdistrict = nil - } - - - - AVinput = { - isMoving = false, - lastInput = "", - keyPressed = false, - currentDirections = { - forward = false, - backwards = false, - right = false, - left = false, - up = false, - down = false, - rollleft = false, - rollright = false, - }, - } - - - ScannerInfoManager = {} - - VendorsStockManager = {} - VendorsStockManager["lookatnpc"] = {} - VendorsStockManager["lookatnpc"].items = {} - - - local itemtable = {} - local myitems = {} - myitems.quantity = math.random(1,10) - myitems.tweak = "Items.Preset_Chao_Neon" - myitems.powerLevel = math.random(1,10) - table.insert(itemtable,myitems) - - local myitems = {} - myitems.quantity = math.random(1,10) - myitems.tweak = "Items.Helmet_03_old_01" - myitems.powerLevel = math.random(1,10) - table.insert(itemtable,myitems) - - local myitems = {} - myitems.quantity = math.random(1,10) - myitems.tweak = "Items.Jacket_02_old_03" - myitems.powerLevel = math.random(1,10) - table.insert(itemtable,myitems) - - local myitems = {} - myitems.quantity = math.random(1,10) - myitems.tweak = "Items.GenericJunkItem14" - myitems.powerLevel = math.random(1,10) - table.insert(itemtable,myitems) - - local myitems = {} - myitems.quantity = math.random(1,10) - myitems.tweak = "Items.SexToyJunkItem4" - myitems.powerLevel = math.random(1,10) - table.insert(itemtable,myitems) - - VendorsStockManager["lookatnpc"].items = itemtable - VendorsStockManager["lookatnpc"].name = "Donk's Dealer" - -- ScannerInfoManager["judy01"] = {} - -- ScannerInfoManager["judy01"].name = "Donk's Love" - -- ScannerInfoManager["judy01"].secondaryname = "Cookie eaters" - -- ScannerInfoManager["judy01"].level = 5 - -- ScannerInfoManager["judy01"].rarity = 0 - -- ScannerInfoManager["judy01"].faction = "faction_mox" - -- ScannerInfoManager["judy01"].attitude = 0 - -- ScannerInfoManager["judy01"].networkstate = 5 - -- ScannerInfoManager["judy01"].text = "Go Buy it for me !" - -- ScannerInfoManager["judy01"].bounty = {} - -- ScannerInfoManager["judy01"].bounty.transgressions= {} - -- ScannerInfoManager["judy01"].bounty.customtransgressions= {"cookier eaters", "donk sucker"} - -- table.insert( ScannerInfoManager["judy01"].bounty.transgressions,"UnpaidDebt") - -- ScannerInfoManager["judy01"].bounty.reward = 130891 - -- ScannerInfoManager["judy01"].bounty.streetreward = 69 - -- ScannerInfoManager["judy01"].bounty.issuedby = "donk" - -- ScannerInfoManager["judy01"].bounty.danger = 5 - - AVList = {"","",} - - AVspeed = 0.3 - AVVelocity = 0.005 - CurrentAVEntity = nil - AVisIn = false - AVseat = nil - AVyaw = 0 - AVroll = 0 - AVrollCam = 0 - AVPitch = 0 - - - - - --Var and Init - - - enummt = { - __index = function(table, key) - if rawget(table.enums, key) then - return key - end - end - } - - - - - openColorPicker = false - - openEditor = false - openEditTrigger = false - openEditActionTrigger = false - openNewTrigger = false - - openTriggerItem = false - - openNewAction = false - openEditAction = false - toti = "" - totitem = "" - searchitem="" - - - camstep = 0.1 - posstep = 0.1 - rotstep = 0.1 - - openNewRoom = false - openEditRoom = false - - - - loadQuest = {} - loadInteract = {} - loadPlace = {} - loadDialog = {} - loadEvent = {} - loadFunction = {} - loadCustomNPC = {} - loadFixer = {} - loadFaction = {} - loadRadio = {} - loadNode = {} - loadCircuit = {} - loadPath = {} - loadLang = {} - LoadInterface = {} - loadHelp ={} - loadPOI = {} - loadShard = {} - loadPhoneDialog = {} - loadScene = {} - loadHousing = {} - - loadQuesttag = "" - loadInteracttag = "" - loadPlacetag = "" - loadDialogtag = "" - loadEventtag = "" - loadFunctiontag = "" - loadCustomNPCtag = "" - loadFixertag = "" - loadFactiontag = "" - loadRadiotag = "" - loadNodetag = "" - loadCircuittag = "" - loadPathtag = "" - loadLangtag = "" - LoadInterfacetag = "" - LoadPOItag = "" - loadHelptag ="" - loadShardtag = "" - loadPhoneDialogtag = "" - loadScenetag = "" - loadHousingtag = "" - currentSelectLocation = {} - - editLocation = false - placetype = "House" - newRequirementItem = "" - selectedTrigger2 = "" - currentSelectTrigger = {} - currentSelectAction = {} - currentSelectRoom = {} - currentSelectOptions = {} - currentSelectObjective = {} - currentSelectConversation = {} - currentSelectMessage = {} - currentSelectChoice = {} - currentSelectSceneStep = {} - currentEditorTrigger = nil - currentEditorItems = nil - currentEditorAction = nil - currentEditorOptions = nil - currentEditorControls = nil - currentcolor = "" - currentcolorTable = {} - questTrigger = true - questStart = true - questEnd = true - questFail = true - currentEditorSubTrigger = {} - editLocation=false - EditorAddColor=false - colorPickerModeRGB = false - genericItem = {} - genericItem.name = "" - genericItem.file = "" - - genericLocation = {} - genericLocation.x = 0 - genericLocation.y = 0 - genericLocation.z = 0 - genericLocation.district = "Watson" - genericLocation.subdistrict = "ArasakaWaterfront" - genericLocation.inVehicule = false - genericLocation.Tag = "" - - genericVIP = {} - genericVIP.name = "" - genericVIP.score = 0 - - EgameMessageSender = - { - NPC = 0, - Player = 1 - } - - defaulftGameMessageSender = "NPC" - defaulttag = "mytag" - dicKey = "" - dicValue = "" - dicInt = 0 - selectedTrigger = "auto" - selectedTrigger2 = "auto" - npcchara = "Judy" - defaultQuestType = "Contract" - npcFixer = "Wakako Okada" - defaultfaction = "Mox" - defaultDistrict = "Watson" - defaultEnumDistrict = "Watson" - defaultJournalEntryState = "Active" - waydialog = "phone" - selectedAction = "notify" - selectedSubAction = "notify" - selectedControlType = "button" - selectedControlvalue = "text" - selectedThemeKey = "" - selectedThemeValue = {} - selectedThemeText = "" - selectedTriggerTable = {} - selectedActionTable = {} - newtrigger = {} - - - selecAction = "" - - currentParentItem = {} - - activeEditedQuest = {} -- 0 - questgraph = {} - choicegraph = {} - activeEditedInteract = {} --1 - activeEditedDialog = {}--2 - activeEditedFixer = {} --3 - activeEditedPlace = {} --4 - activeEditedFunction = {} --5 - activeEditedFaction = {} --5 - activeEditedRadio = {} --5 - activeEditedNode = {} --5loadPlacetag - activeEditedCircuit = {} --5 - activeEditedPath = {} --5 - activeEditedPOI = {} --5 - activeEditedEvent = {} --5 - activeEditedLang = {} --5 - activeEditHelp = {} --5 - activeEditedTheme = {} --5 - activeEditedInterfaces = {} --5 - activeEditedCustomNPC = {} --5 - activeEditedShard = {} --5 - activeEditedPhoneDialog = {} --5 - activeEditedScene = {} --4 - activeEditedHousing = {} - - - - local f = assert(io.open("mod/data/anims/CharacterEntryLibrary.json")) - - lines = f:read("*a") - - encdo = lines - f:close() - entityListJson = trydecodeJSOn(encdo, f ,"mod/data/anims/CharacterEntryLibrary.json") - - - entityListJsonfinal = {} - controltypelist = {"button","label","area","scrollarea","vertical_area","image"} - controltypevaluelist = {"text","number","score","variable"} - - - -- animslibrary = {} - - -- local reader = dir("mod/data/anims") - -- if(reader ~= nil) then - -- for i,v in ipairs(reader) do - -- animslibrary[reader[i].name] = dofile(v) - -- end - - -- end - - wantcorrectpoi = false - poicorrectready = false - currentpoicorrectindex = 1 - - - local f = assert(io.open("mod/external/amm_entities.json")) - - lines = f:read("*a") - - encdo = lines - amm_entities = {} - - local test = trydecodeJSOn(encdo, f ,"mod/external/amm_entities.json") - - for i,v in ipairs(test) do - - amm_entities[v.entity_id] = v - - - - end - - - - - local f = assert(io.open("mod/external/amm_component.json")) - - lines = f:read("*a") - - encdo = lines - amm_component = {} - - local test = trydecodeJSOn(encdo, f ,"mod/external/amm_component.json") - - for i,v in ipairs(test) do - - amm_component[v.cname] = v - - - end - - - - - arrayDBitems = {} - arrayDBitemsfilter = {} - - local f = assert(io.open("mod/data/getItems.json")) - - lines = f:read("*a") - - encdo = lines - - - - - arrayDBitems = trydecodeJSOn(encdo, f,"mod/data/getItems.json") - - - f:close() - - - - - - if AMM ~= nil then - - local ammprops = AMM.API.GetAMMProps() - - for i,v in ipairs(ammprops) do - - local obj = {} - obj.Id = #arrayDBitems + i - obj.Path = v.path - obj.Tag= string.lower(v.name:gsub( " ", "_")) - obj.Title = "(AMM) "..v.name - obj.Statut = 1 - obj.Quantity = 99999999999 - obj.Price = math.random(1,5000) - obj.Inflate = 0 - obj.DefaultStatut = 0 - obj.parentCategory = "amm" - obj.childCategory = "amm" - obj.flag = "amm;" - table.insert(arrayDBitems,obj) - end - - end - - - - - componentCname = {"amm_prop_slot1", "amm_prop_slot2", "amm_prop_slot3", "amm_prop_slot4", "body_01", "trunk_a", "cockpit", "trunk_b", "canopy_right_screen_frame_b", "canopy_right_screen_middle_b", "canopy_right_screen_right_b", "canopy_right_screen_left_b", "canopy_right_screen_frame_a", "canopy_right_screen_middle_a", "canopy_right_screen_right_a", "canopy_right_screen_left_a", "canopy_left_screen_middle_b", "canopy_left_screen_frame_b", "canopy_left_screen_right_b", "canopy_left_screen_left_b", "canopy_left_mainscreen_b", "canopy_left_mainscreen_a", "canopy_left_screen_left_a", "canopy_left_screen_right_a", "canopy_left_screen_middle_a", "canopy_left_screen_frame_a", "canopy_right_screen_a", "av_militech_basilisk__ext01_body_shadow", "av_militech_basilisk__ext01_trunk_b_shadow", "av_militech_basilisk__ext01_trunk_a_shadow", "av_militech_basilisk__ext01_hinges_shadow", "basilisk_vfx_cutout", "elevator_door_large_a", "Mesh8033", "neon", "neon_unlit", "neon_light_a", "mch_003__minotaur_arm_l_01", "mch_003__minotaur_body_01", "mch_003__minotaur_decals", "mch_003__minotaur_lights_glass", "mch_003__minotaur_arm_r_01", "mch_003__minotaur_bags_01", "mch_003__minotaur_hands_01", "mch_003__minotaur_weapons_01", "mch_003__minotaur_legs_01", "mch_003__minotaur_arm_l_4776", "mch_003__minotaur_arm_l_1320", "vs_apartment_table_default", "smoke_machine_a", "Mesh8265", "q110_black_box", "int_accessories_001__johnnysguitar"} - - lightComponents = { - "Light0275", + } + reactionNameList = {"Neutral","Joy","Smile","Sad","Surprise","Aggressive","Anger","Interested","Disinterested","Disappointed","Disgust","Exertion","Nervous","Fear","Terrified","Pain","Sleepy","Unconscious","Dead"} + --Thanks AMM + + editor_check_trigger_test = false + editor_check_action_test = false + editor_check_trigger_test_visble = false + + editor_json = "" + editor_json_tag = "" + editor_json_view = false + editor_json_malformatted = false + editor_json_malformatted_error = "" + editor_json_obj = nil + editor_json_obj_name = "" + + possiblecategory = {} + corpoNews = {} + + + arrayDatapack3 = {} + arrayMyDatapack = {} + + arrayMission = {} + arrayMymissions = {} + editorPathTarget = nil + arrayMarket = {} + recordRotation = false + recordRotationOnly = false + recordRelative = false + recordInitialPosition = {} + arrayMarketItem = {} + lookatEntity = nil + currentpack = "" + + CurrentServerModVersion = {} + CurrentServerModVersion.version = cyberscript.version + + NetServiceOn = true + MultiplayerOn = false + + + canSpawn = true + selectedInstance = 1 + selectedInstancePassword = "none" + + myTag = "" + currentSave.myAvatar = "Character.Judy" + + Avatarindex = 1 + tweakdbtable = {} + + myFriendTag = "" + myPassword = "" + + tokenisvalid = false + myFaction ="Arasaka" + previousConnectedPlayersList = {} + ActualPlayersList = {} + + multiWindowsOpen = false + errormessage = "" + AlreadyLogin = false + friendIsSpaned = false + friendIsReady = false + friendMove = false + + to_spawn = {} + + KillStats = { + totalKills = 0, + totalKillsByGroup = {}, + lastKillLocation = nil, + lastKillTimestamp = nil, + } + + + seats = {"seat_front_left","seat_front_right","seat_back_right","seat_back_left"} + + + + -- + calledfromgarage = true + + + channel = 1 + + currentMultiHouse = {} + ItemOfHouseMultiSpawned = false + isInMultiHouse = false + selectedItemMulti = nil + selectedItemMultiBackup = nil + + + currentHouse = {} + isInHouse = false + ItemOfHouseSpawned = false + worldprocessing = false + messageprocessing = false + selectedItem = nil + SalaryIsPossible = true + --enum type house + + + potentialQuest = {} + possibleQuest = {} + takenQuest = {} + openQuestWindows = false + currentQuest = nil + AIhandler = {} + currentQuestStarted = false + currentQuestFailed = false + + + cancheckmission = false + currentQuestFinished = false + + + canDoTriggerAction = false + canDoStartAction = false + canDoEndAction = false + canDoFailAction = false + + canDoResetAction = false + + DoedTriggerAction = false + DoedStartAction = false + DoedEndAction = false + DoedFailAction = false + AIconversation = {} + DoedResetAction = false + + actionistaken = false + worker = false + currentActionIndex=0 + + currentActionList = nil + currentActionVerb = nil + currentwaitTimer = nil + currentTimer = nil + + displayRemaningTimer = false + displayConsumingTimer = false + displayTimerMessage = "" + + enabledTrack = {} + + + currentTarget={} + currentTargetIsFromNPC = false + currentTargetIsFromFriend = false + + + selectedEntity = false + + enableEntitySelection = false + entitySelectionIsVehicule = false + + + openQuestDialogWindow = false + openPhoneDialogWindow = false + openSpeakDialogWindow = false + openEventDialogWindow = false + openPhone = false + startSpeak = false + currentPhoneDialog = nil + currentPhoneDialogPopup = nil + Phoned = nil + phoneAnim = false + phoneAnimFixer = false + + autoplayRadio = false + autoplayincar = false + shuffleall = false + currentRadio = {} + currentRadioVolume = 100 + pausemusic = false + + + + possibleInteract = {} + possibleInteractDisplay = {} + + currentInteractGroupIndex = 1 + currentInteractGroup = {} + + + + workerTable={} + workerTableKey={} + directWorkerTable = {} + directActionsWorkerTable = {} + toremove = {} + selectTarget = nil + autoScript = true + + goIndex = 0 + + cachedActionResult = false + + mappinManager = {} + currentDistricts2 = { + visible = true, + districtId = nil, + districtLabels = nil, + districtCaption = nil, + factionLabels = nil, + customdistrict = nil + } + + + + AVinput = { + isMoving = false, + lastInput = "", + keyPressed = false, + currentDirections = { + forward = false, + backwards = false, + right = false, + left = false, + up = false, + down = false, + rollleft = false, + rollright = false, + }, + } + + + ScannerInfoManager = {} + + VendorsStockManager = {} + VendorsStockManager["lookatnpc"] = {} + VendorsStockManager["lookatnpc"].items = {} + + + local itemtable = {} + local myitems = {} + myitems.quantity = math.random(1,10) + myitems.tweak = "Items.Preset_Chao_Neon" + myitems.powerLevel = math.random(1,10) + table.insert(itemtable,myitems) + + local myitems = {} + myitems.quantity = math.random(1,10) + myitems.tweak = "Items.Helmet_03_old_01" + myitems.powerLevel = math.random(1,10) + table.insert(itemtable,myitems) + + local myitems = {} + myitems.quantity = math.random(1,10) + myitems.tweak = "Items.Jacket_02_old_03" + myitems.powerLevel = math.random(1,10) + table.insert(itemtable,myitems) + + local myitems = {} + myitems.quantity = math.random(1,10) + myitems.tweak = "Items.GenericJunkItem14" + myitems.powerLevel = math.random(1,10) + table.insert(itemtable,myitems) + + local myitems = {} + myitems.quantity = math.random(1,10) + myitems.tweak = "Items.SexToyJunkItem4" + myitems.powerLevel = math.random(1,10) + table.insert(itemtable,myitems) + + VendorsStockManager["lookatnpc"].items = itemtable + VendorsStockManager["lookatnpc"].name = "Donk's Dealer" + -- ScannerInfoManager["judy01"] = {} + -- ScannerInfoManager["judy01"].name = "Donk's Love" + -- ScannerInfoManager["judy01"].secondaryname = "Cookie eaters" + -- ScannerInfoManager["judy01"].level = 5 + -- ScannerInfoManager["judy01"].rarity = 0 + -- ScannerInfoManager["judy01"].faction = "faction_mox" + -- ScannerInfoManager["judy01"].attitude = 0 + -- ScannerInfoManager["judy01"].networkstate = 5 + -- ScannerInfoManager["judy01"].text = "Go Buy it for me !" + -- ScannerInfoManager["judy01"].bounty = {} + -- ScannerInfoManager["judy01"].bounty.transgressions= {} + -- ScannerInfoManager["judy01"].bounty.customtransgressions= {"cookier eaters", "donk sucker"} + -- table.insert( ScannerInfoManager["judy01"].bounty.transgressions,"UnpaidDebt") + -- ScannerInfoManager["judy01"].bounty.reward = 130891 + -- ScannerInfoManager["judy01"].bounty.streetreward = 69 + -- ScannerInfoManager["judy01"].bounty.issuedby = "donk" + -- ScannerInfoManager["judy01"].bounty.danger = 5 + + AVList = {"","",} + + AVspeed = 0.3 + AVVelocity = 0.005 + CurrentAVEntity = nil + AVisIn = false + AVseat = nil + AVyaw = 0 + AVroll = 0 + AVrollCam = 0 + AVPitch = 0 + + + + + --Var and Init + + + enummt = { + __index = function(table, key) + if rawget(table.enums, key) then + return key + end + end + } + + + + + openColorPicker = false + + openEditor = false + openEditTrigger = false + openEditActionTrigger = false + openNewTrigger = false + + openTriggerItem = false + + openNewAction = false + openEditAction = false + toti = "" + totitem = "" + searchitem="" + + + camstep = 0.1 + posstep = 0.1 + rotstep = 0.1 + + openNewRoom = false + openEditRoom = false + + + + loadQuest = {} + loadInteract = {} + loadPlace = {} + loadDialog = {} + loadEvent = {} + loadFunction = {} + loadCustomNPC = {} + loadFixer = {} + loadFaction = {} + loadRadio = {} + loadNode = {} + loadCircuit = {} + loadPath = {} + loadLang = {} + LoadInterface = {} + loadHelp ={} + loadPOI = {} + loadShard = {} + loadPhoneDialog = {} + loadScene = {} + loadHousing = {} + + loadQuesttag = "" + loadInteracttag = "" + loadPlacetag = "" + loadDialogtag = "" + loadEventtag = "" + loadFunctiontag = "" + loadCustomNPCtag = "" + loadFixertag = "" + loadFactiontag = "" + loadRadiotag = "" + loadNodetag = "" + loadCircuittag = "" + loadPathtag = "" + loadLangtag = "" + LoadInterfacetag = "" + LoadPOItag = "" + loadHelptag ="" + loadShardtag = "" + loadPhoneDialogtag = "" + loadScenetag = "" + loadHousingtag = "" + currentSelectLocation = {} + + editLocation = false + placetype = "House" + newRequirementItem = "" + selectedTrigger2 = "" + currentSelectTrigger = {} + currentSelectAction = {} + currentSelectRoom = {} + currentSelectOptions = {} + currentSelectObjective = {} + currentSelectConversation = {} + currentSelectMessage = {} + currentSelectChoice = {} + currentSelectSceneStep = {} + currentEditorTrigger = nil + currentEditorItems = nil + currentEditorAction = nil + currentEditorOptions = nil + currentEditorControls = nil + currentcolor = "" + currentcolorTable = {} + questTrigger = true + questStart = true + questEnd = true + questFail = true + currentEditorSubTrigger = {} + editLocation=false + EditorAddColor=false + colorPickerModeRGB = false + genericItem = {} + genericItem.name = "" + genericItem.file = "" + + genericLocation = {} + genericLocation.x = 0 + genericLocation.y = 0 + genericLocation.z = 0 + genericLocation.district = "Watson" + genericLocation.subdistrict = "ArasakaWaterfront" + genericLocation.inVehicule = false + genericLocation.Tag = "" + + genericVIP = {} + genericVIP.name = "" + genericVIP.score = 0 + + EgameMessageSender = + { + NPC = 0, + Player = 1 + } + + defaulftGameMessageSender = "NPC" + defaulttag = "mytag" + dicKey = "" + dicValue = "" + dicInt = 0 + selectedTrigger = "auto" + selectedTrigger2 = "auto" + npcchara = "Judy" + defaultQuestType = "Contract" + npcFixer = "Wakako Okada" + defaultfaction = "Mox" + defaultDistrict = "Watson" + defaultEnumDistrict = "Watson" + defaultJournalEntryState = "Active" + waydialog = "phone" + selectedAction = "notify" + selectedSubAction = "notify" + selectedControlType = "button" + selectedControlvalue = "text" + selectedThemeKey = "" + selectedThemeValue = {} + selectedThemeText = "" + selectedTriggerTable = {} + selectedActionTable = {} + newtrigger = {} + + + selecAction = "" + + currentParentItem = {} + + activeEditedQuest = {} -- 0 + questgraph = {} + choicegraph = {} + activeEditedInteract = {} --1 + activeEditedDialog = {}--2 + activeEditedFixer = {} --3 + activeEditedPlace = {} --4 + activeEditedFunction = {} --5 + activeEditedFaction = {} --5 + activeEditedRadio = {} --5 + activeEditedNode = {} --5loadPlacetag + activeEditedCircuit = {} --5 + activeEditedPath = {} --5 + activeEditedPOI = {} --5 + activeEditedEvent = {} --5 + activeEditedLang = {} --5 + activeEditHelp = {} --5 + activeEditedTheme = {} --5 + activeEditedInterfaces = {} --5 + activeEditedCustomNPC = {} --5 + activeEditedShard = {} --5 + activeEditedPhoneDialog = {} --5 + activeEditedScene = {} --4 + activeEditedHousing = {} + + + + local f = assert(io.open("mod/data/anims/CharacterEntryLibrary.json")) + + lines = f:read("*a") + + encdo = lines + f:close() + entityListJson = trydecodeJSOn(encdo, f ,"mod/data/anims/CharacterEntryLibrary.json") + + + entityListJsonfinal = {} + controltypelist = {"button","label","area","scrollarea","vertical_area","image"} + controltypevaluelist = {"text","number","score","variable"} + + + -- animslibrary = {} + + -- local reader = dir("mod/data/anims") + -- if(reader ~= nil) then + -- for i,v in ipairs(reader) do + -- animslibrary[reader[i].name] = dofile(v) + -- end + + -- end + + wantcorrectpoi = false + poicorrectready = false + currentpoicorrectindex = 1 + + + local f = assert(io.open("mod/external/amm_entities.json")) + + lines = f:read("*a") + + encdo = lines + amm_entities = {} + + local test = trydecodeJSOn(encdo, f ,"mod/external/amm_entities.json") + + for i,v in ipairs(test) do + + amm_entities[v.entity_id] = v + + + + end + + + + + local f = assert(io.open("mod/external/amm_component.json")) + + lines = f:read("*a") + + encdo = lines + amm_component = {} + + local test = trydecodeJSOn(encdo, f ,"mod/external/amm_component.json") + + for i,v in ipairs(test) do + + amm_component[v.cname] = v + + + end + + + + + arrayDBitems = {} + arrayDBitemsfilter = {} + + local f = assert(io.open("mod/data/getItems.json")) + + lines = f:read("*a") + + encdo = lines + + + + + arrayDBitems = trydecodeJSOn(encdo, f,"mod/data/getItems.json") + + + f:close() + + + + + + if AMM ~= nil then + + local ammprops = AMM.API.GetAMMProps() + + for i,v in ipairs(ammprops) do + + local obj = {} + obj.Id = #arrayDBitems + i + obj.Path = v.path + obj.Tag= string.lower(v.name:gsub( " ", "_")) + obj.Title = "(AMM) "..v.name + obj.Statut = 1 + obj.Quantity = 99999999999 + obj.Price = math.random(1,5000) + obj.Inflate = 0 + obj.DefaultStatut = 0 + obj.parentCategory = "amm" + obj.childCategory = "amm" + obj.flag = "amm;" + table.insert(arrayDBitems,obj) + end + + end + + + + + componentCname = {"amm_prop_slot1", "amm_prop_slot2", "amm_prop_slot3", "amm_prop_slot4", "body_01", "trunk_a", "cockpit", "trunk_b", "canopy_right_screen_frame_b", "canopy_right_screen_middle_b", "canopy_right_screen_right_b", "canopy_right_screen_left_b", "canopy_right_screen_frame_a", "canopy_right_screen_middle_a", "canopy_right_screen_right_a", "canopy_right_screen_left_a", "canopy_left_screen_middle_b", "canopy_left_screen_frame_b", "canopy_left_screen_right_b", "canopy_left_screen_left_b", "canopy_left_mainscreen_b", "canopy_left_mainscreen_a", "canopy_left_screen_left_a", "canopy_left_screen_right_a", "canopy_left_screen_middle_a", "canopy_left_screen_frame_a", "canopy_right_screen_a", "av_militech_basilisk__ext01_body_shadow", "av_militech_basilisk__ext01_trunk_b_shadow", "av_militech_basilisk__ext01_trunk_a_shadow", "av_militech_basilisk__ext01_hinges_shadow", "basilisk_vfx_cutout", "elevator_door_large_a", "Mesh8033", "neon", "neon_unlit", "neon_light_a", "mch_003__minotaur_arm_l_01", "mch_003__minotaur_body_01", "mch_003__minotaur_decals", "mch_003__minotaur_lights_glass", "mch_003__minotaur_arm_r_01", "mch_003__minotaur_bags_01", "mch_003__minotaur_hands_01", "mch_003__minotaur_weapons_01", "mch_003__minotaur_legs_01", "mch_003__minotaur_arm_l_4776", "mch_003__minotaur_arm_l_1320", "vs_apartment_table_default", "smoke_machine_a", "Mesh8265", "q110_black_box", "int_accessories_001__johnnysguitar"} + + lightComponents = { + "Light0275", "Light7460", "Light5050", "Light1783", @@ -3574,225 +3574,226 @@ function resetVar() "head_light_left_01", "head_light_right_01" } - - haschanged = false - scaleChanged = false - proportionalMode = true - proportionalModeChanged = true - - - - - - - arrayListCharacter = {} - arrayPNJ = {} - - - - for i = 1, 100 do - - selectedTriggerTable[i] = "" - selectedActionTable[i] = "" - end - - - myDatapack = {} - myDatapack.name = "" - myDatapack.desc = "" - myDatapack.author = "" - myDatapack.file = "" - myDatapack.tag = "" - myDatapack.version = "0.0.0" - myDatapack.flags ={} - - myDatapackQuest = {} - myDatapackInteract = {} - myDatapackDialog = {} - myDatapackFixer = {} - myDatapackPlace = {} - myDatapackFunction = {} - myDatapackFaction = {} - myDatapackRadio = {} - myDatapackNode = {} - myDatapackCircuit = {} - myDatapackPath = {} - myDatapackPOI = {} - myDatapackLanguage = {} - myDatapackEvent = {} - myDatapackHousing = {} - myDatapackHousingTemplate = {} - myDatapackHelp = {} - myDatapackTheme = {} - myDatapackInterfaces = {} - myDatapackCustomNPC = {} - myDatapackShard = {} - myDatapackPhoneDialog = {} - myDatapackScene = {} - - inCrewManager = false - selectedCompanion = nil - - savelocation = {} - tempLocation = {} - savelocation.locations = {} - savelocation.desc = "location_"..math.random(0,59656518543133) - savelocation.isFor = "" - savelocation.tag = "location_"..math.random(0,59656518543133) - - saveLocationRotation = false - - playtick=1 - uimargintop = 50 - uifont = 35 - pathtick = 0 - - currentSelectedGameNode = nil - inTaxiWindows = false - inAVTaxiWindows = false - lastcurpos = nil - AVdestination = nil - isHeigh = false - isDown = false - isAVinService = false - xreach = false - yreach = false - zreach = false - isTaxiAVcall = false - - currentItemSpawned = {} - currentItemMultiSpawned = {} - currentPlayerNode = nil - inEditMode = false - - ---@type ShardReadPopupData - notificationData = {} - - ---@type inkGameNotificationToken - notificationToken = {} - - ---@type sampleStyleManagerGameController - eventCatcher = {} - - ---@type table - buttonsData = {} - - currentShardNotificationController = nil - - currentPhoneConversation = nil - currentController = false - currentChattersGameController = nil - currentSubtitlesGameController = nil - - popupManager = nil - popupActive = false - - AffinityPopupisShow = false - - - WebModule = {} - contactList = {} - - mappedFastTravelPoint = {} - mappedFastTravelPointJSON = {} - - MessengerGameController = nil - - KeystoneDownloader = {} - Keystone_currentSelectedItemCategory = nil - Keystone_currentSelectedItem = nil - KeystoneDownloader.displayName = "Cyberpunk Mulitverse" - KeystoneDownloader.widgetName = "CM" - - inputcount = 0 - - table.insert(WebModule,KeystoneDownloader) - - - MetroCurrentTime = 0 - NewMetroTime = 0 - JournalNotificationQueue = nil - - - - GameIsLoaded = false - - - - MasterVolume = 0 - - - SfxVolume = 0 - - - DialogueVolume = 0 - - - MusicVolume =0 - - - CarRadioVolume = 0 - - - SoundManager = {} - - SoundManager.Version = 6 - - SoundManager.MasterVolume = -1 - SoundManager.SfxVolume = -1 - SoundManager.DialogueVolume = -1 - SoundManager.MusicVolume = -1 - SoundManager.CarRadioVolume = -1 - - locationWidgetLeft = 15 - - locationWidgetPosX_top = 400 - - - processingmessage = false - - CurrentOnlineMessage = {} - - LinkController = nil - - locationWidgetPosX_top = 400 - - locationWidgetDisctrict_top = 450 - - locationWidgetSubDisctrict_top = 500 - - locationWidgetFactionDisctrict_top = 550 - - - - - locationWidgetPlace_top = 800 - locationWidgetRoom_top = 900 - - posWdiget = nil - districtWidget = nil - subdistrictWidget = nil - subdistrictWidget = nil - factionwidget = nil - placewidget = nil - roomwidget = nil - placemultiwidget = nil - multistatewidget = nil - factiontitle = nil - timerwidget = nil - avspeedwidget = nil - - openEditSceneStep = false - - openNewSceneStep = false - - enableLocation = true - showcyberscriptfixeronmap = true - showFactionAffinityHud = true - - myarrayDatapackIndex = 1 - - - - + + haschanged = false + scaleChanged = false + proportionalMode = true + proportionalModeChanged = true + + + + + + + arrayListCharacter = {} + arrayPNJ = {} + + + + for i = 1, 100 do + + selectedTriggerTable[i] = "" + selectedActionTable[i] = "" + end + + + myDatapack = {} + myDatapack.name = "" + myDatapack.desc = "" + myDatapack.author = "" + myDatapack.file = "" + myDatapack.tag = "" + myDatapack.version = "0.0.0" + myDatapack.flags ={} + + myDatapackQuest = {} + myDatapackInteract = {} + myDatapackDialog = {} + myDatapackFixer = {} + myDatapackPlace = {} + myDatapackFunction = {} + myDatapackFaction = {} + myDatapackRadio = {} + myDatapackNode = {} + myDatapackCircuit = {} + myDatapackPath = {} + myDatapackPOI = {} + myDatapackLanguage = {} + myDatapackEvent = {} + myDatapackHousing = {} + myDatapackHousingTemplate = {} + myDatapackHelp = {} + myDatapackTheme = {} + myDatapackInterfaces = {} + myDatapackCustomNPC = {} + myDatapackShard = {} + myDatapackPhoneDialog = {} + myDatapackScene = {} + + inCrewManager = false + selectedCompanion = nil + + savelocation = {} + tempLocation = {} + savelocation.locations = {} + savelocation.desc = "location_"..math.random(0,59656518543133) + savelocation.isFor = "" + savelocation.tag = "location_"..math.random(0,59656518543133) + + saveLocationRotation = false + + playtick=1 + uimargintop = 50 + uifont = 35 + pathtick = 0 + + currentSelectedGameNode = nil + inTaxiWindows = false + inAVTaxiWindows = false + lastcurpos = nil + AVdestination = nil + isHeigh = false + isDown = false + isAVinService = false + xreach = false + yreach = false + zreach = false + isTaxiAVcall = false + + currentItemSpawned = {} + currentItemMultiSpawned = {} + currentPlayerNode = nil + inEditMode = false + + ---@type ShardReadPopupData + notificationData = {} + + ---@type inkGameNotificationToken + notificationToken = {} + + ---@type sampleStyleManagerGameController + eventCatcher = {} + + ---@type table + buttonsData = {} + + currentShardNotificationController = nil + + currentPhoneConversation = nil + currentController = false + currentChattersGameController = nil + currentSubtitlesGameController = nil + + popupManager = nil + popupActive = false + + AffinityPopupisShow = false + + + WebModule = {} + contactList = {} + + mappedFastTravelPoint = {} + mappedFastTravelPointJSON = {} + + MessengerGameController = nil + + KeystoneDownloader = {} + Keystone_currentSelectedItemCategory = nil + Keystone_currentSelectedItem = nil + KeystoneDownloader.displayName = "Cyberpunk Mulitverse" + KeystoneDownloader.widgetName = "CM" + + inputcount = 0 + + table.insert(WebModule,KeystoneDownloader) + + + MetroCurrentTime = 0 + NewMetroTime = 0 + JournalNotificationQueue = nil + + + + GameIsLoaded = false + + + + MasterVolume = 0 + + + SfxVolume = 0 + + + DialogueVolume = 0 + + + MusicVolume =0 + + + CarRadioVolume = 0 + + + SoundManager = {} + + SoundManager.Version = 6 + + SoundManager.MasterVolume = -1 + SoundManager.SfxVolume = -1 + SoundManager.DialogueVolume = -1 + SoundManager.MusicVolume = -1 + SoundManager.CarRadioVolume = -1 + + locationWidgetLeft = 15 + + locationWidgetPosX_top = 400 + + + processingmessage = false + + CurrentOnlineMessage = {} + + LinkController = nil + + locationWidgetPosX_top = 400 + + locationWidgetDisctrict_top = 450 + + locationWidgetSubDisctrict_top = 500 + + locationWidgetFactionDisctrict_top = 550 + + + + + locationWidgetPlace_top = 800 + locationWidgetRoom_top = 900 + + posWdiget = nil + districtWidget = nil + subdistrictWidget = nil + subdistrictWidget = nil + factionwidget = nil + placewidget = nil + roomwidget = nil + placemultiwidget = nil + multistatewidget = nil + factiontitle = nil + timerwidget = nil + avspeedwidget = nil + + openEditSceneStep = false + + openNewSceneStep = false + + enableLocation = true + showcyberscriptfixeronmap = true + showcyberscriptfixeronstreet = true + showFactionAffinityHud = true + + myarrayDatapackIndex = 1 + + + + end diff --git a/cyberscript_core.zip b/cyberscript_core.zip index 7f78e8c..2b109c7 100644 Binary files a/cyberscript_core.zip and b/cyberscript_core.zip differ