Fixed bug and added description for new scripting function #17

This commit is contained in:
phobos2077
2017-03-27 00:58:06 +07:00
parent 4e3168e2e3
commit 897f1ab323
2 changed files with 9 additions and 4 deletions
@@ -390,6 +390,10 @@ Some utility/math functions are available:
> object sfall_func0("outlined_object")
- 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 -------
+5 -4
View File
@@ -92,7 +92,7 @@ static void SaveRealDudeState() {
}
// take control of the NPC
static void TakeControlOfNPC(fo::GameObject* npc) {
static void SetCurrentDude(fo::GameObject* npc) {
// remove skill tags
long tagSkill[4];
std::fill(std::begin(tagSkill), std::end(tagSkill), -1);
@@ -146,6 +146,8 @@ static void TakeControlOfNPC(fo::GameObject* npc) {
// restores the real dude state
static void RestoreRealDudeState() {
assert(real_dude != nullptr);
fo::var::obj_dude = real_dude;
fo::var::inven_dude = real_dude;
@@ -173,7 +175,6 @@ static void RestoreRealDudeState() {
SetInventoryCheck(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)
@@ -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))) {
// save "real" dude state
SaveRealDudeState();
TakeControlOfNPC(obj);
SetCurrentDude(obj);
// Do combat turn
int turnResult = fo::func::combat_turn(obj, 1);
@@ -322,7 +323,7 @@ void PartyControl::SwitchToCritter(fo::GameObject* critter) {
SaveRealDudeState();
}
if (critter != nullptr && critter != real_dude) {
TakeControlOfNPC(critter);
SetCurrentDude(critter);
}
}