- added new lua method lastDeadUnitCauseOfDeath, possible int values are:

None = 0
	Attacked = 1
	AttackBoost = 2
	StarvedResource = 3
	StarvedRegeneration = 4
This commit is contained in:
Mark Vejvoda 2011-11-16 21:43:19 +00:00
parent 2d367bd26e
commit d29293d3cf
2 changed files with 20 additions and 0 deletions

View File

@ -147,6 +147,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){
luaScript.registerFunction(getLastDeadUnitName, "lastDeadUnitName");
luaScript.registerFunction(getLastDeadUnitId, "lastDeadUnit");
luaScript.registerFunction(getLastDeadUnitCauseOfDeath, "lastDeadUnitCauseOfDeath");
luaScript.registerFunction(getLastAttackedUnitName, "lastAttackedUnitName");
luaScript.registerFunction(getLastAttackedUnitId, "lastAttackedUnit");
@ -174,6 +175,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){
//last created unit
lastCreatedUnitId= -1;
lastDeadUnitId= -1;
lastDeadUnitCauseOfDeath = ucodNone;
lastAttackedUnitName = "";
lastAttackedUnitId = -1;
@ -231,6 +233,8 @@ void ScriptManager::onUnitDied(const Unit* unit){
lastDeadUnitName= unit->getType()->getName();
lastDeadUnitId= unit->getId();
lastDeadUnitCauseOfDeath = unit->getCauseOfDeath();
luaScript.beginCall("unitDied");
luaScript.endCall();
}
@ -929,6 +933,12 @@ int ScriptManager::getLastDeadUnitId() {
return lastDeadUnitId;
}
int ScriptManager::getLastDeadUnitCauseOfDeath() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
ScriptManager_STREFLOP_Wrapper streflopWrapper;
return lastDeadUnitCauseOfDeath;
}
const string &ScriptManager::getLastAttackedUnitName() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
ScriptManager_STREFLOP_Wrapper streflopWrapper;
@ -1369,6 +1379,12 @@ int ScriptManager::getLastDeadUnitId(LuaHandle* luaHandle){
return luaArguments.getReturnCount();
}
int ScriptManager::getLastDeadUnitCauseOfDeath(LuaHandle* luaHandle){
LuaArguments luaArguments(luaHandle);
luaArguments.returnInt(thisScriptManager->getLastDeadUnitCauseOfDeath());
return luaArguments.getReturnCount();
}
int ScriptManager::getLastAttackedUnitName(LuaHandle* luaHandle) {
LuaArguments luaArguments(luaHandle);
luaArguments.returnString(thisScriptManager->getLastAttackedUnitName());

View File

@ -128,6 +128,7 @@ private:
//last dead unit
string lastDeadUnitName;
int lastDeadUnitId;
int lastDeadUnitCauseOfDeath;
//last attacked unit
string lastAttackedUnitName;
@ -251,6 +252,8 @@ private:
const string &getLastDeadUnitName();
int getLastDeadUnitId();
int getLastDeadUnitCauseOfDeath();
const string &getLastAttackedUnitName();
int getLastAttackedUnitId();
@ -333,6 +336,7 @@ private:
static int getLastDeadUnitName(LuaHandle* luaHandle);
static int getLastDeadUnitId(LuaHandle* luaHandle);
static int getLastDeadUnitCauseOfDeath(LuaHandle* luaHandle);
static int getLastAttackedUnitName(LuaHandle* luaHandle);
static int getLastAttackedUnitId(LuaHandle* luaHandle);