• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua On Step, copy players look and name onto monster? [OTHire]

Xapafe

Member
Joined
Jul 22, 2013
Messages
83
Reaction score
6
Anyone ever heard of anything like this?

Player steps into a room and fights himself? Doppelganger style stuff!

Another idea I have for my server, but as usual I'm unsure where to start. I'm pretty good at overcoming obstacles but I'm really sure this probably isn't possible with OTHire.
 
Anyone ever heard of anything like this?

Player steps into a room and fights himself? Doppelganger style stuff!

Another idea I have for my server, but as usual I'm unsure where to start. I'm pretty good at overcoming obstacles but I'm really sure this probably isn't possible with OTHire.

Sounds like a great idea taken from games like Zelda: OOT or other equivalent games. All of this can be implemented through LUA as far as my understanding goes for what you're trying to accomplish.

These are some links you might find interesting:

1.
2.
3.
4.
 
c2cac611f4b565f79dcae471d25a4461.png

f1042fbff6cebe612c49660cc9ae0e1b.png


Forgive the map it is auto generated.. well i will give you some hints about how to make it...

This is the C++ Code
Code:
int32_t LuaInterface::luaDoCreateCustomMonster(lua_State* L)
{
   //doCreateCustomMonster(name, pos, outfit, health, attspell,defensespell,defense,armor,baseSpeed,exp)
   // created By MeNi for otland.net //
   ScriptEnviroment* env = getEnv();
   MonsterType* pobranyTyp = new MonsterType();
   Monster* monster;
   int64_t health, defense, armor, baseSpeed,experience;
   Outfit_t outfit;
   PositionEx pos;

   experience = popNumber(L);
   baseSpeed = popNumber(L);
   armor = popNumber(L);
   defense = popNumber(L);
   std::string defensespells = popString(L);
   std::string attackspells = popString(L);
   health = popNumber(L);
   outfit = popOutfit(L);
   popPosition(L, pos);
   std::string name = popString(L);

   pobranyTyp->spellAttackList.clear();

   pobranyTyp->health = health;
   pobranyTyp->healthMax = health;
   pobranyTyp->outfit = outfit;
   pobranyTyp->name = name;
   pobranyTyp->nameDescription = name;
   pobranyTyp->lookCorpse = 0;
   pobranyTyp->targetDistance = 1;
   pobranyTyp->experience = experience;
   pobranyTyp->isSummonable = false;
   pobranyTyp->isIllusionable = false;
   pobranyTyp->isConvinceable = false;
   pobranyTyp->isWalkable = true;
   pobranyTyp->pushable = false;
   pobranyTyp->isAttackable = true;
   pobranyTyp->isHostile = true;
   pobranyTyp->canPushItems = true;
   pobranyTyp->canPushCreatures = true;
   pobranyTyp->conditionImmunities |= CONDITION_PARALYZE;
   pobranyTyp->conditionImmunities |= CONDITION_DRUNK;
   pobranyTyp->conditionImmunities |= CONDITION_INVISIBLE;
   pobranyTyp->defense = defense;
   pobranyTyp->armor = armor;
   pobranyTyp->skull = SKULL_RED;
   pobranyTyp->baseSpeed = baseSpeed;
   pobranyTyp->changeTargetSpeed = 0;
   pobranyTyp->changeTargetChance = 0;
   if (!attackspells.empty()){
     xmlNodePtr root_attack = xmlDocGetRootElement(xmlParseMemory(attackspells.c_str(), attackspells.length()));
     xmlNodePtr tmpNode_attack = root_attack->children;
     while (tmpNode_attack)
     {
       if (!xmlStrcmp(tmpNode_attack->name, (const xmlChar*)"attack"))
       {
         spellBlock_t sb;
         if (g_monsters.deserializeSpell(tmpNode_attack, sb, "doCreateCustomMonster"))
           pobranyTyp->spellAttackList.push_back(sb);
       }
       tmpNode_attack = tmpNode_attack->next;
     }
   }
   if (!defensespells.empty()){
     xmlNodePtr root_defense = xmlDocGetRootElement(xmlParseMemory(defensespells.c_str(), defensespells.length()));
     xmlNodePtr tmpNode_defense = root_defense->children;
     while (tmpNode_defense)
     {
       if (!xmlStrcmp(tmpNode_defense->name, (const xmlChar*)"defense"))
       {
         spellBlock_t defense;
         if (g_monsters.deserializeSpell(tmpNode_defense, defense, "doCreateCustomMonster"))
           pobranyTyp->spellDefenseList.push_back(defense);
       }
       tmpNode_defense = tmpNode_defense->next;
     }
   }
   monster = Monster::createMonster(pobranyTyp);

   if (!g_game.placeCreature(monster, pos, false, false))
   {
     delete monster;
     lua_pushboolean(L, false);
     return 1;
   }

   lua_pushnumber(L, env->addThing((Thing*)monster));
   return 1;
}

LUA Code

Code:
//doCreateCustomMonster(name, pos, outfit, health, attspell,defensespell,defense,armor,baseSpeed,exp)

This should be enough to make the monster..

Note:Red skull is in the source
 
c2cac611f4b565f79dcae471d25a4461.png

f1042fbff6cebe612c49660cc9ae0e1b.png


Forgive the map it is auto generated.. well i will give you some hints about how to make it...

