Skip to content

Commit

Permalink
Formatting code in Karma.cpp/Worldmap.cpp modules. Updated other file…
Browse files Browse the repository at this point in the history
…s (for release).
  • Loading branch information
FakelsHub committed Jan 8, 2019
1 parent fb8c597 commit 9609dd0
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 86 deletions.
10 changes: 5 additions & 5 deletions artifacts/config_files/elevators.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
;Controls the elevators
;Image must match up with the image of an existing elevator (relevant for olds sfall 4.1.3 and below)
;Image must match up with the image of an existing elevator (can be overrided in sfall 4.1.4 or newer)
;Make sure you specify the correct number of exit targets
;The maximum number of elevators is currently capped at 50
;Use the index numbers of frm images from intrface.lst to set the appearance of the elevator
;Use the line number (0-indexed) of the corresponding FRM in intrface.lst to set the appearance of the elevator

;Override elevator 0
[0]
Expand All @@ -26,14 +26,14 @@ Tile3=12944

;No forth exit point

;Overrides frm images for 0 elevator
;Override FRM images of elevator 0. Set ButtonsFrm to -1 to use default buttons from MainFrm
MainFrm=143
ButtonsFrm=-1


;An example of a new elevator
[24]
;Set image 24 to create a new type of elevator
;Set Image to 24 to create a new elevator type (0-23 are the original elevator types)
Image=24

;Set the number of buttons
Expand All @@ -43,4 +43,4 @@ ButtonCount=3
MainFrm=148
ButtonsFrm=151

;Set the points exit elevator for all three buttons (see examples above)
;Set up the exit points for all three buttons (see examples above)
4 changes: 2 additions & 2 deletions artifacts/ddraw.ini
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ CreditsAtBottom=0
;at the end of its turn expending its action points
ItemPickUpFix=1

;Set to 1 to fix the behavior of the NPC in an attempt to change its weapon when its action points are zero
SwitchWeaponFix=1
;Set to 1 to prevent switching NPC's weapon at end of turn when its action points are zero
NPCSwitchingWeaponFix=1

;Set to 1, to the NPC to always switch to the best weapon available in his inventory
;Set to 2 will allow the NPC to always pick up the best weapons on the ground within its reach
Expand Down
1 change: 1 addition & 0 deletions artifacts/scripting/headers/sfall.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#define HOOK_USESKILLON (35)
#define HOOK_ONEXPLOSION (36)
#define HOOK_SUBCOMBATDAMAGE (37)
#define HOOK_SETLIGHTING (38)

//Valid arguments to list_begin
#define LIST_CRITTERS (0)
Expand Down
32 changes: 16 additions & 16 deletions artifacts/scripting/sfall function notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ set_fake_trait and set_fake_perk can be used to add additional traits and perks

has_fake_trait and has_fake_perk return the number of levels the player has of the perks/traits with the given name.

perk_add_mode, set_selectable_perk, set_perkbox_title, hide_real_perks, show_real_perks and clear_selectable_perks control the behaviour of the select a perk box. set_selectable_perk can be used to add additional items by setting the 'active' parameter to 1, and to remove them again by setting it to 0. set_perkbox_title can be used to change the title of the box, or by using "" it will be set back to the default. hide and show_real_perks can be used to prevent the dialog from displaying any of the original 119 perks. perk_add_mode modifies what happens when a fake perk is selected from the perks dialog. It is treated as a set of flags - if bit 1 is set then it is added to the players traits, if bit 2 is set it is added to the players perks, and if bit 3 is set it is removed from the list of selectable perks. The default is 0x2. clear_selectable_perks restores the dialog to it's default state.
perk_add_mode, set_selectable_perk, set_perkbox_title, hide_real_perks, show_real_perks and clear_selectable_perks control the behaviour of the select a perk box. set_selectable_perk can be used to add additional items by setting the 'active' parameter to 1, and to remove them again by setting it to 0. set_perkbox_title can be used to change the title of the box, or by using "" it will be set back to the default. hide and show_real_perks can be used to prevent the dialog from displaying any of the original 119 perks. perk_add_mode modifies what happens when a fake perk is selected from the perks dialog. It is treated as a set of flags - if bit 1 is set then it is added to the players traits, if bit 2 is set it is added to the players perks, and if bit 3 is set it is removed from the list of selectable perks. The default is 0x2. clear_selectable_perks restores the dialog to its default state.

