Adding helmets

actorid
Jason Hooks 13 years ago
parent e869433b07
commit 7551926afd

@ -13,7 +13,7 @@ NpcAnimation::~NpcAnimation(){
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0), NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env,OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv): Animation(_env,_rend), mStateID(-1), inv(_inv), timeToChange(0),
robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), robe(inv.getSlot(MWWorld::InventoryStore::Slot_Robe)), helmet(inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)),
lclavicle(0), lclavicle(0),
rclavicle(0), rclavicle(0),
rupperArm(0), rupperArm(0),
@ -160,13 +160,12 @@ void NpcAnimation::updateParts(){
std::string hairModel = "meshes\\" + std::string hairModel = "meshes\\" +
mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model; mEnvironment.mWorld->getStore().bodyParts.find(hairID)->model;
//inv.getSlot(MWWorld::InventoryStore::Slot_Robe); //inv.getSlot(MWWorld::InventoryStore::Slot_Robe);
if(robe != inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){ if(robe != inv.getSlot(MWWorld::InventoryStore::Slot_Robe)){
//A robe was added or removed //A robe was added or removed
if(chest.first) removePartGroup(MWWorld::InventoryStore::Slot_Robe);
{
insert->detachObject(chest.first); chest.first = 0;
}
robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe); robe = inv.getSlot(MWWorld::InventoryStore::Slot_Robe);
if(robe != inv.end()) if(robe != inv.end())
{ {
@ -177,24 +176,48 @@ void NpcAnimation::updateParts(){
for(int i = 0; i < parts.size(); i++) for(int i = 0; i < parts.size(); i++)
{ {
ESM::PartReference part = parts[i]; ESM::PartReference part = parts[i];
if(part.part == ESM::PRT_Cuirass)
{
const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male); const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male);
chest = insertFreePart("meshes\\" + bodypart->model, ":\""); if(bodypart)
} addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Robe,5,"meshes\\" + bodypart->model);
} }
} }
} }
if(robe == inv.end() ){ if(helmet != inv.getSlot(MWWorld::InventoryStore::Slot_Helmet)){
//if(inv.getSlot(MWWorld::InventoryStore::Cuirass) != inv.end()) helmet = inv.getSlot(MWWorld::InventoryStore::Slot_Helmet);
if(chest.first == 0){ removePartGroup(MWWorld::InventoryStore::Slot_Helmet);
const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest"); removeIndividualPart(ESM::PRT_Hair);
chest = insertFreePart("meshes\\" + chestPart->model, ":\""); if(helmet != inv.end()){
const ESM::Armor *armor = (helmet->get<ESM::Armor>())->base;
std::vector<ESM::PartReference> parts = armor->parts.parts;
for(int i = 0; i < parts.size(); i++)
{
ESM::PartReference part = parts[i];
const ESM::BodyPart *bodypart = mEnvironment.mWorld->getStore().bodyParts.search (part.male);
if(bodypart)
addOrReplaceIndividualPart(part.part, MWWorld::InventoryStore::Slot_Helmet,3,"meshes\\" + bodypart->model);
}
} }
} }
if(partpriorities[ESM::PRT_Cuirass] < 1){
const ESM::BodyPart *chestPart = mEnvironment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest");
if(chestPart)
addOrReplaceIndividualPart(ESM::PRT_Cuirass, -1,1,"meshes\\" + chestPart->model);
}
if(partpriorities[ESM::PRT_Head] < 1){
addOrReplaceIndividualPart(ESM::PRT_Head, -1,1,headModel);
}
if(partpriorities[ESM::PRT_Hair] < 1 && partpriorities[ESM::PRT_Head] <= 1){
addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1,hairModel);
}
@ -418,9 +441,10 @@ void NpcAnimation::removeIndividualPart(int type){
} }
} }
bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh){ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, const std::string &mesh){
if(priority >= partpriorities[type]){ if(priority > partpriorities[type]){
removeIndividualPart(type); removeIndividualPart(type);
partslots[type] = group; partslots[type] = group;
partpriorities[type] = priority;
switch(type){ switch(type){
case ESM::PRT_Head: //0 case ESM::PRT_Head: //0
head = insertBoundedPart(mesh, "Head"); head = insertBoundedPart(mesh, "Head");

@ -68,6 +68,7 @@ private:
std::string bodyRaceID; std::string bodyRaceID;
float timeToChange; float timeToChange;
MWWorld::ContainerStoreIterator robe; MWWorld::ContainerStoreIterator robe;
MWWorld::ContainerStoreIterator helmet;
public: public:
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv); NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend, MWWorld::InventoryStore& _inv);

Loading…
Cancel
Save