void UI_DisplayAbilityMessage(AActor* oTarget, int32 nAbility, int32 nDeactivate) { if (!IsPartyMember(oTarget)) { if (nAbility == ABILITY_TALENT_STEALTH) { return; } if (!GetCombatState(oTarget)) { return; } } if (!nDeactivate && (!GetStealthEnabled(oTarget) || IsPartyMember(oTarget))) { if (GetAttributeBool("ShowSpecialMove"))//GetShowSpecialMoveFloaties() { int32 nStringId = GetM2DAInt(TABLE_ABILITIES_SPELLS, "Namestrref", nAbility); FString sDisplay = ""; if (nStringId == 0) { #ifdef DEBUG if (GetDebugHelpersEnabled()) { sDisplay = "?- NO STRINGREF - " + GetM2DAString(TABLE_ABILITIES_SPELLS, "Label", nAbility); } #endif return; } else { sDisplay = GetStringByStringId(nStringId); } /* if(nDeactivate && GetDebugHelpersEnabled()) { // s = "?DEACTIVATING: " + s; }*/ DisplayFloatyMessage(oTarget, sDisplay, FLOATY_MESSAGE, UI_DISPLAY_COLOR_ABILITY, UI_DISPLAY_DURATION_ABILITY); } } }
// take control of the NPC static void TakeControlOfNPC(TGameObj* npc) { // remove skill tags int tagSkill[4]; #if (_MSC_VER < 1600) std::fill(std_begin(tagSkill), std_end(tagSkill), -1); #else std::fill(std::begin(tagSkill), std::end(tagSkill), -1); #endif SkillSetTags(tagSkill, 4); // reset traits ptr_pc_traits[0] = ptr_pc_traits[1] = -1; // reset perks for (int i = 0; i < PERK_count; i++) { (*ptr_perkLevelDataList)[i] = 0; } // change character name CritterPcSetName(CritterName(npc)); // change level int level = IsPartyMember(npc) ? PartyMemberGetCurrentLevel(npc) : 0; *ptr_Level_ = level; *ptr_last_level = level; // reset other stats *ptr_Experience_ = 0; *ptr_free_perk = 0; ptr_curr_pc_stat[0] = 0; *ptr_sneak_working = 0; // deduce active hand by weapon anim code char critterAnim = (npc->artFID & 0xF000) >> 12; // current weapon as seen in hands if (AnimCodeByWeapon(GetInvenWeaponLeft(npc)) == critterAnim) { // definitely left hand.. *ptr_itemCurrentItem = 0; } else { *ptr_itemCurrentItem = 1; } *ptr_inven_pid = npc->pid; // switch main dude_obj pointers - this should be done last! *ptr_obj_dude = npc; *ptr_inven_dude = npc; IsControllingNPC = 1; DelayedExperience = 0; SetInventoryCheck(true); InterfaceRedraw(); }
// return values: 0 - use vanilla handler, 1 - skip vanilla handler, return 0 (normal status), -1 - skip vanilla, return -1 (game ended) static int _stdcall CombatWrapperInner(TGameObj* obj) { if ((obj != *obj_dude_ptr) && (Chars.size() == 0 || IsInPidList(obj)) && (Mode == 1 || IsPartyMember(obj))) { IsControllingNPC = 1; SetInventoryCheck(true); char dudeWeaponSlot = (char)*activeUIHand_ptr; // save "real" dude state real_dude = *obj_dude_ptr; *obj_dude_ptr = obj; *inven_dude_ptr = obj; memcpy(real_traits, dude_traits, sizeof(DWORD)*2); // deduce active hand by weapon anim code char critterAnim = (obj->artFID & 0xF000) >> 12; // current weapon as seen in hands if (AnimCodeByWeapon(GetInvenWeaponLeft(obj)) == critterAnim) { // definitely left hand.. *activeUIHand_ptr = 0; } else { *activeUIHand_ptr = 1; } int turnResult; __asm { call intface_redraw_; mov eax, obj; call combat_turn_; mov turnResult, eax; } // restore state if (IsControllingNPC) { // if game was loaded during turn, PartyControlReset() was called and already restored state *activeUIHand_ptr = dudeWeaponSlot; memcpy(dude_traits, real_traits, sizeof(DWORD)*2); *obj_dude_ptr = real_dude; *inven_dude_ptr = real_dude; __asm { call intface_redraw_; } SetInventoryCheck(false); IsControllingNPC = 0; } // -1 means that combat ended during turn return (turnResult == -1) ? -1 : 1; }
void UI_DisplayMessage(AActor* oTarget, int32 nMessage, FString sParam, int32 nColor) { /* FLOATY_HIT - Rising white number FLOATY_CRITICAL_HIT - Rising white number that grows and turns red FLOATY_MESSAGE - Yellow text (for debugging) */ if (GetM2DAInt(TABLE_UI_MESSAGES, "bDisabled", nMessage)) { #ifdef DEBUG Log_Trace(LOG_CHANNEL_UIMESSAGES, "UI_DisplayMessage " + IntToString(nMessage), "Not showing message " + IntToString(nMessage) + " - bDisabled set.", oTarget); #endif return; } int32 bShow = UI_CheckObjectMask(nMessage, oTarget); if (!bShow) { #ifdef DEBUG Log_Trace(LOG_CHANNEL_UIMESSAGES, "UI_DisplayMessage " + IntToString(nMessage), "Not showing message " + IntToString(nMessage) + " - Object Mask Failed", oTarget); #endif } bShow = bShow && UI_CheckDisplayMask(nMessage, oTarget) && UI_CheckObjectMask(nMessage, oTarget); if (bShow) { int32 nId = GetM2DAInt(TABLE_UI_MESSAGES, "StringId", nMessage); FString sMessage; int32 nType = GetM2DAInt(TABLE_UI_MESSAGES, "Type", nMessage); float fDuration = GetM2DAFloat(TABLE_UI_MESSAGES, "Duration", nMessage); if (fDuration <= 0.2f) { fDuration = UI_DISPLAY_DURATION_DEFAULT; } if (nType == 2 /*debug*/ && !GetDebugHelpersEnabled()) { #ifdef DEBUG Log_Trace(LOG_CHANNEL_UIMESSAGES, "UI_DisplayMessage " + IntToString(nMessage), "Not showing type 2 (debug) message " + IntToString(nMessage) + " - Debug Helpers disabled", oTarget); #endif return; } // ----------------------------------------------------------------- // special messages are defined in the scripted param to this function // ----------------------------------------------------------------- if (nMessage >= UI_MESSAGE_TYPE_SPECIAL) { sMessage = sParam; } else { if (nType == 2 && !LOG_ENABLED) { #ifdef DEBUG Log_Trace(LOG_CHANNEL_UIMESSAGES, "UI_DisplayMessage " + IntToString(nMessage), "Not showing message " + IntToString(nMessage) + " - Debug Type 2 but not log enabled.", oTarget); #endif return; } if (nId == 0) { sMessage = "?" + GetM2DAString(TABLE_UI_MESSAGES, "StringText", nMessage); } else { sMessage = GetStringByStringId(nId); if (sMessage == "") { #ifdef DEBUG LogWarning("String table lookup on UI message failed. Blocking bug to georg. Details:" + IntToString(nMessage) + " strid:" + IntToString(nId)); #endif } } } if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE) { if (GetStealthEnabled(oTarget) && !IsPartyMember(oTarget)) { #ifdef DEBUG Log_Trace(LOG_CHANNEL_UIMESSAGES, "UI_DisplayMessage", "Not showing message: creature stealthy", oTarget); #endif return; } } if (nColor == 0) { nColor = GetM2DAInt(TABLE_UI_MESSAGES, "Color", nMessage); } #ifdef DEBUG Log_Trace(LOG_CHANNEL_UIMESSAGES, "UI_DisplayMessage " + IntToString(nMessage) + " " + IntToHexString(nColor), sMessage, oTarget); #endif if (nType == UI_MESSAGE_TYPE_PORTRAIT) { DisplayPortraitMessage(oTarget, sMessage, nColor); } else if (nType == UI_MESSAGE_TYPE_PORTRAIT_FOLLOWER) { if (IsFollower(oTarget)) { DisplayPortraitMessage(oTarget, sMessage, nColor); } else { DisplayFloatyMessage(oTarget, sMessage, FLOATY_MESSAGE, nColor, fDuration); } } else { if (nMessage == UI_MESSAGE_MISSED || nMessage == UI_MESSAGE_IMMUNE) { DisplayFloatyMessage(oTarget, sMessage, FLOATY_HIT, nColor, fDuration); } else { DisplayFloatyMessage(oTarget, sMessage, FLOATY_MESSAGE, nColor, fDuration); } } } else { #ifdef DEBUG Log_Trace(LOG_CHANNEL_UIMESSAGES, "UI_DisplayMessage", "not showing " + IntToString(nMessage), oTarget); #endif } }