show_iface_tag, hide_iface_tag and is_iface_tag_active relate to the boxes that appear above the interface such as SNEAK and LEVEL. You can use 3 for LEVEL and 4 for ADDICT, or the range from 5 to (4 + the value of BoxBarCount in ddraw.ini) for custom boxes. Remember to add your messages to intrface.msg and set up the font colours in ddraw.ini if you're going to use custom boxes. Starting from sfall 4.1, is_iface_tag_active can also be used to check 0 for SNEAK, 1 for POISONED, and 2 for RADIATED.

Expand Down Expand Up @@ -98,7 +98,7 @@ array - array ID to be used with array-related functions (actually an integer)
----------------------------------------------

> int game_loaded()
- returns 1 the first time it is called after a new game or game load, and 0 any time after. It works on an individual basis for each script, so one script wont interfere with others. It's primary use is for global scripts, so that they know when to call set_global_script_repeat, but it can be called from normal scripts too.
- returns 1 the first time it is called after a new game or game load, and 0 any time after. It works on an individual basis for each script, so one script wont interfere with others. Its primary use is for global scripts, so that they know when to call set_global_script_repeat, but it can be called from normal scripts too.

> void inc_npc_level(string npc)
- takes an NPC name as an argument. The NPC must be in your party. This function ignores player level requirements and the minimum 3 player level delay between NPC level gains. It also ignores the random element, regardless of sfall's NPCAutoLevel setting.
Expand Down Expand Up @@ -223,13 +223,13 @@ was made as a dirty easy hack to allow dynamically change some explosion paramet
- currently y is not used and x means: 1 - reduced explosion pattern (3 effects are spawned instead of 7), 0 - full pattern

> void set_attack_explosion_art(x, y)
- y not used and x is a misc frame ID (last 3 bytes, without object type) to use for the next explosion.
- y is not used and x is a misc frame ID (last 3 bytes, without object type) to use for the next explosion.

> void set_attack_explosion_radius(x)
- changes radius at which explosion will hit secondary targets for the next attack (from the experiments it is limited to something around 8 by the engine)

> void set_attack_is_explosion_fire
- if you call this right before using a weapon with fire damage type, it will produce explosion effects (and radius damage) just like "explosion" type, but all targets will still receive fire damage.
- if you call this right before using a weapon with fire damage type (e.g. in HOOK_AFTERHITROLL), it will produce explosion effects (and radius damage) just like "explosion" type, but all targets will still receive fire damage.

> void set_explosion_radius(grenade, rocket)
- sets a permanent radius of the explosion for grenades and/or rockets. Passing 0 means not changing the corresponding radius.
Expand All @@ -239,15 +239,16 @@ was made as a dirty easy hack to allow dynamically change some explosion paramet
- returns array of the minimum and maximum damage of the explosive item.

> void set_dynamite_damage(minDmg, maxDmg)
- sets the minimum and maximum damage for an explosion of dynamite.
- set damage values will not be reset after an attack.
- sets the minimum and maximum damage for Dynamite.
- changed damage will be reset each time the player reloads the game.

> void set_plastic_damage(minDmg, maxDmg)
- sets the minimum and maximum damage for an explosion of plastic explosive.
- set damage values will not be reset after an attack.
- sets the minimum and maximum damage for Plastic Explosives.
- changed damage will be reset each time the player reloads the game.

> void set_explosion_max_targets(x)
- sets the maximum count of targets for an explosion, valid range 1-6 (default value is 6).
- sets the maximum number of additional targets for an explosion, valid range: 1..6 (default is 6)


Some utility/math functions are available:

Expand Down Expand Up @@ -546,18 +547,17 @@ Some utility/math functions are available:
- passing False to the includeDude argument will ignore dude_obj

> object sfall_func0("loot_obj")
- returns a pointer to the object (container, critter) with which the exchange occurs
- returns a pointer to the target object (container or critter) of the loot screen

> int sfall_func2("get_object_data", object, int offset)
- returns the data of the object at the specified offset (see OBJ_DATA_* constants offsets in define_extra.h)
- returns the data at the specified offset of an object (see OBJ_DATA_* constants in define_extra.h for offsets)

> int sfall_func3("set_object_data", object, int offset, int data)
- sets the data by offset for the specified object
> void sfall_func3("set_object_data", object, int offset, int data)
- sets the data at the specified offset of an object

> int sfall_func2("get_object_ai_data", object, int aiParam)
- returns the setting value from the AI-packet the specified object
- pass the value of the required parameter to the aiParam argument to get AI value (see AI_CAP_* constants in define_extra.h)

- returns the setting value from the AI packet of an object (critter)
- use AI_CAP_* constants from define_extra.h for the aiParam argument to get AI value

------------------------
------ MORE INFO -------
Expand Down
4 changes: 2 additions & 2 deletions sfall/Modules/AI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ void AI::init() {
SafeWrite8(0x4290B5, 0x90);
}

// Fixed an attempt to switching weapons when zero action points
if (GetConfigInt("CombatAI", "SwitchWeaponFix", 0)) {
// Fixed bug switching weapons when action points is zero
if (GetConfigInt("CombatAI", "NPCSwitchingWeaponFix", 0)) {
HookCall(0x42AB57, ai_try_attack_hook_switch_fix);
}

Expand Down
22 changes: 11 additions & 11 deletions sfall/Modules/Karma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static std::string karmaGainMsg;
static std::string karmaLossMsg;
bool displayKarmaChanges;

static DWORD _stdcall DrawCardHook2() {
static DWORD _stdcall DrawCard() {
int reputation = fo::var::game_global_vars[fo::GVAR_PLAYER_REPUTATION];
for (auto& info : karmaFrms) {
if (reputation < info.points) {
Expand All @@ -51,19 +51,19 @@ static DWORD _stdcall DrawCardHook2() {
return karmaFrms.end()->frm;
}

static void __declspec(naked) DrawCardHook() {
static void __declspec(naked) DrawInfoWin_hook() {
__asm {
cmp ds : [FO_VAR_info_line], 10;
jne skip;
cmp eax, 0x30;
jne skip;
cmp ds:[FO_VAR_info_line], 10;
jne skip;
cmp eax, 0x30;
jne skip;
push ecx;
push edx;
call DrawCardHook2;
pop edx;
pop ecx;
call DrawCard;
pop edx;
pop ecx;
skip:
jmp fo::funcoffs::DrawCard_;
jmp fo::funcoffs::DrawCard_;
}
}

Expand Down Expand Up @@ -101,7 +101,7 @@ void ApplyKarmaFRMsPatch() {
? atoi(karmaPointsList[i].c_str())
: INT_MAX;
}
HookCall(0x4367A9, DrawCardHook);
HookCall(0x4367A9, DrawInfoWin_hook);

dlogr(" Done", DL_INIT);
}
Expand Down
98 changes: 49 additions & 49 deletions sfall/Modules/Worldmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ static __declspec(naked) void GetDateWrapper() {
push esi;
push ebx;
call fo::funcoffs::game_time_date_;
mov ecx, ds:[FO_VAR_pc_proto + 0x4C];
pop esi;
mov ecx, ds:[FO_VAR_pc_proto + 0x4C];
pop esi;
test esi, esi;
jz end;
add ecx, [esi];
mov[esi], ecx;
jz end;
add ecx, [esi];
mov [esi], ecx;
end:
pop esi;
pop ecx;
pop esi;
pop ecx;
retn;
}
}
Expand All @@ -71,19 +71,19 @@ static int mapSlotsScrollMax = 27 * (17 - 7);
static __declspec(naked) void ScrollCityListHook() {
__asm {
push ebx;
mov ebx, ds:[0x672F10];
mov ebx, ds:[0x672F10];
test eax, eax;
jl up;
cmp ebx, mapSlotsScrollMax;
je end;
jmp run;
jl up;
cmp ebx, mapSlotsScrollMax;
je end;
jmp run;
up:
test ebx, ebx;
jz end;
jz end;
run:
call fo::funcoffs::wmInterfaceScrollTabsStart_;
end:
pop ebx;
pop ebx;
retn;
}
}
Expand All @@ -95,41 +95,41 @@ static void __stdcall WorldmapLoopHook() {
static DWORD worldMapDelay;
static void __declspec(naked) WorldMapFpsPatch() {
__asm {
pushad;
pushadc;
call WorldmapLoopHook;
mov ecx, worldMapDelay;
mov ecx, worldMapDelay;
tck:
mov eax, ds : [0x50fb08];
mov eax, ds:[0x50fb08];
call fo::funcoffs::elapsed_time_;
cmp eax, ecx;
jl tck;
cmp eax, ecx;
jl tck;
call fo::funcoffs::get_time_;
mov ds : [0x50fb08], eax;
popad;
jmp fo::funcoffs::get_input_;
mov ds:[0x50fb08], eax;
popadc;
jmp fo::funcoffs::get_input_;
}
}

//Only used if the world map speed patch is disabled, so that world map scripts are still run
static void __declspec(naked) WorldMapHook() {
__asm {
pushad;
pushadc;
call WorldmapLoopHook;
popad;
jmp fo::funcoffs::get_input_;
popadc;
jmp fo::funcoffs::get_input_;
}
}

static void __declspec(naked) WorldMapEncPatch1() {
__asm {
inc dword ptr ds : [FO_VAR_wmLastRndTime]
inc dword ptr ds:[FO_VAR_wmLastRndTime];
jmp fo::funcoffs::wmPartyWalkingStep_;
}
}

static void __declspec(naked) WorldMapEncPatch2() {
__asm {
mov dword ptr ds : [FO_VAR_wmLastRndTime], 0;
mov dword ptr ds:[FO_VAR_wmLastRndTime], 0;
retn;
}
}
Expand Down Expand Up @@ -160,36 +160,36 @@ static void __declspec(naked) wmRndEncounterOccurred_hack() {
static void __declspec(naked) ViewportHook() {
__asm {
call fo::funcoffs::wmWorldMapLoadTempData_;
mov eax, ViewportX;
mov ds : [FO_VAR_wmWorldOffsetX], eax
mov eax, ViewportY;
mov ds : [FO_VAR_wmWorldOffsetY], eax;
mov eax, ViewportX;
mov ds:[FO_VAR_wmWorldOffsetX], eax;
mov eax, ViewportY;
mov ds:[FO_VAR_wmWorldOffsetY], eax;
retn;
}
}

static void __declspec(naked) wmTownMapFunc_hack() {
__asm {
cmp edx, 0x31
jl end
cmp edx, ecx
jge end
push edx
sub edx, 0x31
lea eax, ds:0[edx*8]
sub eax, edx
pop edx
cmp dword ptr [edi+eax*4+0x0], 0 // Visited
cmp edx, 0x31;
jl end;
cmp edx, ecx;
jge end;
push edx;
sub edx, 0x31;
lea eax, ds:0[edx*8];
sub eax, edx;
pop edx;
cmp dword ptr [edi+eax*4+0x0], 0; // Visited
je end
cmp dword ptr [edi+eax*4+0x4], -1 // Xpos
cmp dword ptr [edi+eax*4+0x4], -1; // Xpos
je end
cmp dword ptr [edi+eax*4+0x8], -1 // Ypos
je end
retn
cmp dword ptr [edi+eax*4+0x8], -1; // Ypos
je end;
retn;
end:
pop eax // destroy the return address
push 0x4C4976
retn
pop eax; // destroy the return address
push 0x4C4976;
retn;
}
}

Expand All @@ -208,7 +208,7 @@ static __declspec(naked) void PathfinderFix3() {
}

static DWORD _stdcall PathfinderFix2(DWORD perkLevel, DWORD ticks) {
double d = MapMulti*MapMulti2;
double d = MapMulti * MapMulti2;
if (perkLevel == 1) d *= 0.75;
else if (perkLevel == 2) d *= 0.5;
else if (perkLevel == 3) d *= 0.25;
Expand Down
2 changes: 1 addition & 1 deletion sfall/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define TARGETVERSION "Fallout 2 v1.02 US"

#define LEGAL_COPYRIGHT "Copyright (C) 2006-2018, sfall team"
#define LEGAL_COPYRIGHT "Copyright (C) 2006-2019, sfall team"

#define VERSION_MAJOR 4
#define VERSION_MINOR 1
Expand Down

0 comments on commit 9609dd0

Please sign in to comment.