176
Feature requests / Re: giveMorphCommand
« on: 16 May 2012, 15:06:26 »
my bad, sorry
MegaGlests' game mods menu let's you install many new mods. Even more are available on the MegaGlest Wiki and the Mods forum.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Index: source/glest_game/game/script_manager.cpp
===================================================================
--- source/glest_game/game/script_manager.cpp (revision 3326)
+++ source/glest_game/game/script_manager.cpp (working copy)
@@ -265,6 +265,7 @@
luaScript.registerFunction(giveResource, "giveResource");
luaScript.registerFunction(givePositionCommand, "givePositionCommand");
luaScript.registerFunction(giveProductionCommand, "giveProductionCommand");
+ luaScript.registerFunction(giveMorphCommand, "giveMorphCommand");
luaScript.registerFunction(giveAttackCommand, "giveAttackCommand");
luaScript.registerFunction(giveUpgradeCommand, "giveUpgradeCommand");
luaScript.registerFunction(giveAttackStoppedCommand, "giveAttackStoppedCommand");
@@ -925,7 +926,11 @@
ScriptManager_STREFLOP_Wrapper streflopWrapper;
world->giveUpgradeCommand(unitId, producedName);
}
-
+void ScriptManager::giveMorphCommand(int unitId, const string &producedName){
+ if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
+ ScriptManager_STREFLOP_Wrapper streflopWrapper;
+ world->giveMorphCommand(unitId, producedName);
+}
void ScriptManager::giveAttackStoppedCommand(int unitId, const string &itemName,int ignoreRequirements) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
ScriptManager_STREFLOP_Wrapper streflopWrapper;
@@ -1578,6 +1583,13 @@
luaArguments.getString(-1));
return luaArguments.getReturnCount();
}
+int ScriptManager::giveMorphCommand(LuaHandle* luaHandle){
+ LuaArguments luaArguments(luaHandle);
+ thisScriptManager->giveMorphCommand(
+ luaArguments.getInt(-2),
+ luaArguments.getString(-1));
+ return luaArguments.getReturnCount();
+}
int ScriptManager::giveUpgradeCommand(LuaHandle* luaHandle){
LuaArguments luaArguments(luaHandle);
Index: source/glest_game/game/script_manager.h
===================================================================
--- source/glest_game/game/script_manager.h (revision 3326)
+++ source/glest_game/game/script_manager.h (working copy)
@@ -261,6 +261,7 @@
void giveProductionCommand(int unitId, const string &producedName);
void giveAttackCommand(int unitId, int unitToAttackId);
void giveUpgradeCommand(int unitId, const string &upgradeName);
+ void giveMorphCommand(int unitId, const string &producedName);
void disableAi(int factionIndex);
void enableAi(int factionIndex);
@@ -363,6 +364,7 @@
static int giveResource(LuaHandle* luaHandle);
static int givePositionCommand(LuaHandle* luaHandle);
static int giveProductionCommand(LuaHandle* luaHandle);
+ static int giveMorphCommand(LuaHandle* luaHandle);
static int giveAttackCommand(LuaHandle* luaHandle);
static int giveUpgradeCommand(LuaHandle* luaHandle);
Index: source/glest_game/world/world.cpp
===================================================================
--- source/glest_game/world/world.cpp (revision 3326)
+++ source/glest_game/world/world.cpp (working copy)
@@ -1076,7 +1076,32 @@
throw megaglest_runtime_error("Invalid unitId index in giveProductionCommand: " + intToStr(unitId) + " producedName = " + producedName);
}
}
+void World::giveMorphCommand(int unitId, const string &producedName) {
+ Unit *unit= findUnitById(unitId);
+ if(unit != NULL) {
+ const UnitType *ut= unit->getType();
+ //Search for a command that can produce the unit
+ for(int i= 0; i< ut->getCommandTypeCount(); ++i) {
+ const CommandType* ct= ut->getCommandType(i);
+ if(ct != NULL && ct->getClass() == ccMorph) {
+ const MorphCommandType* pct= static_cast<const MorphCommandType*>(ct);
+ if(pct != NULL && pct->getMorphUnit()->getName() == producedName) {
+ if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
+
+ unit->giveCommand(new Command(pct));
+
+ if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
+ break;
+ }
+ }
+ }
+ }
+ else {
+ throw megaglest_runtime_error("Invalid unitId index in giveProductionCommand: " + intToStr(unitId) + " producedName = " + producedName);
+ }
+}
+
void World::giveAttackStoppedCommand(int unitId, const string &itemName, bool ignoreRequirements) {
Unit *unit= findUnitById(unitId);
if(unit != NULL) {
Index: source/glest_game/world/world.h
===================================================================
--- source/glest_game/world/world.h (revision 3326)
+++ source/glest_game/world/world.h (working copy)
@@ -230,6 +230,7 @@
bool getIsUnitAlive(int unitId);
void giveAttackCommand(int unitId, int unitToAttackId);
void giveProductionCommand(int unitId, const string &producedName);
+ void giveMorphCommand(int unitId, const string &producedName);
void giveUpgradeCommand(int unitId, const string &upgradeName);
void giveAttackStoppedCommand(int unitId, const string &itemName,bool ignoreRequirements);
void playStaticSound(const string &playSound);
in Globals:I assume that would not be so easy, because you would need different xml types, a work-arround would be to set a variable to 1 in the <globals> tag of megaglest and ask in startup, wether it's set, or not.That wouldn't work well, though, as it would only stop MG-only scenarios from playing on GAE, but not the other way around. Not sure what you mean by "you would need different xml types".
megaglest = 1
in startup:megaglest = megaglest or 0
if megaglest == 1 then
-- do something for MG
else
-- do something for GAE
end
[URL=http://imageshack.us/photo/my-images/338/screen95.jpg/][IMG]http://img338.imageshack.us/img338/3549/screen95.th.jpg[/img][/URL] [URL=http://imageshack.us/photo/my-images/29/screen96r.jpg/][IMG]http://img29.imageshack.us/img29/6170/screen96r.th.jpg[/img][/URL] [URL=http://imageshack.us/photo/my-images/402/screen97u.jpg/][IMG]http://img402.imageshack.us/img402/2978/screen97u.th.jpg[/img][/URL] [URL=http://imageshack.us/photo/my-images/195/screen98n.jpg/][IMG]http://img195.imageshack.us/img195/4129/screen98n.th.jpg[/img][/URL] [URL=http://imageshack.us/photo/my-images/821/screen99.jpg/][IMG]http://img821.imageshack.us/img821/305/screen99.th.jpg[/img][/URL]
Man 25 minutes on my school wifi to download the MG source. Ugh.
Also, you would have to do the particles yourself. I am not familiar enough with the particle code to modify it.
I presume you want something like the blood lines in hon that symbolize lifesteal?
Yes I've posted some, I really mean is that we have many things to do in megaglest yet. It's amazing that nobody understands programming here but softcoder!, You see has many taxpayers tilesetes mods maps ... ,
I think first before everything we search more developers to megaglest, not to fall all this weight on the back of softcoder.
GAE supports life steal and ep steal and ep burn already with effects, and my own personal version supports it in the source code. Since the effect in the source code was directly modeled on the damage functions, it shouldn't produce any weird errors in multiplayer. I will look at the MG source code to see if it is similar enough to just copy the changes. It only affects 8 files.
If MegaGlest (or you, since you're using a custom engine, right?)No, I'm not using anything different from SVN-head.
If MegaGlest were to implement GAE's effects, you could very easily have "life steal" and "mana burn" (assuming the former just absorbs health and gives it to the attacker while the latter simply damages EP).I think softcoder would not be sooo happy to use GAE-code without much testing in multiplayer, And I can't use code, that might cause problem in multiplayer and I don't want to use anything else than MG-SVN (or the corresponding release that supports, everything I need for my mod)
What sort of spell effects do you have?
In the commercial versions they have:
lifesteal
manaburn
stuns
snares
roots
slows
immobilize
silence
etc.
buildings = {}
record = 1I don't understand what you mean. Do you mean create some new orders in C++ which modders can then call with Lua?Yes, that what I thought about, and did in my mod.
slight edit to include a link to the previous GDC's posting, as per tradition.Oh, it seems I forgot it ... thanks