- added new lua functions:
triggeredCellEventUnitId() showMarker(int flashCount, int factionIndex, string note, string textureFile,Vec2i pos) 1. The first one can be called in a cell trigger event and tell you which unit triggered the event 2. The second flashes a position in the minimap
This commit is contained in:
parent
87c3a11876
commit
0180aa6bba
|
@ -1869,17 +1869,21 @@ void Game::updateNetworkHighligtedCells() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::addOrReplaceInHighlightedCells(MarkedCell mc){
|
void Game::addOrReplaceInHighlightedCells(MarkedCell mc){
|
||||||
|
if(mc.getFactionIndex() >= 0) {
|
||||||
for(int i = highlightedCells.size()-1; i >= 0; i--) {
|
for(int i = highlightedCells.size()-1; i >= 0; i--) {
|
||||||
MarkedCell *currentMc = &highlightedCells[i];
|
MarkedCell *currentMc = &highlightedCells[i];
|
||||||
if(currentMc->getFactionIndex() == mc.getFactionIndex()) {
|
if(currentMc->getFactionIndex() == mc.getFactionIndex()) {
|
||||||
highlightedCells.erase(highlightedCells.begin()+i);
|
highlightedCells.erase(highlightedCells.begin()+i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(mc.getAliveCount() <= 0) {
|
||||||
mc.setAliveCount(200);
|
mc.setAliveCount(200);
|
||||||
|
}
|
||||||
highlightedCells.push_back(mc);
|
highlightedCells.push_back(mc);
|
||||||
CoreData &coreData= CoreData::getInstance();
|
CoreData &coreData= CoreData::getInstance();
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
if(mc.getFaction() != NULL && mc.getFaction()->getTeam() == getWorld()->getThisFaction()->getTeam()) {
|
if(mc.getFaction() == NULL || (mc.getFaction()->getTeam() == getWorld()->getThisFaction()->getTeam())) {
|
||||||
soundRenderer.playFx(coreData.getMarkerSound());
|
soundRenderer.playFx(coreData.getMarkerSound());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2324,6 +2328,22 @@ void Game::removeCellMarker(Vec2i surfaceCellPos, const Faction *faction) {
|
||||||
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
|
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
|
||||||
renderer.forceQuadCacheUpdate();
|
renderer.forceQuadCacheUpdate();
|
||||||
}
|
}
|
||||||
|
void Game::showMarker(Vec2i cellPos, MarkedCell cellData) {
|
||||||
|
//setMarker = true;
|
||||||
|
//if(setMarker) {
|
||||||
|
//Vec2i targetPos = cellData.targetPos;
|
||||||
|
//Vec2i screenPos(x,y-60);
|
||||||
|
//Renderer &renderer= Renderer::getInstance();
|
||||||
|
//renderer.computePosition(screenPos, targetPos);
|
||||||
|
//Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
|
||||||
|
|
||||||
|
//MarkedCell mc(targetPos,world.getThisFaction(),"none",world.getThisFaction()->getStartLocationIndex());
|
||||||
|
addOrReplaceInHighlightedCells(cellData);
|
||||||
|
|
||||||
|
GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();
|
||||||
|
gameNetworkInterface->sendHighlightCellMessage(cellData.getTargetPos(),cellData.getFactionIndex());
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
void Game::mouseDownLeft(int x, int y) {
|
void Game::mouseDownLeft(int x, int y) {
|
||||||
if(this->masterserverMode == true) {
|
if(this->masterserverMode == true) {
|
||||||
|
|
|
@ -302,6 +302,7 @@ public:
|
||||||
|
|
||||||
void addCellMarker(Vec2i cellPos, MarkedCell cellData);
|
void addCellMarker(Vec2i cellPos, MarkedCell cellData);
|
||||||
void removeCellMarker(Vec2i surfaceCellPos, const Faction *faction);
|
void removeCellMarker(Vec2i surfaceCellPos, const Faction *faction);
|
||||||
|
void showMarker(Vec2i cellPos, MarkedCell cellData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//render
|
//render
|
||||||
|
|
|
@ -208,6 +208,7 @@ ScriptManager::ScriptManager() {
|
||||||
gameWon = false;
|
gameWon = false;
|
||||||
currentTimerTriggeredEventId = 0;
|
currentTimerTriggeredEventId = 0;
|
||||||
currentCellTriggeredEventId = 0;
|
currentCellTriggeredEventId = 0;
|
||||||
|
currentCellTriggeredEventUnitId = 0;
|
||||||
currentEventId = 0;
|
currentEventId = 0;
|
||||||
inCellTriggerEvent = false;
|
inCellTriggerEvent = false;
|
||||||
rootNode = NULL;
|
rootNode = NULL;
|
||||||
|
@ -315,6 +316,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
||||||
luaScript.registerFunction(getCellTriggeredEventAreaEntryUnitId, "triggeredEventAreaEntryUnitId");
|
luaScript.registerFunction(getCellTriggeredEventAreaEntryUnitId, "triggeredEventAreaEntryUnitId");
|
||||||
luaScript.registerFunction(getCellTriggeredEventAreaExitUnitId, "triggeredEventAreaExitUnitId");
|
luaScript.registerFunction(getCellTriggeredEventAreaExitUnitId, "triggeredEventAreaExitUnitId");
|
||||||
|
|
||||||
|
luaScript.registerFunction(getCellTriggeredEventUnitId, "triggeredCellEventUnitId");
|
||||||
|
|
||||||
luaScript.registerFunction(setRandomGenInit, "setRandomGenInit");
|
luaScript.registerFunction(setRandomGenInit, "setRandomGenInit");
|
||||||
luaScript.registerFunction(getRandomGen, "getRandomGen");
|
luaScript.registerFunction(getRandomGen, "getRandomGen");
|
||||||
luaScript.registerFunction(getWorldFrameCount, "getWorldFrameCount");
|
luaScript.registerFunction(getWorldFrameCount, "getWorldFrameCount");
|
||||||
|
@ -326,6 +329,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
||||||
|
|
||||||
luaScript.registerFunction(addCellMarker, "addCellMarker");
|
luaScript.registerFunction(addCellMarker, "addCellMarker");
|
||||||
luaScript.registerFunction(removeCellMarker, "removeCellMarker");
|
luaScript.registerFunction(removeCellMarker, "removeCellMarker");
|
||||||
|
luaScript.registerFunction(showMarker, "showMarker");
|
||||||
|
|
||||||
luaScript.registerFunction(getUnitFaction, "unitFaction");
|
luaScript.registerFunction(getUnitFaction, "unitFaction");
|
||||||
luaScript.registerFunction(getUnitName, "unitName");
|
luaScript.registerFunction(getUnitName, "unitName");
|
||||||
|
@ -365,6 +369,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
|
||||||
luaScript.registerFunction(isFreeCellsOrHasUnit, "isFreeCellsOrHasUnit");
|
luaScript.registerFunction(isFreeCellsOrHasUnit, "isFreeCellsOrHasUnit");
|
||||||
luaScript.registerFunction(isFreeCells, "isFreeCells");
|
luaScript.registerFunction(isFreeCells, "isFreeCells");
|
||||||
|
|
||||||
|
luaScript.registerFunction(getHumanFactionId, "humanFaction");
|
||||||
|
|
||||||
//load code
|
//load code
|
||||||
for(int i= 0; i<scenario->getScriptCount(); ++i){
|
for(int i= 0; i<scenario->getScriptCount(); ++i){
|
||||||
const Script* script= scenario->getScript(i);
|
const Script* script= scenario->getScript(i);
|
||||||
|
@ -626,6 +632,7 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
bool triggerEvent = false;
|
bool triggerEvent = false;
|
||||||
currentCellTriggeredEventAreaEntryUnitId = 0;
|
currentCellTriggeredEventAreaEntryUnitId = 0;
|
||||||
currentCellTriggeredEventAreaExitUnitId = 0;
|
currentCellTriggeredEventAreaExitUnitId = 0;
|
||||||
|
currentCellTriggeredEventUnitId = 0;
|
||||||
|
|
||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
case ctet_Unit:
|
case ctet_Unit:
|
||||||
|
@ -646,6 +653,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
__FILE__,__FUNCTION__,__LINE__,movingUnit->getId(), event.type,movingUnit->getPos().getString().c_str(),event.sourceId,event.destId, event.destPos.getString().c_str(), destUnit->getPos().getString().c_str(),srcInDst);
|
__FILE__,__FUNCTION__,__LINE__,movingUnit->getId(), event.type,movingUnit->getPos().getString().c_str(),event.sourceId,event.destId, event.destPos.getString().c_str(), destUnit->getPos().getString().c_str(),srcInDst);
|
||||||
}
|
}
|
||||||
triggerEvent = srcInDst;
|
triggerEvent = srcInDst;
|
||||||
|
if(triggerEvent == true) {
|
||||||
|
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -661,6 +671,10 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
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__);
|
||||||
}
|
}
|
||||||
triggerEvent = srcInDst;
|
triggerEvent = srcInDst;
|
||||||
|
|
||||||
|
if(triggerEvent == true) {
|
||||||
|
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -681,6 +695,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
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__);
|
||||||
}
|
}
|
||||||
triggerEvent = srcInDst;
|
triggerEvent = srcInDst;
|
||||||
|
if(triggerEvent == true) {
|
||||||
|
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -703,6 +720,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
__FILE__,__FUNCTION__,__LINE__,movingUnit->getId(),event.type,movingUnit->getPos().getString().c_str(),event.sourceId,event.destId,event.destPos.getString().c_str(),destUnit->getPos().getString().c_str(),srcInDst);
|
__FILE__,__FUNCTION__,__LINE__,movingUnit->getId(),event.type,movingUnit->getPos().getString().c_str(),event.sourceId,event.destId,event.destPos.getString().c_str(),destUnit->getPos().getString().c_str(),srcInDst);
|
||||||
}
|
}
|
||||||
triggerEvent = srcInDst;
|
triggerEvent = srcInDst;
|
||||||
|
if(triggerEvent == true) {
|
||||||
|
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -717,6 +737,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
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__);
|
||||||
}
|
}
|
||||||
triggerEvent = srcInDst;
|
triggerEvent = srcInDst;
|
||||||
|
if(triggerEvent == true) {
|
||||||
|
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -724,7 +747,7 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
case ctet_FactionAreaPos:
|
case ctet_FactionAreaPos:
|
||||||
{
|
{
|
||||||
if(movingUnit->getFactionIndex() == event.sourceId) {
|
if(movingUnit->getFactionIndex() == event.sourceId) {
|
||||||
//printf("ctet_FactionPos event.destPos = [%s], movingUnit->getPos() [%s]\n",event.destPos.getString().c_str(),movingUnit->getPos().getString().c_str());
|
//if(event.sourceId == 1) printf("ctet_FactionPos event.destPos = [%s], movingUnit->getPos() [%s] Unit id = %d\n",event.destPos.getString().c_str(),movingUnit->getPos().getString().c_str(),movingUnit->getId());
|
||||||
|
|
||||||
bool srcInDst = false;
|
bool srcInDst = false;
|
||||||
for(int x = event.destPos.x; srcInDst == false && x <= event.destPosEnd.x; ++x) {
|
for(int x = event.destPos.x; srcInDst == false && x <= event.destPosEnd.x; ++x) {
|
||||||
|
@ -737,6 +760,10 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
triggerEvent = srcInDst;
|
triggerEvent = srcInDst;
|
||||||
|
if(triggerEvent == true) {
|
||||||
|
//printf("!!!UNIT IN AREA!!! Faction area pos, moving unit faction= %d, trigger faction = %d, unit id = %d\n",movingUnit->getFactionIndex(),event.sourceId,movingUnit->getId());
|
||||||
|
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -761,6 +788,9 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
triggerEvent = srcInDst;
|
triggerEvent = srcInDst;
|
||||||
|
if(triggerEvent == true) {
|
||||||
|
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// If unit is already in cell range check if they are leaving?
|
// If unit is already in cell range check if they are leaving?
|
||||||
else {
|
else {
|
||||||
|
@ -777,6 +807,10 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
triggerEvent = (srcInDst == false);
|
triggerEvent = (srcInDst == false);
|
||||||
|
if(triggerEvent == true) {
|
||||||
|
currentCellTriggeredEventUnitId = movingUnit->getId();
|
||||||
|
}
|
||||||
|
|
||||||
if(triggerEvent == true) {
|
if(triggerEvent == true) {
|
||||||
currentCellTriggeredEventAreaExitUnitId = movingUnit->getId();
|
currentCellTriggeredEventAreaExitUnitId = movingUnit->getId();
|
||||||
|
|
||||||
|
@ -1427,6 +1461,12 @@ void ScriptManager::removeCellMarker(Vec2i pos, int factionIndex) {
|
||||||
return world->removeCellMarker(pos,factionIndex);
|
return world->removeCellMarker(pos,factionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptManager::showMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile, int flashCount) {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
return world->showMarker(pos,factionIndex, note, textureFile, flashCount);
|
||||||
|
}
|
||||||
|
|
||||||
int ScriptManager::getIsUnitAlive(int unitId) {
|
int ScriptManager::getIsUnitAlive(int unitId) {
|
||||||
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;
|
||||||
|
@ -1476,6 +1516,10 @@ int ScriptManager::getCellTriggeredEventAreaExitUnitId() {
|
||||||
return currentCellTriggeredEventAreaExitUnitId;
|
return currentCellTriggeredEventAreaExitUnitId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::getCellTriggeredEventUnitId() {
|
||||||
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
return currentCellTriggeredEventUnitId;
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptManager::setRandomGenInit(int seed) {
|
void ScriptManager::setRandomGenInit(int seed) {
|
||||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
@ -1630,6 +1674,12 @@ int ScriptManager::isFreeCells(int unitSize, int field, Vec2i pos) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::getHumanFactionId() {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||||
|
return this->world->getThisFactionIndex();
|
||||||
|
}
|
||||||
|
|
||||||
// ========================== lua callbacks ===============================================
|
// ========================== lua callbacks ===============================================
|
||||||
|
|
||||||
int ScriptManager::showMessage(LuaHandle* luaHandle){
|
int ScriptManager::showMessage(LuaHandle* luaHandle){
|
||||||
|
@ -2081,6 +2131,32 @@ int ScriptManager::removeCellMarker(LuaHandle* luaHandle){
|
||||||
return luaArguments.getReturnCount();
|
return luaArguments.getReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::showMarker(LuaHandle* luaHandle){
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
|
||||||
|
int flashCount = luaArguments.getInt(-5);
|
||||||
|
//printf("LUA addCellMarker --> START\n");
|
||||||
|
|
||||||
|
int factionIndex = luaArguments.getInt(-4);
|
||||||
|
|
||||||
|
//printf("LUA addCellMarker --> START 1\n");
|
||||||
|
|
||||||
|
Vec2i pos = luaArguments.getVec2i(-1);
|
||||||
|
|
||||||
|
//printf("LUA addCellMarker --> START 2\n");
|
||||||
|
|
||||||
|
string note = luaArguments.getString(-3);
|
||||||
|
|
||||||
|
//printf("LUA addCellMarker --> START 3\n");
|
||||||
|
|
||||||
|
string texture = luaArguments.getString(-2);
|
||||||
|
|
||||||
|
//printf("LUA addCellMarker --> faction [%d] pos [%s] note [%s] texture [%s]\n",factionIndex,pos.getString().c_str(),note.c_str(),texture.c_str());
|
||||||
|
|
||||||
|
thisScriptManager->showMarker(pos,factionIndex,note,texture,flashCount);
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
int ScriptManager::getUnitFaction(LuaHandle* luaHandle){
|
int ScriptManager::getUnitFaction(LuaHandle* luaHandle){
|
||||||
LuaArguments luaArguments(luaHandle);
|
LuaArguments luaArguments(luaHandle);
|
||||||
int factionIndex= thisScriptManager->getUnitFaction(luaArguments.getInt(-1));
|
int factionIndex= thisScriptManager->getUnitFaction(luaArguments.getInt(-1));
|
||||||
|
@ -2136,6 +2212,12 @@ int ScriptManager::getCellTriggeredEventAreaExitUnitId(LuaHandle* luaHandle){
|
||||||
return luaArguments.getReturnCount();
|
return luaArguments.getReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::getCellTriggeredEventUnitId(LuaHandle* luaHandle){
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
luaArguments.returnInt(thisScriptManager->getCellTriggeredEventUnitId());
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
int ScriptManager::setRandomGenInit(LuaHandle* luaHandle){
|
int ScriptManager::setRandomGenInit(LuaHandle* luaHandle){
|
||||||
LuaArguments luaArguments(luaHandle);
|
LuaArguments luaArguments(luaHandle);
|
||||||
thisScriptManager->setRandomGenInit(luaArguments.getInt(-1));
|
thisScriptManager->setRandomGenInit(luaArguments.getInt(-1));
|
||||||
|
@ -2570,6 +2652,13 @@ int ScriptManager::isFreeCells(LuaHandle* luaHandle) {
|
||||||
return luaArguments.getReturnCount();
|
return luaArguments.getReturnCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ScriptManager::getHumanFactionId(LuaHandle* luaHandle) {
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
LuaArguments luaArguments(luaHandle);
|
||||||
|
luaArguments.returnInt(thisScriptManager->getHumanFactionId());
|
||||||
|
return luaArguments.getReturnCount();
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptManager::saveGame(XmlNode *rootNode) {
|
void ScriptManager::saveGame(XmlNode *rootNode) {
|
||||||
std::map<string,string> mapTagReplacements;
|
std::map<string,string> mapTagReplacements;
|
||||||
XmlNode *scriptManagerNode = rootNode->addChild("ScriptManager");
|
XmlNode *scriptManagerNode = rootNode->addChild("ScriptManager");
|
||||||
|
|
|
@ -185,6 +185,7 @@ private:
|
||||||
|
|
||||||
int currentTimerTriggeredEventId;
|
int currentTimerTriggeredEventId;
|
||||||
int currentCellTriggeredEventId;
|
int currentCellTriggeredEventId;
|
||||||
|
int currentCellTriggeredEventUnitId;
|
||||||
|
|
||||||
int currentCellTriggeredEventAreaEntryUnitId;
|
int currentCellTriggeredEventAreaEntryUnitId;
|
||||||
int currentCellTriggeredEventAreaExitUnitId;
|
int currentCellTriggeredEventAreaExitUnitId;
|
||||||
|
@ -306,6 +307,8 @@ private:
|
||||||
int getCellTriggeredEventAreaEntryUnitId();
|
int getCellTriggeredEventAreaEntryUnitId();
|
||||||
int getCellTriggeredEventAreaExitUnitId();
|
int getCellTriggeredEventAreaExitUnitId();
|
||||||
|
|
||||||
|
int getCellTriggeredEventUnitId();
|
||||||
|
|
||||||
void setRandomGenInit(int seed);
|
void setRandomGenInit(int seed);
|
||||||
int getRandomGen(int minVal, int maxVal);
|
int getRandomGen(int minVal, int maxVal);
|
||||||
int getWorldFrameCount();
|
int getWorldFrameCount();
|
||||||
|
@ -335,6 +338,8 @@ private:
|
||||||
void addCellMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile);
|
void addCellMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile);
|
||||||
void removeCellMarker(Vec2i pos, int factionIndex);
|
void removeCellMarker(Vec2i pos, int factionIndex);
|
||||||
|
|
||||||
|
void showMarker(Vec2i pos, int factionIndex, const string ¬e, const string &textureFile, int flashCount);
|
||||||
|
|
||||||
const string &getLastDeadUnitName();
|
const string &getLastDeadUnitName();
|
||||||
int getLastDeadUnitId();
|
int getLastDeadUnitId();
|
||||||
int getLastDeadUnitCauseOfDeath();
|
int getLastDeadUnitCauseOfDeath();
|
||||||
|
@ -361,6 +366,7 @@ private:
|
||||||
int isFreeCellsOrHasUnit(int field, int unitId,Vec2i pos);
|
int isFreeCellsOrHasUnit(int field, int unitId,Vec2i pos);
|
||||||
int isFreeCells(int unitSize, int field,Vec2i pos);
|
int isFreeCells(int unitSize, int field,Vec2i pos);
|
||||||
|
|
||||||
|
int getHumanFactionId();
|
||||||
|
|
||||||
//callbacks, commands
|
//callbacks, commands
|
||||||
static int networkShowMessageForFaction(LuaHandle* luaHandle);
|
static int networkShowMessageForFaction(LuaHandle* luaHandle);
|
||||||
|
@ -435,6 +441,8 @@ private:
|
||||||
static int getCellTriggeredEventAreaEntryUnitId(LuaHandle* luaHandle);
|
static int getCellTriggeredEventAreaEntryUnitId(LuaHandle* luaHandle);
|
||||||
static int getCellTriggeredEventAreaExitUnitId(LuaHandle* luaHandle);
|
static int getCellTriggeredEventAreaExitUnitId(LuaHandle* luaHandle);
|
||||||
|
|
||||||
|
static int getCellTriggeredEventUnitId(LuaHandle* luaHandle);
|
||||||
|
|
||||||
static int setRandomGenInit(LuaHandle* luaHandle);
|
static int setRandomGenInit(LuaHandle* luaHandle);
|
||||||
static int getRandomGen(LuaHandle* luaHandle);
|
static int getRandomGen(LuaHandle* luaHandle);
|
||||||
static int getWorldFrameCount(LuaHandle* luaHandle);
|
static int getWorldFrameCount(LuaHandle* luaHandle);
|
||||||
|
@ -461,6 +469,8 @@ private:
|
||||||
static int addCellMarker(LuaHandle* luaHandle);
|
static int addCellMarker(LuaHandle* luaHandle);
|
||||||
static int removeCellMarker(LuaHandle* luaHandle);
|
static int removeCellMarker(LuaHandle* luaHandle);
|
||||||
|
|
||||||
|
static int showMarker(LuaHandle* luaHandle);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -491,6 +501,8 @@ private:
|
||||||
static int isFreeCellsOrHasUnit(LuaHandle* luaHandle);
|
static int isFreeCellsOrHasUnit(LuaHandle* luaHandle);
|
||||||
static int isFreeCells(LuaHandle* luaHandle);
|
static int isFreeCells(LuaHandle* luaHandle);
|
||||||
|
|
||||||
|
static int getHumanFactionId(LuaHandle* luaHandle);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -5928,9 +5928,12 @@ void Renderer::renderHighlightedCellsOnMinimap() {
|
||||||
|
|
||||||
for(int i = 0;i < highlightedCells->size(); i++) {
|
for(int i = 0;i < highlightedCells->size(); i++) {
|
||||||
const MarkedCell *mc=&highlightedCells->at(i);
|
const MarkedCell *mc=&highlightedCells->at(i);
|
||||||
if(mc->getFaction() != NULL && mc->getFaction()->getTeam() == game->getWorld()->getThisFaction()->getTeam()) {
|
if(mc->getFaction() == NULL || (mc->getFaction()->getTeam() == game->getWorld()->getThisFaction()->getTeam())) {
|
||||||
const Texture2D *texture= game->getHighlightCellTexture();
|
const Texture2D *texture= game->getHighlightCellTexture();
|
||||||
Vec3f color= mc->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
Vec3f color(MarkedCell::static_system_marker_color);
|
||||||
|
if(mc->getFaction() != NULL) {
|
||||||
|
color= mc->getFaction()->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
||||||
|
}
|
||||||
float alpha = 0.49f+0.5f/(mc->getAliveCount()%15);
|
float alpha = 0.49f+0.5f/(mc->getAliveCount()%15);
|
||||||
Vec2i pos=mc->getTargetPos();
|
Vec2i pos=mc->getTargetPos();
|
||||||
if(texture!=NULL){
|
if(texture!=NULL){
|
||||||
|
|
|
@ -3213,6 +3213,15 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||||
listBoxTeams[i].setSelectedItem(intToStr(GameConstants::maxPlayers + fpt_Observer));
|
listBoxTeams[i].setSelectedItem(intToStr(GameConstants::maxPlayers + fpt_Observer));
|
||||||
}
|
}
|
||||||
else if(listBoxTeams[i].getSelectedItem() == intToStr(GameConstants::maxPlayers + fpt_Observer)) {
|
else if(listBoxTeams[i].getSelectedItem() == intToStr(GameConstants::maxPlayers + fpt_Observer)) {
|
||||||
|
|
||||||
|
//printf("Line: %d lastSelectedTeamIndex[i] = %d \n",__LINE__,lastSelectedTeamIndex[i]);
|
||||||
|
|
||||||
|
if((listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
||||||
|
listBoxControls[i].getSelectedItemIndex() == ctCpuUltra || listBoxControls[i].getSelectedItemIndex() == ctCpuMega) &&
|
||||||
|
checkBoxScenario.getValue() == true) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
if(lastSelectedTeamIndex[i] >= 0 && lastSelectedTeamIndex[i] + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
if(lastSelectedTeamIndex[i] >= 0 && lastSelectedTeamIndex[i] + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||||
if(lastSelectedTeamIndex[i] == 0) {
|
if(lastSelectedTeamIndex[i] == 0) {
|
||||||
lastSelectedTeamIndex[i] = GameConstants::maxPlayers-1;
|
lastSelectedTeamIndex[i] = GameConstants::maxPlayers-1;
|
||||||
|
@ -3227,6 +3236,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||||
listBoxTeams[i].setSelectedItem(intToStr(1));
|
listBoxTeams[i].setSelectedItem(intToStr(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gameSettings->setTeam(slotIndex, listBoxTeams[i].getSelectedItemIndex());
|
gameSettings->setTeam(slotIndex, listBoxTeams[i].getSelectedItemIndex());
|
||||||
gameSettings->setStartLocationIndex(slotIndex, i);
|
gameSettings->setStartLocationIndex(slotIndex, i);
|
||||||
|
@ -4317,6 +4327,11 @@ void MenuStateCustomGame::processScenario() {
|
||||||
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||||
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||||
}
|
}
|
||||||
|
// Alow Neutral cpu players
|
||||||
|
else if(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
||||||
|
listBoxControls[i].getSelectedItemIndex() == ctCpuUltra || listBoxControls[i].getSelectedItemIndex() == ctCpuMega) {
|
||||||
|
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lastSelectedTeamIndex[i] = -1;
|
lastSelectedTeamIndex[i] = -1;
|
||||||
|
|
|
@ -1342,6 +1342,31 @@ void World::removeCellMarker(Vec2i pos, int factionIndex) {
|
||||||
game->removeCellMarker(surfaceCellPos, faction);
|
game->removeCellMarker(surfaceCellPos, faction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::showMarker(Vec2i pos, int factionIndex, const string ¬e, const string textureFile, int flashCount) {
|
||||||
|
//Vec2i surfaceCellPos = map.toSurfCoords(pos);
|
||||||
|
//Vec2i surfaceCellPos = pos;
|
||||||
|
const Faction *faction = NULL;
|
||||||
|
if(factionIndex >= 0) {
|
||||||
|
faction = this->getFaction(factionIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec2i surfaceCellPos = map.toSurfCoords(pos);
|
||||||
|
SurfaceCell *sc = map.getSurfaceCell(surfaceCellPos);
|
||||||
|
if(sc == NULL) {
|
||||||
|
throw megaglest_runtime_error("sc == NULL");
|
||||||
|
}
|
||||||
|
Vec3f vertex = sc->getVertex();
|
||||||
|
Vec2i targetPos(vertex.x,vertex.z);
|
||||||
|
|
||||||
|
//printf("pos [%s] scPos [%s][%p] targetPos [%s]\n",pos.getString().c_str(),surfaceCellPos.getString().c_str(),sc,targetPos.getString().c_str());
|
||||||
|
|
||||||
|
MarkedCell mc(targetPos,faction,note,(faction != NULL ? faction->getStartLocationIndex() : -1));
|
||||||
|
if(flashCount > 0) {
|
||||||
|
mc.setAliveCount(flashCount);
|
||||||
|
}
|
||||||
|
game->showMarker(surfaceCellPos, mc);
|
||||||
|
}
|
||||||
|
|
||||||
int World::getUnitFactionIndex(int unitId) {
|
int World::getUnitFactionIndex(int unitId) {
|
||||||
Unit* unit= findUnitById(unitId);
|
Unit* unit= findUnitById(unitId);
|
||||||
if(unit == NULL) {
|
if(unit == NULL) {
|
||||||
|
|
|
@ -248,6 +248,7 @@ public:
|
||||||
|
|
||||||
void addCellMarker(Vec2i pos, int factionIndex, const string ¬e, const string textureFile);
|
void addCellMarker(Vec2i pos, int factionIndex, const string ¬e, const string textureFile);
|
||||||
void removeCellMarker(Vec2i pos, int factionIndex);
|
void removeCellMarker(Vec2i pos, int factionIndex);
|
||||||
|
void showMarker(Vec2i pos, int factionIndex, const string ¬e, const string textureFile,int flashCount);
|
||||||
|
|
||||||
int getUnitFactionIndex(int unitId);
|
int getUnitFactionIndex(int unitId);
|
||||||
const string getUnitName(int unitId);
|
const string getUnitName(int unitId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user