• 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!

[Idea] Python Scriptengine

Leave it the way it is, people would take some time to learn, thats a nice idea but I think LUA systems can be even more improved without having to change the whole codes
 
Well, I'm happy as long as the script system is not python based, I absolutely HATE the tab/space based code-blocks system. =/

Personally I like the Idea of .NET/C++/Java/PHP based script system, it's about as easy to learn as anything else, it supports understandable OOP, and it opens a road for other programming languages, such as C++.
That way people can learn to code NPCs/scripts, and from there move on to learn C++ and then perhaps contribute to the TFS sourcecode.

eAthena uses a C/PHP based coding for their scripts/NPCs, and it works really well. So it IS possible to incorporate it. It's actually thanks to learning how to script NPCs in that emulator, that I learned to code PHP.
 
I'll see if I can make something like ScriptDev2 (from the mangos project).
 
Hmm... Any examples of ScriptDev2? I had a look at their website but I really don't feel like registering just to have a look at example code. ._.
 
I personally wouldn't mind python, because it would FORCE people to use much cleaner code
 
Won't add support for something like PHP, simply because it's not possible from what I can remember. And creating the entier engine is too much work.

ScriptDev2:

Code:
/*######
## npc_thorim
######*/
 
#define GOSSIP_ITEM_THORIM1 "Can you tell me what became of Sif?"
#define GOSSIP_ITEM_THORIM2 "He did more than that, Thorim. He controls Ulduar now."
#define GOSSIP_ITEM_THORIM3 "It needn't end this way."
 
enum
{
    QUEST_SIBLING_RIVALRY = 13064,
 
    SPELL_THORIM_STORY_KILL_CREDIT = 56940,
 
    GOSSIP_TEXTID_THORIM1 = 13799,
    GOSSIP_TEXTID_THORIM2 = 13801,
    GOSSIP_TEXTID_THORIM3 = 13802,
    GOSSIP_TEXTID_THORIM4 = 13803
};
 
bool GossipHello_npc_thorim(Player* pPlayer, Creature* pCreature)
{
    if (pCreature->isQuestGiver())
        pPlayer->PrepareQuestMenu(pCreature->GetGUID());
 
    if (pPlayer->GetQuestStatus(QUEST_SIBLING_RIVALRY) == QUEST_STATUS_INCOMPLETE)
    {
        pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_THORIM1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
        pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM1, pCreature->GetGUID());
    }
    else
        pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
 
    return true;
}
 
bool GossipSelect_npc_thorim(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
    switch(uiAction)
    {
        case GOSSIP_ACTION_INFO_DEF+1:
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_THORIM2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
            pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM2, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_INFO_DEF+2:
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_THORIM3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
            pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM3, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_INFO_DEF+3:
            pPlayer->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM4, pCreature->GetGUID());
            pCreature->CastSpell(pPlayer, SPELL_THORIM_STORY_KILL_CREDIT, true);
            break;
    }
 
    return true;
}
 
/*######
## npc_roxi_ramrocket
######*/
 
#define GOSSIP_TEXT_RAMROCKET1 "How do you fly in this cold climate?"
#define GOSSIP_TEXT_RAMROCKET2 "I hear you sell motorcycle parts."
 
enum
{
    SPELL_MECHANO_HOG = 60866,
    SPELL_MEKGINEER_CHOPPER = 60867
};
 
bool GossipHello_npc_roxi_ramrocket(Player* pPlayer, Creature* pCreature)
{
    if (pCreature->isTrainer())
        pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_TEXT_RAMROCKET1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRAIN);
 
    if (pCreature->isVendor())
    {
        if (pPlayer->HasSpell(SPELL_MECHANO_HOG) || pPlayer->HasSpell(SPELL_MEKGINEER_CHOPPER))
        {
            if (pPlayer->HasSkill(SKILL_ENGINERING) && pPlayer->GetBaseSkillValue(SKILL_ENGINERING) >= 450)
                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, GOSSIP_TEXT_RAMROCKET2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE);
        }
    }
 
    pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
    return true;
}
 
bool GossipSelect_npc_roxi_ramrocket(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
    switch(uiAction)
    {
        case GOSSIP_ACTION_TRAIN:
            pPlayer->SEND_TRAINERLIST(pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_TRADE:
            pPlayer->SEND_VENDORLIST(pCreature->GetGUID());
            break;
    }
 
    return true;
}
 
void AddSC_storm_peaks()
{
    Script* newscript;
 
    newscript = new Script;
    newscript->Name = "npc_loklira_the_crone";
    newscript->pGossipHello = &GossipHello_npc_loklira_the_crone;
    newscript->pGossipSelect = &GossipSelect_npc_loklira_the_crone;
    newscript->RegisterSelf();
 
    newscript = new Script;
    newscript->Name = "npc_thorim";
    newscript->pGossipHello = &GossipHello_npc_thorim;
    newscript->pGossipSelect = &GossipSelect_npc_thorim;
    newscript->RegisterSelf();
 
    newscript = new Script;
    newscript->Name = "npc_roxi_ramrocket";
    newscript->pGossipHello = &GossipHello_npc_roxi_ramrocket;
    newscript->pGossipSelect = &GossipSelect_npc_roxi_ramrocket;
    newscript->RegisterSelf();
}
Code:
#define GOSSIP_ITEM_ROYAL "I am ready to listen"
#define GOSSIP_ITEM_ROYAL_1 "That is tragic. How did this happen?"
#define GOSSIP_ITEM_ROYAL_2 "Interesting, continue please."
#define GOSSIP_ITEM_ROYAL_3 "Unbelievable! How dare they??"
#define GOSSIP_ITEM_ROYAL_4 "Of course I will help!"
 
bool GossipHello_npc_royal_historian_archesonus(Player* pPlayer, Creature* pCreature)
{
    if (pCreature->isQuestGiver())
        pPlayer->PrepareQuestMenu(pCreature->GetGUID());
 
    if (pPlayer->GetQuestStatus(3702) == QUEST_STATUS_INCOMPLETE)
    {
        pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ROYAL, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
        pPlayer->SEND_GOSSIP_MENU(2235, pCreature->GetGUID());
    }
    else
        pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID());
 
    return true;
}
 
