integrated activation into script system

actorid
Marc Zinnschlag 15 years ago
parent f630157bf8
commit 7a313f24ab

@ -279,9 +279,22 @@ void OMW::Engine::activate()
if (ptr.isEmpty())
return;
MWScript::InterpreterContext interpreterContext (mEnvironment,
&ptr.getRefData().getLocals(), ptr);
boost::shared_ptr<MWWorld::Action> action =
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(),
mEnvironment);
action->execute (mEnvironment);
interpreterContext.activate (ptr, action);
std::string script = MWWorld::Class::get (ptr).getScript (ptr);
if (!script.empty())
mScriptManager->run (script, interpreterContext);
if (!interpreterContext.hasActivationBeenHandled())
{
interpreterContext.executeActivation();
}
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Activator::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
ptr.get<ESM::Activator>();
return ref->base->script;
}
void Activator::registerSelf()
{
boost::shared_ptr<Class> instance (new Activator);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
ptr.get<ESM::Apparatus>();
return ref->base->script;
}
void Apparatus::registerSelf()
{
boost::shared_ptr<Class> instance (new Apparatus);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -30,6 +30,14 @@ namespace MWClass
return ref->base->data.health;
}
std::string Armor::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>();
return ref->base->script;
}
void Armor::registerSelf()
{
boost::shared_ptr<Class> instance (new Armor);

@ -19,6 +19,9 @@ namespace MWClass
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
///< Return item max health or throw an exception, if class does not have item health
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Book::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
ptr.get<ESM::Book>();
return ref->base->script;
}
void Book::registerSelf()
{
boost::shared_ptr<Class> instance (new Book);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Clothing::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
return ref->base->script;
}
void Clothing::registerSelf()
{
boost::shared_ptr<Class> instance (new Clothing);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Container::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
ptr.get<ESM::Container>();
return ref->base->script;
}
void Container::registerSelf()
{
boost::shared_ptr<Class> instance (new Container);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -44,6 +44,14 @@ namespace MWClass
return *ptr.getRefData().getCreatureStats();
}
std::string Creature::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
ptr.get<ESM::Creature>();
return ref->base->script;
}
void Creature::registerSelf()
{
boost::shared_ptr<Class> instance (new Creature);

@ -16,6 +16,9 @@ namespace MWClass
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
///< Return creature stats
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -53,6 +53,14 @@ namespace MWClass
}
}
std::string Door::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
ptr.get<ESM::Door>();
return ref->base->script;
}
void Door::registerSelf()
{
boost::shared_ptr<Class> instance (new Door);

@ -17,6 +17,9 @@ namespace MWClass
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
///< Generate action for activation
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
ptr.get<ESM::Ingredient>();
return ref->base->script;
}
void Ingredient::registerSelf()
{
boost::shared_ptr<Class> instance (new Ingredient);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -20,6 +20,14 @@ namespace MWClass
return ref->base->name;
}
std::string Light::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
ptr.get<ESM::Light>();
return ref->base->script;
}
void Light::registerSelf()
{
boost::shared_ptr<Class> instance (new Light);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
ptr.get<ESM::Tool>();
return ref->base->script;
}
void Lockpick::registerSelf()
{
boost::shared_ptr<Class> instance (new Lockpick);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Misc::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref =
ptr.get<ESM::Misc>();
return ref->base->script;
}
void Misc::registerSelf()
{
boost::shared_ptr<Class> instance (new Misc);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -44,6 +44,14 @@ namespace MWClass
return *ptr.getRefData().getCreatureStats();
}
std::string Npc::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
ptr.get<ESM::NPC>();
return ref->base->script;
}
void Npc::registerSelf()
{
boost::shared_ptr<Class> instance (new Npc);

@ -16,6 +16,9 @@ namespace MWClass
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
///< Return creature stats
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Potion::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
ptr.get<ESM::Potion>();
return ref->base->script;
}
void Potion::registerSelf()
{
boost::shared_ptr<Class> instance (new Potion);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Probe::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
ptr.get<ESM::Probe>();
return ref->base->script;
}
void Probe::registerSelf()
{
boost::shared_ptr<Class> instance (new Probe);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -17,6 +17,14 @@ namespace MWClass
return ref->base->name;
}
std::string Repair::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
ptr.get<ESM::Repair>();
return ref->base->script;
}
void Repair::registerSelf()
{
boost::shared_ptr<Class> instance (new Repair);

@ -13,6 +13,9 @@ namespace MWClass
///< \return name (the one that is to be presented to the user; not the internal one);
/// can return an empty string.
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -30,6 +30,14 @@ namespace MWClass
return ref->base->data.health;
}
std::string Weapon::getScript (const MWWorld::Ptr& ptr) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
return ref->base->script;
}
void Weapon::registerSelf()
{
boost::shared_ptr<Class> instance (new Weapon);

@ -19,6 +19,9 @@ namespace MWClass
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
///< Return item max health or throw an exception, if class does not have item health
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
///< Return name of the script attached to ptr
static void registerSelf();
};
}

@ -41,6 +41,11 @@ namespace MWWorld
return boost::shared_ptr<Action> (new NullAction);
}
std::string Class::getScript (const Ptr& ptr) const
{
return "";
}
const Class& Class::get (const std::string& key)
{
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);

@ -58,6 +58,10 @@ namespace MWWorld
///< Generate action for using via inventory menu (default implementation: return a
/// null action).
virtual std::string getScript (const Ptr& ptr) const;
///< Return name of the script attached to ptr (default implementation: return an empty
/// string).
static const Class& get (const std::string& key);
///< If there is no class for this \a key, an exception is thrown.

Loading…
Cancel
Save