├── .gitattributes ├── LICENSE ├── README.md ├── exports.def ├── functions_jip ├── jip_fn_actor.h ├── jip_fn_ammo.h ├── jip_fn_ammo_effect.h ├── jip_fn_armor.h ├── jip_fn_aux_variable.h ├── jip_fn_body_part_data.h ├── jip_fn_ccc.h ├── jip_fn_cell.h ├── jip_fn_class.h ├── jip_fn_climate.h ├── jip_fn_combat_style.h ├── jip_fn_destruction_data.h ├── jip_fn_effect.h ├── jip_fn_explosion.h ├── jip_fn_faction.h ├── jip_fn_global_var.h ├── jip_fn_grass.h ├── jip_fn_imagespace.h ├── jip_fn_impact_data.h ├── jip_fn_input.h ├── jip_fn_inventory.h ├── jip_fn_land_texture.h ├── jip_fn_light.h ├── jip_fn_minimap.h ├── jip_fn_misc_ref.h ├── jip_fn_miscellaneous.h ├── jip_fn_package.h ├── jip_fn_perk.h ├── jip_fn_projectile.h ├── jip_fn_quest.h ├── jip_fn_ref_map.h ├── jip_fn_script.h ├── jip_fn_sound.h ├── jip_fn_string.h ├── jip_fn_texture_set.h ├── jip_fn_ui.h ├── jip_fn_utility.h ├── jip_fn_water.h ├── jip_fn_weapon.h ├── jip_fn_weather.h └── jip_fn_worldspace.h ├── functions_ln ├── ln_fn_activator.h ├── ln_fn_actor.h ├── ln_fn_casino.h ├── ln_fn_cell.h ├── ln_fn_challenge.h ├── ln_fn_game_data.h ├── ln_fn_gamepad.h ├── ln_fn_inventory.h ├── ln_fn_leveled_list.h ├── ln_fn_load_screen.h ├── ln_fn_map_marker.h ├── ln_fn_math.h ├── ln_fn_misc_ref.h ├── ln_fn_miscellaneous.h ├── ln_fn_perk.h ├── ln_fn_race.h ├── ln_fn_radio_ref.h ├── ln_fn_recipe.h ├── ln_fn_terminal.h ├── ln_fn_utility.h └── ln_fn_weapon.h ├── internal ├── Ni_types.cpp ├── Ni_types.h ├── base_defs.h ├── class_vtbls.h ├── containers.cpp ├── containers.h ├── dinput.cpp ├── dinput.h ├── havok.cpp ├── havok.h ├── hooks.h ├── jip_core.cpp ├── jip_core.h ├── lutana.h ├── memory_pool.cpp ├── memory_pool.h ├── netimmerse.cpp ├── netimmerse.h ├── patches_cmd.h ├── patches_game.h ├── prefix.h ├── serialization.h ├── settings_enum.h ├── utility.cpp ├── utility.h ├── version.h ├── xinput.cpp └── xinput.h ├── jip_nvse.cpp ├── jip_nvse.rc ├── jip_nvse.sln ├── jip_nvse.vcxproj ├── jip_nvse.vcxproj.filters ├── jip_nvse.vcxproj.user └── nvse ├── CommandTable.h ├── GameAPI.cpp ├── GameAPI.h ├── GameBSExtraData.cpp ├── GameBSExtraData.h ├── GameData.cpp ├── GameData.h ├── GameEffects.h ├── GameExtraData.cpp ├── GameExtraData.h ├── GameForms.cpp ├── GameForms.h ├── GameOSDepend.h ├── GameObjects.cpp ├── GameObjects.h ├── GameProcess.h ├── GameRTTI.cpp ├── GameRTTI.h ├── GameRTTI_1_4_0_525.inc ├── GameScript.cpp ├── GameScript.h ├── GameSettings.cpp ├── GameSettings.h ├── GameSound.cpp ├── GameSound.h ├── GameTasks.h ├── GameTiles.cpp ├── GameTiles.h ├── GameTypes.cpp ├── GameTypes.h ├── GameUI.cpp ├── GameUI.h ├── ParamInfos.h └── PluginAPI.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JIP-LN-NVSE 2 | An extension for the New Vegas Script Extender (NVSE) 3 | 4 | * Adds 1000+ new script functions. 5 | * Includes numerous engine bug fixes/tweaks. 6 | * Restores several broken game features. 7 | -------------------------------------------------------------------------------- /exports.def: -------------------------------------------------------------------------------- 1 | LIBRARY "jip_nvse" 2 | EXPORTS 3 | NVSEPlugin_Query @1 4 | NVSEPlugin_Load @2 5 | GetJIPLNVersion @3 6 | ToggleObjectCollision @4 7 | GetLNEventMask @10 8 | ProcessLNEventHandler @11 9 | -------------------------------------------------------------------------------- /functions_jip/jip_fn_ammo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetAmmoTraitNumeric, 0, kParams_OneObjectID_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetAmmoTraitNumeric, 0, kParams_OneObjectID_OneInt_OneFloat); 5 | DEFINE_COMMAND_PLUGIN(GetAmmoProjectile, 0, kParams_OneObjectID); 6 | DEFINE_COMMAND_PLUGIN(SetAmmoProjectile, 0, kParams_OneForm_OneOptionalForm); 7 | DEFINE_COMMAND_PLUGIN(SetAmmoCasing, 0, kParams_OneObjectID_OneOptionalObjectID); 8 | 9 | bool Cmd_GetAmmoTraitNumeric_Execute(COMMAND_ARGS) 10 | { 11 | TESAmmo *ammo; 12 | UInt32 traitID; 13 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo, &traitID) && IS_TYPE(ammo, TESAmmo)) 14 | { 15 | switch (traitID) 16 | { 17 | case 0: 18 | *result = ammo->speed; 19 | break; 20 | case 1: 21 | *result = (int)ammo->projPerShot; 22 | break; 23 | case 2: 24 | *result = ammo->casingChance; 25 | break; 26 | case 3: 27 | *result = ammo->clipRounds.clipRounds; 28 | } 29 | } 30 | return true; 31 | } 32 | 33 | bool Cmd_SetAmmoTraitNumeric_Execute(COMMAND_ARGS) 34 | { 35 | TESAmmo *ammo; 36 | UInt32 traitID; 37 | float val; 38 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo, &traitID, &val) && IS_TYPE(ammo, TESAmmo)) 39 | { 40 | switch (traitID) 41 | { 42 | case 0: 43 | ammo->speed = val; 44 | break; 45 | case 1: 46 | ammo->projPerShot = (int)val; 47 | break; 48 | case 2: 49 | ammo->casingChance = val; 50 | break; 51 | case 3: 52 | ammo->clipRounds.clipRounds = val; 53 | } 54 | } 55 | return true; 56 | } 57 | 58 | bool Cmd_GetAmmoProjectile_Execute(COMMAND_ARGS) 59 | { 60 | TESAmmo *ammo; 61 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo) && IS_TYPE(ammo, TESAmmo) && ammo->projectile) 62 | REFR_RES = ammo->projectile->refID; 63 | return true; 64 | } 65 | 66 | bool Cmd_SetAmmoProjectile_Execute(COMMAND_ARGS) 67 | { 68 | TESAmmo *ammo; 69 | BGSProjectile *proj = nullptr; 70 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo, &proj) && IS_TYPE(ammo, TESAmmo) && (!proj || IS_ID(proj, BGSProjectile))) 71 | ammo->projectile = proj; 72 | return true; 73 | } 74 | 75 | bool Cmd_SetAmmoCasing_Execute(COMMAND_ARGS) 76 | { 77 | TESAmmo *ammo; 78 | TESBoundObject *casing = nullptr; 79 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo, &casing) && IS_TYPE(ammo, TESAmmo) && (!casing || kInventoryType[casing->typeID])) 80 | ammo->casingItem = casing; 81 | return true; 82 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_ammo_effect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetNumAmmoEffects, 0, kParams_OneForm); 4 | DEFINE_COMMAND_PLUGIN(GetNthAmmoEffect, 0, kParams_OneForm_OneInt); 5 | DEFINE_COMMAND_PLUGIN(AddAmmoEffect, 0, kParams_TwoForms); 6 | DEFINE_COMMAND_PLUGIN(RemoveAmmoEffect, 0, kParams_TwoForms); 7 | DEFINE_COMMAND_PLUGIN(GetAmmoEffectTraitNumeric, 0, kParams_OneForm_OneInt); 8 | DEFINE_COMMAND_PLUGIN(SetAmmoEffectTraitNumeric, 0, kParams_OneForm_OneInt_OneFloat); 9 | 10 | bool Cmd_GetNumAmmoEffects_Execute(COMMAND_ARGS) 11 | { 12 | TESAmmo *ammo; 13 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo) && IS_TYPE(ammo, TESAmmo)) 14 | *result = (int)ammo->effectList.Count(); 15 | return true; 16 | } 17 | 18 | bool Cmd_GetNthAmmoEffect_Execute(COMMAND_ARGS) 19 | { 20 | TESAmmo *ammo; 21 | UInt32 idx; 22 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo, &idx) && IS_TYPE(ammo, TESAmmo)) 23 | if (TESAmmoEffect *effect = ammo->effectList.GetNthItem(idx)) 24 | REFR_RES = effect->refID; 25 | return true; 26 | } 27 | 28 | bool Cmd_AddAmmoEffect_Execute(COMMAND_ARGS) 29 | { 30 | TESAmmo *ammo; 31 | TESAmmoEffect *effect; 32 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo, &effect) && IS_TYPE(ammo, TESAmmo) && IS_ID(effect, TESAmmoEffect) && !ammo->effectList.IsInList(effect)) 33 | { 34 | ammo->effectList.Prepend(effect); 35 | *result = 1; 36 | } 37 | return true; 38 | } 39 | 40 | bool Cmd_RemoveAmmoEffect_Execute(COMMAND_ARGS) 41 | { 42 | TESAmmo *ammo; 43 | TESAmmoEffect *effect; 44 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ammo, &effect) && IS_TYPE(ammo, TESAmmo) && IS_ID(effect, TESAmmoEffect) && ammo->effectList.Remove(effect)) 45 | *result = 1; 46 | return true; 47 | } 48 | 49 | bool Cmd_GetAmmoEffectTraitNumeric_Execute(COMMAND_ARGS) 50 | { 51 | TESAmmoEffect *effect; 52 | UInt32 traitID; 53 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &effect, &traitID) && IS_ID(effect, TESAmmoEffect)) 54 | { 55 | switch (traitID) 56 | { 57 | case 0: 58 | *result = (int)effect->type; 59 | break; 60 | case 1: 61 | *result = (int)effect->operation; 62 | break; 63 | case 2: 64 | *result = effect->value; 65 | } 66 | } 67 | return true; 68 | } 69 | 70 | bool Cmd_SetAmmoEffectTraitNumeric_Execute(COMMAND_ARGS) 71 | { 72 | TESAmmoEffect *effect; 73 | UInt32 traitID; 74 | float fVal; 75 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &effect, &traitID, &fVal) && IS_ID(effect, TESAmmoEffect) && (fVal >= 0)) 76 | { 77 | UInt32 iVal = (int)fVal; 78 | switch (traitID) 79 | { 80 | case 0: 81 | if (iVal < 6) effect->type = (AmmoEffectID)iVal; 82 | break; 83 | case 1: 84 | if (iVal < 3) effect->operation = iVal; 85 | break; 86 | case 2: 87 | effect->value = fVal; 88 | } 89 | } 90 | return true; 91 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_armor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetArmorRCT, 0, kParams_OneObjectID); 4 | DEFINE_COMMAND_PLUGIN(SetArmorRCT, 0, kParams_OneForm_OneString); 5 | DEFINE_COMMAND_PLUGIN(SetBipedModelPathAlt, 0, kParams_OneObjectID_OneInt_OneFormatString); 6 | DEFINE_COMMAND_PLUGIN(GetArmorAudioTemplate, 0, kParams_OneObjectID); 7 | DEFINE_COMMAND_PLUGIN(SetArmorAudioTemplate, 0, kParams_OneObjectID_OneOptionalObjectID); 8 | DEFINE_COMMAND_PLUGIN(IsArmorAddon, 0, kParams_OneObjectID); 9 | DEFINE_COMMAND_PLUGIN(SetArmorClass, 0, kParams_OneObjectID_OneInt); 10 | DEFINE_COMMAND_PLUGIN(ClearModelAltTextures, 0, kParams_OneObjectID); 11 | 12 | bool Cmd_GetArmorRCT_Execute(COMMAND_ARGS) 13 | { 14 | const char *resStr; 15 | TESObjectARMO *armor; 16 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &armor) && IS_TYPE(armor, TESObjectARMO)) 17 | resStr = armor->bipedModel.modelRDT.nifPath.m_data; 18 | else resStr = NULL; 19 | AssignString(PASS_COMMAND_ARGS, resStr); 20 | return true; 21 | } 22 | 23 | bool Cmd_SetArmorRCT_Execute(COMMAND_ARGS) 24 | { 25 | TESObjectARMO *armor; 26 | char path[0x80]; 27 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &armor, &path) && IS_TYPE(armor, TESObjectARMO)) 28 | armor->bipedModel.modelRDT.nifPath.Set(path); 29 | return true; 30 | } 31 | 32 | bool Cmd_SetBipedModelPathAlt_Execute(COMMAND_ARGS) 33 | { 34 | TESObjectARMO *armor; 35 | UInt32 whichPath; 36 | char buffer[0x80]; 37 | if (ExtractFormatStringArgs(2, buffer, EXTRACT_ARGS_EX, kCommandInfo_SetBipedModelPathAlt.numParams, &armor, &whichPath) && 38 | IS_TYPE(armor, TESObjectARMO) && (whichPath <= 3)) 39 | armor->bipedModel.bipedModel[whichPath].nifPath.Set(buffer); 40 | return true; 41 | } 42 | 43 | bool Cmd_GetArmorAudioTemplate_Execute(COMMAND_ARGS) 44 | { 45 | TESObjectARMO *armor; 46 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &armor) && IS_TYPE(armor, TESObjectARMO) && !armor->overrideSounds && armor->audioTemplate) 47 | REFR_RES = armor->audioTemplate->refID; 48 | return true; 49 | } 50 | 51 | bool Cmd_SetArmorAudioTemplate_Execute(COMMAND_ARGS) 52 | { 53 | TESObjectARMO *armor, *audioTemp = NULL; 54 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &armor, &audioTemp) && IS_TYPE(armor, TESObjectARMO) && !armor->overrideSounds && 55 | (!audioTemp || (IS_TYPE(audioTemp, TESObjectARMO) && audioTemp->overrideSounds))) 56 | armor->audioTemplate = audioTemp; 57 | return true; 58 | } 59 | 60 | bool Cmd_IsArmorAddon_Execute(COMMAND_ARGS) 61 | { 62 | TESForm *form; 63 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form) && IS_TYPE(form, TESObjectARMA)) 64 | *result = 1; 65 | return true; 66 | } 67 | 68 | bool Cmd_SetArmorClass_Execute(COMMAND_ARGS) 69 | { 70 | TESObjectARMO *armor; 71 | UInt32 newClass; 72 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &armor, &newClass) && IS_TYPE(armor, TESObjectARMO) && newClass && (newClass <= 3)) 73 | { 74 | armor->bipedModel.bipedFlags &= ~0x88; 75 | if (newClass > 1) 76 | armor->bipedModel.bipedFlags |= (newClass == 2) ? 8 : 0x80; 77 | } 78 | return true; 79 | } 80 | 81 | bool Cmd_ClearModelAltTextures_Execute(COMMAND_ARGS) 82 | { 83 | TESObjectARMO *armor; 84 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &armor) && IS_TYPE(armor, TESObjectARMO)) 85 | { 86 | TESModelTextureSwap *texSwap = armor->bipedModel.bipedModel; 87 | for (UInt32 index = 0; index < 4; index++) 88 | texSwap[index].textureList.RemoveAll(); 89 | } 90 | return true; 91 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_cell.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(SetCellWaterForm, 0, kParams_OneForm_OneOptionalForm); 4 | DEFINE_COMMAND_PLUGIN(GetCellClimate, 0, kParams_OneForm); 5 | DEFINE_COMMAND_PLUGIN(SetCellClimate, 0, kParams_OneForm_OneOptionalForm); 6 | DEFINE_COMMAND_PLUGIN(GetCellNoiseTexture, 0, kParams_OneForm); 7 | DEFINE_COMMAND_PLUGIN(SetCellNoiseTexture, 0, kParams_OneForm_OneString); 8 | DEFINE_COMMAND_PLUGIN(GetOwnerOfCell, 0, kParams_OneForm); 9 | DEFINE_COMMAND_PLUGIN(GetCellNorthRotation, 0, kParams_OneForm); 10 | 11 | bool Cmd_SetCellWaterForm_Execute(COMMAND_ARGS) 12 | { 13 | TESObjectCELL *cell; 14 | TESWaterForm *water = nullptr; 15 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell, &water) && IS_ID(cell, TESObjectCELL) && (!water || IS_ID(water, TESWaterForm))) 16 | if (auto xCellWater = GetExtraType(&cell->extraDataList, ExtraCellWaterType)) 17 | { 18 | if (water) xCellWater->waterForm = water; 19 | else cell->extraDataList.RemoveByType(kXData_ExtraCellWaterType); 20 | } 21 | else if (water) 22 | cell->extraDataList.AddExtra(ExtraCellWaterType::Create(water)); 23 | return true; 24 | } 25 | 26 | bool Cmd_GetCellClimate_Execute(COMMAND_ARGS) 27 | { 28 | TESObjectCELL *cell; 29 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell) && IS_ID(cell, TESObjectCELL)) 30 | if (auto xCellClimate = GetExtraType(&cell->extraDataList, ExtraCellClimate); xCellClimate && xCellClimate->climate) 31 | REFR_RES = xCellClimate->climate->refID; 32 | return true; 33 | } 34 | 35 | bool Cmd_SetCellClimate_Execute(COMMAND_ARGS) 36 | { 37 | TESObjectCELL *cell; 38 | TESClimate *climate = nullptr; 39 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell, &climate) && IS_ID(cell, TESObjectCELL) && (!climate || IS_ID(climate, TESClimate))) 40 | if (auto xCellClimate = GetExtraType(&cell->extraDataList, ExtraCellClimate)) 41 | { 42 | if (climate) xCellClimate->climate = climate; 43 | else cell->extraDataList.RemoveByType(kXData_ExtraCellClimate); 44 | } 45 | else if (climate) 46 | cell->extraDataList.AddExtra(ExtraCellClimate::Create(climate)); 47 | return true; 48 | } 49 | 50 | bool Cmd_GetCellNoiseTexture_Execute(COMMAND_ARGS) 51 | { 52 | const char *resStr = nullptr; 53 | TESObjectCELL *cell; 54 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell) && IS_ID(cell, TESObjectCELL)) 55 | resStr = cell->noiseTexture.ddsPath.m_data; 56 | AssignString(PASS_COMMAND_ARGS, resStr); 57 | return true; 58 | } 59 | 60 | bool Cmd_SetCellNoiseTexture_Execute(COMMAND_ARGS) 61 | { 62 | TESObjectCELL *cell; 63 | char path[0x80]; 64 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell, &path) && IS_ID(cell, TESObjectCELL)) 65 | cell->noiseTexture.ddsPath.Set(path); 66 | return true; 67 | } 68 | 69 | bool Cmd_GetOwnerOfCell_Execute(COMMAND_ARGS) 70 | { 71 | TESObjectCELL *cell; 72 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell) && IS_ID(cell, TESObjectCELL)) 73 | if (TESForm *owner = ThisCall(0x546A40, cell)) 74 | REFR_RES = owner->refID; 75 | return true; 76 | } 77 | 78 | bool Cmd_GetCellNorthRotation_Execute(COMMAND_ARGS) 79 | { 80 | TESObjectCELL *cell; 81 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell) && IS_ID(cell, TESObjectCELL) && cell->IsInterior()) 82 | if (ExtraNorthRotation *xNorthRot = GetExtraType(&cell->extraDataList, ExtraNorthRotation)) 83 | *result = xNorthRot->rotation * Dbl180dPI; 84 | return true; 85 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_class.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetClassTraitNumeric, 0, kParams_OneClass_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetClassTraitNumeric, 0, kParams_OneClass_TwoInts); 5 | DEFINE_COMMAND_PLUGIN(GetClassFlag, 0, kParams_OneClass_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetClassFlag, 0, kParams_OneClass_TwoInts); 7 | 8 | bool Cmd_GetClassTraitNumeric_Execute(COMMAND_ARGS) 9 | { 10 | TESClass *pClass; 11 | UInt32 traitID; 12 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &pClass, &traitID) && (traitID <= 10)) 13 | if (traitID < 4) 14 | *result = (int)pClass->tagSkills[traitID]; 15 | else 16 | *result = pClass->attributes.attributes[traitID - 4]; 17 | return true; 18 | } 19 | 20 | bool Cmd_SetClassTraitNumeric_Execute(COMMAND_ARGS) 21 | { 22 | TESClass *pClass; 23 | UInt32 traitID; 24 | int val; 25 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &pClass, &traitID, &val) && (traitID <= 10)) 26 | if (traitID < 4) 27 | { 28 | if ((val == -1) || ((val > 31) && (val < 46) && (val != 33))) 29 | pClass->tagSkills[traitID] = val; 30 | } 31 | else if ((val > 0) && (val < 11)) 32 | pClass->attributes.attributes[traitID - 4] = val; 33 | return true; 34 | } 35 | 36 | bool Cmd_GetClassFlag_Execute(COMMAND_ARGS) 37 | { 38 | TESClass *pClass; 39 | UInt32 flagID; 40 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &pClass, &flagID) && (flagID <= 19)) 41 | if (flagID < 2) 42 | { 43 | if (pClass->classFlags & (1 << flagID)) 44 | *result = 1; 45 | } 46 | else if (pClass->services & (1 << (flagID - 2))) 47 | *result = 1; 48 | return true; 49 | } 50 | 51 | bool Cmd_SetClassFlag_Execute(COMMAND_ARGS) 52 | { 53 | TESClass *pClass; 54 | UInt32 flagID, val; 55 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &pClass, &flagID, &val) && (flagID <= 19)) 56 | if (flagID < 2) 57 | { 58 | if (val) pClass->classFlags |= (1 << flagID); 59 | else pClass->classFlags &= ~(1 << flagID); 60 | } 61 | else if (val) pClass->services |= (1 << (flagID - 2)); 62 | else pClass->services &= ~(1 << (flagID - 2)); 63 | return true; 64 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_climate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetClimateSunTexture, 0, kParams_OneForm); 4 | DEFINE_COMMAND_PLUGIN(SetClimateSunTexture, 0, kParams_OneForm_OneString); 5 | DEFINE_COMMAND_PLUGIN(GetClimateSunGlareTexture, 0, kParams_OneForm); 6 | DEFINE_COMMAND_PLUGIN(SetClimateSunGlareTexture, 0, kParams_OneForm_OneString); 7 | DEFINE_COMMAND_PLUGIN(GetClimateNightSkyModel, 0, kParams_OneForm); 8 | DEFINE_COMMAND_PLUGIN(SetClimateNightSkyModel, 0, kParams_OneForm_OneString); 9 | DEFINE_COMMAND_PLUGIN(GetClimateTraitNumeric, 0, kParams_OneForm_OneInt); 10 | DEFINE_COMMAND_PLUGIN(SetClimateTraitNumeric, 0, kParams_OneForm_TwoInts); 11 | DEFINE_COMMAND_PLUGIN(GetClimateNumWeatherTypes, 0, kParams_OneForm); 12 | DEFINE_COMMAND_PLUGIN(GetClimateNthWeatherType, 0, kParams_OneForm_OneInt); 13 | DEFINE_COMMAND_PLUGIN(GetClimateNthWeatherChance, 0, kParams_OneForm_OneInt); 14 | DEFINE_COMMAND_PLUGIN(GetClimateNthWeatherGlobal, 0, kParams_OneForm_OneInt); 15 | DEFINE_COMMAND_PLUGIN(ClimateAddWeatherType, 0, kParams_OneForm_OneWeatherID_OneInt_OneOptionalGlobal); 16 | DEFINE_COMMAND_PLUGIN(ClimateRemoveWeatherType, 0, kParams_OneForm_OneWeatherID); 17 | DEFINE_COMMAND_PLUGIN(GetCurrentClimate, 0, nullptr); 18 | DEFINE_COMMAND_PLUGIN(SetCurrentClimate, 0, kParams_OneForm); 19 | DEFINE_COMMAND_PLUGIN(RefreshCurrentClimate, 0, nullptr); 20 | DEFINE_COMMAND_PLUGIN(ForceClimate, 0, kParams_OneOptionalForm); 21 | 22 | bool Cmd_GetClimateSunTexture_Execute(COMMAND_ARGS) 23 | { 24 | const char *resStr = nullptr; 25 | TESClimate *climate; 26 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate) && IS_ID(climate, TESClimate)) 27 | resStr = climate->sunTexture.ddsPath.m_data; 28 | AssignString(PASS_COMMAND_ARGS, resStr); 29 | return true; 30 | } 31 | 32 | bool Cmd_SetClimateSunTexture_Execute(COMMAND_ARGS) 33 | { 34 | TESClimate *climate; 35 | char path[0x80]; 36 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &path) && IS_ID(climate, TESClimate)) 37 | climate->sunTexture.ddsPath.Set(path); 38 | return true; 39 | } 40 | 41 | bool Cmd_GetClimateSunGlareTexture_Execute(COMMAND_ARGS) 42 | { 43 | const char *resStr = nullptr; 44 | TESClimate *climate; 45 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate) && IS_ID(climate, TESClimate)) 46 | resStr = climate->sunGlareTexture.ddsPath.m_data; 47 | AssignString(PASS_COMMAND_ARGS, resStr); 48 | return true; 49 | } 50 | 51 | bool Cmd_SetClimateSunGlareTexture_Execute(COMMAND_ARGS) 52 | { 53 | TESClimate *climate; 54 | char path[0x80]; 55 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &path) && IS_ID(climate, TESClimate)) 56 | climate->sunGlareTexture.ddsPath.Set(path); 57 | return true; 58 | } 59 | 60 | bool Cmd_GetClimateNightSkyModel_Execute(COMMAND_ARGS) 61 | { 62 | const char *resStr = nullptr; 63 | TESClimate *climate; 64 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate) && IS_ID(climate, TESClimate)) 65 | resStr = climate->nightSkyModel.GetModelPath(); 66 | AssignString(PASS_COMMAND_ARGS, resStr); 67 | return true; 68 | } 69 | 70 | bool Cmd_SetClimateNightSkyModel_Execute(COMMAND_ARGS) 71 | { 72 | TESClimate *climate; 73 | char path[0x80]; 74 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &path) && IS_ID(climate, TESClimate)) 75 | climate->nightSkyModel.SetModelPath(path); 76 | return true; 77 | } 78 | 79 | bool Cmd_GetClimateTraitNumeric_Execute(COMMAND_ARGS) 80 | { 81 | TESClimate *climate; 82 | UInt32 traitID; 83 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &traitID) && IS_ID(climate, TESClimate)) 84 | switch (traitID) 85 | { 86 | case 0: 87 | *result = climate->sunriseBegin * 10; 88 | break; 89 | case 1: 90 | *result = climate->sunriseEnd * 10; 91 | break; 92 | case 2: 93 | *result = climate->sunsetBegin * 10; 94 | break; 95 | case 3: 96 | *result = climate->sunsetEnd * 10; 97 | break; 98 | case 4: 99 | *result = climate->volatility; 100 | break; 101 | case 5: 102 | *result = climate->phaseLength >> 6; 103 | break; 104 | case 6: 105 | *result = climate->phaseLength & 63; 106 | } 107 | return true; 108 | } 109 | 110 | bool Cmd_SetClimateTraitNumeric_Execute(COMMAND_ARGS) 111 | { 112 | TESClimate *climate; 113 | UInt32 traitID, val; 114 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &traitID, &val) && IS_ID(climate, TESClimate)) 115 | switch (traitID) 116 | { 117 | case 0: 118 | climate->sunriseBegin = (val > 1430) ? 143 : (val / 10); 119 | break; 120 | case 1: 121 | climate->sunriseEnd = (val > 1430) ? 143 : (val / 10); 122 | break; 123 | case 2: 124 | climate->sunsetBegin = (val > 1430) ? 143 : (val / 10); 125 | break; 126 | case 3: 127 | climate->sunsetEnd = (val > 1430) ? 143 : (val / 10); 128 | break; 129 | case 4: 130 | climate->volatility = (val > 255) ? 255 : val; 131 | break; 132 | case 5: 133 | climate->phaseLength = (climate->phaseLength & 63) + ((val > 3) ? 192 : (val << 6)); 134 | break; 135 | case 6: 136 | climate->phaseLength = (climate->phaseLength & 192) + ((val > 63) ? 63 : val); 137 | } 138 | return true; 139 | } 140 | 141 | bool Cmd_GetClimateNumWeatherTypes_Execute(COMMAND_ARGS) 142 | { 143 | TESClimate *climate; 144 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate) && IS_ID(climate, TESClimate)) 145 | *result = (int)climate->weatherTypes.Count(); 146 | return true; 147 | } 148 | 149 | bool Cmd_GetClimateNthWeatherType_Execute(COMMAND_ARGS) 150 | { 151 | TESClimate *climate; 152 | UInt32 idx; 153 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &idx) && IS_ID(climate, TESClimate)) 154 | if (WeatherEntry *entry = climate->weatherTypes.GetNthItem(idx); entry && entry->weather) 155 | REFR_RES = entry->weather->refID; 156 | return true; 157 | } 158 | 159 | bool Cmd_GetClimateNthWeatherChance_Execute(COMMAND_ARGS) 160 | { 161 | TESClimate *climate; 162 | UInt32 idx; 163 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &idx) && IS_ID(climate, TESClimate)) 164 | if (WeatherEntry *entry = climate->weatherTypes.GetNthItem(idx)) 165 | *result = (int)entry->chance; 166 | return true; 167 | } 168 | 169 | bool Cmd_GetClimateNthWeatherGlobal_Execute(COMMAND_ARGS) 170 | { 171 | TESClimate *climate; 172 | UInt32 idx; 173 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &idx) && IS_ID(climate, TESClimate)) 174 | if (WeatherEntry *entry = climate->weatherTypes.GetNthItem(idx); entry && entry->global) 175 | REFR_RES = entry->global->refID; 176 | return true; 177 | } 178 | 179 | bool Cmd_ClimateAddWeatherType_Execute(COMMAND_ARGS) 180 | { 181 | TESClimate *climate; 182 | TESWeather *weather; 183 | UInt32 chance; 184 | TESGlobal *global = nullptr; 185 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &weather, &chance, &global) && IS_ID(climate, TESClimate)) 186 | if (WeatherEntry *entry = climate->GetWeatherEntry(weather)) 187 | { 188 | entry->weather = weather; 189 | entry->chance = chance % 101; 190 | entry->global = global; 191 | *result = 1; 192 | } 193 | return true; 194 | } 195 | 196 | bool Cmd_ClimateRemoveWeatherType_Execute(COMMAND_ARGS) 197 | { 198 | TESClimate *climate; 199 | TESWeather *weather; 200 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate, &weather) && IS_ID(climate, TESClimate)) 201 | if (WeatherEntry *entry = climate->GetWeatherEntry(weather, true)) 202 | { 203 | Game_HeapFree(entry); 204 | *result = 1; 205 | } 206 | return true; 207 | } 208 | 209 | bool Cmd_GetCurrentClimate_Execute(COMMAND_ARGS) 210 | { 211 | TESClimate *climate = g_currentSky->currClimate; 212 | if (climate) 213 | REFR_RES = climate->refID; 214 | DoConsolePrint(climate); 215 | return true; 216 | } 217 | 218 | bool Cmd_SetCurrentClimate_Execute(COMMAND_ARGS) 219 | { 220 | TESClimate *climate; 221 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate) && IS_ID(climate, TESClimate)) 222 | { 223 | if (s_forcedClimate && (s_forcedClimate != climate)) 224 | s_forcedClimate = NULL; 225 | g_currentSky->currClimate = climate; 226 | } 227 | return true; 228 | } 229 | 230 | bool Cmd_RefreshCurrentClimate_Execute(COMMAND_ARGS) 231 | { 232 | g_currentSky->RefreshClimate(g_currentSky->currClimate); 233 | return true; 234 | } 235 | 236 | bool Cmd_ForceClimate_Execute(COMMAND_ARGS) 237 | { 238 | TESClimate *climate = nullptr; 239 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &climate) && (!climate || IS_ID(climate, TESClimate))) 240 | s_forcedClimate = climate; 241 | return true; 242 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_combat_style.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetCombatStyleTraitNumeric, 0, kParams_OneCombatStyle_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetCombatStyleTraitNumeric, 0, kParams_OneCombatStyle_OneInt_OneFloat); 5 | DEFINE_COMMAND_PLUGIN(GetCombatStyleFlag, 0, kParams_OneCombatStyle_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetCombatStyleFlag, 0, kParams_OneCombatStyle_TwoInts); 7 | 8 | bool Cmd_GetCombatStyleTraitNumeric_Execute(COMMAND_ARGS) 9 | { 10 | TESCombatStyle *cStyle; 11 | UInt32 traitID; 12 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cStyle, &traitID) && (traitID <= 63)) 13 | switch (traitID) 14 | { 15 | case 0: 16 | case 1: 17 | case 2: 18 | case 3: 19 | case 4: 20 | case 5: 21 | case 6: 22 | case 7: 23 | case 8: 24 | *result = ((float*)cStyle)[6 + traitID]; 25 | break; 26 | case 9: 27 | *result = cStyle->weaponRestrictions; 28 | break; 29 | case 10: 30 | case 11: 31 | case 12: 32 | case 13: 33 | case 14: 34 | *result = ((float*)cStyle)[7 + traitID]; 35 | break; 36 | case 15: 37 | case 16: 38 | *result = ((UInt8*)cStyle)[0x49 + traitID]; 39 | break; 40 | case 17: 41 | case 18: 42 | case 19: 43 | case 20: 44 | case 21: 45 | case 22: 46 | case 23: 47 | case 24: 48 | *result = ((float*)cStyle)[6 + traitID]; 49 | break; 50 | case 25: 51 | case 26: 52 | *result = ((UInt8*)cStyle)[0x63 + traitID]; 53 | break; 54 | case 27: 55 | case 28: 56 | case 29: 57 | *result = ((float*)cStyle)[5 + traitID]; 58 | break; 59 | case 30: 60 | *result = cStyle->powerAttackChance; 61 | break; 62 | case 31: 63 | case 32: 64 | *result = ((float*)cStyle)[5 + traitID]; 65 | break; 66 | case 33: 67 | case 34: 68 | case 35: 69 | case 36: 70 | case 37: 71 | *result = ((UInt8*)cStyle)[0x77 + traitID]; 72 | break; 73 | case 38: 74 | case 39: 75 | *result = ((float*)cStyle)[2 + traitID]; 76 | break; 77 | case 40: 78 | case 41: 79 | *result = ((UInt8*)cStyle)[0x84 + traitID]; 80 | break; 81 | default: 82 | *result = ((float*)cStyle)[2 + traitID]; 83 | break; 84 | } 85 | return true; 86 | } 87 | 88 | bool Cmd_SetCombatStyleTraitNumeric_Execute(COMMAND_ARGS) 89 | { 90 | TESCombatStyle *cStyle; 91 | UInt32 traitID; 92 | float fVal; 93 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cStyle, &traitID, &fVal) && (traitID <= 63)) 94 | { 95 | UInt8 bVal = (int)fVal; 96 | switch (traitID) 97 | { 98 | case 0: 99 | case 1: 100 | case 2: 101 | case 3: 102 | case 4: 103 | case 5: 104 | case 6: 105 | case 7: 106 | case 8: 107 | ((float*)cStyle)[6 + traitID] = fVal; 108 | break; 109 | case 9: 110 | if (bVal && (bVal <= 2)) cStyle->weaponRestrictions = bVal; 111 | break; 112 | case 10: 113 | case 11: 114 | case 12: 115 | case 13: 116 | case 14: 117 | ((float*)cStyle)[7 + traitID] = fVal; 118 | break; 119 | case 15: 120 | case 16: 121 | ((UInt8*)cStyle)[0x49 + traitID] = bVal; 122 | break; 123 | case 17: 124 | case 18: 125 | case 19: 126 | case 20: 127 | case 21: 128 | case 22: 129 | case 23: 130 | case 24: 131 | ((float*)cStyle)[6 + traitID] = fVal; 132 | break; 133 | case 25: 134 | case 26: 135 | ((UInt8*)cStyle)[0x63 + traitID] = bVal; 136 | break; 137 | case 27: 138 | case 28: 139 | case 29: 140 | ((float*)cStyle)[5 + traitID] = fVal; 141 | break; 142 | case 30: 143 | cStyle->powerAttackChance = bVal; 144 | break; 145 | case 31: 146 | case 32: 147 | ((float*)cStyle)[5 + traitID] = fVal; 148 | break; 149 | case 33: 150 | case 34: 151 | case 35: 152 | case 36: 153 | case 37: 154 | ((UInt8*)cStyle)[0x77 + traitID] = bVal; 155 | break; 156 | case 38: 157 | case 39: 158 | ((float*)cStyle)[2 + traitID] = fVal; 159 | break; 160 | case 40: 161 | case 41: 162 | ((UInt8*)cStyle)[0x84 + traitID] = bVal; 163 | break; 164 | default: 165 | ((float*)cStyle)[2 + traitID] = fVal; 166 | break; 167 | } 168 | } 169 | return true; 170 | } 171 | 172 | bool Cmd_GetCombatStyleFlag_Execute(COMMAND_ARGS) 173 | { 174 | TESCombatStyle *cStyle; 175 | UInt32 flagID; 176 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cStyle, &flagID) && (flagID <= 15) && (cStyle->csFlags & (1 << flagID))) 177 | *result = 1; 178 | return true; 179 | } 180 | 181 | bool Cmd_SetCombatStyleFlag_Execute(COMMAND_ARGS) 182 | { 183 | TESCombatStyle *cStyle; 184 | UInt32 flagID, val; 185 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cStyle, &flagID, &val) && (flagID <= 15)) 186 | cStyle->SetFlag(1 << flagID, val != 0); 187 | return true; 188 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_explosion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetExplosionTraitNumeric, 0, kParams_OneBoundObject_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetExplosionTraitNumeric, 0, kParams_OneForm_OneInt_OneFloat); 5 | DEFINE_COMMAND_PLUGIN(GetExplosionTraitForm, 0, kParams_OneBoundObject_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetExplosionTraitForm, 0, kParams_OneForm_OneInt_OneOptionalForm); 7 | DEFINE_COMMAND_PLUGIN(GetExplosionFlag, 0, kParams_OneBoundObject_OneInt); 8 | DEFINE_COMMAND_PLUGIN(SetExplosionFlag, 0, kParams_OneForm_TwoInts); 9 | 10 | bool Cmd_GetExplosionTraitNumeric_Execute(COMMAND_ARGS) 11 | { 12 | BGSExplosion *explosion; 13 | UInt32 traitID; 14 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &explosion, &traitID) && IS_ID(explosion, BGSExplosion)) 15 | switch (traitID) 16 | { 17 | case 0: 18 | *result = explosion->force; 19 | break; 20 | case 1: 21 | *result = explosion->damage; 22 | break; 23 | case 2: 24 | *result = explosion->radius; 25 | break; 26 | case 3: 27 | *result = explosion->ISradius; 28 | break; 29 | case 4: 30 | *result = explosion->RADlevel; 31 | break; 32 | case 5: 33 | *result = explosion->dissipationTime; 34 | break; 35 | case 6: 36 | *result = explosion->RADradius; 37 | break; 38 | case 7: 39 | *result = explosion->soundLevel; 40 | } 41 | return true; 42 | } 43 | 44 | bool Cmd_SetExplosionTraitNumeric_Execute(COMMAND_ARGS) 45 | { 46 | BGSExplosion *explosion; 47 | UInt32 traitID; 48 | float val; 49 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &explosion, &traitID, &val) && IS_ID(explosion, BGSExplosion)) 50 | switch (traitID) 51 | { 52 | case 0: 53 | explosion->force = val; 54 | break; 55 | case 1: 56 | explosion->damage = val; 57 | break; 58 | case 2: 59 | explosion->radius = val; 60 | break; 61 | case 3: 62 | explosion->ISradius = val; 63 | break; 64 | case 4: 65 | explosion->RADlevel = val; 66 | break; 67 | case 5: 68 | explosion->dissipationTime = val; 69 | break; 70 | case 6: 71 | explosion->RADradius = val; 72 | break; 73 | case 7: 74 | explosion->soundLevel = val; 75 | } 76 | return true; 77 | } 78 | 79 | bool Cmd_GetExplosionTraitForm_Execute(COMMAND_ARGS) 80 | { 81 | BGSExplosion *explosion; 82 | UInt32 traitID; 83 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &explosion, &traitID) && IS_ID(explosion, BGSExplosion)) 84 | switch (traitID) 85 | { 86 | case 0: 87 | if (explosion->light) 88 | REFR_RES = explosion->light->refID; 89 | break; 90 | case 1: 91 | if (explosion->sound1) 92 | REFR_RES = explosion->sound1->refID; 93 | break; 94 | case 2: 95 | if (explosion->sound2) 96 | REFR_RES = explosion->sound2->refID; 97 | break; 98 | case 3: 99 | if (explosion->impactDataSet) 100 | REFR_RES = explosion->impactDataSet->refID; 101 | break; 102 | case 4: 103 | if (explosion->placedObj) 104 | REFR_RES = explosion->placedObj->refID; 105 | break; 106 | case 5: 107 | if (explosion->enchantable.enchantItem) 108 | REFR_RES = explosion->enchantable.enchantItem->refID; 109 | break; 110 | case 6: 111 | if (explosion->imageSpaceModForm.imod) 112 | REFR_RES = explosion->imageSpaceModForm.imod->refID; 113 | break; 114 | } 115 | return true; 116 | } 117 | 118 | bool Cmd_SetExplosionTraitForm_Execute(COMMAND_ARGS) 119 | { 120 | BGSExplosion *explosion; 121 | UInt32 traitID; 122 | TESForm *object = NULL; 123 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &explosion, &traitID, &object) && IS_ID(explosion, BGSExplosion)) 124 | switch (traitID) 125 | { 126 | case 0: 127 | explosion->light = (object && IS_ID(object, TESObjectLIGH)) ? (TESObjectLIGH*)object : NULL; 128 | break; 129 | case 1: 130 | explosion->sound1 = (object && IS_ID(object, TESSound)) ? (TESSound*)object : NULL; 131 | break; 132 | case 2: 133 | explosion->sound2 = (object && IS_ID(object, TESSound)) ? (TESSound*)object : NULL; 134 | break; 135 | case 3: 136 | explosion->impactDataSet = (object && IS_ID(object, BGSImpactDataSet)) ? (BGSImpactDataSet*)object : NULL; 137 | break; 138 | case 4: 139 | explosion->placedObj = object; 140 | break; 141 | case 5: 142 | explosion->enchantable.enchantItem = (object && IS_ID(object, EnchantmentItem)) ? (EnchantmentItem*)object : NULL; 143 | break; 144 | case 6: 145 | explosion->imageSpaceModForm.imod = (object && IS_ID(object, TESImageSpaceModifier)) ? (TESImageSpaceModifier*)object : NULL; 146 | break; 147 | } 148 | return true; 149 | } 150 | 151 | bool Cmd_GetExplosionFlag_Execute(COMMAND_ARGS) 152 | { 153 | BGSExplosion *explosion; 154 | UInt32 flagID; 155 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &explosion, &flagID) && IS_ID(explosion, BGSExplosion) && flagID && (flagID <= 31) && (explosion->explFlags & (1 << flagID))) 156 | *result = 1; 157 | return true; 158 | } 159 | 160 | bool Cmd_SetExplosionFlag_Execute(COMMAND_ARGS) 161 | { 162 | BGSExplosion *explosion; 163 | UInt32 flagID, val; 164 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &explosion, &flagID, &val) && IS_ID(explosion, BGSExplosion) && flagID && (flagID <= 31)) 165 | explosion->SetFlag(1 << flagID, val != 0); 166 | return true; 167 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_faction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetFactionReputationType, 0, kParams_OneFaction); 4 | DEFINE_COMMAND_PLUGIN(SetFactionReputationType, 0, kParams_OneFaction_OneOptionalReputation); 5 | 6 | bool Cmd_GetFactionReputationType_Execute(COMMAND_ARGS) 7 | { 8 | TESFaction *faction; 9 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &faction) && faction->reputation) 10 | REFR_RES = faction->reputation->refID; 11 | return true; 12 | } 13 | 14 | bool Cmd_SetFactionReputationType_Execute(COMMAND_ARGS) 15 | { 16 | TESFaction *faction; 17 | TESReputation *reputation = NULL; 18 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &faction, &reputation)) 19 | faction->reputation = reputation; 20 | return true; 21 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_global_var.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetGlobalVariable, 0, kParams_OneGlobal); 4 | DEFINE_COMMAND_PLUGIN(SetGlobalVariable, 0, kParams_OneGlobal_OneFloat); 5 | DEFINE_COMMAND_PLUGIN(GetGlobalRef, 0, kParams_OneGlobal); 6 | DEFINE_COMMAND_PLUGIN(SetGlobalRef, 0, kParams_OneGlobal_OneOptionalForm); 7 | 8 | bool Cmd_GetGlobalVariable_Execute(COMMAND_ARGS) 9 | { 10 | TESGlobal *global; 11 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &global)) 12 | *result = global->data; 13 | return true; 14 | } 15 | 16 | bool Cmd_SetGlobalVariable_Execute(COMMAND_ARGS) 17 | { 18 | TESGlobal *global; 19 | float value; 20 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &global, &value)) 21 | global->data = value; 22 | return true; 23 | } 24 | 25 | bool Cmd_GetGlobalRef_Execute(COMMAND_ARGS) 26 | { 27 | TESGlobal *global; 28 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &global)) 29 | { 30 | if (!(global->flags & 0x200)) 31 | { 32 | global->flags |= 0x200; 33 | GetResolvedRefID(&global->uRefID); 34 | } 35 | REFR_RES = global->uRefID; 36 | } 37 | return true; 38 | } 39 | 40 | bool Cmd_SetGlobalRef_Execute(COMMAND_ARGS) 41 | { 42 | TESGlobal *global; 43 | TESForm *form = nullptr; 44 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &global, &form)) 45 | { 46 | global->uRefID = form ? form->refID : 0; 47 | global->flags |= 0x200; 48 | } 49 | return true; 50 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_grass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetGrassTraitNumeric, 0, kParams_OneForm_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetGrassTraitNumeric, 0, kParams_OneForm_OneInt_OneFloat); 5 | DEFINE_COMMAND_PLUGIN(GetGrassModel, 0, kParams_OneForm); 6 | DEFINE_COMMAND_PLUGIN(SetGrassModel, 0, kParams_OneForm_OneString); 7 | 8 | bool Cmd_GetGrassTraitNumeric_Execute(COMMAND_ARGS) 9 | { 10 | TESGrass *grass; 11 | UInt32 traitID; 12 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &grass, &traitID) && IS_ID(grass, TESGrass)) 13 | switch (traitID) 14 | { 15 | case 0: 16 | *result = grass->density; 17 | break; 18 | case 1: 19 | *result = grass->minSlope; 20 | break; 21 | case 2: 22 | *result = grass->maxSlope; 23 | break; 24 | case 3: 25 | *result = grass->unitFromWaterAmount; 26 | break; 27 | case 4: 28 | *result = grass->unitFromWaterType; 29 | break; 30 | case 5: 31 | *result = grass->positionRange; 32 | break; 33 | case 6: 34 | *result = grass->heightRange; 35 | break; 36 | case 7: 37 | *result = grass->colorRange; 38 | break; 39 | case 8: 40 | *result = grass->wavePeriod; 41 | break; 42 | case 9: 43 | *result = grass->grassFlags; 44 | } 45 | return true; 46 | } 47 | 48 | bool Cmd_SetGrassTraitNumeric_Execute(COMMAND_ARGS) 49 | { 50 | TESGrass *grass; 51 | UInt32 traitID; 52 | float fVal; 53 | if (!ExtractArgsEx(EXTRACT_ARGS_EX, &grass, &traitID, &fVal) || NOT_ID(grass, TESGrass) || (fVal < 0)) return true; 54 | int iVal = fVal; 55 | switch (traitID) 56 | { 57 | case 0: 58 | grass->density = GetMin(iVal, 100); 59 | break; 60 | case 1: 61 | grass->minSlope = GetMin(grass->maxSlope, iVal); 62 | break; 63 | case 2: 64 | grass->maxSlope = GetMax(grass->minSlope, GetMin(iVal, 90)); 65 | break; 66 | case 3: 67 | grass->unitFromWaterAmount = GetMin(iVal, 0xFFFF); 68 | break; 69 | case 4: 70 | grass->unitFromWaterType = GetMin(iVal, 7); 71 | break; 72 | case 5: 73 | grass->positionRange = fVal; 74 | break; 75 | case 6: 76 | grass->heightRange = fVal; 77 | break; 78 | case 7: 79 | grass->colorRange = fVal; 80 | break; 81 | case 8: 82 | grass->wavePeriod = fVal; 83 | break; 84 | case 9: 85 | grass->grassFlags = GetMin(iVal, 7); 86 | } 87 | return true; 88 | } 89 | 90 | bool Cmd_GetGrassModel_Execute(COMMAND_ARGS) 91 | { 92 | const char *resStr = nullptr; 93 | TESGrass *grass; 94 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &grass) && IS_ID(grass, TESGrass)) 95 | resStr = grass->model.GetModelPath(); 96 | AssignString(PASS_COMMAND_ARGS, resStr); 97 | return true; 98 | } 99 | 100 | bool Cmd_SetGrassModel_Execute(COMMAND_ARGS) 101 | { 102 | TESGrass *grass; 103 | char path[0x80]; 104 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &grass, &path) && IS_ID(grass, TESGrass)) 105 | grass->model.SetModelPath(path); 106 | return true; 107 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_imagespace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetImageSpaceTrait, 0, kParams_OneImageSpace_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetImageSpaceTrait, 0, kParams_OneImageSpace_OneInt_OneFloat); 5 | DEFINE_COMMAND_PLUGIN(GetImageSpaceModTrait, 0, kParams_OneIMOD_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetImageSpaceModTrait, 0, kParams_OneIMOD_OneInt_OneFloat); 7 | DEFINE_COMMAND_PLUGIN(GetActiveIMODs, 0, nullptr); 8 | 9 | bool Cmd_GetImageSpaceTrait_Execute(COMMAND_ARGS) 10 | { 11 | TESImageSpace *imgSpace; 12 | UInt32 traitID; 13 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &imgSpace, &traitID) && (traitID <= 32)) 14 | { 15 | if ((traitID >= 21) && (traitID <= 31) && ((traitID <= 23) || (traitID >= 29))) 16 | *result = imgSpace->traitValues[traitID] * 255; 17 | else *result = imgSpace->traitValues[traitID]; 18 | } 19 | return true; 20 | } 21 | 22 | bool Cmd_SetImageSpaceTrait_Execute(COMMAND_ARGS) 23 | { 24 | TESImageSpace *imgSpace; 25 | UInt32 traitID; 26 | float value; 27 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &imgSpace, &traitID, &value) && (traitID <= 32)) 28 | if ((traitID >= 21) && (traitID <= 31) && ((traitID <= 23) || (traitID >= 29))) 29 | imgSpace->traitValues[traitID] = value * (1 / 255.0F); 30 | else imgSpace->traitValues[traitID] = value; 31 | return true; 32 | } 33 | 34 | bool Cmd_GetImageSpaceModTrait_Execute(COMMAND_ARGS) 35 | { 36 | TESImageSpaceModifier *imod; 37 | UInt32 traitID; 38 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &imod, &traitID) && (traitID <= 67)) 39 | { 40 | if (traitID <= 2) 41 | { 42 | switch (traitID) 43 | { 44 | case 0: 45 | *result = imod->duration; 46 | break; 47 | case 1: 48 | *result = imod->radialBlurCentreX; 49 | break; 50 | case 2: 51 | *result = imod->radialBlurCentreY; 52 | break; 53 | } 54 | } 55 | else if (traitID > 63) 56 | { 57 | switch (traitID - 64) 58 | { 59 | case 0: 60 | *result = imod->animable; 61 | break; 62 | case 1: 63 | *result = imod->radBlurUseTarget; 64 | break; 65 | case 2: 66 | *result = imod->DoFUseTarget; 67 | break; 68 | case 3: 69 | *result = imod->DoFMode; 70 | break; 71 | } 72 | } 73 | else if (traitID <= 46) 74 | *result = imod->data654[traitID - 3]->value; 75 | else if (traitID <= 50) 76 | *result = imod->data704[0]->value[traitID - 47] * 255; 77 | else if (traitID <= 54) 78 | *result = imod->data704[1]->value[traitID - 51] * 255; 79 | else 80 | *result = imod->data70C[traitID - 55]->value; 81 | } 82 | return true; 83 | } 84 | 85 | bool Cmd_SetImageSpaceModTrait_Execute(COMMAND_ARGS) 86 | { 87 | TESImageSpaceModifier *imod; 88 | UInt32 traitID; 89 | float value; 90 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &imod, &traitID, &value) && (traitID <= 67)) 91 | if (traitID <= 2) 92 | { 93 | switch (traitID) 94 | { 95 | case 0: 96 | imod->duration = value; 97 | break; 98 | case 1: 99 | imod->radialBlurCentreX = value; 100 | break; 101 | case 2: 102 | imod->radialBlurCentreY = value; 103 | break; 104 | } 105 | } 106 | else if (traitID > 63) 107 | { 108 | UInt8 iVal = UInt8(value) & 3; 109 | switch (traitID - 64) 110 | { 111 | case 0: 112 | imod->animable = iVal; 113 | break; 114 | case 1: 115 | imod->radBlurUseTarget = iVal; 116 | break; 117 | case 2: 118 | imod->DoFUseTarget = iVal; 119 | break; 120 | case 3: 121 | imod->DoFMode = iVal; 122 | break; 123 | } 124 | } 125 | else if (traitID <= 46) 126 | { 127 | traitID -= 3; 128 | imod->fltIntrpl1[traitID].value = value; 129 | imod->data654[traitID]->value = value; 130 | } 131 | else if (traitID <= 50) 132 | { 133 | traitID -= 47; 134 | value *= 1 / 255.0F; 135 | imod->clrIntrpl[0].value[traitID] = value; 136 | imod->data704[0]->value[traitID] = value; 137 | } 138 | else if (traitID <= 54) 139 | { 140 | traitID -= 51; 141 | value *= 1 / 255.0F; 142 | imod->clrIntrpl[1].value[traitID] = value; 143 | imod->data704[1]->value[traitID] = value; 144 | } 145 | else 146 | { 147 | traitID -= 55; 148 | imod->fltIntrpl2[traitID].value = value; 149 | imod->data70C[traitID]->value = value; 150 | } 151 | return true; 152 | } 153 | 154 | bool Cmd_GetActiveIMODs_Execute(COMMAND_ARGS) 155 | { 156 | TempElements *tmpElements = GetTempElements(); 157 | auto traverse = g_TES->activeIMODs.Head(); 158 | do 159 | { 160 | if (ImageSpaceModifierInstance *imodInstance = traverse->data; imodInstance && IS_TYPE(imodInstance, ImageSpaceModifierInstanceForm) && !imodInstance->hidden) 161 | if (TESImageSpaceModifier *imod = ((ImageSpaceModifierInstanceForm*)imodInstance)->imageSpaceMod) 162 | tmpElements->Append(imod); 163 | } 164 | while (traverse = traverse->next); 165 | if (!tmpElements->Empty()) 166 | *result = (int)CreateArray(tmpElements->Data(), tmpElements->Size(), scriptObj); 167 | return true; 168 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_impact_data.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetImpactDataModel, 0, kParams_OneForm); 4 | DEFINE_COMMAND_PLUGIN(SetImpactDataModel, 0, kParams_OneForm_OneString); 5 | DEFINE_COMMAND_PLUGIN(GetImpactDataTrait, 0, kParams_OneForm_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetImpactDataTraitNumeric, 0, kParams_OneForm_OneInt_OneDouble); 7 | DEFINE_COMMAND_PLUGIN(SetImpactDataTraitForm, 0, kParams_OneForm_OneInt_OneOptionalForm); 8 | DEFINE_COMMAND_PLUGIN(GetImpactDataSetForm, 0, kParams_OneForm_OneInt); 9 | DEFINE_COMMAND_PLUGIN(SetImpactDataSetForm, 0, kParams_OneForm_OneInt_OneOptionalForm); 10 | 11 | bool Cmd_GetImpactDataModel_Execute(COMMAND_ARGS) 12 | { 13 | const char *resStr = nullptr; 14 | BGSImpactData *impactData; 15 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &impactData) && IS_ID(impactData, BGSImpactData)) 16 | resStr = impactData->model.GetModelPath(); 17 | AssignString(PASS_COMMAND_ARGS, resStr); 18 | return true; 19 | } 20 | 21 | bool Cmd_SetImpactDataModel_Execute(COMMAND_ARGS) 22 | { 23 | BGSImpactData *impactData; 24 | char path[0x80]; 25 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &impactData, &path) && IS_ID(impactData, BGSImpactData)) 26 | impactData->model.SetModelPath(path); 27 | return true; 28 | } 29 | 30 | bool Cmd_GetImpactDataTrait_Execute(COMMAND_ARGS) 31 | { 32 | BGSImpactData *impactData; 33 | UInt32 traitID; 34 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &impactData, &traitID) && IS_ID(impactData, BGSImpactData)) 35 | switch (traitID) 36 | { 37 | case 1: 38 | *result = impactData->effectOrientation; 39 | break; 40 | case 0: 41 | case 2: 42 | case 3: 43 | *result = ((float*)impactData)[12 + traitID]; 44 | break; 45 | case 4: 46 | *result = impactData->soundLevel; 47 | break; 48 | case 5: 49 | case 6: 50 | case 7: 51 | { 52 | if (TESForm *form = ((TESForm**)impactData)[13 + traitID]) 53 | REFR_RES = form->refID; 54 | break; 55 | } 56 | case 8: 57 | case 9: 58 | case 10: 59 | case 11: 60 | case 12: 61 | case 13: 62 | case 14: 63 | *result = ((float*)impactData)[13 + traitID]; 64 | break; 65 | case 15: 66 | *result = impactData->decalInfo.parallaxPasses; 67 | break; 68 | case 16: 69 | *result = (impactData->decalInfo.flags << 1) | impactData->noDecalData; 70 | break; 71 | case 17: 72 | cvtul2d(RGBHexToDec(impactData->decalInfo.color), result); 73 | } 74 | return true; 75 | } 76 | 77 | bool Cmd_SetImpactDataTraitNumeric_Execute(COMMAND_ARGS) 78 | { 79 | BGSImpactData *impactData; 80 | UInt32 traitID; 81 | double value; 82 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &impactData, &traitID, &value) && IS_ID(impactData, BGSImpactData)) 83 | { 84 | UInt32 intVal = cvtd2ul(value); 85 | switch (traitID) 86 | { 87 | case 1: 88 | if (intVal < 3) impactData->effectOrientation = intVal; 89 | break; 90 | case 0: 91 | case 2: 92 | case 3: 93 | ((float*)impactData)[12 + traitID] = value; 94 | break; 95 | case 4: 96 | if (intVal < 3) impactData->soundLevel = intVal; 97 | break; 98 | case 5: 99 | case 6: 100 | case 7: 101 | case 8: 102 | case 9: 103 | case 10: 104 | case 11: 105 | ((float*)impactData)[16 + traitID] = value; 106 | break; 107 | case 12: 108 | impactData->decalInfo.parallaxPasses = intVal; 109 | break; 110 | case 13: 111 | impactData->noDecalData = intVal & 1; 112 | impactData->decalInfo.flags = intVal >> 1; 113 | break; 114 | case 14: 115 | if (intVal <= 255255255) impactData->decalInfo.color = RGBDecToHex(intVal); 116 | } 117 | } 118 | return true; 119 | } 120 | 121 | bool Cmd_SetImpactDataTraitForm_Execute(COMMAND_ARGS) 122 | { 123 | BGSImpactData *impactData; 124 | UInt32 traitID; 125 | TESForm *object = nullptr; 126 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &impactData, &traitID, &object) && IS_ID(impactData, BGSImpactData)) 127 | switch (traitID) 128 | { 129 | case 0: 130 | impactData->textureSet = (object && IS_ID(object, BGSTextureSet)) ? (BGSTextureSet*)object : nullptr; 131 | break; 132 | case 1: 133 | impactData->sound1 = (object && IS_ID(object, TESSound)) ? (TESSound*)object : nullptr; 134 | break; 135 | case 2: 136 | impactData->sound2 = (object && IS_ID(object, TESSound)) ? (TESSound*)object : nullptr; 137 | } 138 | return true; 139 | } 140 | 141 | bool Cmd_GetImpactDataSetForm_Execute(COMMAND_ARGS) 142 | { 143 | BGSImpactDataSet *impactDataSet; 144 | UInt32 materialID; 145 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &impactDataSet, &materialID) && IS_ID(impactDataSet, BGSImpactDataSet) && (materialID <= 11) && impactDataSet->impactDatas[materialID]) 146 | REFR_RES = impactDataSet->impactDatas[materialID]->refID; 147 | return true; 148 | } 149 | 150 | bool Cmd_SetImpactDataSetForm_Execute(COMMAND_ARGS) 151 | { 152 | BGSImpactDataSet *impactDataSet; 153 | UInt32 materialID; 154 | BGSImpactData *impactData = nullptr; 155 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &impactDataSet, &materialID, &impactData) && IS_ID(impactDataSet, BGSImpactDataSet) && (materialID <= 11) && (!impactData || IS_ID(impactData, BGSImpactData))) 156 | impactDataSet->impactDatas[materialID] = impactData; 157 | return true; 158 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_input.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(SetOnKeyDownEventHandler, 0, kParams_OneForm_OneInt_OneOptionalInt); 4 | DEFINE_COMMAND_PLUGIN(SetOnKeyUpEventHandler, 0, kParams_OneForm_OneInt_OneOptionalInt); 5 | DEFINE_COMMAND_PLUGIN(SetOnControlDownEventHandler, 0, kParams_OneForm_OneInt_OneOptionalInt); 6 | DEFINE_COMMAND_PLUGIN(SetOnControlUpEventHandler, 0, kParams_OneForm_OneInt_OneOptionalInt); 7 | DEFINE_COMMAND_PLUGIN(HoldControl, 0, kParams_OneInt); 8 | DEFINE_COMMAND_PLUGIN(ReleaseControl, 0, kParams_OneInt); 9 | DEFINE_COMMAND_PLUGIN(ToggleVanityWheel, 0, kParams_OneOptionalInt); 10 | DEFINE_COMMAND_PLUGIN(ToggleMouseMovement, 0, kParams_OneOptionalInt); 11 | DEFINE_COMMAND_PLUGIN(ScrollMouseWheel, 0, kParams_OneOptionalInt); 12 | 13 | bool SetOnKeyEventHandler_Execute(COMMAND_ARGS) 14 | { 15 | CAPTURE_ECX(eventMask) 16 | Script *script; 17 | UInt32 addEvnt; 18 | SInt32 keyID = -1; 19 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &script, &addEvnt, &keyID) && IS_ID(script, Script)) 20 | SetInputEventHandler(eventMask, script, keyID, addEvnt != 0); 21 | return true; 22 | } 23 | 24 | __declspec(naked) bool Cmd_SetOnKeyDownEventHandler_Execute(COMMAND_ARGS) 25 | { 26 | __asm 27 | { 28 | mov ecx, kLNEventMask_OnKeyDown 29 | jmp SetOnKeyEventHandler_Execute 30 | } 31 | } 32 | 33 | __declspec(naked) bool Cmd_SetOnKeyUpEventHandler_Execute(COMMAND_ARGS) 34 | { 35 | __asm 36 | { 37 | mov ecx, kLNEventMask_OnKeyUp 38 | jmp SetOnKeyEventHandler_Execute 39 | } 40 | } 41 | 42 | __declspec(naked) bool Cmd_SetOnControlDownEventHandler_Execute(COMMAND_ARGS) 43 | { 44 | __asm 45 | { 46 | mov ecx, kLNEventMask_OnControlDown 47 | jmp SetOnKeyEventHandler_Execute 48 | } 49 | } 50 | 51 | __declspec(naked) bool Cmd_SetOnControlUpEventHandler_Execute(COMMAND_ARGS) 52 | { 53 | __asm 54 | { 55 | mov ecx, kLNEventMask_OnControlUp 56 | jmp SetOnKeyEventHandler_Execute 57 | } 58 | } 59 | 60 | void __fastcall SetCtrlHeldState(UInt32 ctrlID, bool bHold) 61 | { 62 | if (!s_controllerReady) 63 | { 64 | UInt32 keyID = KEYBOARD_BIND(ctrlID); 65 | if (keyID != 0xFF) g_DIHookCtrl->SetKeyHeldState(keyID, bHold); 66 | keyID = MOUSE_BIND(ctrlID); 67 | if (keyID != 0xFF) g_DIHookCtrl->SetKeyHeldState(keyID + 0x100, bHold); 68 | } 69 | else SetXIControlHeld(ctrlID, bHold); 70 | } 71 | 72 | bool Cmd_HoldControl_Execute(COMMAND_ARGS) 73 | { 74 | UInt32 ctrlID; 75 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ctrlID) && (ctrlID < MAX_CONTROL_BIND)) 76 | SetCtrlHeldState(ctrlID, true); 77 | return true; 78 | } 79 | 80 | bool Cmd_ReleaseControl_Execute(COMMAND_ARGS) 81 | { 82 | UInt32 ctrlID; 83 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &ctrlID) && (ctrlID < MAX_CONTROL_BIND)) 84 | SetCtrlHeldState(ctrlID, false); 85 | return true; 86 | } 87 | 88 | bool s_vanityEnabled = true; 89 | 90 | bool Cmd_ToggleVanityWheel_Execute(COMMAND_ARGS) 91 | { 92 | if (s_vanityEnabled) 93 | *result = 1; 94 | UInt32 toggle; 95 | if (NUM_ARGS && ExtractArgsEx(EXTRACT_ARGS_EX, &toggle) && (s_vanityEnabled == !toggle)) 96 | { 97 | s_vanityEnabled = !s_vanityEnabled; 98 | SafeWrite8(0x945A29, toggle ? 0x8B : 0x89); 99 | } 100 | return true; 101 | } 102 | 103 | bool Cmd_ToggleMouseMovement_Execute(COMMAND_ARGS) 104 | { 105 | *result = int(s_mouseMovementState & 3); 106 | UInt32 toggle; 107 | if (NUM_ARGS && ExtractArgsEx(EXTRACT_ARGS_EX, &toggle)) 108 | s_mouseMovementState = toggle | 4; 109 | return true; 110 | } 111 | 112 | bool Cmd_ScrollMouseWheel_Execute(COMMAND_ARGS) 113 | { 114 | SInt32 value; 115 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value)) 116 | g_inputGlobals->currMouseWheelScroll += value; 117 | return true; 118 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_land_texture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetLandTextureTextureSet, 0, kParams_OneForm); 4 | DEFINE_COMMAND_PLUGIN(SetLandTextureTextureSet, 0, kParams_TwoForms); 5 | DEFINE_COMMAND_PLUGIN(GetLandTextureTraitNumeric, 0, kParams_OneForm_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetLandTextureTraitNumeric, 0, kParams_OneForm_TwoInts); 7 | DEFINE_COMMAND_PLUGIN(GetLandTextureNumGrasses, 0, kParams_OneForm); 8 | DEFINE_COMMAND_PLUGIN(GetLandTextureNthGrass, 0, kParams_OneForm_OneInt); 9 | DEFINE_COMMAND_PLUGIN(LandTextureAddGrass, 0, kParams_TwoForms); 10 | DEFINE_COMMAND_PLUGIN(LandTextureRemoveGrass, 0, kParams_TwoForms); 11 | 12 | bool Cmd_GetLandTextureTextureSet_Execute(COMMAND_ARGS) 13 | { 14 | TESLandTexture *landTex; 15 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &landTex) && IS_ID(landTex, TESLandTexture) && landTex->textureSet) 16 | REFR_RES = landTex->textureSet->refID; 17 | return true; 18 | } 19 | 20 | bool Cmd_SetLandTextureTextureSet_Execute(COMMAND_ARGS) 21 | { 22 | TESLandTexture *landTex; 23 | BGSTextureSet *texSet; 24 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &landTex, &texSet) && IS_ID(landTex, TESLandTexture) && IS_ID(texSet, BGSTextureSet)) 25 | landTex->textureSet = texSet; 26 | return true; 27 | } 28 | 29 | bool Cmd_GetLandTextureTraitNumeric_Execute(COMMAND_ARGS) 30 | { 31 | TESLandTexture *landTex; 32 | UInt32 traitID; 33 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &landTex, &traitID) && IS_ID(landTex, TESLandTexture)) 34 | switch (traitID) 35 | { 36 | case 0: 37 | *result = landTex->materialType; 38 | break; 39 | case 1: 40 | *result = landTex->friction; 41 | break; 42 | case 2: 43 | *result = landTex->restitution; 44 | break; 45 | case 3: 46 | *result = landTex->specularExponent; 47 | } 48 | return true; 49 | } 50 | 51 | bool Cmd_SetLandTextureTraitNumeric_Execute(COMMAND_ARGS) 52 | { 53 | TESLandTexture *landTex; 54 | UInt32 traitID, val; 55 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &landTex, &traitID, &val) && IS_ID(landTex, TESLandTexture)) 56 | switch (traitID) 57 | { 58 | case 0: 59 | if (val < 32) landTex->materialType = val; 60 | break; 61 | case 1: 62 | landTex->friction = val; 63 | break; 64 | case 2: 65 | landTex->restitution = val; 66 | break; 67 | case 3: 68 | landTex->specularExponent = val; 69 | } 70 | return true; 71 | } 72 | 73 | bool Cmd_GetLandTextureNumGrasses_Execute(COMMAND_ARGS) 74 | { 75 | TESLandTexture *landTex; 76 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &landTex) && IS_ID(landTex, TESLandTexture)) 77 | *result = (int)landTex->grasses.Count(); 78 | return true; 79 | } 80 | 81 | bool Cmd_GetLandTextureNthGrass_Execute(COMMAND_ARGS) 82 | { 83 | TESLandTexture *landTex; 84 | UInt32 idx; 85 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &landTex, &idx) && IS_ID(landTex, TESLandTexture)) 86 | if (TESGrass *grass = landTex->grasses.GetNthItem(idx)) 87 | REFR_RES = grass->refID; 88 | return true; 89 | } 90 | 91 | bool Cmd_LandTextureAddGrass_Execute(COMMAND_ARGS) 92 | { 93 | TESLandTexture *landTex; 94 | TESGrass *grass; 95 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &landTex, &grass) && IS_ID(landTex, TESLandTexture) && IS_ID(grass, TESGrass) && !landTex->grasses.IsInList(grass)) 96 | { 97 | landTex->grasses.Prepend(grass); 98 | *result = 1; 99 | } 100 | return true; 101 | } 102 | 103 | bool Cmd_LandTextureRemoveGrass_Execute(COMMAND_ARGS) 104 | { 105 | TESLandTexture *landTex; 106 | TESGrass *grass; 107 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &landTex, &grass) && IS_ID(landTex, TESLandTexture) && IS_ID(grass, TESGrass) && landTex->grasses.Remove(grass)) 108 | *result = 1; 109 | return true; 110 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_light.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetLightTraitNumeric, 0, kParams_OneBoundObject_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetLightTraitNumeric, 0, kParams_OneForm_OneInt_OneFloat); 5 | DEFINE_COMMAND_PLUGIN(GetLightFlag, 0, kParams_OneBoundObject_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetLightFlag, 0, kParams_OneForm_TwoInts); 7 | 8 | bool Cmd_GetLightTraitNumeric_Execute(COMMAND_ARGS) 9 | { 10 | TESObjectLIGH *light; 11 | UInt32 traitID; 12 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &light, &traitID) && IS_ID(light, TESObjectLIGH)) 13 | switch (traitID) 14 | { 15 | case 0: 16 | *result = (int)light->radius; 17 | break; 18 | case 1: 19 | *result = light->red; 20 | break; 21 | case 2: 22 | *result = light->green; 23 | break; 24 | case 3: 25 | *result = light->blue; 26 | break; 27 | case 4: 28 | *result = light->falloffExp; 29 | break; 30 | case 5: 31 | *result = light->FOV; 32 | break; 33 | case 6: 34 | *result = light->fadeValue; 35 | } 36 | return true; 37 | } 38 | 39 | __declspec(naked) void __fastcall MarkLightModified(TESObjectLIGH *lightForm) 40 | { 41 | __asm 42 | { 43 | mov eax, offset s_activePtLights 44 | mov edx, [eax+4] 45 | test edx, edx 46 | jz done 47 | push esi 48 | mov esi, [eax] 49 | ALIGN 16 50 | iterHead: 51 | dec edx 52 | js iterEnd 53 | mov eax, [esi] 54 | add esi, 4 55 | cmp [eax+0xE8], ecx 56 | jnz iterHead 57 | mov [eax+0x9E], 1 58 | jmp iterHead 59 | ALIGN 16 60 | iterEnd: 61 | pop esi 62 | done: 63 | retn 64 | } 65 | } 66 | 67 | bool Cmd_SetLightTraitNumeric_Execute(COMMAND_ARGS) 68 | { 69 | TESObjectLIGH *light; 70 | UInt32 traitID; 71 | float val; 72 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &light, &traitID, &val) && IS_ID(light, TESObjectLIGH)) 73 | { 74 | UInt32 intVal = (int)val; 75 | switch (traitID) 76 | { 77 | case 0: 78 | light->radius = intVal; 79 | break; 80 | case 1: 81 | light->red = intVal; 82 | break; 83 | case 2: 84 | light->green = intVal; 85 | break; 86 | case 3: 87 | light->blue = intVal; 88 | break; 89 | case 4: 90 | light->falloffExp = val; 91 | return true; 92 | case 5: 93 | light->FOV = val; 94 | return true; 95 | case 6: 96 | light->fadeValue = val; 97 | break; 98 | default: 99 | return true; 100 | } 101 | MarkLightModified(light); 102 | } 103 | return true; 104 | } 105 | 106 | bool Cmd_GetLightFlag_Execute(COMMAND_ARGS) 107 | { 108 | TESObjectLIGH *light; 109 | UInt32 flagID; 110 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &light, &flagID) && IS_ID(light, TESObjectLIGH) && (flagID <= 31) && (light->lightFlags & (1 << flagID))) 111 | *result = 1; 112 | return true; 113 | } 114 | 115 | bool Cmd_SetLightFlag_Execute(COMMAND_ARGS) 116 | { 117 | TESObjectLIGH *light; 118 | UInt32 flagID, val; 119 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &light, &flagID, &val) && IS_ID(light, TESObjectLIGH) && (flagID <= 31)) 120 | { 121 | flagID = 1 << flagID; 122 | if (val) light->lightFlags |= flagID; 123 | else light->lightFlags &= ~flagID; 124 | MarkLightModified(light); 125 | } 126 | return true; 127 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_package.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetPackageFlag, 0, kParams_OneAIPackage_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetPackageFlag, 0, kParams_OneAIPackage_TwoInts); 5 | 6 | bool Cmd_GetPackageFlag_Execute(COMMAND_ARGS) 7 | { 8 | TESPackage *package; 9 | UInt32 flagID; 10 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &package, &flagID) && (flagID <= 31) && (package->packageFlags & (1 << flagID))) 11 | *result = 1; 12 | return true; 13 | } 14 | 15 | bool Cmd_SetPackageFlag_Execute(COMMAND_ARGS) 16 | { 17 | TESPackage *package; 18 | UInt32 flagID, val; 19 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &package, &flagID, &val) && (flagID <= 31)) 20 | { 21 | flagID = 1 << flagID; 22 | if (val) package->packageFlags |= flagID; 23 | else package->packageFlags &= ~flagID; 24 | } 25 | return true; 26 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_perk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetPerkFlag, 0, kParams_OnePerk_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetPerkFlag, 0, kParams_OnePerk_TwoInts); 5 | 6 | bool Cmd_GetPerkFlag_Execute(COMMAND_ARGS) 7 | { 8 | BGSPerk *perk; 9 | UInt32 flagID; 10 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &perk, &flagID)) 11 | { 12 | bool isSet = false; 13 | switch (flagID) 14 | { 15 | case 0: 16 | isSet = perk->data.isTrait; 17 | break; 18 | case 1: 19 | isSet = perk->data.isPlayable; 20 | break; 21 | case 2: 22 | isSet = perk->data.isHidden; 23 | } 24 | if (isSet) 25 | *result = 1; 26 | } 27 | return true; 28 | } 29 | 30 | bool Cmd_SetPerkFlag_Execute(COMMAND_ARGS) 31 | { 32 | BGSPerk *perk; 33 | UInt32 flagID, value; 34 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &perk, &flagID, &value)) 35 | switch (flagID) 36 | { 37 | case 0: 38 | perk->data.isTrait = (value != 0); 39 | break; 40 | case 1: 41 | perk->data.isPlayable = (value != 0); 42 | break; 43 | case 2: 44 | perk->data.isHidden = (value != 0); 45 | } 46 | return true; 47 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_string.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(sv_RegexMatch, 0, kParams_OneInt_OneFormatString); 4 | DEFINE_COMMAND_PLUGIN(sv_RegexSearch, 0, kParams_OneInt_OneFormatString); 5 | DEFINE_COMMAND_PLUGIN(sv_RegexReplace, 0, kParams_OneInt_OneFormatString); 6 | DEFINE_COMMAND_ALT_PLUGIN(GetStringHash, GetHash, 0, kParams_OneString_TwoOptionalInts); 7 | 8 | bool Cmd_sv_RegexMatch_Execute(COMMAND_ARGS) 9 | { 10 | UInt32 strID; 11 | char rgxStr[0x80]; 12 | if (ExtractFormatStringArgs(1, rgxStr, EXTRACT_ARGS_EX, kCommandInfo_sv_RegexMatch.numParams, &strID)) 13 | if (const char *srcStr = GetStringVar(strID); srcStr && std::regex_match(srcStr, std::regex(rgxStr))) 14 | *result = 1; 15 | return true; 16 | } 17 | 18 | bool Cmd_sv_RegexSearch_Execute(COMMAND_ARGS) 19 | { 20 | NVSEArrayVar *resArr = CreateArray(NULL, 0, scriptObj); 21 | *result = (int)resArr; 22 | UInt32 strID; 23 | char rgxStr[0x80]; 24 | if (ExtractFormatStringArgs(1, rgxStr, EXTRACT_ARGS_EX, kCommandInfo_sv_RegexSearch.numParams, &strID)) 25 | if (const char *srcStr = GetStringVar(strID), *pEnd = srcStr + StrLen(srcStr); srcStr != pEnd) 26 | { 27 | std::cmatch matches; 28 | for (std::regex rgx(rgxStr); std::regex_search(srcStr, matches, rgx); srcStr = pEnd - matches.suffix().str().size()) 29 | AppendElement(resArr, ArrayElementL(matches.str().c_str())); 30 | } 31 | return true; 32 | } 33 | 34 | bool Cmd_sv_RegexReplace_Execute(COMMAND_ARGS) 35 | { 36 | UInt32 strID; 37 | char *buffer = GetStrArgBuffer(); 38 | if (ExtractFormatStringArgs(1, buffer, EXTRACT_ARGS_EX, kCommandInfo_sv_RegexReplace.numParams, &strID)) 39 | if (const char *srcStr = GetStringVar(strID)) 40 | if (char *rgxStr = GetNextToken(buffer, '|'); rgxStr && *rgxStr) 41 | { 42 | AssignString(PASS_COMMAND_ARGS, std::regex_replace(srcStr, std::regex(rgxStr), buffer).c_str()); 43 | return true; 44 | } 45 | AssignString(PASS_COMMAND_ARGS, nullptr); 46 | return true; 47 | } 48 | 49 | bool Cmd_GetStringHash_Execute(COMMAND_ARGS) 50 | { 51 | char *buffer = GetStrArgBuffer(); 52 | UInt32 split = 0, useCase = 0; 53 | if (ExtractArgsEx(EXTRACT_ARGS_EX, buffer, &split, &useCase) && *buffer) 54 | { 55 | auto StrHash = !useCase ? StrHashCI : StrHashCS; 56 | if (!split) 57 | { 58 | *result = (SInt32)StrHash(buffer); 59 | DoConsolePrint(result); 60 | } 61 | else if (FILE *theFile = fopen("GetStringHash.txt", "wb")) 62 | { 63 | while (true) 64 | { 65 | char *barPtr = GetNextToken(buffer, '|'); 66 | fprintf(theFile, "\"%s\"\n%d\n\n", buffer, StrHash(buffer)); 67 | if (!*barPtr) break; 68 | buffer = barPtr; 69 | } 70 | fclose(theFile); 71 | } 72 | } 73 | return true; 74 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_texture_set.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetTextureSetTexture, 0, kParams_OneForm_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetTextureSetTexture, 0, kParams_OneForm_OneInt_OneString); 5 | DEFINE_COMMAND_PLUGIN(GetTextureSetTraitNumeric, 0, kParams_OneForm_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetTextureSetTraitNumeric, 0, kParams_OneForm_OneInt_OneDouble); 7 | DEFINE_COMMAND_PLUGIN(GetTextureSetFlag, 0, kParams_OneForm_OneInt); 8 | DEFINE_COMMAND_PLUGIN(SetTextureSetFlag, 0, kParams_OneForm_TwoInts); 9 | 10 | bool Cmd_GetTextureSetTexture_Execute(COMMAND_ARGS) 11 | { 12 | const char *resStr = nullptr; 13 | BGSTextureSet *texSet; 14 | UInt32 mapID; 15 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &texSet, &mapID) && IS_ID(texSet, BGSTextureSet) && (mapID <= 5)) 16 | resStr = texSet->textures[mapID].ddsPath.m_data; 17 | AssignString(PASS_COMMAND_ARGS, resStr); 18 | return true; 19 | } 20 | 21 | bool Cmd_SetTextureSetTexture_Execute(COMMAND_ARGS) 22 | { 23 | BGSTextureSet *texSet; 24 | UInt32 mapID; 25 | char path[0x80]; 26 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &texSet, &mapID, &path) && IS_ID(texSet, BGSTextureSet) && (mapID <= 5)) 27 | texSet->textures[mapID].ddsPath.Set(path); 28 | return true; 29 | } 30 | 31 | bool Cmd_GetTextureSetTraitNumeric_Execute(COMMAND_ARGS) 32 | { 33 | BGSTextureSet *texSet; 34 | UInt32 traitID; 35 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &texSet, &traitID) && IS_ID(texSet, BGSTextureSet) && texSet->decalInfo) 36 | switch (traitID) 37 | { 38 | case 0: 39 | case 1: 40 | case 2: 41 | case 3: 42 | case 4: 43 | case 5: 44 | case 6: 45 | *result = ((float*)texSet->decalInfo)[traitID]; 46 | break; 47 | case 7: 48 | *result = texSet->decalInfo->parallaxPasses; 49 | break; 50 | case 8: 51 | cvtul2d(RGBHexToDec(texSet->decalInfo->color), result); 52 | } 53 | return true; 54 | } 55 | 56 | bool Cmd_SetTextureSetTraitNumeric_Execute(COMMAND_ARGS) 57 | { 58 | BGSTextureSet *texSet; 59 | UInt32 traitID; 60 | double value; 61 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &texSet, &traitID, &value) && IS_ID(texSet, BGSTextureSet) && (value >= 0) && texSet->decalInfo) 62 | switch (traitID) 63 | { 64 | case 0: 65 | case 1: 66 | case 2: 67 | case 3: 68 | case 4: 69 | case 5: 70 | case 6: 71 | ((float*)texSet->decalInfo)[traitID] = value; 72 | break; 73 | case 7: 74 | texSet->decalInfo->parallaxPasses = (int)value; 75 | break; 76 | case 8: 77 | if (UInt32 decRGB = cvtd2ul(value); decRGB <= 255255255) 78 | texSet->decalInfo->color = RGBDecToHex(decRGB); 79 | } 80 | return true; 81 | } 82 | 83 | bool Cmd_GetTextureSetFlag_Execute(COMMAND_ARGS) 84 | { 85 | BGSTextureSet *texSet; 86 | UInt32 flagID; 87 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &texSet, &flagID) && IS_ID(texSet, BGSTextureSet) && (flagID <= 3)) 88 | if (!flagID) 89 | { 90 | if (texSet->texFlags) 91 | *result = 1; 92 | } 93 | else if (texSet->decalInfo && (texSet->decalInfo->flags & (1 << (flagID - 1)))) 94 | *result = 1; 95 | return true; 96 | } 97 | 98 | bool Cmd_SetTextureSetFlag_Execute(COMMAND_ARGS) 99 | { 100 | BGSTextureSet *texSet; 101 | UInt32 flagID, val; 102 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &texSet, &flagID, &val) && IS_ID(texSet, BGSTextureSet) && (flagID <= 3)) 103 | if (!flagID) 104 | texSet->texFlags = val != 0; 105 | else if (texSet->decalInfo) 106 | if (val) 107 | texSet->decalInfo->flags |= (1 << (flagID - 1)); 108 | else 109 | texSet->decalInfo->flags &= ~(1 << (flagID - 1)); 110 | return true; 111 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_water.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetWaterNoiseTexture, 0, kParams_OneForm); 4 | DEFINE_COMMAND_PLUGIN(SetWaterNoiseTexture, 0, kParams_OneForm_OneString); 5 | DEFINE_COMMAND_PLUGIN(SetWaterFormEffect, 0, kParams_OneForm_OneOptionalForm); 6 | DEFINE_COMMAND_PLUGIN(GetWaterSound, 0, kParams_OneForm); 7 | DEFINE_COMMAND_PLUGIN(SetWaterSound, 0, kParams_OneForm_OneOptionalForm); 8 | 9 | bool Cmd_GetWaterNoiseTexture_Execute(COMMAND_ARGS) 10 | { 11 | const char *resStr = nullptr; 12 | TESWaterForm *water; 13 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &water) && IS_ID(water, TESWaterForm)) 14 | resStr = water->noiseMap.ddsPath.m_data; 15 | AssignString(PASS_COMMAND_ARGS, resStr); 16 | return true; 17 | } 18 | 19 | bool Cmd_SetWaterNoiseTexture_Execute(COMMAND_ARGS) 20 | { 21 | TESWaterForm *water; 22 | char path[0x80]; 23 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &water, &path) && IS_ID(water, TESWaterForm)) 24 | water->noiseMap.ddsPath.Set(path); 25 | return true; 26 | } 27 | 28 | bool Cmd_SetWaterFormEffect_Execute(COMMAND_ARGS) 29 | { 30 | TESWaterForm *water; 31 | SpellItem *effect = nullptr; 32 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &water, &effect) && IS_ID(water, TESWaterForm) && (!effect || IS_ID(effect, SpellItem))) 33 | water->drinkEffect = effect; 34 | return true; 35 | } 36 | 37 | bool Cmd_GetWaterSound_Execute(COMMAND_ARGS) 38 | { 39 | TESWaterForm *water; 40 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &water) && IS_ID(water, TESWaterForm) && water->sound) 41 | REFR_RES = water->sound->refID; 42 | return true; 43 | } 44 | 45 | bool Cmd_SetWaterSound_Execute(COMMAND_ARGS) 46 | { 47 | TESWaterForm *water; 48 | TESSound *sound = nullptr; 49 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &water, &sound) && IS_ID(water, TESWaterForm) && (!sound || IS_ID(sound, TESSound))) 50 | water->sound = sound; 51 | return true; 52 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_weather.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetWeatherImageSpaceMod, 0, kParams_OneWeatherID_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetWeatherImageSpaceMod, 0, kParams_OneWeatherID_OneInt_OneOptionalImageSpaceMod); 5 | DEFINE_COMMAND_PLUGIN(GetWeatherTexture, 0, kParams_OneWeatherID_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetWeatherTexture, 0, kParams_OneWeatherID_OneInt_OneString); 7 | DEFINE_COMMAND_PLUGIN(GetWeatherPrecipitationModel, 0, kParams_OneWeatherID); 8 | DEFINE_COMMAND_PLUGIN(SetWeatherPrecipitationModel, 0, kParams_OneWeatherID_OneString); 9 | DEFINE_COMMAND_PLUGIN(GetWeatherTraitNumeric, 0, kParams_OneWeatherID_OneInt); 10 | DEFINE_COMMAND_PLUGIN(SetWeatherTraitNumeric, 0, kParams_OneWeatherID_OneInt_OneDouble); 11 | DEFINE_COMMAND_PLUGIN(GetWeatherRGBColor, 0, kParams_OneWeatherID_TwoInts_OneOptionalInt); 12 | DEFINE_COMMAND_PLUGIN(SetWeatherRGBColor, 0, kParams_OneWeatherID_ThreeInts_OneOptionalInt); 13 | DEFINE_COMMAND_PLUGIN(GetCurrentWeather, 0, nullptr); 14 | DEFINE_COMMAND_PLUGIN(SetWeatherTransitionTimeOverride, 0, kParams_OneOptionalInt); 15 | DEFINE_COMMAND_PLUGIN(GetWindDirection, 0, nullptr); 16 | DEFINE_COMMAND_PLUGIN(SetWindDirection, 0, kParams_OneFloat); 17 | DEFINE_COMMAND_PLUGIN(SetWindSpeedMult, 0, kParams_OneFloat); 18 | DEFINE_COMMAND_PLUGIN(TriggerLightningFX, 0, nullptr); 19 | DEFINE_COMMAND_PLUGIN(ResetClouds, 0, nullptr); 20 | DEFINE_COMMAND_PLUGIN(ReloadCloudTextures, 0, nullptr); 21 | 22 | bool Cmd_GetWeatherImageSpaceMod_Execute(COMMAND_ARGS) 23 | { 24 | TESWeather *weather; 25 | UInt32 time; 26 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &time) && (time <= 5) && weather->imageSpaceMods[time]) 27 | REFR_RES = weather->imageSpaceMods[time]->refID; 28 | return true; 29 | } 30 | 31 | bool Cmd_SetWeatherImageSpaceMod_Execute(COMMAND_ARGS) 32 | { 33 | TESWeather *weather; 34 | UInt32 time; 35 | TESImageSpaceModifier *imgSpcMod = NULL; 36 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &time, &imgSpcMod) && (time <= 5)) 37 | weather->imageSpaceMods[time] = imgSpcMod; 38 | return true; 39 | } 40 | 41 | bool Cmd_GetWeatherTexture_Execute(COMMAND_ARGS) 42 | { 43 | const char *resStr = nullptr; 44 | TESWeather *weather; 45 | UInt32 layer; 46 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &layer) && (layer <= 3)) 47 | resStr = weather->layerTextures[layer].ddsPath.m_data; 48 | AssignString(PASS_COMMAND_ARGS, resStr); 49 | return true; 50 | } 51 | 52 | bool Cmd_SetWeatherTexture_Execute(COMMAND_ARGS) 53 | { 54 | TESWeather *weather; 55 | UInt32 layer; 56 | char path[0x80]; 57 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &layer, &path) && (layer <= 3)) 58 | weather->layerTextures[layer].ddsPath.Set(path); 59 | return true; 60 | } 61 | 62 | bool Cmd_GetWeatherPrecipitationModel_Execute(COMMAND_ARGS) 63 | { 64 | const char *resStr = nullptr; 65 | TESWeather *weather; 66 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather)) 67 | resStr = weather->model.GetModelPath(); 68 | AssignString(PASS_COMMAND_ARGS, resStr); 69 | return true; 70 | } 71 | 72 | bool Cmd_SetWeatherPrecipitationModel_Execute(COMMAND_ARGS) 73 | { 74 | TESWeather *weather; 75 | char path[0x80]; 76 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &path)) 77 | weather->model.SetModelPath(path); 78 | return true; 79 | } 80 | 81 | bool Cmd_GetWeatherTraitNumeric_Execute(COMMAND_ARGS) 82 | { 83 | TESWeather *weather; 84 | UInt32 traitID; 85 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &traitID) && (traitID <= 20)) 86 | switch (traitID) 87 | { 88 | case 0: 89 | case 1: 90 | case 2: 91 | case 3: 92 | *result = weather->cloudSpeed[traitID] * (1 / 2550.0); 93 | break; 94 | case 4: 95 | *result = weather->windSpeed * (1 / 255.0); 96 | break; 97 | case 5: 98 | *result = weather->transDelta * 0.001; 99 | break; 100 | case 6: 101 | case 7: 102 | case 8: 103 | case 9: 104 | case 10: 105 | case 11: 106 | case 12: 107 | *result = ((UInt8*)weather)[0xDE + traitID] * (1 / 255.0); 108 | break; 109 | case 13: 110 | *result = weather->weatherClassification; 111 | break; 112 | case 14: 113 | cvtul2d(RGBHexToDec(weather->lightningColor), result); 114 | break; 115 | default: 116 | *result = weather->fogDistance[traitID - 15]; 117 | } 118 | return true; 119 | } 120 | 121 | bool Cmd_SetWeatherTraitNumeric_Execute(COMMAND_ARGS) 122 | { 123 | TESWeather *weather; 124 | UInt32 traitID; 125 | double value; 126 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &traitID, &value) && (traitID <= 20)) 127 | switch (traitID) 128 | { 129 | case 0: 130 | case 1: 131 | case 2: 132 | case 3: 133 | weather->cloudSpeed[traitID] = (value > 0.1) ? 255 : (value * 2550); 134 | break; 135 | case 4: 136 | weather->windSpeed = (value > 1) ? 255 : (value * 255); 137 | break; 138 | case 5: 139 | weather->transDelta = (value > 0.25) ? 255 : (value * 1000); 140 | break; 141 | case 6: 142 | case 7: 143 | case 8: 144 | case 9: 145 | case 10: 146 | case 11: 147 | case 12: 148 | ((UInt8*)weather)[0xDE + traitID] = (value > 1) ? 255 : (value * 255); 149 | break; 150 | case 13: 151 | if (UInt32 intVal = (int)value; !(intVal & (intVal - 1))) 152 | weather->weatherClassification = intVal; 153 | break; 154 | case 14: 155 | if (UInt32 decRGB = cvtd2ul(value); decRGB <= 255255255) 156 | weather->lightningColor = RGBDecToHex(decRGB); 157 | break; 158 | default: 159 | weather->fogDistance[traitID - 15] = value; 160 | } 161 | return true; 162 | } 163 | 164 | bool Cmd_GetWeatherRGBColor_Execute(COMMAND_ARGS) 165 | { 166 | TESWeather *weather; 167 | UInt32 type, time, layer = 0; 168 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &type, &time, &layer) && (type <= 9) && (time <= 5)) 169 | if (type != 2) 170 | cvtul2d(RGBHexToDec(weather->colors[type][time]), result); 171 | else if (layer <= 3) 172 | cvtul2d(RGBHexToDec(weather->cloudColor[layer][time]), result); 173 | return true; 174 | } 175 | 176 | bool Cmd_SetWeatherRGBColor_Execute(COMMAND_ARGS) 177 | { 178 | TESWeather *weather; 179 | UInt32 type, time, rgb, layer = 0; 180 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weather, &type, &time, &rgb, &layer) && (type <= 9) && (time <= 5) && (rgb <= 255255255)) 181 | if (type != 2) 182 | weather->colors[type][time] = RGBDecToHex(rgb); 183 | else if (layer <= 3) 184 | weather->cloudColor[layer][time] = RGBDecToHex(rgb); 185 | return true; 186 | } 187 | 188 | bool Cmd_GetCurrentWeather_Execute(COMMAND_ARGS) 189 | { 190 | TESWeather *weather = g_currentSky->currWeather; 191 | if (weather) 192 | REFR_RES = weather->refID; 193 | DoConsolePrint(weather); 194 | return true; 195 | } 196 | 197 | bool Cmd_SetWeatherTransitionTimeOverride_Execute(COMMAND_ARGS) 198 | { 199 | UInt32 transTime = 0; 200 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &transTime)) 201 | { 202 | if (transTime != 0) s_weatherTransitionRateOverride = 120.0F / (int)transTime; 203 | HOOK_SET(UpdateWeather, transTime != 0); 204 | } 205 | return true; 206 | } 207 | 208 | bool Cmd_GetWindDirection_Execute(COMMAND_ARGS) 209 | { 210 | *result = g_currentSky->windDirection * -Dbl180dPI; 211 | DoConsolePrint(result); 212 | return true; 213 | } 214 | 215 | bool Cmd_SetWindDirection_Execute(COMMAND_ARGS) 216 | { 217 | float windDirection; 218 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &windDirection)) 219 | g_currentSky->windDirection = windDirection * -FltPId180; 220 | return true; 221 | } 222 | 223 | bool Cmd_SetWindSpeedMult_Execute(COMMAND_ARGS) 224 | { 225 | float speedMult; 226 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &speedMult)) 227 | s_windSpeedMult = speedMult * (1 / 255.0F); 228 | return true; 229 | } 230 | 231 | bool Cmd_TriggerLightningFX_Execute(COMMAND_ARGS) 232 | { 233 | if (g_currentSky->GetIsRaining()) 234 | g_currentSky->lightningFxPerc = 1; 235 | return true; 236 | } 237 | 238 | bool Cmd_ResetClouds_Execute(COMMAND_ARGS) 239 | { 240 | _mm_storeu_ps((float*)0x11FF8B4, _mm_setzero_ps()); 241 | return true; 242 | } 243 | 244 | bool Cmd_ReloadCloudTextures_Execute(COMMAND_ARGS) 245 | { 246 | if (Clouds *clouds = g_currentSky->clouds) 247 | { 248 | clouds->bForceUpdate = 1; 249 | clouds->Update(g_currentSky, 0); 250 | } 251 | return true; 252 | } -------------------------------------------------------------------------------- /functions_jip/jip_fn_worldspace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetWorldspaceFlag, 0, kParams_OneWorldspace_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetWorldspaceFlag, 0, kParams_OneWorldspace_TwoInts); 5 | DEFINE_COMMAND_PLUGIN(GetWorldspaceClimate, 0, kParams_OneWorldspace); 6 | DEFINE_COMMAND_PLUGIN(SetWorldspaceClimate, 0, kParams_OneWorldspace_OneOptionalForm); 7 | DEFINE_COMMAND_PLUGIN(GetWorldspaceNoiseTexture, 0, kParams_OneWorldspace); 8 | DEFINE_COMMAND_PLUGIN(SetWorldspaceNoiseTexture, 0, kParams_OneForm_OneString); 9 | DEFINE_COMMAND_PLUGIN(GetWorldspaceWaterType, 0, kParams_OneWorldspace); 10 | DEFINE_COMMAND_PLUGIN(SetWorldspaceWaterType, 0, kParams_OneWorldspace_OneOptionalForm); 11 | DEFINE_COMMAND_PLUGIN(GetWorldspaceImagespace, 0, kParams_OneWorldspace); 12 | DEFINE_COMMAND_PLUGIN(SetWorldspaceImagespace, 0, kParams_OneWorldspace_OneOptionalForm); 13 | DEFINE_COMMAND_PLUGIN(GetWorldspacePersistentCell, 0, kParams_OneWorldspace); 14 | 15 | bool Cmd_GetWorldspaceFlag_Execute(COMMAND_ARGS) 16 | { 17 | TESWorldSpace *wspc; 18 | UInt32 flagID; 19 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wspc, &flagID) && (flagID <= 7) && (wspc->worldFlags & (1 << flagID))) 20 | *result = 1; 21 | return true; 22 | } 23 | 24 | bool Cmd_SetWorldspaceFlag_Execute(COMMAND_ARGS) 25 | { 26 | TESWorldSpace *wspc; 27 | UInt32 flagID, val; 28 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wspc, &flagID, &val) && (flagID <= 7)) 29 | { 30 | flagID = 1 << flagID; 31 | if (val) wspc->worldFlags |= flagID; 32 | else wspc->worldFlags &= ~flagID; 33 | } 34 | return true; 35 | } 36 | 37 | bool Cmd_GetWorldspaceClimate_Execute(COMMAND_ARGS) 38 | { 39 | TESWorldSpace *wldSpc; 40 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wldSpc)) 41 | { 42 | while (wldSpc->parent && (wldSpc->parentFlags & 0x10)) 43 | wldSpc = wldSpc->parent; 44 | TESClimate *climate = wldSpc->climate; 45 | if (climate) REFR_RES = climate->refID; 46 | DoConsolePrint(climate); 47 | } 48 | return true; 49 | } 50 | 51 | bool Cmd_SetWorldspaceClimate_Execute(COMMAND_ARGS) 52 | { 53 | TESWorldSpace *wldSpc; 54 | TESClimate *climate = nullptr; 55 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wldSpc, &climate) && (!climate || IS_ID(climate, TESClimate))) 56 | { 57 | if (wldSpc->parent && (wldSpc->parentFlags & 16)) 58 | wldSpc->parentFlags -= 16; 59 | wldSpc->climate = climate; 60 | if (Sky *currSky = Sky::Get(); currSky && g_thePlayer->parentCell) 61 | if (TESWorldSpace *pcWspc = g_thePlayer->parentCell->worldSpace) 62 | { 63 | while (pcWspc->parent && (pcWspc->parentFlags & 16)) 64 | pcWspc = pcWspc->parent; 65 | if (pcWspc == wldSpc) 66 | currSky->currClimate = climate; 67 | } 68 | } 69 | return true; 70 | } 71 | 72 | bool Cmd_GetWorldspaceNoiseTexture_Execute(COMMAND_ARGS) 73 | { 74 | const char *resStr = nullptr; 75 | TESWorldSpace *wspc; 76 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wspc)) 77 | resStr = wspc->waterNoiseTexture.ddsPath.m_data; 78 | AssignString(PASS_COMMAND_ARGS, resStr); 79 | return true; 80 | } 81 | 82 | bool Cmd_SetWorldspaceNoiseTexture_Execute(COMMAND_ARGS) 83 | { 84 | TESWorldSpace *wspc; 85 | char path[0x80]; 86 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wspc, &path) && IS_ID(wspc, TESWorldSpace)) 87 | wspc->waterNoiseTexture.ddsPath.Set(path); 88 | return true; 89 | } 90 | 91 | bool Cmd_GetWorldspaceWaterType_Execute(COMMAND_ARGS) 92 | { 93 | TESWorldSpace *wldSpc; 94 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wldSpc) && wldSpc->waterFormFirst) 95 | REFR_RES = wldSpc->waterFormFirst->refID; 96 | return true; 97 | } 98 | 99 | bool Cmd_SetWorldspaceWaterType_Execute(COMMAND_ARGS) 100 | { 101 | TESWorldSpace *wldSpc; 102 | TESWaterForm *water = nullptr; 103 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wldSpc, &water) && (!water || IS_ID(water, TESWaterForm))) 104 | wldSpc->waterFormFirst = water; 105 | return true; 106 | } 107 | 108 | bool Cmd_GetWorldspaceImagespace_Execute(COMMAND_ARGS) 109 | { 110 | TESWorldSpace *wldSpc; 111 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wldSpc) && wldSpc->imageSpace) 112 | REFR_RES = wldSpc->imageSpace->refID; 113 | return true; 114 | } 115 | 116 | bool Cmd_SetWorldspaceImagespace_Execute(COMMAND_ARGS) 117 | { 118 | TESWorldSpace *wldSpc; 119 | TESImageSpace *imgSpc = nullptr; 120 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wldSpc, &imgSpc) && (!imgSpc || IS_ID(imgSpc, TESImageSpace))) 121 | wldSpc->imageSpace = imgSpc; 122 | return true; 123 | } 124 | 125 | bool Cmd_GetWorldspacePersistentCell_Execute(COMMAND_ARGS) 126 | { 127 | TESWorldSpace *wldSpc; 128 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &wldSpc) && wldSpc->cell) 129 | REFR_RES = wldSpc->cell->refID; 130 | return true; 131 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_activator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetActivatorRadioStation, 0, kParams_OneOptionalForm); 4 | DEFINE_COMMAND_PLUGIN(SetActivatorRadioStation, 0, kParams_OneForm_OneOptionalForm); 5 | DEFINE_COMMAND_PLUGIN(GetActivatorPrompt, 0, kParams_OneOptionalForm); 6 | DEFINE_COMMAND_PLUGIN(SetActivatorPrompt, 0, kParams_OneString_OneOptionalForm); 7 | DEFINE_COMMAND_PLUGIN(GetActivatorWaterType, 0, kParams_OneOptionalForm); 8 | DEFINE_COMMAND_PLUGIN(SetActivatorWaterType, 0, kParams_OneForm_OneOptionalForm); 9 | DEFINE_COMMAND_PLUGIN(GetActivatorSoundLooping, 0, kParams_OneOptionalForm); 10 | DEFINE_COMMAND_PLUGIN(SetActivatorSoundLooping, 0, kParams_OneForm_OneOptionalForm); 11 | DEFINE_COMMAND_PLUGIN(GetActivatorSoundActivate, 0, kParams_OneOptionalForm); 12 | DEFINE_COMMAND_PLUGIN(SetActivatorSoundActivate, 0, kParams_OneForm_OneOptionalForm); 13 | 14 | bool Cmd_GetActivatorRadioStation_Execute(COMMAND_ARGS) 15 | { 16 | TESObjectACTI *activator = nullptr; 17 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &activator)) 18 | if (activator || (thisObj && (activator = (TESObjectACTI*)thisObj->baseForm))) 19 | if (IS_ID(activator, TESObjectACTI) && activator->radioStation) 20 | REFR_RES = activator->radioStation->refID; 21 | return true; 22 | } 23 | 24 | bool Cmd_SetActivatorRadioStation_Execute(COMMAND_ARGS) 25 | { 26 | BGSTalkingActivator *radio; 27 | TESObjectACTI *activator = nullptr; 28 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &radio, &activator) && IS_ID(radio, BGSTalkingActivator)) 29 | if (activator || (thisObj && (activator = (TESObjectACTI*)thisObj->baseForm))) 30 | if IS_ID(activator, TESObjectACTI) 31 | activator->radioStation = radio; 32 | return true; 33 | } 34 | 35 | bool Cmd_GetActivatorPrompt_Execute(COMMAND_ARGS) 36 | { 37 | const char *resStr = nullptr; 38 | TESObjectACTI *activator = nullptr; 39 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &activator)) 40 | if (activator || (thisObj && (activator = (TESObjectACTI*)thisObj->baseForm))) 41 | if IS_ID(activator, TESObjectACTI) 42 | resStr = activator->activationPrompt.m_data; 43 | AssignString(PASS_COMMAND_ARGS, resStr); 44 | return true; 45 | } 46 | 47 | bool Cmd_SetActivatorPrompt_Execute(COMMAND_ARGS) 48 | { 49 | char prompt[0x80]; 50 | TESObjectACTI *activator = nullptr; 51 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &prompt, &activator)) 52 | if (activator || (thisObj && (activator = (TESObjectACTI*)thisObj->baseForm))) 53 | if IS_ID(activator, TESObjectACTI) 54 | activator->activationPrompt.Set(prompt); 55 | return true; 56 | } 57 | 58 | bool Cmd_GetActivatorWaterType_Execute(COMMAND_ARGS) 59 | { 60 | TESForm *form = nullptr; 61 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form)) 62 | if (form || (thisObj && (form = thisObj->baseForm))) 63 | { 64 | TESWaterForm *waterType = nullptr; 65 | if IS_ID(form, TESObjectACTI) 66 | waterType = ((TESObjectACTI*)form)->waterType; 67 | else if IS_ID(form, BGSPlaceableWater) 68 | waterType = ((BGSPlaceableWater*)form)->water; 69 | if (waterType) 70 | REFR_RES = waterType->refID; 71 | } 72 | return true; 73 | } 74 | 75 | bool Cmd_SetActivatorWaterType_Execute(COMMAND_ARGS) 76 | { 77 | TESWaterForm *water; 78 | TESForm *form = nullptr; 79 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &water, &form) && IS_ID(water, TESWaterForm)) 80 | if (form || (thisObj && (form = thisObj->baseForm))) 81 | if IS_ID(form, TESObjectACTI) 82 | ((TESObjectACTI*)form)->waterType = water; 83 | else if IS_ID(form, BGSPlaceableWater) 84 | ((BGSPlaceableWater*)form)->water = water; 85 | return true; 86 | } 87 | 88 | bool Cmd_GetActivatorSoundLooping_Execute(COMMAND_ARGS) 89 | { 90 | TESObjectACTI *activator = nullptr; 91 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &activator)) 92 | if (activator || (thisObj && (activator = (TESObjectACTI*)thisObj->baseForm))) 93 | if (IS_ID(activator, TESObjectACTI) && activator->loopingSound) 94 | REFR_RES = activator->loopingSound->refID; 95 | return true; 96 | } 97 | 98 | bool Cmd_SetActivatorSoundLooping_Execute(COMMAND_ARGS) 99 | { 100 | TESSound *sound; 101 | TESObjectACTI *activator = nullptr; 102 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &sound, &activator) && IS_ID(sound, TESSound)) 103 | if (activator || (thisObj && (activator = (TESObjectACTI*)thisObj->baseForm))) 104 | if IS_ID(activator, TESObjectACTI) 105 | activator->loopingSound = sound; 106 | return true; 107 | } 108 | 109 | bool Cmd_GetActivatorSoundActivate_Execute(COMMAND_ARGS) 110 | { 111 | TESObjectACTI *activator = nullptr; 112 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &activator)) 113 | if (activator || (thisObj && (activator = (TESObjectACTI*)thisObj->baseForm))) 114 | if (IS_ID(activator, TESObjectACTI) && activator->activationSound) 115 | REFR_RES = activator->activationSound->refID; 116 | return true; 117 | } 118 | 119 | bool Cmd_SetActivatorSoundActivate_Execute(COMMAND_ARGS) 120 | { 121 | TESSound *sound; 122 | TESObjectACTI *activator = nullptr; 123 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &sound, &activator) && IS_ID(sound, TESSound)) 124 | if (activator || (thisObj && (activator = (TESObjectACTI*)thisObj->baseForm))) 125 | if IS_ID(activator, TESObjectACTI) 126 | activator->activationSound = sound; 127 | return true; 128 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_casino.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetCasinoMaxWinnings, 0, kParams_OneCasino); 4 | DEFINE_COMMAND_PLUGIN(SetCasinoMaxWinnings, 0, kParams_OneCasino_OneInt); 5 | DEFINE_COMMAND_PLUGIN(GetCasinoBJPayout, 0, kParams_OneCasino); 6 | DEFINE_COMMAND_PLUGIN(SetCasinoBJPayout, 0, kParams_OneCasino_OneFloat); 7 | DEFINE_COMMAND_PLUGIN(GetCasinoBJ17Stand, 0, kParams_OneCasino); 8 | DEFINE_COMMAND_PLUGIN(SetCasinoBJ17Stand, 0, kParams_OneCasino_OneInt); 9 | DEFINE_COMMAND_PLUGIN(GetCasinoNumDecks, 0, kParams_OneCasino); 10 | DEFINE_COMMAND_PLUGIN(SetCasinoNumDecks, 0, kParams_OneCasino_OneInt); 11 | DEFINE_COMMAND_PLUGIN(GetCasinoShufflePercent, 0, kParams_OneCasino); 12 | DEFINE_COMMAND_PLUGIN(SetCasinoShufflePercent, 0, kParams_OneCasino_OneFloat); 13 | DEFINE_COMMAND_PLUGIN(GetCasinoReelStops, 0, kParams_OneCasino_OneInt); 14 | DEFINE_COMMAND_PLUGIN(SetCasinoReelStops, 0, kParams_OneForm_TwoInts); 15 | 16 | bool Cmd_GetCasinoMaxWinnings_Execute(COMMAND_ARGS) 17 | { 18 | TESCasino *casino; 19 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino)) 20 | *result = (int)casino->maxWinnings; 21 | return true; 22 | } 23 | 24 | bool Cmd_SetCasinoMaxWinnings_Execute(COMMAND_ARGS) 25 | { 26 | TESCasino *casino; 27 | UInt32 value; 28 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino, &value)) 29 | casino->maxWinnings = value; 30 | return true; 31 | } 32 | 33 | bool Cmd_GetCasinoBJPayout_Execute(COMMAND_ARGS) 34 | { 35 | TESCasino *casino; 36 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino)) 37 | *result = casino->blackjackPayout; 38 | return true; 39 | } 40 | 41 | bool Cmd_SetCasinoBJPayout_Execute(COMMAND_ARGS) 42 | { 43 | TESCasino *casino; 44 | float value; 45 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino, &value)) 46 | casino->blackjackPayout = value; 47 | return true; 48 | } 49 | 50 | bool Cmd_GetCasinoBJ17Stand_Execute(COMMAND_ARGS) 51 | { 52 | TESCasino *casino; 53 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino)) 54 | *result = (int)casino->casinoFlags; 55 | return true; 56 | } 57 | 58 | bool Cmd_SetCasinoBJ17Stand_Execute(COMMAND_ARGS) 59 | { 60 | TESCasino *casino; 61 | UInt32 value; 62 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino, &value)) 63 | casino->casinoFlags = value != 0; 64 | return true; 65 | } 66 | 67 | bool Cmd_GetCasinoNumDecks_Execute(COMMAND_ARGS) 68 | { 69 | TESCasino *casino; 70 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino)) 71 | *result = (int)casino->numDecks; 72 | return true; 73 | } 74 | 75 | bool Cmd_SetCasinoNumDecks_Execute(COMMAND_ARGS) 76 | { 77 | TESCasino *casino; 78 | UInt32 value; 79 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino, &value)) 80 | casino->numDecks = value; 81 | return true; 82 | } 83 | 84 | bool Cmd_GetCasinoShufflePercent_Execute(COMMAND_ARGS) 85 | { 86 | TESCasino *casino; 87 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino)) 88 | *result = casino->shufflePercent; 89 | return true; 90 | } 91 | 92 | bool Cmd_SetCasinoShufflePercent_Execute(COMMAND_ARGS) 93 | { 94 | TESCasino *casino; 95 | float value; 96 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino, &value)) 97 | casino->shufflePercent = value; 98 | return true; 99 | } 100 | 101 | bool Cmd_GetCasinoReelStops_Execute(COMMAND_ARGS) 102 | { 103 | TESCasino *casino; 104 | UInt32 slot; 105 | int reelStops = -1; 106 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino, &slot) && (slot > 0) && (slot < 8)) 107 | reelStops = (int)casino->reelStops[slot - 1]; 108 | *result = reelStops; 109 | return true; 110 | } 111 | 112 | bool Cmd_SetCasinoReelStops_Execute(COMMAND_ARGS) 113 | { 114 | TESCasino *casino; 115 | UInt32 slot, value; 116 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &casino, &slot, &value) && IS_ID(casino, TESCasino) && (slot > 0) && (slot < 8)) 117 | casino->reelStops[slot - 1] = value; 118 | return true; 119 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_cell.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetCellWaterHeight, 0, kParams_OneOptionalForm); 4 | DEFINE_COMMAND_PLUGIN(SetCellWaterHeight, 0, kParams_OneFloat_OneOptionalForm); 5 | DEFINE_COMMAND_PLUGIN(GetCellWaterForm, 0, kParams_OneOptionalForm); 6 | DEFINE_COMMAND_PLUGIN(GetCellImageSpace, 0, kParams_OneForm); 7 | DEFINE_COMMAND_PLUGIN(GetCellLightingTemplate, 0, kParams_OneForm); 8 | DEFINE_COMMAND_PLUGIN(SetCellLightingTemplate, 0, kParams_OneForm_OneOptionalForm); 9 | DEFINE_COMMAND_PLUGIN(GetCellFlag, 0, kParams_OneForm_OneInt); 10 | DEFINE_COMMAND_PLUGIN(SetCellFlag, 0, kParams_OneForm_TwoInts); 11 | 12 | bool Cmd_GetCellWaterHeight_Execute(COMMAND_ARGS) 13 | { 14 | TESObjectCELL *cell = NULL; 15 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell)) 16 | { 17 | if (!cell) 18 | cell = g_thePlayer->parentCell; 19 | if (cell && IS_ID(cell, TESObjectCELL)) 20 | *result = cell->waterHeight; 21 | } 22 | return true; 23 | } 24 | 25 | bool Cmd_SetCellWaterHeight_Execute(COMMAND_ARGS) 26 | { 27 | float height; 28 | TESObjectCELL *cell = NULL; 29 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &height, &cell)) 30 | { 31 | if (!cell) 32 | cell = g_thePlayer->parentCell; 33 | if (cell && IS_ID(cell, TESObjectCELL)) 34 | cell->waterHeight = height; 35 | } 36 | return true; 37 | } 38 | 39 | bool Cmd_GetCellWaterForm_Execute(COMMAND_ARGS) 40 | { 41 | TESObjectCELL *cell = NULL; 42 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell)) 43 | { 44 | if (!cell) 45 | cell = g_thePlayer->parentCell; 46 | if (cell && IS_ID(cell, TESObjectCELL)) 47 | if (auto xCellWater = GetExtraType(&cell->extraDataList, ExtraCellWaterType); xCellWater && xCellWater->waterForm) 48 | REFR_RES = xCellWater->waterForm->refID; 49 | else if (cell->worldSpace && cell->worldSpace->waterFormFirst) 50 | REFR_RES = cell->worldSpace->waterFormFirst->refID; 51 | } 52 | return true; 53 | } 54 | 55 | bool Cmd_GetCellImageSpace_Execute(COMMAND_ARGS) 56 | { 57 | TESObjectCELL *cell; 58 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell) && IS_ID(cell, TESObjectCELL)) 59 | if (auto xCellIS = GetExtraType(&cell->extraDataList, ExtraCellImageSpace); xCellIS && xCellIS->imageSpace) 60 | REFR_RES = xCellIS->imageSpace->refID; 61 | return true; 62 | } 63 | 64 | bool Cmd_GetCellLightingTemplate_Execute(COMMAND_ARGS) 65 | { 66 | TESObjectCELL *cell; 67 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell) && IS_ID(cell, TESObjectCELL) && cell->lightingTemplate) 68 | REFR_RES = cell->lightingTemplate->refID; 69 | return true; 70 | } 71 | 72 | bool Cmd_SetCellLightingTemplate_Execute(COMMAND_ARGS) 73 | { 74 | TESObjectCELL *cell; 75 | BGSLightingTemplate *lgtTemp = NULL; 76 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell, &lgtTemp) && IS_ID(cell, TESObjectCELL) && (!lgtTemp || IS_ID(lgtTemp, BGSLightingTemplate))) 77 | cell->lightingTemplate = lgtTemp; 78 | return true; 79 | } 80 | 81 | bool Cmd_GetCellFlag_Execute(COMMAND_ARGS) 82 | { 83 | TESObjectCELL *cell; 84 | UInt32 flag; 85 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell, &flag) && IS_ID(cell, TESObjectCELL) && (flag <= 16)) 86 | if (flag <= 7) 87 | { 88 | if (cell->cellFlags & (1 << flag)) 89 | *result = 1; 90 | } 91 | else if (cell->inheritFlags & (1 << (flag - 8))) 92 | *result = 1; 93 | return true; 94 | } 95 | 96 | bool Cmd_SetCellFlag_Execute(COMMAND_ARGS) 97 | { 98 | TESObjectCELL *cell; 99 | UInt32 flag, value; 100 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &cell, &flag, &value) && IS_ID(cell, TESObjectCELL) && (flag <= 16)) 101 | if (flag <= 7) 102 | { 103 | if (value) cell->cellFlags |= (1 << flag); 104 | else cell->cellFlags &= ~(1 << flag); 105 | } 106 | else if (value) cell->inheritFlags |= (1 << (flag - 8)); 107 | else cell->inheritFlags &= ~(1 << (flag - 8)); 108 | return true; 109 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_challenge.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetChallengeType, 0, kParams_OneChallenge); 4 | DEFINE_COMMAND_PLUGIN(GetChallengeFlags, 0, kParams_OneChallenge); 5 | DEFINE_COMMAND_PLUGIN(SetChallengeFlags, 0, kParams_OneChallenge_OneInt); 6 | DEFINE_COMMAND_PLUGIN(GetChallengeThreshold, 0, kParams_OneChallenge); 7 | DEFINE_COMMAND_PLUGIN(SetChallengeThreshold, 0, kParams_OneChallenge_OneInt); 8 | DEFINE_COMMAND_PLUGIN(GetChallengeInterval, 0, kParams_OneChallenge); 9 | DEFINE_COMMAND_PLUGIN(SetChallengeInterval, 0, kParams_OneChallenge_OneInt); 10 | DEFINE_COMMAND_PLUGIN(GetChallengeValue1, 0, kParams_OneChallenge); 11 | DEFINE_COMMAND_PLUGIN(SetChallengeValue1, 0, kParams_OneChallenge_OneInt); 12 | DEFINE_COMMAND_PLUGIN(GetChallengeValue2, 0, kParams_OneChallenge); 13 | DEFINE_COMMAND_PLUGIN(SetChallengeValue2, 0, kParams_OneChallenge_OneInt); 14 | DEFINE_COMMAND_PLUGIN(GetChallengeValue3, 0, kParams_OneChallenge); 15 | DEFINE_COMMAND_PLUGIN(SetChallengeValue3, 0, kParams_OneChallenge_OneInt); 16 | DEFINE_COMMAND_PLUGIN(GetChallengeForm1, 0, kParams_OneChallenge); 17 | DEFINE_COMMAND_PLUGIN(SetChallengeForm1, 0, kParams_OneChallenge_OneForm); 18 | DEFINE_COMMAND_PLUGIN(GetChallengeForm2, 0, kParams_OneChallenge); 19 | DEFINE_COMMAND_PLUGIN(SetChallengeForm2, 0, kParams_OneChallenge_OneForm); 20 | 21 | bool Cmd_GetChallengeType_Execute(COMMAND_ARGS) 22 | { 23 | TESChallenge *challenge; 24 | int type = -1; 25 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge)) 26 | type = (int)challenge->data.type; 27 | *result = type; 28 | return true; 29 | } 30 | 31 | bool Cmd_GetChallengeFlags_Execute(COMMAND_ARGS) 32 | { 33 | TESChallenge *challenge; 34 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge)) 35 | *result = (int)challenge->data.flags; 36 | return true; 37 | } 38 | 39 | bool Cmd_SetChallengeFlags_Execute(COMMAND_ARGS) 40 | { 41 | TESChallenge *challenge; 42 | UInt32 value; 43 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge, &value)) 44 | challenge->data.flags = value; 45 | return true; 46 | } 47 | 48 | bool Cmd_GetChallengeThreshold_Execute(COMMAND_ARGS) 49 | { 50 | TESChallenge *challenge; 51 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge)) 52 | *result = (int)challenge->data.threshold; 53 | return true; 54 | } 55 | 56 | bool Cmd_SetChallengeThreshold_Execute(COMMAND_ARGS) 57 | { 58 | TESChallenge *challenge; 59 | UInt32 value; 60 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge, &value)) 61 | challenge->data.threshold = value; 62 | return true; 63 | } 64 | 65 | bool Cmd_GetChallengeInterval_Execute(COMMAND_ARGS) 66 | { 67 | TESChallenge *challenge; 68 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge)) 69 | *result = (int)challenge->data.interval; 70 | return true; 71 | } 72 | 73 | bool Cmd_SetChallengeInterval_Execute(COMMAND_ARGS) 74 | { 75 | TESChallenge *challenge; 76 | UInt32 value; 77 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge, &value)) 78 | challenge->data.interval = value; 79 | return true; 80 | } 81 | 82 | bool Cmd_GetChallengeValue1_Execute(COMMAND_ARGS) 83 | { 84 | TESChallenge *challenge; 85 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge)) 86 | *result = challenge->data.value1; 87 | return true; 88 | } 89 | 90 | bool Cmd_SetChallengeValue1_Execute(COMMAND_ARGS) 91 | { 92 | TESChallenge *challenge; 93 | UInt32 value; 94 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge, &value)) 95 | challenge->data.value1 = value; 96 | return true; 97 | } 98 | 99 | bool Cmd_GetChallengeValue2_Execute(COMMAND_ARGS) 100 | { 101 | TESChallenge *challenge; 102 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge)) 103 | *result = challenge->data.value2; 104 | return true; 105 | } 106 | 107 | bool Cmd_SetChallengeValue2_Execute(COMMAND_ARGS) 108 | { 109 | TESChallenge *challenge; 110 | UInt32 value; 111 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge, &value)) 112 | challenge->data.value2 = value; 113 | return true; 114 | } 115 | 116 | bool Cmd_GetChallengeValue3_Execute(COMMAND_ARGS) 117 | { 118 | TESChallenge *challenge; 119 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge)) 120 | *result = (int)challenge->data.value3; 121 | return true; 122 | } 123 | 124 | bool Cmd_SetChallengeValue3_Execute(COMMAND_ARGS) 125 | { 126 | TESChallenge *challenge; 127 | UInt32 value; 128 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge, &value)) 129 | challenge->data.value3 = value; 130 | return true; 131 | } 132 | 133 | bool Cmd_GetChallengeForm1_Execute(COMMAND_ARGS) 134 | { 135 | TESChallenge *challenge; 136 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge) && challenge->SNAM) 137 | REFR_RES = challenge->SNAM->refID; 138 | return true; 139 | } 140 | 141 | bool Cmd_SetChallengeForm1_Execute(COMMAND_ARGS) 142 | { 143 | TESChallenge *challenge; 144 | TESForm *value; 145 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge, &value)) 146 | challenge->SNAM = value; 147 | return true; 148 | } 149 | 150 | bool Cmd_GetChallengeForm2_Execute(COMMAND_ARGS) 151 | { 152 | TESChallenge *challenge; 153 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge) && challenge->XNAM) 154 | REFR_RES = challenge->XNAM->refID; 155 | return true; 156 | } 157 | 158 | bool Cmd_SetChallengeForm2_Execute(COMMAND_ARGS) 159 | { 160 | TESChallenge *challenge; 161 | TESForm *value; 162 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &challenge, &value)) 163 | challenge->XNAM = value; 164 | return true; 165 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_leveled_list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_ALT_PLUGIN(LeveledListAddForm, LListAddForm, 0, kParams_TwoForms_TwoInts_OneFloat); 4 | DEFINE_COMMAND_ALT_PLUGIN(LeveledListRemoveForm, LListRemoveForm, 0, kParams_TwoForms); 5 | DEFINE_COMMAND_ALT_PLUGIN(LeveledListReplaceForm, LListReplaceForm, 0, kParams_ThreeForms); 6 | DEFINE_COMMAND_PLUGIN(GetChanceNone, 0, kParams_OneForm); 7 | DEFINE_COMMAND_PLUGIN(SetChanceNone, 0, kParams_OneForm_OneInt); 8 | DEFINE_COMMAND_PLUGIN(GetChanceNoneGlobal, 0, kParams_OneForm); 9 | DEFINE_COMMAND_PLUGIN(SetChanceNoneGlobal, 0, kParams_OneForm_OneOptionalForm); 10 | DEFINE_COMMAND_ALT_PLUGIN(GetNumLevItems, LListGetCount, 0, kParams_OneForm); 11 | DEFINE_COMMAND_ALT_PLUGIN(GetNthLevItem, LListGetNthForm, 0, kParams_OneForm_OneInt); 12 | DEFINE_COMMAND_ALT_PLUGIN(SetNthLevItem, LListsetNthForm, 0, kParams_OneForm_OneInt_OneForm); 13 | DEFINE_COMMAND_ALT_PLUGIN(GetNthLevItemLevel, LListGetNthLevel, 0, kParams_OneForm_OneInt); 14 | DEFINE_COMMAND_ALT_PLUGIN(SetNthLevItemLevel, LListSetNthLevel, 0, kParams_OneForm_TwoInts); 15 | DEFINE_COMMAND_ALT_PLUGIN(GetNthLevItemCount, LListGetNthCount, 0, kParams_OneForm_OneInt); 16 | DEFINE_COMMAND_ALT_PLUGIN(SetNthLevItemCount, LListSetNthCount, 0, kParams_OneForm_TwoInts); 17 | DEFINE_COMMAND_ALT_PLUGIN(RemoveNthLevItem, LListRemoveNthForm, 0, kParams_OneForm_OneInt); 18 | DEFINE_COMMAND_ALT_PLUGIN(LeveledListClear, LListClear, 0, kParams_OneForm); 19 | DEFINE_COMMAND_ALT_PLUGIN(GetLevItemIndexByLevel, LListGetLevelIndex, 0, kParams_OneForm_OneInt); 20 | DEFINE_COMMAND_ALT_PLUGIN(GetLevItemIndexByForm, LListGetFormIndex, 0, kParams_TwoForms); 21 | DEFINE_COMMAND_ALT_PLUGIN(DumpLevList, LListDump, 0, kParams_OneForm); 22 | DEFINE_COMMAND_ALT_PLUGIN(GetLeveledListFlags, LListGetFlags, 0, kParams_OneForm); 23 | DEFINE_COMMAND_ALT_PLUGIN(SetLeveledListFlags, LListSetFlags, 0, kParams_OneForm_OneInt); 24 | DEFINE_COMMAND_ALT_PLUGIN(LeveledListHasFormDeep, LListHasFormDeep, 0, kParams_TwoForms); 25 | 26 | bool Cmd_LeveledListAddForm_Execute(COMMAND_ARGS) 27 | { 28 | TESForm *list, *form; 29 | UInt32 level, count; 30 | float health; 31 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &list, &form, &level, &count, &health)) 32 | if (auto lvlList = list->GetLvlList()) 33 | { 34 | if (health < 0) 35 | health = 0; 36 | else if (health > 1.0F) 37 | health *= 0.01F; 38 | lvlList->AddItem(form, level, count, health); 39 | } 40 | return true; 41 | } 42 | 43 | bool Cmd_LeveledListRemoveForm_Execute(COMMAND_ARGS) 44 | { 45 | TESForm *list, *form; 46 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &list, &form)) 47 | if (auto lvlList = list->GetLvlList()) 48 | *result = (int)lvlList->RemoveItem(form); 49 | return true; 50 | } 51 | 52 | bool Cmd_LeveledListReplaceForm_Execute(COMMAND_ARGS) 53 | { 54 | TESForm *list, *oldform, *newform; 55 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &list, &oldform, &newform)) 56 | if (auto lvlList = list->GetLvlList()) 57 | { 58 | auto iter = lvlList->list.Head(); 59 | do 60 | { 61 | if (TESLeveledList::ListData *data = iter->data; data && (data->form == oldform)) 62 | data->form = newform; 63 | } 64 | while (iter = iter->next); 65 | } 66 | return true; 67 | } 68 | 69 | bool Cmd_GetChanceNone_Execute(COMMAND_ARGS) 70 | { 71 | TESForm *form; 72 | int chanceNone = -1; 73 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form)) 74 | if (auto lvlList = form->GetLvlList()) 75 | chanceNone = lvlList->chanceNone; 76 | *result = chanceNone; 77 | return true; 78 | } 79 | 80 | bool Cmd_SetChanceNone_Execute(COMMAND_ARGS) 81 | { 82 | TESForm *form; 83 | UInt32 newChance; 84 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &newChance) && (newChance <= 100)) 85 | if (auto lvlList = form->GetLvlList()) 86 | lvlList->chanceNone = newChance; 87 | return true; 88 | } 89 | 90 | bool Cmd_GetChanceNoneGlobal_Execute(COMMAND_ARGS) 91 | { 92 | TESForm *form; 93 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form)) 94 | if (auto lvlList = form->GetLvlList(); lvlList && lvlList->global) 95 | REFR_RES = lvlList->global->refID; 96 | return true; 97 | } 98 | 99 | bool Cmd_SetChanceNoneGlobal_Execute(COMMAND_ARGS) 100 | { 101 | TESForm *list; 102 | TESGlobal *global = nullptr; 103 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &list, &global) && (!global || IS_ID(global, TESGlobal))) 104 | if (auto lvlList = list->GetLvlList()) 105 | lvlList->global = global; 106 | return true; 107 | } 108 | 109 | bool Cmd_GetNumLevItems_Execute(COMMAND_ARGS) 110 | { 111 | TESForm *form; 112 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form)) 113 | if (auto lvlList = form->GetLvlList()) 114 | *result = (int)lvlList->list.Count(); 115 | return true; 116 | } 117 | 118 | bool Cmd_GetNthLevItem_Execute(COMMAND_ARGS) 119 | { 120 | TESForm *form; 121 | UInt32 index; 122 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &index)) 123 | if (auto lvlList = form->GetLvlList()) 124 | if (TESLeveledList::ListData *data = lvlList->list.GetNthItem(index); data && data->form) 125 | REFR_RES = data->form->refID; 126 | return true; 127 | } 128 | 129 | bool Cmd_SetNthLevItem_Execute(COMMAND_ARGS) 130 | { 131 | TESForm *list, *form; 132 | UInt32 index; 133 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &list, &index, &form)) 134 | if (auto lvlList = list->GetLvlList()) 135 | if (TESLeveledList::ListData *data = lvlList->list.GetNthItem(index)) 136 | data->form = form; 137 | return true; 138 | } 139 | 140 | bool Cmd_GetNthLevItemLevel_Execute(COMMAND_ARGS) 141 | { 142 | TESForm *form; 143 | UInt32 index; 144 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &index)) 145 | if (auto lvlList = form->GetLvlList()) 146 | if (TESLeveledList::ListData* data = lvlList->list.GetNthItem(index)) 147 | *result = data->level; 148 | return true; 149 | } 150 | 151 | bool Cmd_SetNthLevItemLevel_Execute(COMMAND_ARGS) 152 | { 153 | TESForm *form; 154 | UInt32 index; 155 | UInt32 level; 156 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &index, &level)) 157 | if (auto lvlList = form->GetLvlList()) 158 | if (TESLeveledList::ListData *data = lvlList->list.GetNthItem(index)) 159 | data->level = level; 160 | return true; 161 | } 162 | 163 | bool Cmd_GetNthLevItemCount_Execute(COMMAND_ARGS) 164 | { 165 | TESForm *form; 166 | UInt32 index; 167 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &index)) 168 | if (auto lvlList = form->GetLvlList()) 169 | if (TESLeveledList::ListData *data = lvlList->list.GetNthItem(index)) 170 | *result = data->count; 171 | return true; 172 | } 173 | 174 | bool Cmd_SetNthLevItemCount_Execute(COMMAND_ARGS) 175 | { 176 | TESForm *form; 177 | UInt32 index; 178 | UInt32 count; 179 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &index, &count)) 180 | if (auto lvlList = form->GetLvlList()) 181 | if (TESLeveledList::ListData *data = lvlList->list.GetNthItem(index)) 182 | data->count = count; 183 | return true; 184 | } 185 | 186 | bool Cmd_RemoveNthLevItem_Execute(COMMAND_ARGS) 187 | { 188 | TESForm *form; 189 | UInt32 index; 190 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &index)) 191 | if (auto lvlList = form->GetLvlList()) 192 | lvlList->list.RemoveNth(index); 193 | return true; 194 | } 195 | 196 | bool Cmd_LeveledListClear_Execute(COMMAND_ARGS) 197 | { 198 | TESForm *form; 199 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form)) 200 | if (auto lvlList = form->GetLvlList()) 201 | lvlList->list.RemoveAll(); 202 | return true; 203 | } 204 | 205 | bool Cmd_GetLevItemIndexByLevel_Execute(COMMAND_ARGS) 206 | { 207 | TESForm *form; 208 | UInt32 level; 209 | SInt32 index = -1; 210 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &level)) 211 | if (auto lvlList = form->GetLvlList()) 212 | index = lvlList->GetItemIndexByLevel(level); 213 | *result = index; 214 | return true; 215 | } 216 | 217 | bool Cmd_GetLevItemIndexByForm_Execute(COMMAND_ARGS) 218 | { 219 | TESForm *list, *form; 220 | SInt32 index = -1; 221 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &list, &form)) 222 | if (auto lvlList = list->GetLvlList()) 223 | index = lvlList->GetItemIndexByForm(form); 224 | *result = index; 225 | return true; 226 | } 227 | 228 | bool Cmd_DumpLevList_Execute(COMMAND_ARGS) 229 | { 230 | TESForm *form; 231 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form) && IsConsoleOpen()) 232 | if (auto lvlList = form->GetLvlList()) 233 | { 234 | Console_Print("Dumping LeveledList [%08X]", form->refID); 235 | s_dumpLvlListIndent = 60; 236 | lvlList->Dump(); 237 | } 238 | return true; 239 | } 240 | 241 | bool Cmd_GetLeveledListFlags_Execute(COMMAND_ARGS) 242 | { 243 | TESForm *form; 244 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form)) 245 | if (auto lvlList = form->GetLvlList()) 246 | *result = lvlList->flags; 247 | return true; 248 | } 249 | 250 | bool Cmd_SetLeveledListFlags_Execute(COMMAND_ARGS) 251 | { 252 | TESForm *form; 253 | UInt32 flags; 254 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &form, &flags)) 255 | if (auto lvlList = form->GetLvlList()) 256 | lvlList->flags = flags; 257 | return true; 258 | } 259 | 260 | bool Cmd_LeveledListHasFormDeep_Execute(COMMAND_ARGS) 261 | { 262 | TESForm *list, *form; 263 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &list, &form)) 264 | if (auto lvlList = list->GetLvlList(); lvlList && LeveledListHasFormDeep(lvlList, form, GetTempFormList())) 265 | *result = 1; 266 | return true; 267 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_load_screen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetLoadScreenTexture, 0, kParams_OneForm); 4 | DEFINE_COMMAND_PLUGIN(SetLoadScreenTexture, 0, kParams_OneForm_OneString); 5 | DEFINE_COMMAND_PLUGIN(GetLoadScreenType, 0, kParams_OneForm); 6 | DEFINE_COMMAND_PLUGIN(SetLoadScreenType, 0, kParams_TwoForms); 7 | DEFINE_COMMAND_PLUGIN(GetLoadScreenTypeTextRGB, 0, kParams_OneForm); 8 | DEFINE_COMMAND_PLUGIN(SetLoadScreenTypeTextRGB, 0, kParams_OneForm_ThreeFloats); 9 | 10 | bool Cmd_GetLoadScreenTexture_Execute(COMMAND_ARGS) 11 | { 12 | const char *resStr = nullptr; 13 | TESLoadScreen *loadScreen; 14 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &loadScreen) && IS_ID(loadScreen, TESLoadScreen)) 15 | resStr = loadScreen->texture.ddsPath.m_data; 16 | AssignString(PASS_COMMAND_ARGS, resStr); 17 | return true; 18 | } 19 | 20 | bool Cmd_SetLoadScreenTexture_Execute(COMMAND_ARGS) 21 | { 22 | TESLoadScreen *loadScreen; 23 | char path[0x80]; 24 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &loadScreen, &path) && IS_ID(loadScreen, TESLoadScreen)) 25 | loadScreen->texture.ddsPath.Set(path); 26 | return true; 27 | } 28 | 29 | bool Cmd_GetLoadScreenType_Execute(COMMAND_ARGS) 30 | { 31 | TESLoadScreen *loadScreen; 32 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &loadScreen) && IS_ID(loadScreen, TESLoadScreen) && loadScreen->type) 33 | REFR_RES = loadScreen->type->refID; 34 | return true; 35 | } 36 | 37 | bool Cmd_SetLoadScreenType_Execute(COMMAND_ARGS) 38 | { 39 | TESLoadScreen *loadScreen; 40 | TESLoadScreenType *loadScrType; 41 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &loadScreen, &loadScrType) && IS_ID(loadScreen, TESLoadScreen) && IS_ID(loadScrType, TESLoadScreenType)) 42 | loadScreen->type = loadScrType; 43 | return true; 44 | } 45 | 46 | const char *kRGBPrefixes[] = {"r", "g", "b"}; 47 | 48 | bool Cmd_GetLoadScreenTypeTextRGB_Execute(COMMAND_ARGS) 49 | { 50 | TESLoadScreenType *loadScrType; 51 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &loadScrType) && IS_ID(loadScrType, TESLoadScreenType)) 52 | { 53 | ArrayElementL values[3] = {loadScrType->fontColor1.r, loadScrType->fontColor1.g, loadScrType->fontColor1.b}; 54 | *result = (int)CreateStringMap(kRGBPrefixes, values, 3, scriptObj); 55 | } 56 | return true; 57 | } 58 | 59 | bool Cmd_SetLoadScreenTypeTextRGB_Execute(COMMAND_ARGS) 60 | { 61 | TESLoadScreenType *loadScrType; 62 | NiColor inRGB; 63 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &loadScrType, &inRGB.r, &inRGB.g, &inRGB.b) && IS_ID(loadScrType, TESLoadScreenType)) 64 | loadScrType->fontColor1 = inRGB; 65 | return true; 66 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_map_marker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(IsMapMarker, 1, nullptr); 4 | DEFINE_COMMAND_PLUGIN(GetMapMarkerName, 1, nullptr); 5 | DEFINE_COMMAND_PLUGIN(SetMapMarkerName, 1, kParams_OneString); 6 | DEFINE_COMMAND_PLUGIN(SetMapMarkerVisible, 1, kParams_OneInt); 7 | DEFINE_COMMAND_PLUGIN(GetMapMarkerTravel, 1, nullptr); 8 | DEFINE_COMMAND_PLUGIN(SetMapMarkerTravel, 1, kParams_OneInt); 9 | DEFINE_COMMAND_PLUGIN(GetMapMarkerHidden, 1, nullptr); 10 | DEFINE_COMMAND_PLUGIN(SetMapMarkerHidden, 1, kParams_OneInt); 11 | DEFINE_COMMAND_PLUGIN(GetMapMarkerType, 1, nullptr); 12 | DEFINE_COMMAND_PLUGIN(SetMapMarkerType, 1, kParams_OneInt); 13 | DEFINE_COMMAND_PLUGIN(GetMapMarkerRep, 1, nullptr); 14 | DEFINE_COMMAND_PLUGIN(SetMapMarkerRep, 1, kParams_OneOptionalForm); 15 | 16 | bool Cmd_IsMapMarker_Execute(COMMAND_ARGS) 17 | { 18 | if (thisObj->baseForm->refID == 0x10) 19 | *result = 1; 20 | return true; 21 | } 22 | 23 | bool Cmd_GetMapMarkerName_Execute(COMMAND_ARGS) 24 | { 25 | const char *resStr = nullptr; 26 | if (auto markerData = thisObj->GetMapMarkerData()) 27 | resStr = markerData->fullName.name.m_data; 28 | AssignString(PASS_COMMAND_ARGS, resStr); 29 | return true; 30 | } 31 | 32 | bool Cmd_SetMapMarkerName_Execute(COMMAND_ARGS) 33 | { 34 | char nameStr[0x80]; 35 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &nameStr)) 36 | if (auto markerData = thisObj->GetMapMarkerData()) 37 | markerData->fullName.name.Set(nameStr); 38 | return true; 39 | } 40 | 41 | bool Cmd_SetMapMarkerVisible_Execute(COMMAND_ARGS) 42 | { 43 | UInt32 visible; 44 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &visible)) 45 | if (auto markerData = thisObj->GetMapMarkerData()) 46 | if (visible) 47 | markerData->flags |= 1; 48 | else 49 | markerData->flags &= ~1; 50 | return true; 51 | } 52 | 53 | bool Cmd_GetMapMarkerTravel_Execute(COMMAND_ARGS) 54 | { 55 | if (auto markerData = thisObj->GetMapMarkerData(); markerData && (markerData->flags & 2)) 56 | *result = 1; 57 | return true; 58 | } 59 | 60 | bool Cmd_SetMapMarkerTravel_Execute(COMMAND_ARGS) 61 | { 62 | UInt32 travel; 63 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &travel)) 64 | if (auto markerData = thisObj->GetMapMarkerData()) 65 | if (travel) 66 | markerData->flags |= 2; 67 | else 68 | markerData->flags &= ~2; 69 | return true; 70 | } 71 | 72 | bool Cmd_GetMapMarkerHidden_Execute(COMMAND_ARGS) 73 | { 74 | if (auto markerData = thisObj->GetMapMarkerData(); markerData && (markerData->flags & 4)) 75 | *result = 1; 76 | return true; 77 | } 78 | 79 | bool Cmd_SetMapMarkerHidden_Execute(COMMAND_ARGS) 80 | { 81 | UInt32 hidden; 82 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &hidden)) 83 | if (auto markerData = thisObj->GetMapMarkerData()) 84 | if (hidden) 85 | markerData->flags |= 4; 86 | else 87 | markerData->flags &= ~4; 88 | return true; 89 | } 90 | 91 | bool Cmd_GetMapMarkerType_Execute(COMMAND_ARGS) 92 | { 93 | int type = -1; 94 | if (auto markerData = thisObj->GetMapMarkerData()) 95 | type = markerData->type; 96 | *result = type; 97 | return true; 98 | } 99 | 100 | bool Cmd_SetMapMarkerType_Execute(COMMAND_ARGS) 101 | { 102 | UInt32 type; 103 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &type) && (type <= 14)) 104 | if (auto markerData = thisObj->GetMapMarkerData()) 105 | markerData->type = type; 106 | return true; 107 | } 108 | 109 | bool Cmd_GetMapMarkerRep_Execute(COMMAND_ARGS) 110 | { 111 | if (auto markerData = thisObj->GetMapMarkerData(); markerData && markerData->reputation) 112 | REFR_RES = markerData->reputation->refID; 113 | return true; 114 | } 115 | 116 | bool Cmd_SetMapMarkerRep_Execute(COMMAND_ARGS) 117 | { 118 | TESReputation *reputation = nullptr; 119 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &reputation) && (!reputation || IS_ID(reputation, TESReputation))) 120 | if (auto markerData = thisObj->GetMapMarkerData()) 121 | markerData->reputation = reputation; 122 | return true; 123 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_math.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(fsqrt, 0, kParams_OneDouble); 4 | DEFINE_CMD_COND_PLUGIN(GetDistance2D, 1, kParams_OneObjectRef); 5 | DEFINE_CMD_COND_PLUGIN(GetDistance3D, 1, kParams_OneObjectRef); 6 | DEFINE_COMMAND_PLUGIN(fSin, 0, kParams_OneFloat); 7 | DEFINE_COMMAND_PLUGIN(fCos, 0, kParams_OneFloat); 8 | DEFINE_COMMAND_PLUGIN(fTan, 0, kParams_OneFloat); 9 | DEFINE_COMMAND_PLUGIN(fAsin, 0, kParams_OneFloat); 10 | DEFINE_COMMAND_PLUGIN(fAcos, 0, kParams_OneFloat); 11 | DEFINE_COMMAND_PLUGIN(fAtan, 0, kParams_OneFloat); 12 | DEFINE_COMMAND_PLUGIN(fAtan2, 0, kParams_TwoFloats); 13 | 14 | bool Cmd_fsqrt_Execute(COMMAND_ARGS) 15 | { 16 | double value; 17 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value)) 18 | { 19 | __asm 20 | { 21 | xorps xmm1, xmm1 22 | maxsd xmm1, value 23 | sqrtsd xmm0, xmm1 24 | mov eax, result 25 | movlpd [eax], xmm0 26 | } 27 | } 28 | return true; 29 | } 30 | 31 | bool Cmd_GetDistance2D_Execute(COMMAND_ARGS) 32 | { 33 | TESObjectREFR *refr; 34 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &refr) && thisObj->GetInSameCellOrWorld(refr)) 35 | *result = Point2Distance(thisObj->position, refr->position); 36 | else *result = FLT_MAX; 37 | return true; 38 | } 39 | 40 | bool Cmd_GetDistance2D_Eval(COMMAND_ARGS_EVAL) 41 | { 42 | TESObjectREFR *refr = (TESObjectREFR*)arg1; 43 | *result = thisObj->GetInSameCellOrWorld(refr) ? Point2Distance(thisObj->position, refr->position) : FLT_MAX; 44 | return true; 45 | } 46 | 47 | bool Cmd_GetDistance3D_Execute(COMMAND_ARGS) 48 | { 49 | TESObjectREFR *refr; 50 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &refr)) 51 | *result = thisObj->GetDistance(refr); 52 | else *result = FLT_MAX; 53 | return true; 54 | } 55 | 56 | bool Cmd_GetDistance3D_Eval(COMMAND_ARGS_EVAL) 57 | { 58 | *result = thisObj->GetDistance((TESObjectREFR*)arg1); 59 | return true; 60 | } 61 | 62 | bool Cmd_fSin_Execute(COMMAND_ARGS) 63 | { 64 | float value; 65 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value)) 66 | *result = Sin(value * FltPId180); 67 | return true; 68 | } 69 | 70 | bool Cmd_fCos_Execute(COMMAND_ARGS) 71 | { 72 | float value; 73 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value)) 74 | *result = Cos(value * FltPId180); 75 | return true; 76 | } 77 | 78 | bool Cmd_fTan_Execute(COMMAND_ARGS) 79 | { 80 | float value; 81 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value)) 82 | *result = Tan(value * FltPId180); 83 | return true; 84 | } 85 | 86 | bool Cmd_fAsin_Execute(COMMAND_ARGS) 87 | { 88 | float value; 89 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value)) 90 | *result = ASin(value) * Dbl180dPI; 91 | return true; 92 | } 93 | 94 | bool Cmd_fAcos_Execute(COMMAND_ARGS) 95 | { 96 | float value; 97 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value)) 98 | *result = ACos(value) * Dbl180dPI; 99 | return true; 100 | } 101 | 102 | bool Cmd_fAtan_Execute(COMMAND_ARGS) 103 | { 104 | float value; 105 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value)) 106 | *result = ATan(value) * Dbl180dPI; 107 | return true; 108 | } 109 | 110 | bool Cmd_fAtan2_Execute(COMMAND_ARGS) 111 | { 112 | float y, x; 113 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &y, &x)) 114 | *result = ATan2(y, x) * Dbl180dPI; 115 | return true; 116 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_misc_ref.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(IsParentActivateOnly, 0, kParams_OneOptionalObjectRef); 4 | DEFINE_COMMAND_PLUGIN(SetBaseForm, 1, kParams_OneBoundObject); 5 | DEFINE_COMMAND_ALT_PLUGIN(GetInventoryWeight, GetInvWeight, 1, kParams_OneOptionalInt); 6 | DEFINE_CMD_ALT_COND_PLUGIN(GetReferenceFlag, GetRefFlag, 1, kParams_OneInt); 7 | DEFINE_COMMAND_ALT_PLUGIN(SetReferenceFlag, SetRefFlag, 1, kParams_TwoInts); 8 | DEFINE_COMMAND_PLUGIN(HasActionRef, 1, nullptr); 9 | DEFINE_COMMAND_PLUGIN(GetRadius, 0, kParams_OneOptionalForm); 10 | DEFINE_COMMAND_PLUGIN(SetRadius, 0, kParams_OneFloat_OneOptionalForm); 11 | 12 | bool Cmd_IsParentActivateOnly_Execute(COMMAND_ARGS) 13 | { 14 | TESObjectREFR *refr = nullptr; 15 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &refr)) 16 | if (refr || (refr = thisObj)) 17 | if (auto xActivate = GetExtraType(&refr->extraDataList, ExtraActivateRef)) 18 | *result = (int)xActivate->flags; 19 | return true; 20 | } 21 | 22 | bool Cmd_SetBaseForm_Execute(COMMAND_ARGS) 23 | { 24 | TESForm *form; 25 | if (!containingObj && ExtractArgsEx(EXTRACT_ARGS_EX, &form)) 26 | { 27 | thisObj->baseForm = form; 28 | thisObj->Update3D(); 29 | } 30 | return true; 31 | } 32 | 33 | bool Cmd_GetInventoryWeight_Execute(COMMAND_ARGS) 34 | { 35 | if (auto xChanges = GetExtraType(&thisObj->extraDataList, ExtraContainerChanges); xChanges && xChanges->data) 36 | *result = xChanges->data->GetInventoryWeight(); 37 | DoConsolePrint(result); 38 | return true; 39 | } 40 | 41 | bool Cmd_GetReferenceFlag_Eval(COMMAND_ARGS_EVAL) 42 | { 43 | if (thisObj->flags & (UInt32)arg1) 44 | *result = 1; 45 | return true; 46 | } 47 | 48 | bool Cmd_GetReferenceFlag_Execute(COMMAND_ARGS) 49 | { 50 | UInt32 flag; 51 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &flag) && (thisObj->flags & flag)) 52 | *result = 1; 53 | DoConsolePrint(result); 54 | return true; 55 | } 56 | 57 | bool Cmd_SetReferenceFlag_Execute(COMMAND_ARGS) 58 | { 59 | UInt32 flag, inval; 60 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &flag, &inval)) 61 | { 62 | if (inval) thisObj->flags |= flag; 63 | else thisObj->flags &= ~flag; 64 | //ThisCall(0x84A690, *(void**)0x11DDF38, thisObj, 1, 0); 65 | } 66 | return true; 67 | } 68 | 69 | bool Cmd_HasActionRef_Execute(COMMAND_ARGS) 70 | { 71 | if (thisObj->extraDataList.HasType(kXData_ExtraAction)) 72 | *result = 1; 73 | return true; 74 | } 75 | 76 | bool Cmd_GetRadius_Execute(COMMAND_ARGS) 77 | { 78 | TESObjectLIGH *light = nullptr; 79 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &light)) 80 | if (!light) 81 | { 82 | if (thisObj) 83 | if (auto xRadius = GetExtraType(&thisObj->extraDataList, ExtraRadius)) 84 | *result = xRadius->radius; 85 | } 86 | else if IS_ID(light, TESObjectLIGH) 87 | *result = (int)light->radius; 88 | return true; 89 | } 90 | 91 | bool Cmd_SetRadius_Execute(COMMAND_ARGS) 92 | { 93 | float value; 94 | TESObjectLIGH *light = nullptr; 95 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &value, &light)) 96 | if (!light) 97 | { 98 | if (thisObj) 99 | if (auto xRadius = GetExtraType(&thisObj->extraDataList, ExtraRadius)) 100 | xRadius->radius = value; 101 | else thisObj->extraDataList.AddExtra(ExtraRadius::Create(value)); 102 | } 103 | else if IS_ID(light, TESObjectLIGH) 104 | light->radius = (int)value; 105 | return true; 106 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_race.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetRaceVoice, 0, kParams_OneForm_OneInt); 4 | DEFINE_COMMAND_PLUGIN(SetRaceVoice, 0, kParams_OneForm_OneInt_OneForm); 5 | DEFINE_COMMAND_PLUGIN(GetRaceAgeRace, 0, kParams_OneForm_OneInt); 6 | DEFINE_COMMAND_PLUGIN(SetRaceAgeRace, 0, kParams_OneForm_OneInt_OneForm); 7 | DEFINE_COMMAND_PLUGIN(SetRace, 0, kParams_TwoForms); 8 | 9 | bool Cmd_GetRaceVoice_Execute(COMMAND_ARGS) 10 | { 11 | TESRace *race; 12 | UInt32 gender; 13 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &race, &gender) && IS_ID(race, TESRace)) 14 | if (BGSVoiceType *voice = race->voiceTypes[gender != 0]) 15 | REFR_RES = voice->refID; 16 | return true; 17 | } 18 | 19 | bool Cmd_SetRaceVoice_Execute(COMMAND_ARGS) 20 | { 21 | TESRace *race; 22 | UInt32 gender; 23 | BGSVoiceType *voice; 24 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &race, &gender, &voice) && IS_ID(race, TESRace) && IS_ID(voice, BGSVoiceType)) 25 | race->voiceTypes[gender != 0] = voice; 26 | return true; 27 | } 28 | 29 | bool Cmd_GetRaceAgeRace_Execute(COMMAND_ARGS) 30 | { 31 | TESRace *race; 32 | UInt32 age; 33 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &race, &age) && IS_ID(race, TESRace)) 34 | if (race = race->ageRace[age != 0]) 35 | REFR_RES = race->refID; 36 | return true; 37 | } 38 | 39 | bool Cmd_SetRaceAgeRace_Execute(COMMAND_ARGS) 40 | { 41 | TESRace *race, *ageRace; 42 | UInt32 age; 43 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &race, &age, &ageRace) && IS_ID(race, TESRace) && IS_ID(ageRace, TESRace)) 44 | race->ageRace[age != 0] = ageRace; 45 | return true; 46 | } 47 | 48 | bool Cmd_SetRace_Execute(COMMAND_ARGS) 49 | { 50 | TESNPC *npc; 51 | TESRace *race; 52 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &npc, &race) && IS_ID(npc, TESNPC) && IS_ID(race, TESRace)) 53 | npc->SetRace(race); 54 | return true; 55 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_radio_ref.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(IsRadioRef, 1, nullptr); 4 | DEFINE_COMMAND_PLUGIN(GetRadioBroadcastType, 1, nullptr); 5 | DEFINE_COMMAND_PLUGIN(SetRadioBroadcastType, 1, kParams_OneInt); 6 | DEFINE_COMMAND_PLUGIN(GetRadioRadius, 1, nullptr); 7 | DEFINE_COMMAND_PLUGIN(SetRadioRadius, 1, kParams_OneFloat); 8 | DEFINE_COMMAND_PLUGIN(GetRadioStatic, 1, nullptr); 9 | DEFINE_COMMAND_PLUGIN(SetRadioStatic, 1, kParams_OneFloat); 10 | DEFINE_COMMAND_PLUGIN(GetRadioPosRef, 1, nullptr); 11 | DEFINE_COMMAND_PLUGIN(SetRadioPosRef, 1, kParams_OneObjectRef); 12 | 13 | bool Cmd_IsRadioRef_Execute(COMMAND_ARGS) 14 | { 15 | if (thisObj->extraDataList.HasType(kXData_ExtraRadioData)) 16 | *result = 1; 17 | return true; 18 | } 19 | 20 | bool Cmd_GetRadioBroadcastType_Execute(COMMAND_ARGS) 21 | { 22 | if (auto xRadio = GetExtraType(&thisObj->extraDataList, ExtraRadioData)) 23 | *result = (int)xRadio->rangeType; 24 | return true; 25 | } 26 | 27 | bool Cmd_SetRadioBroadcastType_Execute(COMMAND_ARGS) 28 | { 29 | UInt32 type; 30 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &type) && (type <= 4)) 31 | if (auto xRadio = GetExtraType(&thisObj->extraDataList, ExtraRadioData)) 32 | if (xRadio->rangeType = type) 33 | { 34 | xRadio->radius = 0; 35 | xRadio->staticPerc = 0; 36 | } 37 | return true; 38 | } 39 | 40 | bool Cmd_GetRadioRadius_Execute(COMMAND_ARGS) 41 | { 42 | if (auto xRadio = GetExtraType(&thisObj->extraDataList, ExtraRadioData); xRadio && !xRadio->rangeType) 43 | *result = xRadio->radius; 44 | return true; 45 | } 46 | 47 | bool Cmd_SetRadioRadius_Execute(COMMAND_ARGS) 48 | { 49 | float radius; 50 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &radius) && (radius >= 0)) 51 | if (auto xRadio = GetExtraType(&thisObj->extraDataList, ExtraRadioData); xRadio && !xRadio->rangeType) 52 | xRadio->radius = radius; 53 | return true; 54 | } 55 | 56 | bool Cmd_GetRadioStatic_Execute(COMMAND_ARGS) 57 | { 58 | if (auto xRadio = GetExtraType(&thisObj->extraDataList, ExtraRadioData); xRadio && !xRadio->rangeType) 59 | *result = xRadio->staticPerc; 60 | return true; 61 | } 62 | 63 | bool Cmd_SetRadioStatic_Execute(COMMAND_ARGS) 64 | { 65 | float radStatic; 66 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &radStatic) && (radStatic >= 0)) 67 | if (auto xRadio = GetExtraType(&thisObj->extraDataList, ExtraRadioData); xRadio && !xRadio->rangeType) 68 | xRadio->staticPerc = radStatic; 69 | return true; 70 | } 71 | 72 | bool Cmd_GetRadioPosRef_Execute(COMMAND_ARGS) 73 | { 74 | if (auto xRadio = GetExtraType(&thisObj->extraDataList, ExtraRadioData); xRadio && !xRadio->rangeType && xRadio->positionRef) 75 | REFR_RES = xRadio->positionRef->refID; 76 | return true; 77 | } 78 | 79 | bool Cmd_SetRadioPosRef_Execute(COMMAND_ARGS) 80 | { 81 | TESObjectREFR *refr; 82 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &refr)) 83 | if (auto xRadio = GetExtraType(&thisObj->extraDataList, ExtraRadioData); xRadio && !xRadio->rangeType) 84 | xRadio->positionRef = refr; 85 | return true; 86 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_terminal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetTerminalLock, 0, kParams_OneOptionalForm); 4 | DEFINE_COMMAND_PLUGIN(GetPasswordNote, 0, kParams_OneOptionalForm); 5 | DEFINE_COMMAND_PLUGIN(SetPasswordNote, 0, kParams_OneForm_OneOptionalForm); 6 | DEFINE_COMMAND_PLUGIN(GetLockedOut, 0, kParams_OneOptionalObjectRef); 7 | DEFINE_COMMAND_PLUGIN(SetLockedOut, 0, kParams_OneInt_OneOptionalObjectRef); 8 | 9 | bool Cmd_GetTerminalLock_Execute(COMMAND_ARGS) 10 | { 11 | BGSTerminal *terminal = NULL; 12 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &terminal)) 13 | { 14 | if (!terminal) 15 | { 16 | if (!thisObj) return true; 17 | terminal = (BGSTerminal*)thisObj->baseForm; 18 | } 19 | if IS_ID(terminal, BGSTerminal) 20 | * result = (terminal->data.terminalFlags & BGSTerminal::kTerminalFlagUnlocked) ? -1 : terminal->data.difficulty; 21 | } 22 | return true; 23 | } 24 | 25 | bool Cmd_GetPasswordNote_Execute(COMMAND_ARGS) 26 | { 27 | BGSTerminal *terminal = NULL; 28 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &terminal)) 29 | { 30 | if (!terminal) 31 | { 32 | if (!thisObj) return true; 33 | terminal = (BGSTerminal*)thisObj->baseForm; 34 | } 35 | if (IS_ID(terminal, BGSTerminal) && terminal->password) 36 | REFR_RES = terminal->password->refID; 37 | } 38 | return true; 39 | } 40 | 41 | bool Cmd_SetPasswordNote_Execute(COMMAND_ARGS) 42 | { 43 | BGSNote *note; 44 | BGSTerminal *terminal = NULL; 45 | if (ExtractArgsEx(EXTRACT_ARGS_EX, ¬e, &terminal) && IS_ID(note, BGSNote)) 46 | { 47 | if (!terminal) 48 | { 49 | if (!thisObj) return true; 50 | terminal = (BGSTerminal*)thisObj->baseForm; 51 | } 52 | if IS_ID(terminal, BGSTerminal) 53 | terminal->password = note; 54 | } 55 | return true; 56 | } 57 | 58 | bool Cmd_GetLockedOut_Execute(COMMAND_ARGS) 59 | { 60 | TESObjectREFR *refr = NULL; 61 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &refr)) 62 | { 63 | if (!refr) 64 | { 65 | if (!thisObj) return true; 66 | refr = thisObj; 67 | } 68 | if (refr->flags & 0x100) 69 | *result = 3; 70 | else if IS_ID(refr->baseForm, BGSTerminal) 71 | { 72 | if (auto xTermState = GetExtraType(&refr->extraDataList, ExtraTerminalState)) 73 | *result = xTermState->lockedOut & 0xF; 74 | } 75 | else if (auto xLock = GetExtraType(&refr->extraDataList, ExtraLock); xLock && xLock->data) 76 | *result = (int)(xLock->data->unk0C & 0xF); 77 | else if IS_ID(refr->baseForm, TESObjectDOOR) 78 | if (auto xTeleport = GetExtraType(&refr->extraDataList, ExtraTeleport); xTeleport && xTeleport->data && xTeleport->data->linkedDoor) 79 | if (xLock = GetExtraType(&xTeleport->data->linkedDoor->extraDataList, ExtraLock); xLock && xLock->data) 80 | *result = (int)(xLock->data->unk0C & 0xF); 81 | } 82 | return true; 83 | } 84 | 85 | bool Cmd_SetLockedOut_Execute(COMMAND_ARGS) 86 | { 87 | UInt32 state; 88 | TESObjectREFR *refr = NULL; 89 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &state, &refr) && (state <= 2)) 90 | { 91 | if (!refr) 92 | { 93 | if (!thisObj) return true; 94 | refr = thisObj; 95 | } 96 | if IS_ID(refr->baseForm, BGSTerminal) 97 | { 98 | auto xTermState = GetExtraType(&refr->extraDataList, ExtraTerminalState); 99 | if (!xTermState) 100 | { 101 | if (!state) return true; 102 | xTermState = (ExtraTerminalState*)refr->extraDataList.AddExtra(ExtraTerminalState::Create()); 103 | xTermState->lockLevel = ((BGSTerminal*)refr->baseForm)->data.difficulty; 104 | } 105 | xTermState->lockedOut = state; 106 | refr->MarkModified(0x80000000); 107 | } 108 | else if (auto xLock = GetExtraType(&refr->extraDataList, ExtraLock); xLock && xLock->data) 109 | { 110 | xLock->data->unk0C = state; 111 | refr->MarkModified(0x1000); 112 | } 113 | else 114 | { 115 | if IS_ID(refr->baseForm, TESObjectDOOR) 116 | if (auto xTeleport = GetExtraType(&refr->extraDataList, ExtraTeleport); xTeleport && xTeleport->data && xTeleport->data->linkedDoor) 117 | { 118 | refr = xTeleport->data->linkedDoor; 119 | if (xLock = GetExtraType(&refr->extraDataList, ExtraLock); xLock && xLock->data) 120 | { 121 | xLock->data->unk0C = state; 122 | refr->MarkModified(0x1000); 123 | return true; 124 | } 125 | } 126 | if (state) 127 | { 128 | xLock = (ExtraLock*)refr->extraDataList.AddExtra(ExtraLock::Create()); 129 | xLock->data->unk0C = state; 130 | refr->MarkModified(0x1000); 131 | } 132 | } 133 | } 134 | return true; 135 | } -------------------------------------------------------------------------------- /functions_ln/ln_fn_weapon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | DEFINE_COMMAND_PLUGIN(GetWeaponKillImpulse, 0, kParams_OneObjectID); 4 | DEFINE_COMMAND_PLUGIN(SetWeaponKillImpulse, 0, kParams_OneForm_OneFloat); 5 | DEFINE_COMMAND_PLUGIN(GetWeaponImpulseDistance, 0, kParams_OneObjectID); 6 | DEFINE_COMMAND_PLUGIN(SetWeaponImpulseDistance, 0, kParams_OneForm_OneFloat); 7 | DEFINE_COMMAND_PLUGIN(GetWeaponVATSEffect, 0, kParams_OneObjectID); 8 | DEFINE_COMMAND_PLUGIN(SetWeaponVATSEffect, 0, kParams_TwoForms); 9 | DEFINE_COMMAND_PLUGIN(GetWeaponCritFlags, 0, kParams_OneObjectID); 10 | DEFINE_COMMAND_PLUGIN(SetWeaponCritFlags, 0, kParams_OneObjectID_OneInt); 11 | 12 | bool Cmd_GetWeaponKillImpulse_Execute(COMMAND_ARGS) 13 | { 14 | TESObjectWEAP *weapon; 15 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon) && IS_ID(weapon, TESObjectWEAP)) 16 | *result = weapon->killImpulse; 17 | return true; 18 | } 19 | 20 | bool Cmd_SetWeaponKillImpulse_Execute(COMMAND_ARGS) 21 | { 22 | TESObjectWEAP *weapon; 23 | float impulse; 24 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon, &impulse) && IS_ID(weapon, TESObjectWEAP)) 25 | weapon->killImpulse = impulse; 26 | return true; 27 | } 28 | 29 | bool Cmd_GetWeaponImpulseDistance_Execute(COMMAND_ARGS) 30 | { 31 | TESObjectWEAP *weapon; 32 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon) && IS_ID(weapon, TESObjectWEAP)) 33 | *result = weapon->impulseDist; 34 | return true; 35 | } 36 | 37 | bool Cmd_SetWeaponImpulseDistance_Execute(COMMAND_ARGS) 38 | { 39 | TESObjectWEAP *weapon; 40 | float impDist; 41 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon, &impDist) && IS_ID(weapon, TESObjectWEAP)) 42 | weapon->impulseDist = impDist; 43 | return true; 44 | } 45 | 46 | bool Cmd_GetWeaponVATSEffect_Execute(COMMAND_ARGS) 47 | { 48 | TESObjectWEAP *weapon; 49 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon) && IS_ID(weapon, TESObjectWEAP) && weapon->VATSEffect) 50 | REFR_RES = weapon->VATSEffect->refID; 51 | return true; 52 | } 53 | 54 | bool Cmd_SetWeaponVATSEffect_Execute(COMMAND_ARGS) 55 | { 56 | TESObjectWEAP *weapon; 57 | SpellItem *effect; 58 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon, &effect) && IS_ID(weapon, TESObjectWEAP) && IS_ID(effect, SpellItem)) 59 | weapon->VATSEffect = effect; 60 | return true; 61 | } 62 | 63 | bool Cmd_GetWeaponCritFlags_Execute(COMMAND_ARGS) 64 | { 65 | TESObjectWEAP *weapon; 66 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon) && IS_ID(weapon, TESObjectWEAP)) 67 | *result = weapon->critDamageFlags; 68 | return true; 69 | } 70 | 71 | bool Cmd_SetWeaponCritFlags_Execute(COMMAND_ARGS) 72 | { 73 | TESObjectWEAP *weapon; 74 | UInt32 flags; 75 | if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon, &flags) && IS_ID(weapon, TESObjectWEAP)) 76 | weapon->critDamageFlags = flags; 77 | return true; 78 | } -------------------------------------------------------------------------------- /internal/containers.cpp: -------------------------------------------------------------------------------- 1 | #include "internal/containers.h" 2 | 3 | __declspec(naked) char* __fastcall CopyStringKey(const char *key) 4 | { 5 | __asm 6 | { 7 | push esi 8 | push edi 9 | mov esi, ecx 10 | call StrLen 11 | lea edi, [eax+1] 12 | lea ecx, [edi+0x14] 13 | and cl, 0xF0 14 | push ecx 15 | call MemoryPool::Alloc 16 | pop dword ptr [eax] 17 | add eax, 4 18 | mov ecx, edi 19 | mov edi, eax 20 | rep movsb 21 | pop edi 22 | pop esi 23 | retn 24 | } 25 | } 26 | 27 | __declspec(naked) UInt32 __fastcall AlignBucketCount(UInt32 count) 28 | { 29 | __asm 30 | { 31 | mov eax, MAP_MIN_BUCKET_COUNT 32 | cmp ecx, eax 33 | cmovb ecx, eax 34 | mov eax, MAP_MAX_BUCKET_COUNT 35 | cmp ecx, eax 36 | cmova ecx, eax 37 | bsf eax, ecx 38 | bsr ecx, ecx 39 | cmp al, cl 40 | setnz al 41 | inc eax 42 | shl eax, cl 43 | retn 44 | } 45 | } 46 | 47 | #define STR_HASH_SEED 0xD39CA509UL 48 | 49 | __declspec(naked) UInt32 __fastcall StrHashCS(const char *inKey) 50 | { 51 | __asm 52 | { 53 | test ecx, ecx 54 | jz nullStr 55 | push ebx 56 | mov eax, STR_HASH_SEED 57 | ALIGN 16 58 | iterHead: 59 | mov ebx, [ecx] 60 | test bl, bl 61 | jz done 62 | movzx edx, bl 63 | shl edx, 4 64 | sub eax, edx 65 | mov edx, eax 66 | shl eax, 5 67 | sub eax, edx 68 | test bh, bh 69 | jz done 70 | movzx edx, bh 71 | shl edx, 0xC 72 | sub eax, edx 73 | mov edx, eax 74 | shl eax, 5 75 | sub eax, edx 76 | shr ebx, 0x10 77 | test bl, bl 78 | jz done 79 | movzx edx, bl 80 | shl edx, 0x14 81 | sub eax, edx 82 | mov edx, eax 83 | shl eax, 5 84 | sub eax, edx 85 | test bh, bh 86 | jz done 87 | movzx edx, bh 88 | sub eax, edx 89 | mov edx, eax 90 | shl eax, 5 91 | sub eax, edx 92 | add ecx, 4 93 | jmp iterHead 94 | nullStr: 95 | xor eax, eax 96 | retn 97 | ALIGN 16 98 | done: 99 | pop ebx 100 | retn 101 | } 102 | } 103 | 104 | __declspec(naked) UInt32 __fastcall StrHashCI(const char *inKey) 105 | { 106 | __asm 107 | { 108 | test ecx, ecx 109 | jz nullStr 110 | push ebx 111 | push esi 112 | mov eax, STR_HASH_SEED 113 | mov esi, ecx 114 | xor ecx, ecx 115 | ALIGN 16 116 | iterHead: 117 | mov ebx, [esi] 118 | test bl, bl 119 | jz done 120 | mov cl, bl 121 | movzx edx, kLwrCaseConverter[ecx] 122 | shl edx, 4 123 | sub eax, edx 124 | mov edx, eax 125 | shl eax, 5 126 | sub eax, edx 127 | test bh, bh 128 | jz done 129 | mov cl, bh 130 | movzx edx, kLwrCaseConverter[ecx] 131 | shl edx, 0xC 132 | sub eax, edx 133 | mov edx, eax 134 | shl eax, 5 135 | sub eax, edx 136 | shr ebx, 0x10 137 | test bl, bl 138 | jz done 139 | mov cl, bl 140 | movzx edx, kLwrCaseConverter[ecx] 141 | shl edx, 0x14 142 | sub eax, edx 143 | mov edx, eax 144 | shl eax, 5 145 | sub eax, edx 146 | test bh, bh 147 | jz done 148 | mov cl, bh 149 | movzx edx, kLwrCaseConverter[ecx] 150 | sub eax, edx 151 | mov edx, eax 152 | shl eax, 5 153 | sub eax, edx 154 | add esi, 4 155 | jmp iterHead 156 | nullStr: 157 | xor eax, eax 158 | retn 159 | ALIGN 16 160 | done: 161 | pop esi 162 | pop ebx 163 | retn 164 | } 165 | } -------------------------------------------------------------------------------- /internal/dinput.cpp: -------------------------------------------------------------------------------- 1 | #include "internal/dinput.h" 2 | 3 | __declspec(naked) bool __fastcall DIHookControl::IsKeyPressed(UInt32 keycode, UInt32 flags) 4 | { 5 | __asm 6 | { 7 | cmp edx, kMaxMacros 8 | jnb retnFalse 9 | lea ecx, [ecx+edx*8+4] 10 | sub ecx, edx 11 | mov eax, [esp+4] 12 | and eax, 7 13 | mov edx, kFlagMask[eax*4] 14 | test [ecx], edx 15 | setnz al 16 | retn 4 17 | retnFalse: 18 | xor al, al 19 | retn 4 20 | ALIGN 4 21 | kFlagMask: 22 | EMIT_DW_4(0x00000100, 0x00000100, 0x00000001, 0x00000101) 23 | EMIT_DW_4(0x00010000, 0x00010100, 0x00010001, 0x00010101) 24 | } 25 | } 26 | 27 | bool DIHookControl::IsKeyPressedRaw(UInt32 keycode) 28 | { 29 | return (keycode < kMaxMacros) && m_keys[keycode].rawState; 30 | } 31 | 32 | bool DIHookControl::IsLMBPressed() 33 | { 34 | return m_keys[0x100].rawState; 35 | } 36 | 37 | bool DIHookControl::IsKeyDisabled(UInt32 keycode) 38 | { 39 | return (keycode < kMaxMacros) && (*(UInt16*)&m_keys[keycode].userDisable & 0x101); 40 | } 41 | 42 | bool DIHookControl::IsKeyHeld(UInt32 keycode) 43 | { 44 | return (keycode < kMaxMacros) && m_keys[keycode].hold; 45 | } 46 | 47 | bool DIHookControl::IsKeyTapped(UInt32 keycode) 48 | { 49 | return (keycode < kMaxMacros) && m_keys[keycode].tap; 50 | } 51 | 52 | void DIHookControl::SetKeyDisableState(UInt32 keycode, bool bDisable) 53 | { 54 | if (keycode < kMaxMacros) 55 | *(UInt16*)&m_keys[keycode].userDisable = bDisable ? 0x101 : 0; 56 | } 57 | 58 | void DIHookControl::SetLMBDisabled(bool bDisable) 59 | { 60 | m_keys[0x100].userDisable = bDisable; 61 | } 62 | 63 | void DIHookControl::SetKeyHeldState(UInt32 keycode, bool bHold) 64 | { 65 | if (keycode < kMaxMacros) 66 | m_keys[keycode].hold = bHold; 67 | } 68 | 69 | void DIHookControl::TapKey(UInt32 keycode) 70 | { 71 | if (keycode < kMaxMacros) 72 | m_keys[keycode].tap = true; 73 | } -------------------------------------------------------------------------------- /internal/dinput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum 4 | { 5 | kDeviceType_Keyboard = 1, 6 | kDeviceType_Mouse 7 | }; 8 | 9 | enum 10 | { 11 | // first 256 for keyboard, then 8 mouse buttons, then mouse wheel up, wheel down 12 | kMacro_MouseButtonOffset = 256, 13 | kMacro_MouseWheelOffset = kMacro_MouseButtonOffset + 8, 14 | 15 | kMaxMacros = kMacro_MouseWheelOffset + 2, 16 | }; 17 | 18 | class DIHookControl 19 | { 20 | public: 21 | enum 22 | { 23 | // data sources 24 | kFlag_GameState = 1 << 0, // input passed to game post-filtering 25 | kFlag_RawState = 1 << 1, // user input 26 | kFlag_InsertedState = 1 << 2, // keydown was inserted by script 27 | kFlag_Pressed = kFlag_GameState | kFlag_RawState | kFlag_InsertedState, 28 | 29 | // modifiers 30 | kFlag_IgnoreDisabled_User = 1 << 3, // ignore user-disabled keys 31 | kFlag_IgnoreDisabled_Script = 1 << 4, // ignore script-disabled keys 32 | kFlag_IgnoreDisabled = kFlag_IgnoreDisabled_User | kFlag_IgnoreDisabled_Script, 33 | 34 | kFlag_DefaultBackCompat = kFlag_GameState, 35 | }; 36 | 37 | enum 38 | { 39 | kDisable_User = 1 << 0, 40 | kDisable_Script = 1 << 1, 41 | 42 | kDisable_All = kDisable_User | kDisable_Script, 43 | }; 44 | 45 | bool __fastcall IsKeyPressed(UInt32 keycode, UInt32 flags = 1); 46 | bool IsKeyPressedRaw(UInt32 keycode); 47 | bool IsLMBPressed(); 48 | bool IsKeyDisabled(UInt32 keycode); 49 | bool IsKeyHeld(UInt32 keycode); 50 | bool IsKeyTapped(UInt32 keycode); 51 | 52 | void SetKeyDisableState(UInt32 keycode, bool bDisable); 53 | void SetLMBDisabled(bool bDisable); 54 | void SetKeyHeldState(UInt32 keycode, bool bHold); 55 | void TapKey(UInt32 keycode); 56 | 57 | private: 58 | struct KeyInfo 59 | { 60 | bool rawState; // state from dinput last update 61 | bool gameState; // state sent to the game last update 62 | bool insertedState; // true if a script pushed/held this key down last update 63 | 64 | bool hold; // key is held down 65 | bool tap; // key is being tapped 66 | bool userDisable; // key cannot be pressed by user 67 | bool scriptDisable; // key cannot be pressed by script 68 | }; 69 | 70 | void **vtbl; 71 | KeyInfo m_keys[kMaxMacros]; 72 | }; 73 | static_assert(sizeof(DIHookControl) == 0x74C); 74 | 75 | extern DIHookControl *g_DIHookCtrl; -------------------------------------------------------------------------------- /internal/memory_pool.cpp: -------------------------------------------------------------------------------- 1 | #include "internal/memory_pool.h" 2 | 3 | MemoryPool s_memoryPool; 4 | 5 | size_t MemoryPool::GetTotalAllocSize() {return s_memoryPool.m_allocPoolCount * MEMORY_POOL_SIZE;} 6 | 7 | __declspec(naked) void* __fastcall MemoryPool::Alloc(size_t size) 8 | { 9 | __asm 10 | { 11 | cmp ecx, MAX_BLOCK_SIZE 12 | ja doMalloc 13 | push esi 14 | mov esi, ecx 15 | mov ecx, offset s_memoryPool.m_cs 16 | call PrimitiveCS::Enter 17 | mov edx, esi 18 | shr edx, 2 19 | lea edx, [eax+edx+4] 20 | mov eax, [edx] 21 | test eax, eax 22 | jz newSection 23 | mov ecx, [eax] 24 | mov [edx], ecx 25 | and s_memoryPool.m_cs.selfPtr, 0 26 | pop esi 27 | retn 28 | ALIGN 16 29 | doMalloc: 30 | push 0x10 31 | push ecx 32 | call _aligned_malloc 33 | add esp, 8 34 | retn 35 | newSection: 36 | push edi 37 | push edx 38 | mov edi, s_memoryPool.m_freeSections 39 | test edi, edi 40 | jz newPool 41 | mov eax, [edi] 42 | mov s_memoryPool.m_freeSections, eax 43 | jmp gotSection 44 | newPool: 45 | push MEMORY_POOL_SIZE+0x40 46 | call malloc 47 | pop ecx 48 | add eax, 0x20 49 | and eax, 0xFFFFFFF0 50 | mov edi, eax 51 | mov ecx, offset s_memoryPool.m_freeSections 52 | mov edx, MEMORY_POOL_SIZE/POOL_SECTION_SIZE-1 53 | sectLinker: 54 | add eax, POOL_SECTION_SIZE 55 | mov [ecx], eax 56 | mov ecx, eax 57 | dec edx 58 | jnz sectLinker 59 | mov [eax], edx 60 | inc s_memoryPool.m_allocPoolCount 61 | gotSection: 62 | pop ecx 63 | lea eax, [esi+edi] 64 | lea edx, [edi+POOL_SECTION_SIZE] 65 | sub edx, esi 66 | ALIGN 16 67 | blockLinker: 68 | mov [ecx], eax 69 | mov ecx, eax 70 | add eax, esi 71 | cmp eax, edx 72 | jbe blockLinker 73 | add edx, esi 74 | xor esi, esi 75 | mov [ecx], esi 76 | sub edx, eax 77 | jbe done 78 | push eax 79 | test edx, 0xFFFFFF00 80 | setnz cl 81 | or cl, 4 82 | shr edx, cl 83 | or esi, 1 84 | shl esi, cl 85 | ALIGN 16 86 | surplIter: 87 | mov ecx, eax 88 | add eax, esi 89 | mov [ecx], eax 90 | dec edx 91 | ja surplIter 92 | shr esi, 2 93 | lea eax, s_memoryPool.m_freeSections[esi] 94 | mov edx, [eax] 95 | mov [ecx], edx 96 | pop dword ptr [eax] 97 | done: 98 | and s_memoryPool.m_cs.selfPtr, 0 99 | mov eax, edi 100 | pop edi 101 | pop esi 102 | retn 103 | } 104 | } 105 | 106 | __declspec(naked) void __fastcall MemoryPool::Free(void *pBlock, size_t size) 107 | { 108 | __asm 109 | { 110 | test ecx, ecx 111 | jz nullPtr 112 | cmp edx, MAX_BLOCK_SIZE 113 | ja doFree 114 | push edx 115 | push ecx 116 | mov ecx, offset s_memoryPool.m_cs 117 | call PrimitiveCS::Enter 118 | pop ecx 119 | pop edx 120 | shr edx, 2 121 | lea edx, [eax+edx+4] 122 | mov eax, [edx] 123 | mov [ecx], eax 124 | mov [edx], ecx 125 | and s_memoryPool.m_cs.selfPtr, 0 126 | nullPtr: 127 | retn 128 | ALIGN 16 129 | doFree: 130 | push ecx 131 | call _aligned_free 132 | pop ecx 133 | retn 134 | } 135 | } 136 | 137 | __declspec(naked) void* __fastcall MemoryPool::Realloc(void *pBlock, size_t curSize, size_t reqSize) 138 | { 139 | __asm 140 | { 141 | mov eax, ecx 142 | mov ecx, [esp+4] 143 | test eax, eax 144 | jz nullPtr 145 | cmp ecx, edx 146 | jbe done 147 | cmp edx, MAX_BLOCK_SIZE 148 | ja doRealloc 149 | push esi 150 | push edi 151 | mov esi, eax 152 | mov edi, edx 153 | call MemoryPool::Alloc 154 | mov ecx, edi 155 | mov edx, ecx 156 | shr ecx, 2 157 | mov edi, eax 158 | rep movsd 159 | mov edi, eax 160 | mov ecx, esi 161 | sub ecx, edx 162 | call MemoryPool::Free 163 | mov eax, edi 164 | pop edi 165 | pop esi 166 | retn 4 167 | ALIGN 16 168 | doRealloc: 169 | push 0x10 170 | push ecx 171 | push eax 172 | call _aligned_realloc 173 | add esp, 0xC 174 | retn 4 175 | ALIGN 16 176 | nullPtr: 177 | call MemoryPool::Alloc 178 | done: 179 | retn 4 180 | } 181 | } -------------------------------------------------------------------------------- /internal/memory_pool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_BLOCK_SIZE 0x800UL 4 | #define POOL_SECTION_SIZE 0x1000UL 5 | #define MEMORY_POOL_SIZE 0x40000UL 6 | 7 | struct MemoryPool 8 | { 9 | struct BlockNode 10 | { 11 | BlockNode *m_next; 12 | // Data 13 | }; 14 | 15 | PrimitiveCS m_cs; 16 | BlockNode *m_freeSections = nullptr; 17 | BlockNode *m_sections[MAX_BLOCK_SIZE >> 4] = {nullptr}; 18 | size_t m_allocPoolCount = 0; 19 | 20 | static void* __fastcall Alloc(size_t size); 21 | static void __fastcall Free(void *pBlock, size_t size); 22 | static void* __fastcall Realloc(void *pBlock, size_t curSize, size_t reqSize); 23 | 24 | static size_t GetTotalAllocSize(); 25 | }; 26 | 27 | template consteval size_t AlignAlloc() 28 | { 29 | return (sizeof(T) & 0xF) ? ((sizeof(T) & 0xFFFFFFF0) + 0x10) : sizeof(T); 30 | } 31 | 32 | template __forceinline size_t AlignNumAlloc(size_t numAlloc) 33 | { 34 | switch (sizeof(T) & 0xF) 35 | { 36 | case 0: 37 | return numAlloc; 38 | case 2: 39 | case 6: 40 | case 0xA: 41 | case 0xE: 42 | return (numAlloc & 7) ? ((numAlloc & 0xFFFFFFF8) + 8) : numAlloc; 43 | case 4: 44 | case 0xC: 45 | return (numAlloc & 3) ? ((numAlloc & 0xFFFFFFFC) + 4) : numAlloc; 46 | case 8: 47 | return (numAlloc & 1) ? (numAlloc + 1) : numAlloc; 48 | default: 49 | return (numAlloc & 0xF) ? ((numAlloc & 0xFFFFFFF0) + 0x10) : numAlloc; 50 | } 51 | } 52 | 53 | template __forceinline T* Pool_Alloc() 54 | { 55 | return (T*)MemoryPool::Alloc(AlignAlloc()); 56 | } 57 | 58 | template __forceinline void Pool_Free(void *block) 59 | { 60 | MemoryPool::Free(block, AlignAlloc()); 61 | } 62 | 63 | template __forceinline T* Pool_CAlloc(size_t count = 1) 64 | { 65 | return (T*)MemoryPool::Alloc(count * sizeof(T)); 66 | } 67 | 68 | template __forceinline void Pool_CFree(void *block, size_t count = 1) 69 | { 70 | MemoryPool::Free(block, count * sizeof(T)); 71 | } 72 | 73 | template __forceinline T* Pool_CRealloc(void *block, size_t curCount, size_t newCount) 74 | { 75 | return (T*)MemoryPool::Realloc(block, curCount * sizeof(T), newCount * sizeof(T)); 76 | } -------------------------------------------------------------------------------- /internal/version.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jazzisparis/JIP-LN-NVSE/5a30ac4356ea0e93b9ff357b5031b1e420240a4d/internal/version.h -------------------------------------------------------------------------------- /internal/xinput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct alignas(16) XINPUT_GAMEPAD_EX 4 | { 5 | UInt32 eventCount; // 00 6 | UInt16 wButtons; // 04 7 | UInt8 bLeftTrigger; // 06 8 | UInt8 bRightTrigger; // 07 9 | SInt16 sThumbLX; // 08 10 | SInt16 sThumbLY; // 0A 11 | SInt16 sThumbRX; // 0C 12 | SInt16 sThumbRY; // 0E 13 | }; 14 | extern XINPUT_GAMEPAD_EX s_gamePad; 15 | 16 | extern bool s_controllerReady; 17 | 18 | typedef UInt32 (__stdcall *_XInputGetStateEx)(UInt32, XINPUT_GAMEPAD_EX*); 19 | extern _XInputGetStateEx XInputGetStateEx; 20 | 21 | extern int s_deadZoneLS, s_deadZoneRS; 22 | extern double s_deadZoneLSg, s_deadZoneRSg, s_deadZoneLSd, s_deadZoneRSd; 23 | 24 | struct XInputStateMods 25 | { 26 | UInt16 buttonSkip; // 00 27 | UInt16 buttonHold; // 02 28 | UInt16 buttonTap; // 04 29 | UInt8 triggerMods; // 06 30 | UInt8 stickSkip; // 07 31 | }; 32 | extern XInputStateMods s_XIStateMods; 33 | 34 | UInt32 __stdcall Hook_XInputGetState(UInt32 index, XINPUT_GAMEPAD_EX *currState); 35 | 36 | bool HookXInput(); 37 | 38 | bool __fastcall GetXIControlPressed(XINPUT_GAMEPAD_EX *xiState, UInt32 ctrlID); 39 | 40 | bool __fastcall GetXIControlDisabled(UInt32 ctrlID); 41 | 42 | void __fastcall SetXIControlDisabled(UInt32 ctrlID, bool bDisable); 43 | 44 | void __fastcall SetXIControlHeld(UInt32 ctrlID, bool bHold); 45 | 46 | bool __fastcall TapXIControl(UInt32 ctrlID); -------------------------------------------------------------------------------- /jip_nvse.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jazzisparis/JIP-LN-NVSE/5a30ac4356ea0e93b9ff357b5031b1e420240a4d/jip_nvse.rc -------------------------------------------------------------------------------- /jip_nvse.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.7.34024.191 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jip_nvse", "jip_nvse.vcxproj", "{AE7CFEE7-4058-4E3C-ADC2-AE7480EE2028}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {AE7CFEE7-4058-4E3C-ADC2-AE7480EE2028}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {AE7CFEE7-4058-4E3C-ADC2-AE7480EE2028}.Debug|Win32.Build.0 = Debug|Win32 16 | {AE7CFEE7-4058-4E3C-ADC2-AE7480EE2028}.Release|Win32.ActiveCfg = Release|Win32 17 | {AE7CFEE7-4058-4E3C-ADC2-AE7480EE2028}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {6BFDCA57-C14C-4F82-B9B0-2031762EC08C} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /jip_nvse.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /nvse/GameAPI.cpp: -------------------------------------------------------------------------------- 1 | #include "nvse/GameAPI.h" 2 | 3 | // arg1 = 1, ignored if canCreateNew is false, passed to 'init' function if a new object is created 4 | typedef void * (* _GetSingleton)(bool canCreateNew); 5 | 6 | const _ExtractArgs ExtractArgs = (_ExtractArgs)0x005ACCB0; 7 | 8 | const _CreateFormInstance CreateFormInstance = (_CreateFormInstance)0x00465110; 9 | 10 | const _GetSingleton ConsoleManager_GetSingleton = (_GetSingleton)0x0071B160; 11 | bool * bEchoConsole = (bool*)0x011F158C; 12 | 13 | const _QueueUIMessage QueueUIMessage = (_QueueUIMessage)0x007052F0; 14 | 15 | const _ShowMessageBox ShowMessageBox = (_ShowMessageBox)0x00703E80; 16 | const _ShowMessageBox_Callback ShowMessageBox_Callback = (_ShowMessageBox_Callback)0x005B4A70; 17 | const _ShowMessageBox_pScriptRefID ShowMessageBox_pScriptRefID = (_ShowMessageBox_pScriptRefID)0x011CAC64; 18 | const _ShowMessageBox_button ShowMessageBox_button = (_ShowMessageBox_button)0x0118C684; 19 | 20 | bool GetConsoleEcho() 21 | { 22 | return *bEchoConsole; 23 | } 24 | 25 | void SetConsoleEcho(bool doEcho) 26 | { 27 | *bEchoConsole = doEcho; 28 | } 29 | 30 | ConsoleManager * ConsoleManager::GetSingleton(void) 31 | { 32 | return (ConsoleManager *)ConsoleManager_GetSingleton(true); 33 | } 34 | 35 | void Console_Print(const char *fmt, ...) 36 | { 37 | va_list args; 38 | va_start(args, fmt); 39 | ThisCall(0x71D0A0, g_consoleManager, fmt, args); 40 | va_end(args); 41 | } 42 | 43 | void ConsoleManager::Clear() 44 | { 45 | ThisCall(0x71E070, &printedLines); 46 | unk024 = 0; 47 | ThisCall(0x71D410, this); 48 | } 49 | 50 | SaveGameManager* SaveGameManager::GetSingleton() 51 | { 52 | return *(SaveGameManager**)0x11DE134; 53 | } 54 | 55 | UInt32 ScriptLocals::ResetAllVariables() 56 | { 57 | if (!m_vars) return 0; 58 | auto varIter = m_vars->Head(); 59 | ScriptVar *scriptVar; 60 | UInt32 numVars = 0; 61 | do 62 | { 63 | scriptVar = varIter->data; 64 | if (scriptVar) 65 | { 66 | scriptVar->data = 0.0; 67 | numVars++; 68 | } 69 | } 70 | while (varIter = varIter->next); 71 | return numVars; 72 | } 73 | 74 | __declspec(naked) ScriptVar* __fastcall ScriptLocals::GetVariable(UInt32 id) const 75 | { 76 | __asm 77 | { 78 | mov eax, [ecx+0xC] 79 | ALIGN 16 80 | iterHead: 81 | test eax, eax 82 | jz notFound 83 | mov ecx, [eax] 84 | mov eax, [eax+4] 85 | test ecx, ecx 86 | jz iterHead 87 | cmp [ecx], edx 88 | jnz iterHead 89 | mov eax, ecx 90 | notFound: 91 | retn 92 | } 93 | } 94 | 95 | ScriptLocals *ScriptLocals::CreateCopy() 96 | { 97 | ScriptLocals *pEventList = Game_HeapAlloc(); 98 | pEventList->m_script = m_script; 99 | pEventList->m_flags = m_flags; 100 | pEventList->m_eventList = nullptr; 101 | pEventList->m_vars = nullptr; 102 | pEventList->m_effScrFlags = nullptr; 103 | if (m_eventList) 104 | { 105 | auto eventList = Game_HeapAlloc::Node>(); 106 | eventList->data = nullptr; 107 | eventList->next = nullptr; 108 | pEventList->m_eventList = (EventList*)eventList; 109 | auto evtIter = m_eventList->Head(); 110 | Event *pEvent; 111 | do 112 | { 113 | if (!evtIter->data) continue; 114 | pEvent = Game_HeapAlloc(); 115 | *pEvent = *evtIter->data; 116 | if (eventList->data) 117 | eventList = eventList->Append(pEvent); 118 | else eventList->data = pEvent; 119 | } 120 | while (evtIter = evtIter->next); 121 | } 122 | if (m_vars) 123 | { 124 | auto pVars = Game_HeapAlloc::Node>(); 125 | pVars->data = nullptr; 126 | pVars->next = nullptr; 127 | pEventList->m_vars = (VarList*)pVars; 128 | auto varIter = m_vars->Head(); 129 | ScriptVar *pVar; 130 | do 131 | { 132 | if (!varIter->data) continue; 133 | pVar = Game_HeapAlloc(); 134 | *pVar = *varIter->data; 135 | if (pVars->data) 136 | pVars = pVars->Append(pVar); 137 | else pVars->data = pVar; 138 | } 139 | while (varIter = varIter->next); 140 | } 141 | if (m_effScrFlags) 142 | { 143 | pEventList->m_effScrFlags = Game_HeapAlloc(); 144 | *pEventList->m_effScrFlags = *m_effScrFlags; 145 | } 146 | return pEventList; 147 | } 148 | 149 | BGSSaveLoadGame *g_BGSSaveLoadGame; 150 | 151 | UInt32 *NiTPtrMap::Lookup(UInt32 key) const; 152 | void NiTPtrMap::Insert(UInt32 key, UInt32 value); 153 | 154 | __declspec(naked) UInt32 __fastcall BGSSaveLoadGame::EncodeRefID(UInt32 *pRefID) 155 | { 156 | __asm 157 | { 158 | mov eax, [edx] 159 | cmp eax, 0xFF000000 160 | jnb isCreated 161 | mov ecx, [ecx+8] 162 | push esi 163 | push edi 164 | mov esi, ecx 165 | mov edi, edx 166 | push eax 167 | call NiTPtrMap::Lookup 168 | test eax, eax 169 | jnz found 170 | mov eax, [esi+0x20] 171 | inc dword ptr [esi+0x20] 172 | mov edx, [edi] 173 | push eax 174 | push edx 175 | push eax 176 | push eax 177 | push edx 178 | mov ecx, esi 179 | call NiTPtrMap::Insert 180 | lea ecx, [esi+0x10] 181 | call NiTPtrMap::Insert 182 | pop eax 183 | found: 184 | mov [edi], eax 185 | pop edi 186 | pop esi 187 | isCreated: 188 | retn 189 | } 190 | } 191 | 192 | __declspec(naked) UInt32 __fastcall BGSSaveLoadGame::DecodeRefID(UInt32 *pRefID) 193 | { 194 | __asm 195 | { 196 | mov eax, [edx] 197 | test eax, eax 198 | js isCreated 199 | push edx 200 | push eax 201 | mov ecx, [ecx+8] 202 | add ecx, 0x10 203 | call NiTPtrMap::Lookup 204 | pop ecx 205 | mov [ecx], eax 206 | isCreated: 207 | retn 208 | } 209 | } -------------------------------------------------------------------------------- /nvse/GameBSExtraData.cpp: -------------------------------------------------------------------------------- 1 | #include "nvse/GameBSExtraData.h" 2 | #include "nvse/GameExtraData.h" 3 | 4 | bool BaseExtraList::HasType(UInt32 type) const 5 | { 6 | return (m_presenceBitfield[type >> 3] & (1 << (type & 7))) != 0; 7 | } 8 | 9 | __declspec(naked) void __fastcall BaseExtraList::SetTypePresent(UInt32 type, bool present) 10 | { 11 | __asm 12 | { 13 | mov eax, edx 14 | shr eax, 5 15 | lea ecx, [ecx+eax*4+8] 16 | mov eax, [ecx] 17 | cmp [esp+4], 0 18 | jz unset 19 | bts eax, edx 20 | mov [ecx], eax 21 | retn 4 22 | unset: 23 | btr eax, edx 24 | mov [ecx], eax 25 | retn 4 26 | } 27 | } 28 | 29 | __declspec(naked) BSExtraData *BaseExtraList::GetByType(UInt32 xType) const 30 | { 31 | __asm 32 | { 33 | cmp dword ptr [ecx+4], 0 34 | jz retnNULL 35 | mov edx, [esp+4] 36 | shr edx, 5 37 | mov eax, [ecx+edx*4+8] 38 | mov edx, [esp+4] 39 | bt eax, edx 40 | jnc retnNULL 41 | push ecx 42 | mov ecx, EXTRA_DATA_CS 43 | call LightCS::Enter 44 | pop ecx 45 | mov eax, [ecx+4] 46 | mov edx, [esp+4] 47 | ALIGN 16 48 | iterHead: 49 | cmp [eax+4], dl 50 | jz lockLeave 51 | mov eax, [eax+8] 52 | test eax, eax 53 | jnz iterHead 54 | lockLeave: 55 | mov edx, EXTRA_DATA_CS 56 | dec dword ptr [edx+4] 57 | jnz done 58 | and dword ptr [edx], 0 59 | done: 60 | retn 4 61 | retnNULL: 62 | xor eax, eax 63 | retn 4 64 | } 65 | } 66 | 67 | __declspec(naked) ExtraDataList *ExtraDataList::Create() 68 | { 69 | __asm 70 | { 71 | push 0x20 72 | call Game_DoHeapAlloc 73 | xorps xmm0, xmm0 74 | movups [eax], xmm0 75 | movups [eax+0x10], xmm0 76 | mov dword ptr [eax], kVtbl_ExtraDataList 77 | retn 78 | } 79 | } 80 | 81 | __declspec(naked) char __fastcall BaseExtraList::GetExtraFactionRank(TESFaction *faction) const 82 | { 83 | __asm 84 | { 85 | push edx 86 | push kXData_ExtraFactionChanges 87 | call BaseExtraList::GetByType 88 | pop edx 89 | test eax, eax 90 | jz noRank 91 | mov eax, [eax+0xC] 92 | ALIGN 16 93 | iterHead: 94 | test eax, eax 95 | jz noRank 96 | mov ecx, [eax] 97 | mov eax, [eax+4] 98 | test ecx, ecx 99 | jz iterHead 100 | cmp [ecx], edx 101 | jnz iterHead 102 | mov al, [ecx+4] 103 | retn 104 | noRank: 105 | dec al 106 | retn 107 | } 108 | } 109 | 110 | SInt32 BaseExtraList::GetCount() const 111 | { 112 | ExtraCount *xCount = GetExtraType(this, ExtraCount); 113 | return xCount ? xCount->count : 1; 114 | } 115 | 116 | void __fastcall ExtraValueStr(BSExtraData *xData, char *buffer) 117 | { 118 | switch (xData->type) 119 | { 120 | case kXData_ExtraOwnership: 121 | { 122 | ExtraOwnership *xOwnership = (ExtraOwnership*)xData; 123 | sprintf_s(buffer, 0x20, "%08X", xOwnership->owner ? xOwnership->owner->refID : 0); 124 | break; 125 | } 126 | case kXData_ExtraCount: 127 | { 128 | ExtraCount *xCount = (ExtraCount*)xData; 129 | sprintf_s(buffer, 0x20, "%d", xCount->count); 130 | break; 131 | } 132 | default: 133 | sprintf_s(buffer, 0x20, "%08X", ((UInt32*)xData)[3]); 134 | break; 135 | } 136 | } 137 | 138 | void BaseExtraList::DebugDump() const 139 | { 140 | PrintDebug("\nBaseExtraList Dump:"); 141 | Console_Print("BaseExtraList Dump:"); 142 | s_debug().Indent(); 143 | if (m_data) 144 | { 145 | char dataStr[0x20]; 146 | for (BSExtraData *traverse = m_data; traverse; traverse = traverse->next) 147 | { 148 | ExtraValueStr(traverse, dataStr); 149 | PrintDebug("%08X\t%02X\t%s\t%s", traverse, traverse->type, GetExtraDataName(traverse->type), dataStr); 150 | Console_Print("%08X %02X %s %s", traverse, traverse->type, GetExtraDataName(traverse->type), dataStr); 151 | } 152 | Console_Print(" "); 153 | } 154 | else 155 | { 156 | PrintDebug("No data in list"); 157 | Console_Print("No data in list"); 158 | } 159 | s_debug().Outdent(); 160 | } 161 | -------------------------------------------------------------------------------- /nvse/GameBSExtraData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Added to remove a cyclic dependency between GameForms.h and GameExtraData.h 4 | 5 | // 0C 6 | class BSExtraData 7 | { 8 | public: 9 | virtual void Destroy(bool doFree) = 0; 10 | virtual bool Differs(BSExtraData *compareTo) = 0; 11 | 12 | UInt8 type; // 04 13 | UInt8 pad05[3]; // 05 14 | BSExtraData *next; // 08 15 | }; 16 | 17 | struct NPCPerksInfo; 18 | 19 | // 020 20 | struct BaseExtraList 21 | { 22 | virtual void Destroy(bool doFree); 23 | 24 | BSExtraData *m_data; // 04 25 | UInt8 m_presenceBitfield[0x13]; // 08 - if a bit is set, then the extralist should contain that extradata 26 | UInt8 jipRefFlags5F; // 1B 0x5F in TESObjectREFR 27 | union // 1C JIP only! 28 | { 29 | NPCPerksInfo *perksInfo; 30 | TESAmmo *ammo; // Stored for projectile refs 31 | }; 32 | 33 | bool HasType(UInt32 type) const; 34 | void __fastcall SetTypePresent(UInt32 type, bool present); 35 | BSExtraData *GetByType(UInt32 xType) const; 36 | __forceinline BSExtraData *AddExtra(BSExtraData *toAdd) 37 | { 38 | return ThisCall(ADDR_AddExtraData, this, toAdd); 39 | } 40 | __forceinline void RemoveExtra(BSExtraData *toRemove, bool doFree) 41 | { 42 | ThisCall(0x410020, this, toRemove, doFree); 43 | } 44 | __forceinline void RemoveByType(UInt8 xType) 45 | { 46 | ThisCall(ADDR_RemoveExtraType, this, xType); 47 | } 48 | __forceinline void RemoveAll(bool doFree) 49 | { 50 | ThisCall(0x40FAE0, this, doFree); 51 | } 52 | __forceinline void CopyFrom(const BaseExtraList *sourceList, bool bCopyAndRemove) 53 | { 54 | ThisCall(0x412490, this, sourceList, bCopyAndRemove); 55 | } 56 | void DebugDump() const; 57 | char __fastcall GetExtraFactionRank(TESFaction *faction) const; 58 | SInt32 GetCount() const; 59 | }; 60 | 61 | class ExtraCount; 62 | class ExtraJIP; 63 | 64 | struct ExtraDataList : public BaseExtraList 65 | { 66 | ExtraDataList *CreateCopy(bool bCopyAndRemove = false); 67 | static ExtraDataList *Create(); 68 | 69 | ExtraCount *AddExtraCount(SInt32 count); 70 | ExtraJIP *AddExtraJIP(UINT _key = 0); 71 | }; 72 | static_assert(sizeof(ExtraDataList) == 0x20); -------------------------------------------------------------------------------- /nvse/GameData.cpp: -------------------------------------------------------------------------------- 1 | #include "nvse/GameData.h" 2 | #include "internal/jip_core.h" 3 | 4 | __declspec(naked) ModInfo* __fastcall DataHandler::LookupModByName(const char *modName) const 5 | { 6 | _asm 7 | { 8 | push ebx 9 | lea ebx, [ecx+0x21C] 10 | mov ecx, edx 11 | call StrHashCI 12 | mov ecx, eax 13 | mov edx, [ebx-4] 14 | ALIGN 16 15 | iterHead: 16 | mov eax, [ebx] 17 | cmp [eax+0x120], ecx 18 | jz done 19 | add ebx, 4 20 | dec edx 21 | jnz iterHead 22 | xor eax, eax 23 | done: 24 | pop ebx 25 | retn 26 | } 27 | } 28 | 29 | char kDecompilePath[0x100] = "DecompiledScripts (JIP)\\"; 30 | 31 | void DataHandler::DecompileModScripts(UInt8 modIdx, UInt8 typeMask) 32 | { 33 | FileStream outFile; 34 | char *wBuffer = GetStrArgBuffer(), *mainEnd = StrCopy(kDecompilePath + 24, GetNthModName(modIdx)), *typeEnd; 35 | *mainEnd++ = '\\'; 36 | 37 | if (typeMask & 1) 38 | { 39 | typeEnd = StrCopy(mainEnd, "Script\\"); 40 | auto scrIter = scriptList.Head(); 41 | do 42 | { 43 | if (auto pScript = scrIter->data; pScript && pScript->info.dataLength && (pScript->GetOverridingModIdx() == modIdx)) 44 | { 45 | char *fileEnd = StrCopy(typeEnd, pScript->GetEditorID()); 46 | *(UInt32*)fileEnd = 'txt.'; 47 | fileEnd[4] = 0; 48 | if (outFile.OpenWriteEx(kDecompilePath, wBuffer, 0x10000)) 49 | { 50 | size_t numWritten = DecompileToBuffer(pScript, outFile, nullptr); 51 | outFile.Close(); 52 | if (!numWritten) 53 | remove(kDecompilePath); 54 | } 55 | } 56 | } 57 | while (scrIter = scrIter->next); 58 | } 59 | 60 | if (typeMask & 2) 61 | { 62 | typeEnd = StrCopy(mainEnd, "Quest\\"); 63 | auto qstIter = questList.Head(); 64 | do 65 | { 66 | if (auto pQuest = qstIter->data; pQuest && (pQuest->GetOverridingModIdx() == modIdx)) 67 | { 68 | char *fileEnd = StrCopy(typeEnd, pQuest->GetEditorID()); 69 | *(UInt32*)fileEnd = 'txt.'; 70 | fileEnd[4] = 0; 71 | if (outFile.OpenWriteEx(kDecompilePath, wBuffer, 0x10000)) 72 | { 73 | size_t numWritten = pQuest->DecompileResultScripts(outFile, nullptr); 74 | outFile.Close(); 75 | if (!numWritten) 76 | remove(kDecompilePath); 77 | } 78 | } 79 | } 80 | while (qstIter = qstIter->next); 81 | } 82 | 83 | if (typeMask & 4) 84 | { 85 | typeEnd = StrCopy(mainEnd, "Package\\"); 86 | auto pkgIter = packageList.Head(); 87 | do 88 | { 89 | if (auto pPackage = pkgIter->data; pPackage && (pPackage->GetOverridingModIdx() == modIdx)) 90 | { 91 | char *fileEnd = StrCopy(typeEnd, pPackage->GetEditorID()); 92 | *(UInt32*)fileEnd = 'txt.'; 93 | fileEnd[4] = 0; 94 | if (outFile.OpenWriteEx(kDecompilePath, wBuffer, 0x10000)) 95 | { 96 | size_t numWritten = pPackage->DecompileResultScripts(outFile, nullptr); 97 | outFile.Close(); 98 | if (!numWritten) 99 | remove(kDecompilePath); 100 | } 101 | } 102 | } 103 | while (pkgIter = pkgIter->next); 104 | } 105 | 106 | if (typeMask & 8) 107 | { 108 | typeEnd = StrCopy(mainEnd, "Dialogue\\"); 109 | auto dlgIter = topicInfoList.Head(); 110 | do 111 | { 112 | if (auto pTopic = dlgIter->data; pTopic && (pTopic->GetOverridingModIdx() == modIdx) && pTopic->parentTopic) 113 | { 114 | sprintf_s(typeEnd, 0x80, "%06X [%s].txt", pTopic->refID & 0xFFFFFF, pTopic->parentTopic->editorIDstr.CStr()); 115 | if (outFile.OpenWriteEx(kDecompilePath, wBuffer, 0x10000)) 116 | { 117 | size_t numWritten = pTopic->DecompileResultScripts(outFile, nullptr); 118 | outFile.Close(); 119 | if (!numWritten) 120 | remove(kDecompilePath); 121 | } 122 | } 123 | } 124 | while (dlgIter = dlgIter->next); 125 | } 126 | 127 | if (typeMask & 0x10) 128 | { 129 | typeEnd = StrCopy(mainEnd, "Terminal\\"); 130 | for (auto bndIter = boundObjectList->first; bndIter; bndIter = bndIter->next) 131 | if (IS_ID(bndIter, BGSTerminal) && (bndIter->GetOverridingModIdx() == modIdx)) 132 | if (auto terminal = (BGSTerminal*)bndIter; !terminal->menuEntries.Empty()) 133 | { 134 | char *fileEnd = StrCopy(typeEnd, terminal->GetEditorID()); 135 | *(UInt32*)fileEnd = 'txt.'; 136 | fileEnd[4] = 0; 137 | if (outFile.OpenWriteEx(kDecompilePath, wBuffer, 0x10000)) 138 | { 139 | size_t numWritten = terminal->DecompileResultScripts(outFile, nullptr); 140 | outFile.Close(); 141 | if (!numWritten) 142 | remove(kDecompilePath); 143 | } 144 | } 145 | } 146 | } 147 | 148 | void Sky::RefreshMoon() 149 | { 150 | if (masserMoon) masserMoon->Destroy(true); 151 | masserMoon = ThisCall(0x634A70, Game_HeapAlloc(), (const char*)0x104EEB0, GMST_FLT(fMasserAngleFadeStart), GMST_FLT(fMasserAngleFadeEnd), 152 | GMST_FLT(fMasserAngleShadowEarlyFade), GMST_FLT(fMasserSpeed), GMST_FLT(fMasserZOffset), GMST_INT(iMasserSize)); 153 | masserMoon->Refresh(niNode008, (const char*)0x104EEB0); 154 | } 155 | 156 | __declspec(naked) bool Sky::GetIsRaining() const 157 | { 158 | __asm 159 | { 160 | mov eax, [ecx+0x10] 161 | test eax, eax 162 | jz checkSecond 163 | cmp byte ptr [eax+0xEB], 4 164 | jz weatherPerc 165 | checkSecond: 166 | mov eax, [ecx+0x14] 167 | test eax, eax 168 | jz retnFalse 169 | cmp byte ptr [eax+0xEB], 4 170 | jnz retnFalse 171 | weatherPerc: 172 | movss xmm0, PS_V3_One 173 | comiss xmm0, [ecx+0xF4] 174 | setbe al 175 | retn 176 | retnFalse: 177 | xor al, al 178 | retn 179 | } 180 | } 181 | 182 | void __fastcall WaterSurfaceManager::Update(NiCamera *camera) 183 | { 184 | if (!waterGroups.Empty()) 185 | { 186 | *(bool*)0x11F91C5 = 1; 187 | ThisCall(0x4E21B0, this, camera, 0); 188 | *(bool*)0x11F91C5 = 0; 189 | } 190 | } 191 | 192 | __declspec(naked) void __fastcall WaterSurfaceManager::UpdateEx(NiCamera *camera) 193 | { 194 | __asm 195 | { 196 | cmp dword ptr [ecx+0x3C], 0 197 | jz done 198 | mov eax, 0x11C7B70 199 | push dword ptr [eax] 200 | and dword ptr [eax], 0 201 | push dword ptr [eax+0x50] 202 | and dword ptr [eax+0x50], 0 203 | push eax 204 | push 0 205 | push edx 206 | mov byte ptr ds:0x11F91C5, 1 207 | CALL_EAX(0x4E21B0) 208 | mov byte ptr ds:0x11F91C5, 0 209 | pop eax 210 | pop dword ptr [eax+0x50] 211 | pop dword ptr [eax] 212 | done: 213 | retn 214 | } 215 | } 216 | 217 | GridCellArray *g_gridCellArray; 218 | 219 | __declspec(naked) TESObjectCELL* __vectorcall GridCellArray::GetCellAtPos(__m128 pos) const 220 | { 221 | __asm 222 | { 223 | pxor xmm3, xmm3 224 | unpcklpd xmm0, xmm3 225 | cvttps2dq xmm0, xmm0 226 | psrad xmm0, 0xC 227 | movq xmm1, qword ptr [ecx+4] 228 | psubd xmm0, xmm1 229 | movd xmm1, [ecx+0xC] 230 | unpcklps xmm1, xmm1 231 | movaps xmm2, xmm1 232 | psrld xmm2, 1 233 | paddd xmm0, xmm2 234 | pcmpgtd xmm1, xmm0 235 | movmskps eax, xmm1 236 | cmp al, 3 237 | jnz retnNull 238 | movaps xmm1, xmm0 239 | phaddd xmm1, xmm3 240 | psrldq xmm2, 4 241 | pslld xmm0, xmm2 242 | paddd xmm0, xmm1 243 | pextrw edx, xmm0, 0 244 | mov ecx, [ecx+0x10] 245 | mov eax, [ecx+edx*4] 246 | retn 247 | retnNull: 248 | xor eax, eax 249 | retn 250 | } 251 | } 252 | 253 | __declspec(naked) TESObjectCELL* __vectorcall GridCellArray::GetCellAtCoord(__m128i cellXY) const 254 | { 255 | __asm 256 | { 257 | push ebx 258 | mov ebx, ecx 259 | movd eax, xmm0 260 | movsx edx, ax 261 | sar eax, 0x10 262 | mov ecx, [ebx+0xC] 263 | shr ecx, 1 264 | sub eax, [ebx+4] 265 | add eax, ecx 266 | cmp eax, [ebx+0xC] 267 | jnb retnNull 268 | sub edx, [ebx+8] 269 | add edx, ecx 270 | cmp edx, [ebx+0xC] 271 | jnb retnNull 272 | add edx, eax 273 | shl eax, cl 274 | add edx, eax 275 | mov ecx, [ebx+0x10] 276 | mov eax, [ecx+edx*4] 277 | pop ebx 278 | retn 279 | retnNull: 280 | xor eax, eax 281 | pop ebx 282 | retn 283 | } 284 | } 285 | 286 | void TES::UnloadBufferedExterior(TESObjectCELL *cell) 287 | { 288 | UInt32 bufferSize = INIS_UINT(uExterior_Cell_Buffer_General); 289 | for (UInt32 i = 0; i < bufferSize; i++) 290 | if (!exteriorsBuffer[i]) 291 | { 292 | bufferSize = i; 293 | break; 294 | } 295 | for (UInt32 i = 0; i < bufferSize; i++) 296 | { 297 | if (exteriorsBuffer[i] != cell) 298 | continue; 299 | MemCopy(exteriorsBuffer + i, exteriorsBuffer + i + 1, (bufferSize - i - 1) << 2); 300 | ThisCall(0x462290, g_dataHandler, cell); 301 | break; 302 | } 303 | } -------------------------------------------------------------------------------- /nvse/GameEffects.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 48 4 | class ActiveEffect 5 | { 6 | public: 7 | /*000*/virtual void Destroy(bool doFree); 8 | /*004*/virtual ActiveEffect *Clone(); 9 | /*008*/virtual void Unk_02(); 10 | /*00C*/virtual void Unk_03(float arg); 11 | /*010*/virtual void SaveGame(UInt32 arg); 12 | /*014*/virtual void LoadGame(UInt32 arg); 13 | /*018*/virtual void Unk_06(UInt32 arg); 14 | /*01C*/virtual void Unk_07(UInt32 arg); 15 | /*020*/virtual void Unk_08(UInt32 arg); 16 | /*024*/virtual void Unk_09(UInt32 arg); 17 | /*028*/virtual void Unk_0A(UInt32 arg); 18 | /*02C*/virtual void CopyTo(ActiveEffect *_target); 19 | /*030*/virtual bool Unk_0C(UInt32 arg); 20 | /*034*/virtual bool Unk_0D(UInt32 arg); 21 | /*038*/virtual bool ResetCasterIfSame(MagicCaster *_caster); 22 | /*03C*/virtual bool Unk_0F(); 23 | /*040*/virtual void Unk_10(UInt32 arg); 24 | /*044*/virtual void CopyFrom(ActiveEffect *from); 25 | /*048*/virtual bool Unk_12(UInt32 arg); 26 | /*04C*/virtual bool Unk_13(MagicTarget *_target); 27 | /*050*/virtual void Unk_14(); 28 | /*054*/virtual void Unk_15(); 29 | /*058*/virtual void Unk_16(); 30 | 31 | float timeElapsed; // 04 32 | MagicItem *magicItem; // 08 33 | EffectItem *effectItem; // 0C 34 | bool bActive; // 10 35 | bool bApplied; // 11 36 | bool byte12; // 12 37 | bool bTerminated; // 13 set to 1 when effect is to be removed 38 | UInt8 byte14; // 14 39 | UInt8 pad15[3]; // 15 40 | UInt32 flags; // 18 41 | float magnitude; // 1C - adjusted based on target? 42 | float duration; // 20 - adjusted based on target? 43 | MagicTarget *target; // 24 44 | MagicCaster *caster; // 28 45 | UInt32 spellType; // 2C e.g. SpellItem::kType_Ability 46 | Sound sound; // 30 47 | TESForm *enchantObject; // 3C Object responsible for effect 48 | tList *list40; // 40 49 | UInt32 unk44; // 44 50 | 51 | __forceinline void Remove(bool immediate) 52 | { 53 | ThisCall(0x804210, this, immediate); 54 | } 55 | }; 56 | 57 | // 4C 58 | class ValueModifierEffect : public ActiveEffect 59 | { 60 | public: 61 | virtual void SetActorValueID(UInt32 avID); 62 | virtual UInt32 GetActorValueID(); 63 | virtual void Unk_19(Actor *actor, float modifier, UInt32 avCode); 64 | 65 | UInt32 actorVal; 66 | }; 67 | 68 | // 50 69 | class ScriptEffect : public ActiveEffect 70 | { 71 | public: 72 | Script *script; // 48 73 | ScriptLocals *eventList; // 4C 74 | }; 75 | 76 | // 48 77 | class DispelEffect : public ActiveEffect 78 | { 79 | public: 80 | virtual void Unk_17(void); 81 | }; 82 | 83 | // 50 84 | class CureEffect : public ActiveEffect 85 | { 86 | public: 87 | virtual void Unk_17(void); 88 | 89 | UInt32 unk48[2]; // 48 90 | }; 91 | 92 | // 5C 93 | class AbsorbEffect : public ValueModifierEffect 94 | { 95 | public: 96 | virtual void Unk_1A(void); 97 | 98 | UInt32 unk4C[4]; // 4C 99 | }; 100 | 101 | // 50 102 | class ShieldEffect : public ValueModifierEffect 103 | { 104 | public: 105 | virtual void Unk_1A(void); 106 | 107 | UInt32 unk4C; // 4C 108 | }; 109 | 110 | // 4C 111 | class CalmEffect : public ValueModifierEffect 112 | { 113 | public: 114 | virtual void Unk_1A(void); 115 | }; 116 | 117 | // 4C 118 | class DemoralizeEffect : public ActiveEffect 119 | { 120 | public: 121 | virtual void Unk_17(void); 122 | 123 | UInt32 unk48; // 48 124 | }; 125 | 126 | // 50 127 | class FrenzyEffect : public ValueModifierEffect 128 | { 129 | public: 130 | virtual void Unk_1A(void); 131 | 132 | UInt32 unk4C; // 4C 133 | }; 134 | 135 | // 48 136 | class CommandEffect : public ActiveEffect 137 | { 138 | public: 139 | virtual void Unk_17(void); 140 | }; 141 | 142 | // 48 143 | class CommandCreatureEffect : public CommandEffect 144 | { 145 | public: 146 | }; 147 | 148 | // 48 149 | class CommandHumanoidEffect : public CommandEffect 150 | { 151 | public: 152 | }; 153 | 154 | // 4C 155 | class InvisibilityEffect : public ValueModifierEffect 156 | { 157 | public: 158 | virtual void Unk_1A(void); 159 | }; 160 | 161 | // 4C 162 | class ChameleonEffect : public ValueModifierEffect 163 | { 164 | public: 165 | virtual void Unk_1A(void); 166 | }; 167 | 168 | // 4C 169 | class LightEffect : public ActiveEffect 170 | { 171 | public: 172 | NiPointLight *ptLight; // 48 173 | }; 174 | 175 | // 4C 176 | class DarknessEffect : public ValueModifierEffect 177 | { 178 | public: 179 | virtual void Unk_1A(void); 180 | }; 181 | 182 | // 4C 183 | class NightEyeEffect : public ValueModifierEffect 184 | { 185 | public: 186 | virtual void Unk_1A(void); 187 | }; 188 | 189 | // 48 190 | class LockEffect : public ActiveEffect 191 | { 192 | public: 193 | virtual void Unk_17(void); 194 | }; 195 | 196 | // 48 197 | class OpenEffect : public ActiveEffect 198 | { 199 | public: 200 | virtual void Unk_17(void); 201 | }; 202 | 203 | // 4C 204 | class AssociatedItemEffect : public ActiveEffect 205 | { 206 | public: 207 | virtual void Unk_17(void); 208 | 209 | TESObject *item; // 48 - creature, armor, weapon 210 | }; 211 | 212 | // AC 213 | class BoundItemEffect : public AssociatedItemEffect 214 | { 215 | public: 216 | UInt32 unk48[24]; // 4C 217 | }; 218 | 219 | // 74 220 | class SummonCreatureEffect : public AssociatedItemEffect 221 | { 222 | public: 223 | UInt32 unk48[10]; // 4C 224 | }; 225 | 226 | // 4C 227 | class DetectLifeEffect : public ValueModifierEffect 228 | { 229 | public: 230 | virtual void Unk_1A(void); 231 | }; 232 | 233 | // 60 234 | class TelekinesisEffect : public ValueModifierEffect 235 | { 236 | public: 237 | virtual void Unk_1A(void); 238 | 239 | UInt32 unk4C[5]; // 4C 240 | }; 241 | 242 | // 4C 243 | class DisintegrateArmorEffect : public ActiveEffect 244 | { 245 | public: 246 | UInt32 unk48; // 48 247 | }; 248 | 249 | // 48 250 | class DisintegrateWeaponEffect : public ActiveEffect 251 | { 252 | public: 253 | }; 254 | 255 | // 4C 256 | class ParalysisEffect : public ValueModifierEffect 257 | { 258 | public: 259 | virtual void Unk_1A(void); 260 | }; 261 | 262 | // 70 263 | class ReanimateEffect : public ActiveEffect 264 | { 265 | public: 266 | UInt32 unk48[10]; // 48 267 | }; 268 | 269 | // 4C 270 | class TurnUndeadEffect : public ActiveEffect 271 | { 272 | public: 273 | virtual void Unk_17(void); 274 | 275 | UInt32 unk48; // 48 276 | }; 277 | 278 | // 50 279 | class SunDamageEffect : public ActiveEffect 280 | { 281 | public: 282 | virtual void Unk_17(void); 283 | 284 | UInt32 unk48[2]; // 48 285 | }; 286 | 287 | // 48 288 | class VampirismEffect : public ActiveEffect 289 | { 290 | public: 291 | virtual void Unk_17(void); 292 | }; 293 | 294 | // 4C 295 | class ConcussionEffect : public ActiveEffect 296 | { 297 | public: 298 | float unk48; // 48 299 | }; 300 | 301 | // 50 302 | class ValueAndConditionsEffect : public ValueModifierEffect 303 | { 304 | public: 305 | virtual void Unk_1A(void); 306 | 307 | UInt32 unk4C; // 4C 308 | }; 309 | 310 | // 50 311 | class LimbConditionEffect : public ValueModifierEffect 312 | { 313 | public: 314 | virtual void Unk_1A(void); 315 | 316 | UInt32 unk4C; // 4C 317 | }; 318 | 319 | // 18 320 | class BSTempEffect : public NiObject 321 | { 322 | public: 323 | virtual void Unk_23(void); 324 | virtual void Unk_24(void); 325 | virtual void Unk_25(void); 326 | virtual void Unk_26(void); 327 | virtual void Unk_27(void); 328 | virtual void Unk_28(void); 329 | virtual void Unk_29(void); 330 | virtual void Unk_2A(void); 331 | virtual void Unk_2B(void); 332 | virtual void Unk_2C(void); 333 | virtual void Unk_2D(void); 334 | virtual void Unk_2E(void); 335 | virtual void Unk_2F(void); 336 | virtual void Unk_30(void); 337 | 338 | float lifetime; // 08 339 | TESObjectCELL *cell; // 0C 340 | float age; // 10 341 | bool initialized;// 14 342 | UInt8 pad15[3]; // 15 343 | }; 344 | 345 | // 28 346 | class MagicHitEffect : public BSTempEffect 347 | { 348 | public: 349 | virtual void Unk_31(void); 350 | virtual void Unk_32(void); 351 | virtual void Unk_33(void); 352 | virtual void Unk_34(void); 353 | virtual void Unk_35(void); 354 | virtual void Unk_36(void); 355 | virtual void Unk_37(void); 356 | virtual void Unk_38(void); 357 | 358 | ActiveEffect *activeEffect; // 18 359 | TESObjectREFR *target; // 1C 360 | float unk20; // 20 361 | UInt8 flags; // 24 1 - Stop 362 | UInt8 pad25[3]; // 25 363 | }; 364 | 365 | // 6C 366 | class MagicShaderHitEffect : public MagicHitEffect 367 | { 368 | public: 369 | UInt32 unk28[2]; // 28 370 | TESEffectShader *effectShader; // 30 371 | float flt34; // 34 372 | BSSimpleArray shaderProps; // 38 373 | NiNode *shaderNode; // 48 374 | UInt32 unk4C; // 4C 375 | BSSimpleArray objects; // 50 Seen BSFadeNode 376 | float flt60; // 60 377 | float flt64; // 64 378 | NiProperty *prop68; // 68 Seen 0x10AE0C8 379 | }; 380 | static_assert(sizeof(MagicShaderHitEffect) == 0x6C); -------------------------------------------------------------------------------- /nvse/GameOSDepend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_CONTROL_BIND 28 4 | 5 | enum ControlCode 6 | { 7 | /*00*/eCtrlID_Forward, 8 | /*01*/eCtrlID_Backward, 9 | /*02*/eCtrlID_Left, 10 | /*03*/eCtrlID_Right, 11 | /*04*/eCtrlID_Attack, 12 | /*05*/eCtrlID_Activate, 13 | /*06*/eCtrlID_AimBlock, 14 | /*07*/eCtrlID_ReadyItem, 15 | /*08*/eCtrlID_Crouch, 16 | /*09*/eCtrlID_Run, 17 | /*0A*/eCtrlID_AlwaysRun, 18 | /*0B*/eCtrlID_AutoMove, 19 | /*0C*/eCtrlID_Jump, 20 | /*0D*/eCtrlID_TogglePOV, 21 | /*0E*/eCtrlID_MenuMode, 22 | /*0F*/eCtrlID_SleepWait, 23 | /*10*/eCtrlID_VATS_, 24 | /*11*/eCtrlID_Hotkey1, 25 | /*12*/eCtrlID_AmmoSwap, 26 | /*13*/eCtrlID_Hotkey3, 27 | /*14*/eCtrlID_Hotkey4, 28 | /*15*/eCtrlID_Hotkey5, 29 | /*16*/eCtrlID_Hotkey6, 30 | /*17*/eCtrlID_Hotkey7, 31 | /*18*/eCtrlID_Hotkey8, 32 | /*19*/eCtrlID_QuickSave, 33 | /*1A*/eCtrlID_QuickLoad, 34 | /*1B*/eCtrlID_Grab 35 | }; 36 | 37 | enum KeyState 38 | { 39 | kKeyState_Held, 40 | kKeyState_Pressed, 41 | kKeyState_Depressed, 42 | kKeyState_Changed 43 | }; 44 | 45 | enum ControllerState 46 | { 47 | kCtrlState_NotHeld = -1, 48 | kCtrlState_Held, 49 | kCtrlState_Depressed, 50 | kCtrlState_Pressed 51 | }; 52 | 53 | enum XboxControlCode 54 | { 55 | kXboxCtrl_DPAD_UP = 1, 56 | kXboxCtrl_DPAD_DOWN, 57 | kXboxCtrl_DPAD_RIGHT = 4, 58 | kXboxCtrl_DPAD_LEFT, 59 | kXboxCtrl_START, 60 | kXboxCtrl_BACK, 61 | kXboxCtrl_LS_BUTTON, 62 | kXboxCtrl_RS_BUTTON, 63 | kXboxCtrl_BUTTON_A, 64 | kXboxCtrl_BUTTON_B, 65 | kXboxCtrl_BUTTON_X, 66 | kXboxCtrl_BUTTON_Y, 67 | kXboxCtrl_RB, 68 | kXboxCtrl_LB, 69 | kXboxCtrl_LT, 70 | kXboxCtrl_RT, 71 | kXboxCtrl_LS_UP = 0x13, 72 | kXboxCtrl_LS_DOWN, 73 | kXboxCtrl_LS_RIGHT = 0x16, 74 | kXboxCtrl_LS_LEFT, 75 | }; 76 | 77 | enum XboxButtonBit 78 | { 79 | kXboxBit_DPAD_UP, 80 | kXboxBit_DPAD_DOWN, 81 | kXboxBit_DPAD_LEFT, 82 | kXboxBit_DPAD_RIGHT, 83 | kXboxBit_START, 84 | kXboxBit_BACK, 85 | kXboxBit_LS_BUTTON, 86 | kXboxBit_RS_BUTTON, 87 | kXboxBit_LB, 88 | kXboxBit_RB, 89 | kXboxBit_GUIDE, 90 | kXboxBit_BUTTON_A = 0xC, 91 | kXboxBit_BUTTON_B, 92 | kXboxBit_BUTTON_X, 93 | kXboxBit_BUTTON_Y 94 | }; 95 | 96 | enum XboxButtonMask 97 | { 98 | kXboxMask_DPAD_UP = 1, 99 | kXboxMask_DPAD_DOWN = 2, 100 | kXboxMask_DPAD_LEFT = 4, 101 | kXboxMask_DPAD_RIGHT = 8, 102 | kXboxMask_START = 0x10, 103 | kXboxMask_BACK = 0x20, 104 | kXboxMask_LS_BUTTON = 0x40, 105 | kXboxMask_RS_BUTTON = 0x80, 106 | kXboxMask_LB = 0x100, 107 | kXboxMask_RB = 0x200, 108 | kXboxMask_GUIDE = 0x400, 109 | kXboxMask_BUTTON_A = 0x1000, 110 | kXboxMask_BUTTON_B = 0x2000, 111 | kXboxMask_BUTTON_X = 0x4000, 112 | kXboxMask_BUTTON_Y = 0x8000, 113 | }; 114 | 115 | enum SpecialInputCode : UInt32 116 | { 117 | kInputCode_Backspace = 0x80000000, 118 | kInputCode_ArrowLeft = 0x80000001, 119 | kInputCode_ArrowRight = 0x80000002, 120 | kInputCode_ArrowUp = 0x80000003, 121 | kInputCode_ArrowDown = 0x80000004, 122 | kInputCode_Home = 0x80000005, 123 | kInputCode_End = 0x80000006, 124 | kInputCode_Delete = 0x80000007, 125 | kInputCode_Enter = 0x80000008, 126 | kInputCode_PageUp = 0x80000009, 127 | kInputCode_PageDown = 0x8000000A 128 | }; 129 | 130 | struct _IDirectInput8; 131 | 132 | class DInputInterface 133 | { 134 | public: 135 | virtual void Unk_00(void); 136 | virtual void Unk_01(void); 137 | virtual void Unk_02(void); 138 | virtual void Unk_03(void); 139 | virtual void Unk_04(void); 140 | virtual void Unk_05(void); 141 | virtual void Unk_06(DInputInterface *intrfc, UInt32 arg2, void *arg3); 142 | virtual UInt32 GetStatesChanged(DInputInterface *intrfc); 143 | virtual void Unk_08(void); 144 | virtual void OutputStates(DInputInterface *intrfc, UInt32 bufSize, char *buffer); 145 | virtual void Unk_0A(void); 146 | virtual void Unk_0B(DInputInterface *intrfc, void *arg2); 147 | virtual void Unk_0C(void); 148 | virtual void Unk_0D(DInputInterface *intrfc, HWND window, UInt32 type); 149 | virtual void Unk_0E(void); 150 | virtual void Unk_0F(void); 151 | virtual void Unk_10(void); 152 | virtual void Unk_11(void); 153 | virtual void Unk_12(void); 154 | virtual void Unk_13(void); 155 | virtual void Unk_14(void); 156 | virtual void Unk_15(void); 157 | virtual void Unk_16(void); 158 | virtual void Unk_17(void); 159 | virtual void Unk_18(void); 160 | virtual void QueryStates(DInputInterface *intrfc); 161 | }; 162 | 163 | // 1C04 164 | class OSInputGlobals 165 | { 166 | public: 167 | enum 168 | { 169 | kFlag_HasJoysticks = 1 << 0, 170 | kFlag_HasMouse = 1 << 1, 171 | kFlag_HasKeyboard = 1 << 2, 172 | kFlag_BackgroundMouse = 1 << 3, 173 | }; 174 | 175 | UInt8 controllerDisabled; // 0000 176 | UInt8 pad0001[3]; // 0001 177 | UInt32 flags; // 0004 178 | _IDirectInput8 *directInput; // 0008 179 | void *ptr000C[8]; // 000C 180 | DInputInterface *keyboardInterface; // 002C 181 | DInputInterface *mouseInterface; // 0030 182 | UInt32 unk0034[320]; // 0034 183 | UInt32 unk0534[1264]; // 0534 184 | UInt32 unk18F4; // 18F4 185 | UInt8 currKeyStates[256]; // 18F8 186 | UInt8 lastKeyStates[256]; // 19F8 187 | UInt32 unk1AF8[11]; // 1AF8 188 | int currMouseMovementX; // 1B24 189 | int currMouseMovementY; // 1B28 190 | int currMouseWheelScroll; // 1B2C 191 | UInt8 currButtonStates[8]; // 1B30 192 | int lastMouseMovementX; // 1B38 193 | int lastMouseMovementY; // 1B3C 194 | int lastMouseWheelScroll; // 1B40 195 | UInt8 lastButtonStates[8]; // 1B44 196 | UInt32 ltrtButtonState; // 1B4C 197 | UInt8 mouseSensitivity; // 1B50 198 | UInt8 pad1B51[3]; // 1B51 199 | UInt32 unk1B54; // 1B54 200 | UInt8 buttonStates1B58[8]; // 1B58 201 | UInt32 unk1B60[8]; // 1B60 202 | UInt32 *controllerVibration; // 1B80 203 | UInt32 unk1B84; // 1B84 204 | UInt8 controllerNotDisabled; // 1B88 205 | UInt8 pad1B89[3]; // 1B89 206 | UInt32 unk1B8C[2]; // 1B8C 207 | UInt8 keyBinds[28]; // 1B94 208 | UInt8 mouseBinds[28]; // 1BB0 209 | UInt8 joystickBinds[28]; // 1BCC 210 | UInt8 controllerBinds[28]; // 1BE8 211 | 212 | __forceinline static OSInputGlobals *GetSingleton() {return *(OSInputGlobals**)0x11F35CC;} 213 | }; 214 | static_assert(sizeof(OSInputGlobals) == 0x1C04); 215 | 216 | extern OSInputGlobals *g_inputGlobals; 217 | #define KEYBOARD_BIND(ctrlID) g_inputGlobals->keyBinds[ctrlID] 218 | #define MOUSE_BIND(ctrlID) g_inputGlobals->mouseBinds[ctrlID] 219 | #define CONTROLLER_BIND(ctrlID) g_inputGlobals->controllerBinds[ctrlID] 220 | 221 | // 20 222 | struct BSPackedTask 223 | { 224 | union TaskArg 225 | { 226 | UInt8 byteVal; 227 | SInt32 intVal; 228 | UInt32 uintVal; 229 | float fltVal; 230 | void *ptrVal; 231 | TESForm *formVal; 232 | }; 233 | 234 | UInt32 type; // 00 235 | UInt32 cmdOpcode; // 04 236 | UInt32 thisObj; // 08 refID 237 | TaskArg args[5]; // 0C 238 | }; 239 | 240 | // 10 241 | struct ScrapHeapBuffer 242 | { 243 | BSPackedTask *buffer; 244 | BSPackedTask *firstFree; 245 | BSPackedTask *bufferEnd; 246 | UInt32 unk0C; 247 | }; 248 | 249 | // 28 250 | class BSTCommonScrapHeapMessageQueue 251 | { 252 | public: 253 | virtual void Destroy(bool doFree); 254 | virtual bool QueueTask(BSPackedTask *pTask); 255 | virtual void Unk_02(void); 256 | virtual void Unk_03(void); 257 | virtual void Unk_04(void); 258 | virtual void Unk_05(void); 259 | virtual void Unk_06(void); 260 | 261 | typedef void (__cdecl *DoQueuedTask)(BSPackedTask *taskData); 262 | 263 | UInt32 unk04; // 04 264 | ScrapHeapBuffer *taskBuffer; // 08 265 | UInt32 unk0C; // 0C 266 | void *ptr10; // 10 267 | UInt32 currCount; // 14 268 | HANDLE semaphore; // 18 269 | UInt32 maxCount; // 1C 270 | DoQueuedTask doQueuedTask; // 20 0x87B990 271 | UInt8 byte24; // 24 272 | UInt8 pad25[3]; // 25 273 | }; 274 | 275 | // 10 276 | struct TaskQueueInterface 277 | { 278 | BSTCommonScrapHeapMessageQueue *taskQueueMain; // 00 279 | BSTCommonScrapHeapMessageQueue *taskQueueScnd; // 04 280 | BSTCommonScrapHeapMessageQueue *taskQueue; // 08 Same as main 281 | UInt32 threadID; // 0C 282 | 283 | __forceinline static TaskQueueInterface *GetSingleton() {return *(TaskQueueInterface**)0x11DF1A8;} 284 | }; 285 | extern TaskQueueInterface *g_scrapHeapQueue; 286 | 287 | // A4 288 | class OSGlobals 289 | { 290 | public: 291 | UInt8 oneMore; // 00 292 | UInt8 quitGame; // 01 293 | UInt8 exitToMainMenu; // 02 294 | UInt8 isWindowActive; // 03 295 | UInt8 byte04; // 04 296 | UInt8 byte05; // 05 297 | UInt8 tfcState; // 06 298 | bool freezeTime; // 07 299 | HWND window; // 08 300 | HINSTANCE procInstance; // 0C 301 | UInt32 mainThreadID; // 10 302 | HANDLE mainThreadHandle; // 14 303 | ScrapHeapBuffer shBuffer18; // 18 304 | BSTCommonScrapHeapMessageQueue shQueue28; // 28 305 | ScrapHeapBuffer shBuffer50; // 50 306 | BSTCommonScrapHeapMessageQueue shQueue60; // 60 307 | BSShaderAccumulator *shaderAccum88; // 88 308 | BSShaderAccumulator *shaderAccum8C; // 8C 309 | BSShaderAccumulator *shaderAccum90; // 90 310 | BSShaderAccumulator *shaderAccum94; // 94 311 | BSShaderAccumulator *shaderAccum98; // 98 312 | UInt32 unk9C; // 9C 313 | NiCamera *cameraA0; // A0 314 | 315 | __forceinline static OSGlobals *GetSingleton() {return *(OSGlobals**)0x11DEA0C;} 316 | }; 317 | static_assert(sizeof(OSGlobals) == 0xA4); 318 | 319 | extern OSGlobals *g_OSGlobals; -------------------------------------------------------------------------------- /nvse/GameRTTI.cpp: -------------------------------------------------------------------------------- 1 | #include "nvse/GameRTTI.h" 2 | #include "nvse/GameRTTI_1_4_0_525.inc" -------------------------------------------------------------------------------- /nvse/GameScript.cpp: -------------------------------------------------------------------------------- 1 | #include "nvse/GameScript.h" 2 | 3 | __declspec(naked) void SuppressConsoleOutput() 4 | { 5 | __asm 6 | { 7 | mov eax, fs:0x2C 8 | mov edx, g_TLSIndex 9 | mov eax, [eax+edx*4] 10 | mov [eax+0x268], 0 11 | retn 12 | } 13 | } 14 | 15 | TESForm* __stdcall LookupFormByRefID(UInt32 refID); 16 | void Script::RefVariable::Resolve(ScriptLocals *eventList) 17 | { 18 | if (varIdx && eventList) 19 | if (ScriptVar *var = eventList->GetVariable(varIdx)) 20 | form = LookupFormByRefID(var->data.refID); 21 | } 22 | 23 | bool Script::Compile(const char *scrName) 24 | { 25 | ScriptBuffer scrBuffer; 26 | scrBuffer.scriptText = text; 27 | scrBuffer.runtimeMode = 0; 28 | scrBuffer.scriptName.Set(scrName); 29 | scrBuffer.partialScript = true; 30 | scrBuffer.currScript = this; 31 | return StdCall(0x5AEB90, this, &scrBuffer); 32 | } 33 | 34 | bool Script::Init(char *scrText, const char *scrName) 35 | { 36 | Constructor(); 37 | MarkAsTemporary(); 38 | text = scrText; 39 | bool success = Compile(scrName) && info.dataLength; 40 | text = nullptr; 41 | return success; 42 | } 43 | 44 | Script *Script::Create(char *scrText, const char *scrName) 45 | { 46 | Script *pScript = Game_HeapAlloc