bool GossipSelect_npc_royal_historian_archesonus(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
    switch(uiAction)
    {
        case GOSSIP_ACTION_INFO_DEF:
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ROYAL_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
            pPlayer->SEND_GOSSIP_MENU(2236, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_INFO_DEF+1:
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ROYAL_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
            pPlayer->SEND_GOSSIP_MENU(2237, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_INFO_DEF+2:
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ROYAL_3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
            pPlayer->SEND_GOSSIP_MENU(2238, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_INFO_DEF+3:
            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_ROYAL_4, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
            pPlayer->SEND_GOSSIP_MENU(2239, pCreature->GetGUID());
            break;
        case GOSSIP_ACTION_INFO_DEF+4:
            pPlayer->CLOSE_GOSSIP_MENU();
            pPlayer->AreaExploredOrEventHappens(3702);
            break;
    }
    return true;
}
 
void AddSC_ironforge()
{
    Script *newscript;
 
    newscript = new Script;
    newscript->Name = "npc_royal_historian_archesonus";
    newscript->pGossipHello = &GossipHello_npc_royal_historian_archesonus;
    newscript->pGossipSelect = &GossipSelect_npc_royal_historian_archesonus;
    newscript->RegisterSelf();
}
You can also make a class based on Script, but can't find some code that actually does that.
 
First of all... OH FUCK YES, please dear god let this become part of OT/TFS scripting...

Second of all... Pointers? What good could pointers do in NPC/whatever scripting? (Aside from creating delicious memory leaks/crashes when noobs plays around with them)

Still... most delicious scripting language ever, I want! <3
 
that example looks like C stian, but why would you want it implented. It looks so much at the code from tfs you could simply better hardcode things theno_O
 
that example looks like C stian, but why would you want it implented. It looks so much at the code from tfs you could simply better hardcode things theno_O

Well the main differences would be the usage of { }, enum and similar things that aint in LUA.

But again, the only real difference between C++ and C is Objects, thus if the examples doesn't contain any OOP examples, it would look like C.
 
Pointeres allow you to modify the data without the need to return it. And the references are there to save having two copies of the same function. C++ got some cleanings after functions return buildtin.

There is a million scripts. Only examples i can find that uses objects are the AIs, and basicly there isn't so much need to script hardcore complex AIs in Tibia.
 
Pointeres allow you to modify the data without the need to return it. And the references are there to save having two copies of the same function. C++ got some cleanings after functions return buildtin.

There is a million scripts. Only examples i can find that uses objects are the AIs, and basicly there isn't so much need to script hardcore complex AIs in Tibia.

*Facepalms*

Ah yes... Silly me.

Still, it would be a wonderful language to code in regardless. :)
 
Well, currently the only real alternatives are Python, C# and C++. And if you really want to have everything objectish in the C++ implant then just extend Script with all the calls you want directly?
 

no... not as a scripting language for TFS

Pointeres allow you to modify the data without the need to return it. And the references are there to save having two copies of the same function.

references allow you to do the same and are safer than pointers. they have nothing to do with "save having two copies of the same function". the only way you can have two copies of a functions is if it has been inlined
 
If it is possible I think a .NET language is better. This has great tools to program in and it is very easy to understand.

,,l,,


@kornholijo
No for anything, c# suck balls, and i dont know how reference may be safer than a pointer.

@stian
"And the references are there to save having two copies of the same function."

That is the opposite of a reference, when you for example, give a normal variable as a param of a function, and you edit it, you are actually editing the copy of the variable, so you will be able to edit it, without modifyind its real value, which is what i guess you said about reference.

Here a small example of it:

No-reference:
Code:
#include <iostream>

int test(int x)
{
   x = 10;
}

int main()
{
  int y = 5;
  test(y);
  std::cout << y;
}

Output:
Code:
5

Reference:
Code:
#include <iostream>

int test(int &x)
{
   x = 10;
}

int main()
{
  int y = 5;
  test(y);
  std::cout << y;
}

Output:
Code:
10

@thread
Why?, LUA works, and there is thousand stuff made already in LUA, script system should be changed when it become not powerful enough to do something that someone wants to do, and we didn't reach that point I guess.
 
Last edited:
@up, yes a refrence copy the memory address and gives it to the new value. Basicly the both become one.

Also, there is alot of talk about new revscriptsys for TFS. And it will require alot of rewriting of the current system. The way scripts are included will change so we can support multiple script engines. And people might (or might not) like the changes, Python got threading support out of the box witch we might use to create a crash free script handler. Allowing us to create a much more stable system. This can be done for LUA too, but it's much harder.

Why do we even need Windows and Linux? 4.4BSD and Unix worked just fine too.
 
Back
Top