mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed bug and added description for new scripting function #17
This commit is contained in:
@@ -390,6 +390,10 @@ Some utility/math functions are available:
|
|||||||
> object sfall_func0("outlined_object")
|
> object sfall_func0("outlined_object")
|
||||||
- returns an object that is currently highlighted by hovering the mouse above it
|
- returns an object that is currently highlighted by hovering the mouse above it
|
||||||
|
|
||||||
|
> object sfall_func1("set_dude_obj", critter)
|
||||||
|
- take control of a given critter
|
||||||
|
- passing 0 will reset control back to "real" dude
|
||||||
|
|
||||||
|
|
||||||
------------------------
|
------------------------
|
||||||
------ MORE INFO -------
|
------ MORE INFO -------
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ static void SaveRealDudeState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// take control of the NPC
|
// take control of the NPC
|
||||||
static void TakeControlOfNPC(fo::GameObject* npc) {
|
static void SetCurrentDude(fo::GameObject* npc) {
|
||||||
// remove skill tags
|
// remove skill tags
|
||||||
long tagSkill[4];
|
long tagSkill[4];
|
||||||
std::fill(std::begin(tagSkill), std::end(tagSkill), -1);
|
std::fill(std::begin(tagSkill), std::end(tagSkill), -1);
|
||||||
@@ -146,6 +146,8 @@ static void TakeControlOfNPC(fo::GameObject* npc) {
|
|||||||
|
|
||||||
// restores the real dude state
|
// restores the real dude state
|
||||||
static void RestoreRealDudeState() {
|
static void RestoreRealDudeState() {
|
||||||
|
assert(real_dude != nullptr);
|
||||||
|
|
||||||
fo::var::obj_dude = real_dude;
|
fo::var::obj_dude = real_dude;
|
||||||
fo::var::inven_dude = real_dude;
|
fo::var::inven_dude = real_dude;
|
||||||
|
|
||||||
@@ -173,7 +175,6 @@ static void RestoreRealDudeState() {
|
|||||||
|
|
||||||
SetInventoryCheck(false);
|
SetInventoryCheck(false);
|
||||||
isControllingNPC = false;
|
isControllingNPC = false;
|
||||||
real_dude = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return values: 0 - use vanilla handler, 1 - skip vanilla handler, return 0 (normal status), -1 - skip vanilla, return -1 (game ended)
|
// return values: 0 - use vanilla handler, 1 - skip vanilla handler, return 0 (normal status), -1 - skip vanilla, return -1 (game ended)
|
||||||
@@ -181,7 +182,7 @@ static int _stdcall CombatWrapperInner(fo::GameObject* obj) {
|
|||||||
if ((obj != fo::var::obj_dude) && (allowedCritterPids.size() == 0 || IsInPidList(obj)) && (controlMode == 1 || fo::func::isPartyMember(obj))) {
|
if ((obj != fo::var::obj_dude) && (allowedCritterPids.size() == 0 || IsInPidList(obj)) && (controlMode == 1 || fo::func::isPartyMember(obj))) {
|
||||||
// save "real" dude state
|
// save "real" dude state
|
||||||
SaveRealDudeState();
|
SaveRealDudeState();
|
||||||
TakeControlOfNPC(obj);
|
SetCurrentDude(obj);
|
||||||
|
|
||||||
// Do combat turn
|
// Do combat turn
|
||||||
int turnResult = fo::func::combat_turn(obj, 1);
|
int turnResult = fo::func::combat_turn(obj, 1);
|
||||||
@@ -322,7 +323,7 @@ void PartyControl::SwitchToCritter(fo::GameObject* critter) {
|
|||||||
SaveRealDudeState();
|
SaveRealDudeState();
|
||||||
}
|
}
|
||||||
if (critter != nullptr && critter != real_dude) {
|
if (critter != nullptr && critter != real_dude) {
|
||||||
TakeControlOfNPC(critter);
|
SetCurrentDude(critter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user