This is the C++ Code
Code:
int32_t LuaInterface::luaDoCreateCustomMonster(lua_State* L)
{
   //doCreateCustomMonster(name, pos, outfit, health, attspell,defensespell,defense,armor,baseSpeed,exp)
   // created By MeNi for otland.net //
   ScriptEnviroment* env = getEnv();
   MonsterType* pobranyTyp = new MonsterType();
   Monster* monster;
   int64_t health, defense, armor, baseSpeed,experience;
   Outfit_t outfit;
   PositionEx pos;

   experience = popNumber(L);
   baseSpeed = popNumber(L);
   armor = popNumber(L);
   defense = popNumber(L);
   std::string defensespells = popString(L);
   std::string attackspells = popString(L);
   health = popNumber(L);
   outfit = popOutfit(L);
   popPosition(L, pos);
   std::string name = popString(L);

   pobranyTyp->spellAttackList.clear();

   pobranyTyp->health = health;
   pobranyTyp->healthMax = health;
   pobranyTyp->outfit = outfit;
   pobranyTyp->name = name;
   pobranyTyp->nameDescription = name;
   pobranyTyp->lookCorpse = 0;
   pobranyTyp->targetDistance = 1;
   pobranyTyp->experience = experience;
   pobranyTyp->isSummonable = false;
   pobranyTyp->isIllusionable = false;
   pobranyTyp->isConvinceable = false;
   pobranyTyp->isWalkable = true;
   pobranyTyp->pushable = false;
   pobranyTyp->isAttackable = true;
   pobranyTyp->isHostile = true;
   pobranyTyp->canPushItems = true;
   pobranyTyp->canPushCreatures = true;
   pobranyTyp->conditionImmunities |= CONDITION_PARALYZE;
   pobranyTyp->conditionImmunities |= CONDITION_DRUNK;
   pobranyTyp->conditionImmunities |= CONDITION_INVISIBLE;
   pobranyTyp->defense = defense;
   pobranyTyp->armor = armor;
   pobranyTyp->skull = SKULL_RED;
   pobranyTyp->baseSpeed = baseSpeed;
   pobranyTyp->changeTargetSpeed = 0;
   pobranyTyp->changeTargetChance = 0;
   if (!attackspells.empty()){
     xmlNodePtr root_attack = xmlDocGetRootElement(xmlParseMemory(attackspells.c_str(), attackspells.length()));
     xmlNodePtr tmpNode_attack = root_attack->children;
     while (tmpNode_attack)
     {
       if (!xmlStrcmp(tmpNode_attack->name, (const xmlChar*)"attack"))
       {
         spellBlock_t sb;
         if (g_monsters.deserializeSpell(tmpNode_attack, sb, "doCreateCustomMonster"))
           pobranyTyp->spellAttackList.push_back(sb);
       }
       tmpNode_attack = tmpNode_attack->next;
     }
   }
   if (!defensespells.empty()){
     xmlNodePtr root_defense = xmlDocGetRootElement(xmlParseMemory(defensespells.c_str(), defensespells.length()));
     xmlNodePtr tmpNode_defense = root_defense->children;
     while (tmpNode_defense)
     {
       if (!xmlStrcmp(tmpNode_defense->name, (const xmlChar*)"defense"))
       {
         spellBlock_t defense;
         if (g_monsters.deserializeSpell(tmpNode_defense, defense, "doCreateCustomMonster"))
           pobranyTyp->spellDefenseList.push_back(defense);
       }
       tmpNode_defense = tmpNode_defense->next;
     }
   }
   monster = Monster::createMonster(pobranyTyp);

   if (!g_game.placeCreature(monster, pos, false, false))
   {
     delete monster;
     lua_pushboolean(L, false);
     return 1;
   }

   lua_pushnumber(L, env->addThing((Thing*)monster));
   return 1;
}

LUA Code

Code:
//doCreateCustomMonster(name, pos, outfit, health, attspell,defensespell,defense,armor,baseSpeed,exp)

This should be enough to make the monster..

Note:Red skull is in the source

Holy shit, thank you so much for this.

Which area of the source does this need to go into? monster.cpp?
 
Holy shit, thank you so much for this.

Which area of the source does this need to go into? monster.cpp?
This is incomplete, you need to put that in luascript.cpp .. and you need to have some scripting experience.. or it would be just useless.. i used the same script for multiple things.. and i think i like your idea so i will do it for my server lol
 
This is incomplete, you need to put that in luascript.cpp .. and you need to have some scripting experience.. or it would be just useless.. i used the same script for multiple things.. and i think i like your idea so i will do it for my server lol

Ha!

Man I have -SOME- experience. Let me ask you this.

I have taken a blank 7.6 map that only have creature spawns and I'm in the process of totally scripting it from the ground up.

I've redone all of the tool scripts, I've written almost all of the quests including postman and paradox and I've pretty much figured out how to solve most issues that are LUA based (Aside from the damn postman quest discount, see my thread HERE and HERE if you feel like taking a crack at that one.) Do you think I have enough know how to figure this out? Once I finish the cipsoft shit I'm going to start writing some custom stuff.

BTW thanks for responding to me to begin with man!
 
Ha!

Man I have -SOME- experience. Let me ask you this.

I have taken a blank 7.6 map that only have creature spawns and I'm in the process of totally scripting it from the ground up.

I've redone all of the tool scripts, I've written almost all of the quests including postman and paradox and I've pretty much figured out how to solve most issues that are LUA based (Aside from the damn postman quest discount, see my thread HERE and HERE if you feel like taking a crack at that one.) Do you think I have enough know how to figure this out? Once I finish the cipsoft shit I'm going to start writing some custom stuff.

BTW thanks for responding to me to begin with man!
i gave you the hardest part in the source.. the rest is totally up to you.. but i guess you would figure it out on your own.. but the attackspells and defenseSpells might be hard for you to add..atleast you could try it.. just add the function to the source and give it a try
 
Back
Top