Skip to content

Commit

Permalink
Merge pull request #275 from doug1234/master
Browse files Browse the repository at this point in the history
Made Turn Undead accessible to python and added extra rage feat
  • Loading branch information
DudeMcDude authored Feb 8, 2018
2 parents 8fecd8e + 43fb2d8 commit 29817b3
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 23 deletions.
3 changes: 2 additions & 1 deletion TemplePlus/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion TemplePlus/d20_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 7 additions & 16 deletions TemplePlus/d20_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ 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);
} else if (feats.HasFeatCountByClass(objHnd, FEAT_TURN_UNDEAD)) {
_ConditionAddToAttribs_NumArgs2(dispatcher, conds.GetByName("Turn Undead"), 0, 0);
}

if (objects.StatLevelGet(objHnd, stat_level_paladin) >= 3)
{
_ConditionAddToAttribs_NumArgs0(dispatcher, conds.GetByName("Turn Undead"));
if (feats.HasFeatCountByClass(objHnd, FEAT_BARBARIAN_RAGE)) {
_ConditionAddToAttribs_NumArgs2(dispatcher, conds.GetByName("Barbarian_Rage"), 0, 0);
}

if (objects.StatLevelGet(objHnd, stat_level_bard) >= 1){
Expand Down Expand Up @@ -211,7 +212,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);
}
}

Expand All @@ -222,19 +223,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)
Expand Down
6 changes: 4 additions & 2 deletions TemplePlus/python/python_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ 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 {
logger->info("Extend Existing Error: Condition {} does not exist!", condName);
}
})
.def("add_item_force_remove_callback", [](CondStructNew &condStr){
Expand Down
5 changes: 4 additions & 1 deletion TemplePlus/ui/ui_char_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions tpdatasrc/tpgamefiles/rules/feats/extend rage.txt
Original file line number Diff line number Diff line change
@@ -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.
description: Each of your rages lasts 5 rounds longer than its normal duration.
prereq descr: Barbarian rage ability.
5 changes: 5 additions & 0 deletions tpdatasrc/tpgamefiles/rules/feats/extra rage.txt
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions tpdatasrc/tpgamefiles/scr/feats/feat - Extra Rage.py
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions tpdatasrc/tpgamefiles/scr/tpModifiers/extra_rage.py
Original file line number Diff line number Diff line change
@@ -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, ())

0 comments on commit 29817b3

Please sign in to comment.