Skip to content

Commit

Permalink
Merge pull request #414 from doug1234/master
Browse files Browse the repository at this point in the history
Change charge distance to 10 feet.
  • Loading branch information
doug1234 authored Aug 21, 2020
2 parents 03ef626 + 20d022d commit 43643d4
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 4 deletions.
51 changes: 49 additions & 2 deletions TemplePlus/action_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ static class ActnSeqReplacements : public TempleFix
return actSeqSys.PerformOnAnimComplete(obj, animId);
}

static unsigned int ChargeAttackAddToSeq(D20Actn* d20a, ActnSeq* actSeq, TurnBasedStatus* tbStat)
{
return actSeqSys.ChargeAttackAddToSeq(d20a, actSeq, tbStat);
}

static void TurnStart(objHndl obj);

static void(__cdecl*orgTurnStart)(objHndl obj);



static ActionErrorCode AddToSeqSimple(D20Actn*, ActnSeq*, TurnBasedStatus*);
static ActionErrorCode AddToSeqWithTarget(D20Actn*, ActnSeq*, TurnBasedStatus*);

Expand All @@ -153,6 +159,8 @@ static class ActnSeqReplacements : public TempleFix
replaceFunction(0x100999E0, GreybarReset);
replaceFunction(0x10099CF0, PerformOnAnimComplete);

replaceFunction(0x100959B0, ChargeAttackAddToSeq);

replaceFunction<void(__cdecl)(objHndl)>(0x100934E0, [](objHndl handle)
{
actSeqSys.ActionTypeAutomatedSelection(handle);
Expand All @@ -168,8 +176,6 @@ int(__cdecl* ActnSeqReplacements::orgChooseTargetCallback)(void * );
int(__cdecl* ActnSeqReplacements::orgSeqRenderFuncMove) (D20Actn* d20a, UiIntgameTurnbasedFlags flags);
void(__cdecl* ActnSeqReplacements::orgTurnStart)(objHndl obj);



#pragma region Action Sequence System Implementation

ActionSequenceSystem actSeqSys;
Expand Down Expand Up @@ -2895,6 +2901,47 @@ int ActionSequenceSystem::ActionFrameProcess(objHndl obj)
return actFrameFunc(d20a);
}

unsigned int ActionSequenceSystem::ChargeAttackAddToSeq(D20Actn* d20a, ActnSeq* actSeq, TurnBasedStatus* tbStat)
{
if (!d20a->d20ATarget.handle) return AEC_TARGET_INVALID;

if (tbStat->tbsFlags & (TBSF_Movement | TBSF_1))
{
return AEC_ALREADY_MOVED;
}

auto mainWeapon = inventory.ItemWornAt(d20a->d20APerformer, EquipSlot::WeaponPrimary);
if (inventory.IsRangedWeapon(mainWeapon)) {
return AEC_NEED_MELEE_WEAPON;
}

const auto reach = critterSys.GetReach(d20a->d20APerformer, d20a->d20ActType);
const auto distance = locSys.DistanceToObj(d20a->d20APerformer, d20a->d20ATarget);
if (distance <= (reach + 5.0)) //The "+ 5.0" is new to requre 10 feet distance for a charge
{
return AEC_TARGET_TOO_CLOSE;
}

//New: Can't charge if fatigued or exhaused
const auto fatigued = d20Sys.D20QueryPython(d20a->d20APerformer, "Fatigued");
const auto exhausted = d20Sys.D20QueryPython(d20a->d20APerformer, "Exhausted");
if (fatigued != 0 || exhausted != 0) {
return AEC_INVALID_ACTION;
}

D20Actn d20aNew(*d20a);
d20aNew.d20ActType = D20A_UNSPECIFIED_MOVE;
d20aNew.d20Caf |= D20CAF_CHARGE | D20CAF_FREE_ACTION;
d20aNew.destLoc = objects.GetLocationFull(d20a->d20ATarget);
const auto result = MoveSequenceParse(&d20aNew, actSeq, tbStat, 0.0, reach, 1);

if (!result) {
memcpy(&actSeq->d20ActArray[actSeq->d20ActArrayNum++], &d20aNew, sizeof(D20Actn));
}

return result;
}

void ActionSequenceSystem::PerformOnAnimComplete(objHndl obj, int animId)
{
// do checks:
Expand Down
1 change: 1 addition & 0 deletions TemplePlus/action_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ struct ActionSequenceSystem : temple::AddressTable
int ActionFrameProcess(objHndl obj);
void PerformOnAnimComplete(objHndl obj, int animId); // runs any actions that need to be run when the animation finishes

unsigned int ChargeAttackAddToSeq(D20Actn* d20a, ActnSeq* actSeq, TurnBasedStatus* tbStat);

bool projectileCheckBeforeNextAction();
uint32_t ShouldTriggerCombat(ActnSeq* actSeq);
Expand Down
Binary file modified tpdata/co8infra.dat
Binary file not shown.
Binary file modified tpdata/tpgamefiles.dat
Binary file not shown.
41 changes: 41 additions & 0 deletions tpdatasrc/tpgamefiles/scr/Spell566 - Harm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from toee import *

def OnBeginSpellCast( spell ):
print "Harm OnBeginSpellCast"
print "spell.target_list=", spell.target_list
print "spell.caster=", spell.caster, " caster.level= ", spell.caster_level
game.particles( "sp-necromancy-conjure", spell.caster )

def OnSpellEffect( spell ):
print "Harm OnSpellEffect"

target = spell.target_list[0]

# check if target is friendly (willing target)
if target.obj.is_friendly( spell.caster ):
if not target.obj.is_category_type( mc_type_undead ):
# Harm target
target.obj.condition_add_with_args( 'sp-Harm', spell.id, spell.duration, 0 )
else:
# Heal undead
target.obj.condition_add_with_args( 'sp-Heal', spell.id, spell.duration, 0 )

else:
attack_result = spell.caster.perform_touch_attack(target.obj, 1)
if attack_result & D20CAF_HIT:
# check if target is undead
if not target.obj.is_category_type( mc_type_undead ):
target.obj.condition_add_with_args( 'sp-Harm', spell.id, spell.duration, 0 )
else:
target.obj.condition_add_with_args( 'sp-Heal', spell.id, spell.duration, 0 )

game.particles( 'sp-Harm', target.obj )

spell.target_list.remove_target( target.obj )
spell.spell_end( spell.id )

def OnBeginRound( spell ):
print "Harm OnBeginRound"

def OnEndSpellCast( spell ):
print "Harm OnEndSpellCast"
3 changes: 1 addition & 2 deletions tpdatasrc/tpgamefiles/scr/tpModifiers/fatigue_exhaustion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from utilities import *
print "Registering fatigue_exhaust"

# Note: Not currently supporting no run or charge for fatigue as per SRD. This is the same
# as barbarian fatigue previously worked.
# Note: Not current disabling run when fatigued. Charge will be correctly disabled.

def FatigueOnAdd(attachee, args, evt_obj):
partSys = game.particles("Barbarian Fatigue", attachee )
Expand Down

0 comments on commit 43643d4

Please sign in to comment.