1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/lib/ERMScriptModule.cpp
mateuszb 4eef7aa83b * partially done OB receiver
* minor structure imprevements
2011-05-15 18:21:07 +00:00

52 lines
1.4 KiB
C++

#define VCMI_DLL
#include "ERMScriptModule.h"
#include "ERMInterpreter.h"
#include <boost/assign/std/vector.hpp>
#include <boost/assign/list_of.hpp>
#include "CObjectHandler.h"
using namespace boost::assign;
CScriptingModule::~CScriptingModule()
{
}
CERMScriptModule::CERMScriptModule(void)
{
}
CERMScriptModule::~CERMScriptModule(void)
{
}
void CERMScriptModule::init()
{
interpreter = new ERMInterpreter();
interpreter->init();
interpreter->scanForScripts();
interpreter->scanScripts();
interpreter->executeInstructions();
interpreter->executeTriggerType("PI");
}
void CERMScriptModule::heroVisit(const CGHeroInstance *visitor, const CGObjectInstance *visitedObj, bool start)
{
if(!visitedObj)
return;
interpreter->setCurrentlyVisitedObj(visitedObj->pos);
ERMInterpreter::TIDPattern tip;
tip[1] = list_of(visitedObj->ID);
tip[2] = list_of(visitedObj->ID)(visitedObj->subID);
tip[3] = list_of(visitedObj->pos.x)(visitedObj->pos.y)(visitedObj->pos.z);
interpreter->executeTriggerType(VERMInterpreter::TriggerType("OB"), start, tip);
}
void CERMScriptModule::battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side)
{
interpreter->executeTriggerType("BA", 0);
interpreter->executeTriggerType("BR", -1);
interpreter->executeTriggerType("BF", 0);
//TODO tactics or not
}