forked from teamnwah/openmw-tes3coop
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.setLevel(ref->mBase->mData.mLevel);
|
||||||
|
|
||||||
data->mCreatureStats.setHello(ref->mBase->mAiData.mHello);
|
data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello);
|
||||||
data->mCreatureStats.setFight(ref->mBase->mAiData.mFight);
|
data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight);
|
||||||
data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee);
|
data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee);
|
||||||
data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm);
|
data->mCreatureStats.setAiSetting (3, ref->mBase->mAiData.mAlarm);
|
||||||
|
|
||||||
// spells
|
// spells
|
||||||
for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin());
|
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.setLevel (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->mCreatureStats.setHello(ref->mBase->mAiData.mHello);
|
data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello);
|
||||||
data->mCreatureStats.setFight(ref->mBase->mAiData.mFight);
|
data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight);
|
||||||
data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee);
|
data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee);
|
||||||
data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm);
|
data->mCreatureStats.setAiSetting (3, ref->mBase->mAiData.mAlarm);
|
||||||
|
|
||||||
// spells
|
// spells
|
||||||
for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin());
|
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;
|
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||||
break;
|
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
|
case 71://Should Attack
|
||||||
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
if(!selectCompare<int,int>(comp,0,select.mI)) return false;
|
||||||
break;
|
break;
|
||||||
|
@ -184,7 +168,7 @@ namespace MWDialogue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogueManager::isMatching (const MWWorld::Ptr& actor,
|
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
|
int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) const
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
|
|
||||||
switch (select.getFunction())
|
switch (select.getFunction())
|
||||||
{
|
{
|
||||||
case SelectWrapper::Function_Journal:
|
case SelectWrapper::Function_Journal:
|
||||||
|
@ -204,7 +206,6 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
case SelectWrapper::Function_Item:
|
case SelectWrapper::Function_Item:
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player);
|
MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player);
|
||||||
|
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
@ -226,6 +227,10 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con
|
||||||
|
|
||||||
return mChoice;
|
return mChoice;
|
||||||
|
|
||||||
|
case SelectWrapper::Function_AiSetting:
|
||||||
|
|
||||||
|
return MWWorld::Class::get (player).getCreatureStats (player).getAiSetting (select.getArgument());
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
throw std::runtime_error ("unknown integer select function");
|
throw std::runtime_error ("unknown integer select function");
|
||||||
|
|
|
@ -66,6 +66,7 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction()
|
||||||
case 46: return Function_SameFaction;
|
case 46: return Function_SameFaction;
|
||||||
case 50: return Function_Choice;
|
case 50: return Function_Choice;
|
||||||
case 58: return Function_PcCorprus;
|
case 58: return Function_PcCorprus;
|
||||||
|
case 67: case 68: case 69: case 70: return Function_AiSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Function_None;
|
return Function_None;
|
||||||
|
@ -96,12 +97,34 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() con
|
||||||
return Function_None;
|
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
|
MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
||||||
{
|
{
|
||||||
static const Function integerFunctions[] =
|
static const Function integerFunctions[] =
|
||||||
{
|
{
|
||||||
Function_Journal, Function_Item, Function_Dead,
|
Function_Journal, Function_Item, Function_Dead,
|
||||||
Function_Choice,
|
Function_Choice,
|
||||||
|
Function_AiSetting,
|
||||||
Function_None // end marker
|
Function_None // end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ namespace MWDialogue
|
||||||
Function_Global,
|
Function_Global,
|
||||||
Function_SameFaction,
|
Function_SameFaction,
|
||||||
Function_Choice,
|
Function_Choice,
|
||||||
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus
|
Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus,
|
||||||
|
Function_AiSetting
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Type
|
enum Type
|
||||||
|
@ -47,6 +48,8 @@ namespace MWDialogue
|
||||||
|
|
||||||
Function getFunction() const;
|
Function getFunction() const;
|
||||||
|
|
||||||
|
int getArgument() const;
|
||||||
|
|
||||||
Type getType() const;
|
Type getType() const;
|
||||||
|
|
||||||
bool isInverted() const;
|
bool isInverted() const;
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
CreatureStats::CreatureStats()
|
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)
|
void CreatureStats::increaseLevelHealthBonus (float value)
|
||||||
|
@ -91,24 +93,10 @@ namespace MWMechanics
|
||||||
return mLevel;
|
return mLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CreatureStats::getHello() const
|
int CreatureStats::getAiSetting (int index) const
|
||||||
{
|
{
|
||||||
return mHello;
|
assert (index>=0 && index<4);
|
||||||
}
|
return mAiSettings[index];
|
||||||
|
|
||||||
int CreatureStats::getFight() const
|
|
||||||
{
|
|
||||||
return mFight;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CreatureStats::getFlee() const
|
|
||||||
{
|
|
||||||
return mFlee;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CreatureStats::getAlarm() const
|
|
||||||
{
|
|
||||||
return mAlarm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Stat<int> &CreatureStats::getAttribute(int index)
|
Stat<int> &CreatureStats::getAttribute(int index)
|
||||||
|
@ -196,24 +184,10 @@ namespace MWMechanics
|
||||||
mMagicEffects = effects;
|
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
|
bool CreatureStats::isDead() const
|
||||||
|
|
|
@ -24,10 +24,7 @@ namespace MWMechanics
|
||||||
Spells mSpells;
|
Spells mSpells;
|
||||||
ActiveSpells mActiveSpells;
|
ActiveSpells mActiveSpells;
|
||||||
MagicEffects mMagicEffects;
|
MagicEffects mMagicEffects;
|
||||||
int mHello;
|
int mAiSettings[4];
|
||||||
int mFight;
|
|
||||||
int mFlee;
|
|
||||||
int mAlarm;
|
|
||||||
AiSequence mAiSequence;
|
AiSequence mAiSequence;
|
||||||
float mLevelHealthBonus;
|
float mLevelHealthBonus;
|
||||||
bool mDead;
|
bool mDead;
|
||||||
|
@ -53,13 +50,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
int getLevel() const;
|
int getLevel() const;
|
||||||
|
|
||||||
int getHello() const;
|
int getAiSetting (int index) const;
|
||||||
|
///< 0: hello, 1 fight, 2 flee, 3 alarm
|
||||||
int getFight() const;
|
|
||||||
|
|
||||||
int getFlee() const;
|
|
||||||
|
|
||||||
int getAlarm() const;
|
|
||||||
|
|
||||||
Stat<int> & getAttribute(int index);
|
Stat<int> & getAttribute(int index);
|
||||||
|
|
||||||
|
@ -87,13 +79,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
void setLevel(int level);
|
void setLevel(int level);
|
||||||
|
|
||||||
void setHello(int value);
|
void setAiSetting (int index, int value);
|
||||||
|
///< 0: hello, 1 fight, 2 flee, 3 alarm
|
||||||
void setFight(int value);
|
|
||||||
|
|
||||||
void setFlee(int value);
|
|
||||||
|
|
||||||
void setAlarm(int value);
|
|
||||||
|
|
||||||
const AiSequence& getAiSequence() const;
|
const AiSequence& getAiSequence() const;
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace MWScript
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
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;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
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;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
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;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
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