Skip to content

Commit

Permalink
Added new scripting functions to show/hide/redraw main interface and …
Browse files Browse the repository at this point in the history
…to exec map_update_p_proc for all map objects #51
  • Loading branch information
phobos2077 committed Nov 4, 2016
1 parent af4bad3 commit 18b3476
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
9 changes: 5 additions & 4 deletions sfall/FalloutEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ const DWORD intface_update_hit_points_ = 0x45EBD8;
const DWORD intface_update_items_ = 0x45EFEC;
const DWORD intface_update_move_points_ = 0x45EE0C;
const DWORD intface_use_item_ = 0x45F5EC;
const DWORD intface_show_ = 0x45EA10;
const DWORD intface_hide_ = 0x45E9E0;
const DWORD intface_is_hidden_ = 0x45EA5C;
const DWORD invenUnwieldFunc_ = 0x472A64;
const DWORD invenWieldFunc_ = 0x472768;
const DWORD inven_display_msg_ = 0x472D24;
Expand Down Expand Up @@ -735,9 +738,7 @@ int __stdcall ScrPtr(int scriptId, TScript** scriptPtr) {

// redraws the main game interface windows (useful after changing some data like active hand, etc.)
void InterfaceRedraw() {
__asm {
call intface_redraw_
}
__asm call intface_redraw_
}

// pops value type from Data stack (must be followed by InterpretPopLong)
Expand Down Expand Up @@ -823,4 +824,4 @@ TGameObj* __stdcall InvenLeftHand(TGameObj* critter) {
TGameObj* __stdcall InvenRightHand(TGameObj* critter) {
__asm mov eax, critter
__asm call inven_right_hand_
}
}
21 changes: 12 additions & 9 deletions sfall/FalloutEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ extern const DWORD intface_update_hit_points_;
extern const DWORD intface_update_items_;
extern const DWORD intface_update_move_points_;
extern const DWORD intface_use_item_;
extern const DWORD intface_show_;
extern const DWORD intface_hide_;
extern const DWORD intface_is_hidden_;
extern const DWORD invenUnwieldFunc_; // (int critter@<eax>, int slot@<edx>, int a3@<ebx>) - int result (-1 on error, 0 on success)
extern const DWORD invenWieldFunc_; // (int who@<eax>, int item@<edx>, int a3@<ecx>, int slot@<ebx>) - int result (-1 on error, 0 on success)
extern const DWORD inven_display_msg_;
Expand Down Expand Up @@ -864,6 +867,15 @@ void SkillSetTags(int* tags, DWORD num);
// redraws the main game interface windows (useful after changing some data like active hand, etc.)
void InterfaceRedraw();

// critter worn item (armor)
TGameObj* __stdcall InvenWorn(TGameObj* critter);

// item in critter's left hand slot
TGameObj* __stdcall InvenLeftHand(TGameObj* critter);

// item in critter's right hand slot
TGameObj* __stdcall InvenRightHand(TGameObj* critter);

// pops value type from Data stack (must be followed by InterpretPopLong)
DWORD __stdcall InterpretPopShort(TProgram* scriptPtr);

Expand All @@ -889,12 +901,3 @@ void __declspec() DebugPrintf(const char* fmt, ...);

// returns the name of current procedure by program pointer
const char* __stdcall FindCurrentProc(TProgram* program);

// critter worn item (armor)
TGameObj* __stdcall InvenWorn(TGameObj* critter);

// item in critter's left hand slot
TGameObj* __stdcall InvenLeftHand(TGameObj* critter);

// item in critter's right hand slot
TGameObj* __stdcall InvenRightHand(TGameObj* critter);
3 changes: 3 additions & 0 deletions sfall/ScriptExtender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ static void _stdcall PrintOpcodeError(const char* fmt, ...) {
}

// Handle opcodes
// scriptPtr - pointer to script program (from the engine)
// func - opcode handler
// hasReturn - true if opcode has return value (is expression)
static void __stdcall HandleOpcode(TProgram* scriptPtr, void(*func)(), int argNum, bool hasReturn) {
assert(argNum < OP_MAX_ARGUMENTS);

Expand Down
21 changes: 21 additions & 0 deletions sfall/ScriptOps/InterfaceOp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,24 @@ static void __declspec(naked) IsIfaceTagActive() {
retn;
}
}

static void sf_intface_redraw() {
InterfaceRedraw();
}

static void sf_intface_show() {
__asm call intface_show_
}

static void sf_intface_hide() {
__asm call intface_hide_
}

static void sf_intface_is_hidden() {
int isHidden;
__asm {
call intface_is_hidden_
mov isHidden, eax;
}
SetOpReturn(isHidden);
}
5 changes: 5 additions & 0 deletions sfall/ScriptOps/MetaruleOp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ static const SfallMetarule metaruleArray[] = {
{"validate_test", sf_test, 2, 5, {DATATYPE_MASK_INT, DATATYPE_MASK_INT | DATATYPE_MASK_FLOAT, DATATYPE_MASK_STR, DATATYPE_NONE}},
{"spatial_radius", sf_spatial_radius, 1, 1, {DATATYPE_MASK_VALID_OBJ}},
{"critter_inven_obj2", sf_critter_inven_obj2, 2, 2, {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}},
{"intface_redraw", sf_intface_redraw, 0, 0, {}},
{"intface_show", sf_intface_show, 0, 0, {}},
{"intface_hide", sf_intface_hide, 0, 0, {}},
{"intface_is_hidden", sf_intface_is_hidden, 0, 0, {}},
{"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0, {}},
};

static void InitMetaruleTable() {
Expand Down
5 changes: 5 additions & 0 deletions sfall/ScriptOps/MiscOps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1674,3 +1674,8 @@ static void __declspec(naked) op_tile_light() {
_RET_VAL_INT(ebp)
_OP_END
}


static void sf_exec_map_update_scripts() {
__asm call scr_exec_map_update_scripts_
}

0 comments on commit 18b3476

Please sign in to comment.