mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added "set_drugs_data" script function (from Mr.Stalin)
Fixed vanilla drugs in Drugs.ini not getting loaded.
This commit is contained in:
@@ -18,7 +18,7 @@ PID=0
|
||||
; this count is 4 for Buffout/Mentats/Psycho/Jet
|
||||
; set -1 to leave this parameter unchanged
|
||||
NumEffects=-1
|
||||
; the duration of the withdrawal effects of addiction in minutes (i.e. 1440 = 24 game hours)
|
||||
; the duration of the addiction effect in game minutes (i.e. 1440 = 24 game hours)
|
||||
; set to 0 to use the default time (7 days for all drugs except Jet)
|
||||
AddictTime=0
|
||||
; the number of the global variable from vault13.gam responsible for displaying addiction in the character screen
|
||||
|
||||
@@ -277,6 +277,7 @@
|
||||
#define set_can_rest_on_map(map, elev, value) sfall_func3("set_can_rest_on_map", map, elev, value)
|
||||
#define set_car_intface_art(artIndex) sfall_func1("set_car_intface_art", artIndex)
|
||||
#define set_cursor_mode(mode) sfall_func1("set_cursor_mode", mode)
|
||||
#define set_drugs_data(type, pid, value) sfall_func3("set_drugs_data", type, pid, value)
|
||||
#define set_dude_obj(critter) sfall_func1("set_dude_obj", critter)
|
||||
#define set_flags(obj, flags) sfall_func2("set_flags", obj, flags)
|
||||
#define set_iface_tag_text(tag, text, color) sfall_func3("set_iface_tag_text", tag, text, color)
|
||||
|
||||
@@ -573,6 +573,11 @@ Some utility/math functions are available:
|
||||
- enables/disables the engine function that increases the level of party members in the player leveling process
|
||||
- if the engine function is disabled, the process of leveling up party members should be performed by script functions
|
||||
|
||||
> void sfall_func3("set_drugs_data", int type, int pid, int value)
|
||||
- overrides the parameters of drugs set in the configuration file (DrugsFile setting in ddraw.ini)
|
||||
- type: 0 - changes the value of NumEffects for the drug (see Drugs.ini for the description of NumEffects)
|
||||
1 - changes the duration of the addiction effect for the drug (a value of 1 = one game minute)
|
||||
|
||||
------------------------
|
||||
------ MORE INFO -------
|
||||
------------------------
|
||||
|
||||
@@ -335,7 +335,7 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
// take the drug pid from the list after loading sfalldb.sav
|
||||
// take the drug pid from the list after loading sfallgv.sav
|
||||
static void __declspec(naked) item_d_load_hack() {
|
||||
__asm {
|
||||
mov [ebp], edi; // edi->queue_drug
|
||||
@@ -350,7 +350,7 @@ skip:
|
||||
}
|
||||
}
|
||||
|
||||
// add drug pid to the list to save to sfalldb.sav
|
||||
// add drug pid to the list to save to sfallgv.sav
|
||||
static void __declspec(naked) item_d_save_hack() {
|
||||
__asm {
|
||||
pushadc;
|
||||
|
||||
@@ -292,12 +292,11 @@ void Drugs::init() {
|
||||
drugs[i].iniNumEffects = ef;
|
||||
fo::var::drugInfoList[set].numEffects = ef;
|
||||
} else {
|
||||
drugs[i].iniNumEffects = fo::var::drugInfoList[set].numEffects;
|
||||
drugs[i].iniNumEffects = fo::var::drugInfoList[set].numEffects; // default value from engine
|
||||
}
|
||||
set = -1;
|
||||
drugs[i].numEffects = set; // set -1, to use the value from the engine
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
drugs[drugsCount].numEffects = drugs[drugsCount].iniNumEffects = max(0, ef);
|
||||
int gvar = GetPrivateProfileIntA(section, "GvarID", 0, iniDrugs);
|
||||
drugs[drugsCount].gvarID = max(0, gvar); // not allow negative values
|
||||
@@ -307,6 +306,7 @@ void Drugs::init() {
|
||||
drugs[drugsCount].frmID = GetPrivateProfileIntA(section, "FrmID", -1, iniDrugs);
|
||||
addictionGvarCount++;
|
||||
}
|
||||
}
|
||||
drugsCount++;
|
||||
}
|
||||
}
|
||||
@@ -315,7 +315,7 @@ void Drugs::init() {
|
||||
MakeCall(0x43C15C, list_karma_hack, 2);
|
||||
MakeCall(0x47A5B8, pid_to_gvar_hack, 1);
|
||||
MakeCall(0x47A50C, perform_withdrawal_start_hack);
|
||||
SafeWrite32(0x47A523, 0x9090EBD1); // shr ebx, 1
|
||||
SafeWrite32(0x47A523, 0x9090EBD1); // shr ebx, 1 (fix for trait drug addict)
|
||||
SafeWrite8(0x47A527, 0x90);
|
||||
|
||||
if (addictionGvarCount) {
|
||||
|
||||
@@ -117,6 +117,7 @@ static const SfallMetarule metarules[] = {
|
||||
{"set_can_rest_on_map", sf_set_rest_on_map, 3, 3, {ARG_INT, ARG_INT, ARG_INT}},
|
||||
{"set_car_intface_art", sf_set_car_intface_art, 1, 1, {ARG_INT}},
|
||||
{"set_cursor_mode", sf_set_cursor_mode, 1, 1, {ARG_INT}},
|
||||
{"set_drugs_data", sf_set_drugs_data, 3, 3, {ARG_INT, ARG_INT, ARG_INT}},
|
||||
{"set_dude_obj", sf_set_dude_obj, 1, 1, {ARG_OBJECT}},
|
||||
{"set_flags", sf_set_flags, 2, 2, {ARG_OBJECT, ARG_INT}},
|
||||
{"set_iface_tag_text", sf_set_iface_tag_text, 3, 3, {ARG_INT, ARG_STRING, ARG_INT}},
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "..\..\..\FalloutEngine\Fallout2.h"
|
||||
#include "..\..\Combat.h"
|
||||
#include "..\..\Drugs.h"
|
||||
#include "..\..\Explosions.h"
|
||||
#include "..\..\Inventory.h"
|
||||
#include "..\..\LoadGameHook.h"
|
||||
@@ -499,5 +500,24 @@ void sf_get_object_ai_data(OpcodeContext& ctx) {
|
||||
ctx.setReturn(value, DataType::INT);
|
||||
}
|
||||
|
||||
void sf_set_drugs_data(OpcodeContext& ctx) {
|
||||
int type = ctx.arg(0).rawValue();
|
||||
int pid = ctx.arg(1).rawValue();
|
||||
int val = ctx.arg(2).rawValue();
|
||||
int result;
|
||||
switch (type) {
|
||||
case 0:
|
||||
result = Drugs::SetDrugNumEffect(pid, val);
|
||||
break;
|
||||
case 1:
|
||||
result = Drugs::SetDrugAddictTimeOff(pid, val);
|
||||
break;
|
||||
default:
|
||||
ctx.printOpcodeError("set_drugs_data() - invalid value for type argument.");
|
||||
return;
|
||||
}
|
||||
if (result) ctx.printOpcodeError("set_drugs_data() - drug PID not found in the configuration file.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,5 +107,7 @@ void sf_set_object_data(OpcodeContext&);
|
||||
|
||||
void sf_get_object_ai_data(OpcodeContext&);
|
||||
|
||||
void sf_set_drugs_data(OpcodeContext&);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user