Skip to content

Commit

Permalink
Added Tolerant Townsfolk houserules option (NPCs will tolerate monstr…
Browse files Browse the repository at this point in the history
…ous party members when conversing)
  • Loading branch information
DudeMcDude committed Aug 12, 2016
1 parent e8460dc commit 6946aa8
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Configurator/HouseRulesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
</StackPanel>
<CheckBox VerticalAlignment="Center" Content="Allow XP overflow" IsChecked="{Binding AllowXpOverflow}" Margin="0,5,0,5" ToolTip="Allows experience points to accumulate beyond the limit of the next level."/>
<CheckBox VerticalAlignment="Center" Content="Slower levelling" IsChecked="{Binding SlowerLevelling}" Margin="0,5,0,5" ToolTip="Adjuts the experience point curve such that you rapidly get to level 3, but level more slowly afterwards. You will be about 1-2 levels behind a normal game."/>
<CheckBox VerticalAlignment="Center" Content="Tolerant Townsfolk" IsChecked="{Binding TolerantTownsfolk}" Margin="0,5,0,5" ToolTip="Townsfolk will be tolerant of monstrous party members and NPCs."/>
<CheckBox VerticalAlignment="Center" Content="Prestige Classes (WIP preview)" IsChecked="{Binding NewClasses}" Margin="0,5,0,5" ToolTip="Enables Prestige Classes. Currently WIP!"/>
</StackPanel>
<Button x:Name="button" Content="Ok" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" Width="75" Click="button_Click"/>
</Grid>
Expand Down
32 changes: 31 additions & 1 deletion Configurator/IniViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public class IniViewModel : DependencyObject
public static readonly DependencyProperty SlowerLevellingProperty = DependencyProperty.Register(
"SlowerLevelling", typeof(bool), typeof(IniViewModel), new PropertyMetadata(default(bool)));

public static readonly DependencyProperty TolerantTownsfolkProperty = DependencyProperty.Register(
"TolerantTownsfolk", typeof(bool), typeof(IniViewModel), new PropertyMetadata(default(bool)));

public static readonly DependencyProperty NewClassesProperty = DependencyProperty.Register(
"NewClasses", typeof(bool), typeof(IniViewModel), new PropertyMetadata(default(bool)));

public IEnumerable<HpOnLevelUpType> HpOnLevelUpTypes => Enum.GetValues(typeof (HpOnLevelUpType))
.Cast<HpOnLevelUpType>();

Expand Down Expand Up @@ -128,7 +134,17 @@ public bool SlowerLevelling
get { return (bool)GetValue(SlowerLevellingProperty); }
set { SetValue(SlowerLevellingProperty, value); }
}


public bool TolerantTownsfolk
{
get { return (bool)GetValue(TolerantTownsfolkProperty); }
set { SetValue(TolerantTownsfolkProperty, value); }
}
public bool NewClasses
{
get { return (bool)GetValue(NewClassesProperty); }
set { SetValue(NewClassesProperty, value); }
}

/// <summary>
/// Tries to find an installation directory based on common locations and the Windows registry.
Expand Down Expand Up @@ -206,6 +222,18 @@ public void LoadFromIni(IniData iniData)
SlowerLevelling = slowerLevelling;
}

bool tolerantTownsfolk;
if (bool.TryParse(tpData["tolerantNpcs"], out tolerantTownsfolk))
{
TolerantTownsfolk = tolerantTownsfolk;
}

bool newClasses;
if (bool.TryParse(tpData["newClasses"], out newClasses))
{
NewClasses = newClasses;
}

}

public void SaveToIni(IniData iniData)
Expand Down Expand Up @@ -241,6 +269,8 @@ public void SaveToIni(IniData iniData)
tpData["maxLevel"] = MaxLevel.ToString();
tpData["allowXpOverflow"] = AllowXpOverflow ? "true" : "false";
tpData["slowerLevelling"] = SlowerLevelling ? "true" : "false";
tpData["newClasses"] = NewClasses? "true" : "false";
tpData["tolerantNpcs"] = TolerantTownsfolk? "true" : "false";
}
}

Expand Down
3 changes: 2 additions & 1 deletion TemplePlus/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ static ConfigSetting configSettings[] = {
CONF_INT(msaaSamples),
CONF_INT(msaaQuality),
CONF_BOOL(showNpcStats),
CONF_BOOL(newClasses)
CONF_BOOL(newClasses),
CONF_BOOL(tolerantNpcs)
};

void TemplePlusConfig::Load() {
Expand Down
1 change: 1 addition & 0 deletions TemplePlus/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct TemplePlusConfig
bool allowXpOverflow = false;
bool slowerLevelling = false;
bool newClasses = false; // Prestige classes and such
bool tolerantNpcs = false; // NPCs tolerate monster party members

std::unordered_map<std::string, VanillaSetting> vanillaSettings;
void AddVanillaSetting(const std::string &name,
Expand Down
7 changes: 7 additions & 0 deletions TemplePlus/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class LegacyPartySystemHacks : TempleFix
SetMaxPCs((char)config.maxPCs);
replaceFunction(0x1002BBE0, AddToPcGroup);
replaceFunction(0x1002BC40, AddToNpcGroup);

// TriggersFearfulResponse
static BOOL(__cdecl *orgFearfulResponse)(objHndl) = replaceFunction<BOOL(__cdecl)(objHndl)>(0x10080720, [](objHndl handle){
if (config.tolerantNpcs)
return FALSE;
return orgFearfulResponse(handle);
});
}
} partyHacks;

Expand Down
Binary file modified tpdata/tpgamefiles.dat
Binary file not shown.

0 comments on commit 6946aa8

Please sign in to comment.