mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
Issue #219: rewrote AI settings and implemented AI settings filters
This commit is contained in:
parent
eb4e72aaa7
commit
ceaf1677ce
9 changed files with 65 additions and 89 deletions
|
@ -62,10 +62,10 @@ namespace MWClass
|
|||
|
||||
data->mCreatureStats.setLevel(ref->mBase->mData.mLevel);
|
||||
|
||||
data->mCreatureStats.setHello(ref->mBase->mAiData.mHello);
|
||||
data->mCreatureStats.setFight(ref->mBase->mAiData.mFight);
|
||||
data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee);
|
||||
data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm);
|
||||
data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello);
|
||||
data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight);
|
||||
data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee);
|
||||
data->mCreatureStats.setAiSetting (3, ref->mBase->mAiData.mAlarm);
|
||||
|
||||
// spells
|
||||
for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin());
|
||||
|
|
|
@ -109,10 +109,10 @@ namespace MWClass
|
|||
data->mCreatureStats.setLevel (1);
|
||||
}
|
||||
|
||||
data->mCreatureStats.setHello(ref->mBase->mAiData.mHello);
|
||||
data->mCreatureStats.setFight(ref->mBase->mAiData.mFight);
|
||||
data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee);
|
||||
data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm);
|
||||
data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello);
|
||||
data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight);
|
||||
data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee);
|
||||
data->mCreatureStats.setAiSetting (3, ref->mBase->mAiData.mAlarm);
|
||||
|
||||
// spells
|
||||
for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin());
|
||||
|
|
|
@ -157,22 +157,6 @@ namespace MWDialogue
|
|||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||
break;
|
||||
|
||||
case 67://Fight
|
||||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||
break;
|
||||
|
||||
case 68://Hello????
|
||||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||
break;
|
||||
|
||||
case 69://Alarm
|
||||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||
break;
|
||||
|
||||
case 70://Flee
|
||||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||
break;
|
||||
|
||||
case 71://Should Attack
|
||||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||
break;
|
||||
|
@ -184,7 +168,7 @@ namespace MWDialogue
|
|||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DialogueManager::isMatching (const MWWorld::Ptr& actor,
|
||||
|
|
|
@ -196,6 +196,8 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c
|
|||
|
||||
int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) const
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
||||
switch (select.getFunction())
|
||||
{
|
||||
case SelectWrapper::Function_Journal:
|
||||
|
@ -204,7 +206,6 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
|||
|
||||
case SelectWrapper::Function_Item:
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player);
|
||||
|
||||
int sum = 0;
|
||||
|
@ -226,6 +227,10 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
|||
|
||||
return mChoice;
|
||||
|
||||
case SelectWrapper::Function_AiSetting:
|
||||
|
||||
return MWWorld::Class::get (player).getCreatureStats (player).getAiSetting (select.getArgument());
|
||||
|
||||
default:
|
||||
|
||||
throw std::runtime_error ("unknown integer select function");
|
||||
|
@ -235,7 +240,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
|||
bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) const
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
||||
|
||||
switch (select.getFunction())
|
||||
{
|
||||
case SelectWrapper::Function_Id:
|
||||
|
|
|
@ -66,6 +66,7 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
|
|||
case 46: return Function_SameFaction;
|
||||
case 50: return Function_Choice;
|
||||
case 58: return Function_PcCorprus;
|
||||
case 67: case 68: case 69: case 70: return Function_AiSetting;
|
||||
}
|
||||
|
||||
return Function_None;
|
||||
|
@ -96,12 +97,34 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() con
|
|||
return Function_None;
|
||||
}
|
||||
|
||||
int MWDialogue::SelectWrapper::getArgument() const
|
||||
{
|
||||
if (mSelect.mSelectRule[1]!='1')
|
||||
return 0;
|
||||
|
||||
int index = 0;
|
||||
|
||||
std::istringstream (mSelect.mSelectRule.substr(2,2)) >> index;
|
||||
|
||||
switch (index)
|
||||
{
|
||||
// AI settings
|
||||
case 67: return 1;
|
||||
case 68: return 0;
|
||||
case 69: return 3;
|
||||
case 70: return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
||||
{
|
||||
static const Function integerFunctions[] =
|
||||
{
|
||||
Function_Journal, Function_Item, Function_Dead,
|
||||
Function_Choice,
|
||||
Function_AiSetting,
|
||||
Function_None // end marker
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ namespace MWDialogue
|
|||
Function_Global,
|
||||
Function_SameFaction,
|
||||
Function_Choice,
|
||||
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus
|
||||
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus,
|
||||
Function_AiSetting
|
||||
};
|
||||
|
||||
enum Type
|
||||
|
@ -47,6 +48,8 @@ namespace MWDialogue
|
|||
|
||||
Function getFunction() const;
|
||||
|
||||
int getArgument() const;
|
||||
|
||||
Type getType() const;
|
||||
|
||||
bool isInverted() const;
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
namespace MWMechanics
|
||||
{
|
||||
CreatureStats::CreatureStats()
|
||||
: mLevel (0), mHello (0), mFight (0), mFlee (0), mAlarm (0), mLevelHealthBonus(0.f), mDead (false)
|
||||
: mLevel (0), mLevelHealthBonus(0.f), mDead (false)
|
||||
{
|
||||
for (int i=0; i<4; ++i)
|
||||
mAiSettings[i] = 0;
|
||||
}
|
||||
|
||||
void CreatureStats::increaseLevelHealthBonus (float value)
|
||||
|
@ -90,27 +92,13 @@ namespace MWMechanics
|
|||
{
|
||||
return mLevel;
|
||||
}
|
||||
|
||||
int CreatureStats::getAiSetting (int index) const
|
||||
{
|
||||
assert (index>=0 && index<4);
|
||||
return mAiSettings[index];
|
||||
}
|
||||
|
||||
int CreatureStats::getHello() const
|
||||
{
|
||||
return mHello;
|
||||
}
|
||||
|
||||
int CreatureStats::getFight() const
|
||||
{
|
||||
return mFight;
|
||||
}
|
||||
|
||||
int CreatureStats::getFlee() const
|
||||
{
|
||||
return mFlee;
|
||||
}
|
||||
|
||||
int CreatureStats::getAlarm() const
|
||||
{
|
||||
return mAlarm;
|
||||
}
|
||||
|
||||
Stat<int> &CreatureStats::getAttribute(int index)
|
||||
{
|
||||
if (index < 0 || index > 7) {
|
||||
|
@ -196,25 +184,11 @@ namespace MWMechanics
|
|||
mMagicEffects = effects;
|
||||
}
|
||||
|
||||
void CreatureStats::setHello(int value)
|
||||
void CreatureStats::setAiSetting (int index, int value)
|
||||
{
|
||||
mHello = value;
|
||||
assert (index>=0 && index<4);
|
||||
mAiSettings[index] = value;
|
||||
}
|
||||
|
||||
void CreatureStats::setFight(int value)
|
||||
{
|
||||
mFight = value;
|
||||
}
|
||||
|
||||
void CreatureStats::setFlee(int value)
|
||||
{
|
||||
mFlee = value;
|
||||
}
|
||||
|
||||
void CreatureStats::setAlarm(int value)
|
||||
{
|
||||
mAlarm = value;
|
||||
}
|
||||
|
||||
bool CreatureStats::isDead() const
|
||||
{
|
||||
|
|
|
@ -24,10 +24,7 @@ namespace MWMechanics
|
|||
Spells mSpells;
|
||||
ActiveSpells mActiveSpells;
|
||||
MagicEffects mMagicEffects;
|
||||
int mHello;
|
||||
int mFight;
|
||||
int mFlee;
|
||||
int mAlarm;
|
||||
int mAiSettings[4];
|
||||
AiSequence mAiSequence;
|
||||
float mLevelHealthBonus;
|
||||
bool mDead;
|
||||
|
@ -53,13 +50,8 @@ namespace MWMechanics
|
|||
|
||||
int getLevel() const;
|
||||
|
||||
int getHello() const;
|
||||
|
||||
int getFight() const;
|
||||
|
||||
int getFlee() const;
|
||||
|
||||
int getAlarm() const;
|
||||
int getAiSetting (int index) const;
|
||||
///< 0: hello, 1 fight, 2 flee, 3 alarm
|
||||
|
||||
Stat<int> & getAttribute(int index);
|
||||
|
||||
|
@ -87,14 +79,9 @@ namespace MWMechanics
|
|||
|
||||
void setLevel(int level);
|
||||
|
||||
void setHello(int value);
|
||||
|
||||
void setFight(int value);
|
||||
|
||||
void setFlee(int value);
|
||||
|
||||
void setAlarm(int value);
|
||||
|
||||
void setAiSetting (int index, int value);
|
||||
///< 0: hello, 1 fight, 2 flee, 3 alarm
|
||||
|
||||
const AiSequence& getAiSequence() const;
|
||||
|
||||
AiSequence& getAiSequence();
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setHello(value);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (0, value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -146,7 +146,7 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setFight(value);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (1, value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -162,7 +162,7 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setFlee(value);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (2, value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -178,7 +178,7 @@ namespace MWScript
|
|||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||
runtime.pop();
|
||||
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAlarm(value);
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (3, value);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue