From d6fa707f2fde1fe3f120feafa3a024ed19d1bec6 Mon Sep 17 00:00:00 2001 From: doug1234 Date: Tue, 30 Jan 2018 21:39:03 -0500 Subject: [PATCH 1/6] I added the TurnUndead condition to the conditions object so it could be used in python. The logic in also needed to be fixed in d20 status in order to work correctly. I also added a message for when a condition is not found by extend existing. --- TemplePlus/condition.cpp | 3 ++- TemplePlus/d20_status.cpp | 23 +++++------------------ TemplePlus/python/python_dispatcher.cpp | 10 ++++++++-- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/TemplePlus/condition.cpp b/TemplePlus/condition.cpp index 38bd8b3f0..13d99db23 100644 --- a/TemplePlus/condition.cpp +++ b/TemplePlus/condition.cpp @@ -1905,6 +1905,7 @@ void _FeatConditionsRegister() conds.hashmethods.CondStructAddToHashtable(conds.ConditionFightDefensively); conds.hashmethods.CondStructAddToHashtable(conds.ConditionAnimalCompanionAnimal); conds.hashmethods.CondStructAddToHashtable(conds.ConditionAutoendTurn); + conds.hashmethods.CondStructAddToHashtable(conds.ConditionTurnUndead); // Craft Wand @@ -2243,7 +2244,7 @@ void ConditionSystem::RegisterNewConditions() DispatcherHookInit((CondStructNew*)ConditionTurnUndead, 6, dispTypeD20ActionPerform, DK_D20A_DIVINE_MIGHT, CondArgDecrement, 1, 0); // decrement the number of turn charges remaining; DispatcherHookInit((CondStructNew*)ConditionGreaterTurning, 6, dispTypeD20ActionPerform, DK_D20A_DIVINE_MIGHT, CondArgDecrement, 1, 0); // decrement the number of turn charges remaining - + // Divine Might Bonus (gets activated when you choose the action from the Radial Menu) mCondDivineMightBonus = &condDivineMightBonus; cond = mCondDivineMightBonus; condName = mCondDivineMightBonusName; diff --git a/TemplePlus/d20_status.cpp b/TemplePlus/d20_status.cpp index 9fb325e27..3f931d191 100644 --- a/TemplePlus/d20_status.cpp +++ b/TemplePlus/d20_status.cpp @@ -75,13 +75,10 @@ void D20StatusSystem::initClass(objHndl objHnd){ _D20StatusInitDomains(objHnd); } - if (feats.HasFeatCountByClass(objHnd, FEAT_REBUKE_UNDEAD)){ + if (feats.HasFeatCountByClass(objHnd, FEAT_REBUKE_UNDEAD)) { _ConditionAddToAttribs_NumArgs2(dispatcher, conds.GetByName("Turn Undead"), 1, 0); - } - - if (objects.StatLevelGet(objHnd, stat_level_paladin) >= 3) - { - _ConditionAddToAttribs_NumArgs0(dispatcher, conds.GetByName("Turn Undead")); + } else if (feats.HasFeatCountByClass(objHnd, FEAT_TURN_UNDEAD)) { + _ConditionAddToAttribs_NumArgs2(dispatcher, conds.GetByName("Turn Undead"), 0, 0); } if (objects.StatLevelGet(objHnd, stat_level_bard) >= 1){ @@ -211,7 +208,7 @@ void D20StatusSystem::initDomains(objHndl objHnd) uint32_t arg2 = *(conds.ConditionArrayDomainsArg2 + 3 * domain_1); if (condStructDomain1 != nullptr) { - _ConditionAddToAttribs_NumArgs2(dispatcher, condStructDomain1, arg1, arg2); + _ConditionAddToAttribs_NumArgs2(dispatcher, condStructDomain1, arg1, arg2); } } @@ -222,19 +219,9 @@ void D20StatusSystem::initDomains(objHndl objHnd) uint32_t arg2 = *(conds.ConditionArrayDomainsArg2 + 3 * domain_2); if (condStructDomain2 != nullptr) { - _ConditionAddToAttribs_NumArgs2(dispatcher, condStructDomain2, arg1, arg2); + _ConditionAddToAttribs_NumArgs2(dispatcher, condStructDomain2, arg1, arg2); } } - - auto alignmentchoice = objects.getInt32(objHnd, obj_f_critter_alignment_choice); - if (alignmentchoice == 2) - { - _ConditionAddToAttribs_NumArgs2(dispatcher, conds.ConditionTurnUndead, 1, 0); - } - else - { - _ConditionAddToAttribs_NumArgs2(dispatcher, conds.ConditionTurnUndead, 0, 0); - } } void D20StatusSystem::initFeats(objHndl objHnd) diff --git a/TemplePlus/python/python_dispatcher.cpp b/TemplePlus/python/python_dispatcher.cpp index cdc10a2fe..9b176d2a2 100644 --- a/TemplePlus/python/python_dispatcher.cpp +++ b/TemplePlus/python/python_dispatcher.cpp @@ -153,13 +153,19 @@ PYBIND11_EMBEDDED_MODULE(tpdp, m) { .def_readwrite("name", &CondStructNew::condName) .def("extend_existing", [](CondStructNew &condStr, std::string condName){ auto cond = (CondStructNew*)conds.GetByName(condName); - if (cond){ - for (auto i = 0; i < 100 && cond->subDispDefs[i].dispType != 0; i++){ + if (cond) { + for (auto i = 0; i < 100 && cond->subDispDefs[i].dispType != 0; i++) { condStr.subDispDefs[condStr.numHooks++] = cond->subDispDefs[i]; } condStr.numArgs = cond->numArgs; condStr.condName = cond->condName; condStr.Register(); + } else { + std::stringstream s; + s << "Extend Existing Error: Condition "; + s << condName; + s << " does not exist!"; + logger->info(s.str().c_str()); } }) .def("add_item_force_remove_callback", [](CondStructNew &condStr){ From de0d58f1ea8ea5fad119f06ffa4dd63b50500ec5 Mon Sep 17 00:00:00 2001 From: doug1234 Date: Tue, 30 Jan 2018 22:37:20 -0500 Subject: [PATCH 2/6] Added extra rage. --- TemplePlus/d20_status.cpp | 4 ++++ .../tpgamefiles/rules/feats/extra rage.txt | 5 +++++ .../tpgamefiles/scr/feats/feat - Extra Rage.py | 10 ++++++++++ .../tpgamefiles/scr/tpModifiers/extra_rage.py | 18 ++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 tpdatasrc/tpgamefiles/rules/feats/extra rage.txt create mode 100644 tpdatasrc/tpgamefiles/scr/feats/feat - Extra Rage.py create mode 100644 tpdatasrc/tpgamefiles/scr/tpModifiers/extra_rage.py diff --git a/TemplePlus/d20_status.cpp b/TemplePlus/d20_status.cpp index 3f931d191..35f57e924 100644 --- a/TemplePlus/d20_status.cpp +++ b/TemplePlus/d20_status.cpp @@ -81,6 +81,10 @@ void D20StatusSystem::initClass(objHndl objHnd){ _ConditionAddToAttribs_NumArgs2(dispatcher, conds.GetByName("Turn Undead"), 0, 0); } + if (feats.HasFeatCountByClass(objHnd, FEAT_BARBARIAN_RAGE)) { + _ConditionAddToAttribs_NumArgs2(dispatcher, conds.GetByName("Barbarian_Rage"), 0, 0); + } + if (objects.StatLevelGet(objHnd, stat_level_bard) >= 1){ _ConditionAddToAttribs_NumArgs0(dispatcher, conds.GetByName("Bardic Music")); } diff --git a/tpdatasrc/tpgamefiles/rules/feats/extra rage.txt b/tpdatasrc/tpgamefiles/rules/feats/extra rage.txt new file mode 100644 index 000000000..8526d9607 --- /dev/null +++ b/tpdatasrc/tpgamefiles/rules/feats/extra rage.txt @@ -0,0 +1,5 @@ +name: Extra Rage +flags: 12582913 +prereqs: +description: You rage two more times per day than you otherwise could. +prereq descr: Barbarian rage ability. \ No newline at end of file diff --git a/tpdatasrc/tpgamefiles/scr/feats/feat - Extra Rage.py b/tpdatasrc/tpgamefiles/scr/feats/feat - Extra Rage.py new file mode 100644 index 000000000..a320033f3 --- /dev/null +++ b/tpdatasrc/tpgamefiles/scr/feats/feat - Extra Rage.py @@ -0,0 +1,10 @@ +from toee import * + + +def CheckPrereq(attachee, classLevelled, abilityScoreRaised): + + #Barbarian Rage Check + if not attachee.has_feat(feat_barbarian_rage): + return 0 + + return 1 diff --git a/tpdatasrc/tpgamefiles/scr/tpModifiers/extra_rage.py b/tpdatasrc/tpgamefiles/scr/tpModifiers/extra_rage.py new file mode 100644 index 000000000..ae3dab9f9 --- /dev/null +++ b/tpdatasrc/tpgamefiles/scr/tpModifiers/extra_rage.py @@ -0,0 +1,18 @@ +#Extra Rage: Complete Warrior, p. 98 + +from templeplus.pymod import PythonModifier +from toee import * +import tpdp + +print "Registering Extra Rage" + +def ExtraRageNewDay(attachee, args, evt_obj): + ExtraRageCount = attachee.has_feat("Extra Rage") + + #Extra Rage grands 2 additional uses or rage each time the feat is taken + args.set_arg(0, args.get_arg(0) + 2 * ExtraRageCount) + return 0 + +extendRageFeat = PythonModifier() +extendRageFeat.ExtendExisting("Barbarian_Rage") +extendRageFeat.AddHook(ET_OnNewDay, EK_NEWDAY_REST, ExtraRageNewDay, ()) From f0a85289ec872c85f070e28a08b9416d1402dfb9 Mon Sep 17 00:00:00 2001 From: doug1234 Date: Fri, 2 Feb 2018 22:30:03 -0500 Subject: [PATCH 3/6] Fixed nasty typo that would cause crashes using python actions (and some others). --- TemplePlus/d20_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TemplePlus/d20_defs.h b/TemplePlus/d20_defs.h index 43eca5683..24a0d5710 100644 --- a/TemplePlus/d20_defs.h +++ b/TemplePlus/d20_defs.h @@ -334,7 +334,7 @@ static const char *d20ActionNames[] = { "D20A_OPEN_CONTAINER", "D20A_THROW", "D20A_THROW_GRENADE", - "D20A_FEINT," + "D20A_FEINT", "D20A_READY_SPELL", "D20A_READY_COUNTERSPELL", "D20A_READY_ENTER", From 73b2a999402f4091d8250781eb06aa5dea8c922a Mon Sep 17 00:00:00 2001 From: doug1234 Date: Fri, 2 Feb 2018 22:43:30 -0500 Subject: [PATCH 4/6] Now using the logger's formatting. --- TemplePlus/python/python_dispatcher.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/TemplePlus/python/python_dispatcher.cpp b/TemplePlus/python/python_dispatcher.cpp index 9b176d2a2..ee1bca5df 100644 --- a/TemplePlus/python/python_dispatcher.cpp +++ b/TemplePlus/python/python_dispatcher.cpp @@ -161,11 +161,7 @@ PYBIND11_EMBEDDED_MODULE(tpdp, m) { condStr.condName = cond->condName; condStr.Register(); } else { - std::stringstream s; - s << "Extend Existing Error: Condition "; - s << condName; - s << " does not exist!"; - logger->info(s.str().c_str()); + logger->info("Extend Existing Error: Condition {} does not exist!", condName); } }) .def("add_item_force_remove_callback", [](CondStructNew &condStr){ From 7bc50b2e68cf9dadfd6a32c2c34e2998df3a9d3d Mon Sep 17 00:00:00 2001 From: doug1234 Date: Fri, 2 Feb 2018 23:01:10 -0500 Subject: [PATCH 5/6] Added prereq text for the feat. --- tpdatasrc/tpgamefiles/rules/feats/extend rage.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tpdatasrc/tpgamefiles/rules/feats/extend rage.txt b/tpdatasrc/tpgamefiles/rules/feats/extend rage.txt index 162fbb507..1f5f8f6d7 100644 --- a/tpdatasrc/tpgamefiles/rules/feats/extend rage.txt +++ b/tpdatasrc/tpgamefiles/rules/feats/extend rage.txt @@ -1,4 +1,5 @@ name: Extend Rage -flags: 12582912 +flags: 12582913 prereqs: -description: Each of your rages lasts 5 rounds longer than its normal duration. \ No newline at end of file +description: Each of your rages lasts 5 rounds longer than its normal duration. +prereq descr: Barbarian rage ability. \ No newline at end of file From 43fb2d8be09044698680f0f218d56b9510992bd2 Mon Sep 17 00:00:00 2001 From: doug1234 Date: Wed, 7 Feb 2018 21:59:36 -0500 Subject: [PATCH 6/6] Now calling D20StatusRefresh at the end of FinishBtnMsg() so that obj_f_critter_alignment_choice will be correct during the refresh. --- TemplePlus/ui/ui_char_editor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TemplePlus/ui/ui_char_editor.cpp b/TemplePlus/ui/ui_char_editor.cpp index a0b3c8525..f37483a27 100644 --- a/TemplePlus/ui/ui_char_editor.cpp +++ b/TemplePlus/ui/ui_char_editor.cpp @@ -1531,7 +1531,10 @@ BOOL UiCharEditor::FinishBtnMsg(int widId, TigMsg * msg){ if ( spellcastCond.size() ){ conds.AddTo(charEdited, spellcastCond, {0,0,0,0, 0,0,0,0}); } - + + // Final refresh once alignment_choice has been set + d20StatusSys.D20StatusRefresh(charEdited); + return 1; }