mirror of
https://github.com/glest/glest-source.git
synced 2025-08-21 15:41:24 +02:00
- attempt to fix lua code to properly get unit's killer:
lastDeadUnitKillerName lastDeadUnitKiller
This commit is contained in:
@@ -148,6 +148,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){
|
|||||||
luaScript.registerFunction(getLastDeadUnitName, "lastDeadUnitName");
|
luaScript.registerFunction(getLastDeadUnitName, "lastDeadUnitName");
|
||||||
luaScript.registerFunction(getLastDeadUnitId, "lastDeadUnit");
|
luaScript.registerFunction(getLastDeadUnitId, "lastDeadUnit");
|
||||||
luaScript.registerFunction(getLastDeadUnitCauseOfDeath, "lastDeadUnitCauseOfDeath");
|
luaScript.registerFunction(getLastDeadUnitCauseOfDeath, "lastDeadUnitCauseOfDeath");
|
||||||
|
luaScript.registerFunction(getLastDeadUnitKillerName, "lastDeadUnitKillerName");
|
||||||
|
luaScript.registerFunction(getLastDeadUnitKillerId, "lastDeadUnitKiller");
|
||||||
|
|
||||||
luaScript.registerFunction(getLastAttackedUnitName, "lastAttackedUnitName");
|
luaScript.registerFunction(getLastAttackedUnitName, "lastAttackedUnitName");
|
||||||
luaScript.registerFunction(getLastAttackedUnitId, "lastAttackedUnit");
|
luaScript.registerFunction(getLastAttackedUnitId, "lastAttackedUnit");
|
||||||
@@ -174,8 +176,11 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){
|
|||||||
|
|
||||||
//last created unit
|
//last created unit
|
||||||
lastCreatedUnitId= -1;
|
lastCreatedUnitId= -1;
|
||||||
|
lastDeadUnitName = "";
|
||||||
lastDeadUnitId= -1;
|
lastDeadUnitId= -1;
|
||||||
lastDeadUnitCauseOfDeath = ucodNone;
|
lastDeadUnitCauseOfDeath = ucodNone;
|
||||||
|
lastDeadUnitKillerName = "";
|
||||||
|
lastDeadUnitKillerId= -1;
|
||||||
|
|
||||||
lastAttackedUnitName = "";
|
lastAttackedUnitName = "";
|
||||||
lastAttackedUnitId = -1;
|
lastAttackedUnitId = -1;
|
||||||
@@ -231,6 +236,25 @@ void ScriptManager::onUnitCreated(const Unit* unit){
|
|||||||
void ScriptManager::onUnitDied(const Unit* unit){
|
void ScriptManager::onUnitDied(const Unit* unit){
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
if(unit->getLastAttackerUnitId() >= 0) {
|
||||||
|
Unit *killer = world->findUnitById(unit->getLastAttackerUnitId());
|
||||||
|
|
||||||
|
if(killer != NULL) {
|
||||||
|
lastAttackingUnitName= killer->getType()->getName();
|
||||||
|
lastAttackingUnitId= killer->getId();
|
||||||
|
|
||||||
|
lastDeadUnitKillerName= killer->getType()->getName();
|
||||||
|
lastDeadUnitKillerId= killer->getId();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastDeadUnitKillerName= "";
|
||||||
|
lastDeadUnitKillerId= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lastAttackedUnitName= unit->getType()->getName();
|
||||||
|
lastAttackedUnitId= unit->getId();
|
||||||
|
|
||||||
lastDeadUnitName= unit->getType()->getName();
|
lastDeadUnitName= unit->getType()->getName();
|
||||||
lastDeadUnitId= unit->getId();
|
lastDeadUnitId= unit->getId();
|
||||||
lastDeadUnitCauseOfDeath = unit->getCauseOfDeath();
|
lastDeadUnitCauseOfDeath = unit->getCauseOfDeath();
|
||||||
@@ -939,6 +963,18 @@ int ScriptManager::getLastDeadUnitCauseOfDeath() {
|
|||||||
return lastDeadUnitCauseOfDeath;
|
return lastDeadUnitCauseOfDeath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string &ScriptManager::getLastDeadUnitKillerName() {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
return lastDeadUnitKillerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScriptManager::getLastDeadUnitKillerId() {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
return lastDeadUnitKillerId;
|
||||||
|
}
|
||||||
|
|
||||||
const string &ScriptManager::getLastAttackedUnitName() {
|
const string &ScriptManager::getLastAttackedUnitName() {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
@@ -1385,6 +1421,18 @@ int ScriptManager::getLastDeadUnitCauseOfDeath(LuaHandle* luaHandle){
|
|||||||
return luaArguments.getReturnCount();
|
return luaArguments.getReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::getLastDeadUnitKillerName(LuaHandle* luaHandle){
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
luaArguments.returnString(thisScriptManager->getLastDeadUnitKillerName());
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ScriptManager::getLastDeadUnitKillerId(LuaHandle* luaHandle){
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
luaArguments.returnInt(thisScriptManager->getLastDeadUnitKillerId());
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
int ScriptManager::getLastAttackedUnitName(LuaHandle* luaHandle) {
|
int ScriptManager::getLastAttackedUnitName(LuaHandle* luaHandle) {
|
||||||
LuaArguments luaArguments(luaHandle);
|
LuaArguments luaArguments(luaHandle);
|
||||||
luaArguments.returnString(thisScriptManager->getLastAttackedUnitName());
|
luaArguments.returnString(thisScriptManager->getLastAttackedUnitName());
|
||||||
|
@@ -130,6 +130,10 @@ private:
|
|||||||
int lastDeadUnitId;
|
int lastDeadUnitId;
|
||||||
int lastDeadUnitCauseOfDeath;
|
int lastDeadUnitCauseOfDeath;
|
||||||
|
|
||||||
|
//last dead unit's killer
|
||||||
|
string lastDeadUnitKillerName;
|
||||||
|
int lastDeadUnitKillerId;
|
||||||
|
|
||||||
//last attacked unit
|
//last attacked unit
|
||||||
string lastAttackedUnitName;
|
string lastAttackedUnitName;
|
||||||
int lastAttackedUnitId;
|
int lastAttackedUnitId;
|
||||||
@@ -253,7 +257,8 @@ private:
|
|||||||
const string &getLastDeadUnitName();
|
const string &getLastDeadUnitName();
|
||||||
int getLastDeadUnitId();
|
int getLastDeadUnitId();
|
||||||
int getLastDeadUnitCauseOfDeath();
|
int getLastDeadUnitCauseOfDeath();
|
||||||
|
const string &getLastDeadUnitKillerName();
|
||||||
|
int getLastDeadUnitKillerId();
|
||||||
|
|
||||||
const string &getLastAttackedUnitName();
|
const string &getLastAttackedUnitName();
|
||||||
int getLastAttackedUnitId();
|
int getLastAttackedUnitId();
|
||||||
@@ -337,6 +342,8 @@ private:
|
|||||||
static int getLastDeadUnitName(LuaHandle* luaHandle);
|
static int getLastDeadUnitName(LuaHandle* luaHandle);
|
||||||
static int getLastDeadUnitId(LuaHandle* luaHandle);
|
static int getLastDeadUnitId(LuaHandle* luaHandle);
|
||||||
static int getLastDeadUnitCauseOfDeath(LuaHandle* luaHandle);
|
static int getLastDeadUnitCauseOfDeath(LuaHandle* luaHandle);
|
||||||
|
static int getLastDeadUnitKillerName(LuaHandle* luaHandle);
|
||||||
|
static int getLastDeadUnitKillerId(LuaHandle* luaHandle);
|
||||||
|
|
||||||
static int getLastAttackedUnitName(LuaHandle* luaHandle);
|
static int getLastAttackedUnitName(LuaHandle* luaHandle);
|
||||||
static int getLastAttackedUnitId(LuaHandle* luaHandle);
|
static int getLastAttackedUnitId(LuaHandle* luaHandle);
|
||||||
|
@@ -2063,6 +2063,8 @@ void UnitUpdater::damage(Unit *attacker, const AttackSkillType* ast, Unit *attac
|
|||||||
default:
|
default:
|
||||||
throw runtime_error("detected unsupported pathfinder type!");
|
throw runtime_error("detected unsupported pathfinder type!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attacked->setCauseOfDeath(ucodAttacked);
|
||||||
scriptManager->onUnitDied(attacked);
|
scriptManager->onUnitDied(attacked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user