Author Topic: Few more lua functions - a new network scenario  (Read 1641 times)

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Few more lua functions - a new network scenario
« on: 13 October 2012, 05:09:31 »
I am working on a simple network scenario to be included in the upcoming release called 'capture enemy flag'. I have added the following new lua functions in svn to support what I am doing in that scenario:

triggeredCellEventUnitId()
showMarker(int flashCount, int factionIndex, string note, string textureFile,Vec2i pos)
humanFaction()

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
3. the third returns the faction index of the human player

*Update: I have added the new network scenario in svn (currently called capture enemy flag) which supports two players over network (and a neutral cpu player that will attack anyone that comes near him). The scenario shows trigger areas, network messages, cell markers, etc. Can you capture the enemy players flag and return home safely before they do?
« Last Edit: 13 October 2012, 05:34:44 by softcoder »

MightyMic

  • Technician
  • ****
  • Posts: 150
  • To mod, or not to mod...
    • View Profile
Re: Few more lua functions
« Reply #1 on: 13 October 2012, 05:15:36 »
Sounds great!
Might I suggest calling it "Capture the Flag"
That just sounds better to me :D

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Re: Few more lua functions - a new network scenario
« Reply #2 on: 13 October 2012, 07:35:30 »
Updated again, now you can do special untit selecting and unselecting using a colored circle:

highlightUnit(int unit, float radius, float thickness, Vec4f color)
unhighlightUnit(int unit);

See the scenario in svn for usage.

titi_son

  • Draco Rider
  • *****
  • Posts: 283
  • titi_son
    • View Profile
Re: Few more lua functions - a new network scenario
« Reply #3 on: 14 October 2012, 08:30:27 »
I tried to run the scenario "capture_enemy_flag" and it crashed:

Code: [Select]
megaglest v3.7.0-dev
Compiled using: GNUC: 40403 on: Oct 14 2012 10:18:14
SVN: [Rev: 3488:3690M] - using STREFLOP [SSE] - [no-denormals]
[2012-10-14 10:23:49] *ERROR* In [menu_state_custom_game.cpp::simpleTask Line 2984] error checking response from masterserver elapsed seconds = 0.00 / 15
Response:
Trying to connect to '178.3.6.5' using port '61357'...
socket_connect() failed.
 Reason: (111) Connection refused
wrong router setup
[2012-10-14 10:23:58] *ERROR* In [menu_state_custom_game.cpp::simpleTask Line 2984] error checking response from masterserver elapsed seconds = 9.00 / 15
Response:
Trying to connect to '178.3.6.5' using port '61357'...
socket_connect() failed.
 Reason: (111) Connection refused
wrong router setup
[2012-10-14 10:25:36] *ERROR* This map only supports 4 playersIn [/home/tscharn/megaglest_svn/megaglest/source/glest_game/main/main.cpp::handleSIGSEGV Line: 4904] Error detected: signal 11:
Error saved to logfile [/home/tscharn/.megaglest/error.log]
[2012-10-14 10:25:36] *ERROR* In [/home/tscharn/megaglest_svn/megaglest/source/glest_game/main/main.cpp::handleRuntimeError Line: 372] [In [/home/tscharn/megaglest_svn/megaglest/source/glest_game/main/main.cpp::handleSIGSEGV Line: 4904] Error detected: signal 11:
] gameInitialized = 1, program = 0x965ad48
[2012-10-14 10:25:41] *ERROR* In [/home/tscharn/megaglest_svn/megaglest/source/glest_game/main/main.cpp::handleRuntimeError Line: 391] [In [/home/tscharn/megaglest_svn/megaglest/source/glest_game/main/main.cpp::handleSIGSEGV Line: 4904] Error detected: signal 11:

Stack Trace:
./megaglest:Glest::Game::ExceptionHandler::handleRuntimeError(char const*, bool)address [0x82ad055] line: 0
./megaglest:Glest::Game::handleSIGSEGV(int)address [0x827dbf9] line: 4909
[0xb7723400]address [0xb7723400] line: 0
./megaglest:Glest::Game::Game::init(bool)address [0x81bd879] line: 1083
./megaglest:Glest::Game::Game::init()address [0x81ad4fc] line: 975
./megaglest:Glest::Game::Program::setState(Glest::Game::ProgramState*, bool)address [0x82cc15e] line: 568
./megaglest:Glest::Game::MenuStateCustomGame::PlayNow(bool)address [0x83fca94] line: 1769
./megaglest:Glest::Game::MenuStateCustomGame::mouseClick(int, int, Shared::Platform::MouseButton)address [0x8404eba] line: 1051
./megaglest:Glest::Game::MainMenu::mouseDownLeft(int, int)address [0x83d3f37] line: 218
./megaglest:Glest::Game::MainWindow::eventMouseDown(int, int, Shared::Platform::MouseButton)address [0x8279a8f] line: 616
./megaglest:Shared::Platform::Window::handleMouseDown(SDL_Event)address [0x867742f] line: 676
./megaglest:Shared::Platform::Window::handleEvent()address [0x8677e7a] line: 161
./megaglest:Glest::Game::glestMain(int, char**)address [0x82a0fa5] line: 4676
./megaglest:Glest::Game::glestMainWrapper(int, char**)address [0x82a4dd3] line: 4943
./megaglest:main()address [0x82a4f13] line: 4963
/lib/tls/i686/cmov/libc.so.6:__libc_start_main()address [0xb69c0bd6] line: 0
./megaglest() [0x8125811]address [0x8125811]
]
Segmentation fault (core dumped)

I also have a core if you need it.
My first Tilseset: SPRING :) (included in Megaglest )

Secret Hint: To play online join the IRC #megaglest-lobby on freenode which is the lobby chat ingame. So you can chat with or wait for people in the lobby without running megaglest all the time.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Re: Few more lua functions - a new network scenario
« Reply #4 on: 14 October 2012, 22:01:51 »
This seems more like connection problems to me, your connection is being blocked by the router?

*Update: I'm unable to reproduce this crash, could you reproduce this and tell me the exact steps so i can reproduce it?
« Last Edit: 15 October 2012, 03:15:26 by softcoder »

titi_son

  • Draco Rider
  • *****
  • Posts: 283
  • titi_son
    • View Profile
Re: Few more lua functions - a new network scenario
« Reply #5 on: 15 October 2012, 12:14:23 »
Ah i think this could be a bug , but not a bug which have to do anything with the scenario.
I played LAN but lots of error msg about the router appear. (and thats right because i have a wrong port in options, but you can play LAN even if this is wrong or not?)
I pressed on host game in multiplayer menu and then tick off the publish button.
And then it crashed.
« Last Edit: 15 October 2012, 13:25:50 by PT »
My first Tilseset: SPRING :) (included in Megaglest )

Secret Hint: To play online join the IRC #megaglest-lobby on freenode which is the lobby chat ingame. So you can chat with or wait for people in the lobby without running megaglest all the time.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,238
    • View Profile
Re: Few more lua functions - a new network scenario
« Reply #6 on: 15 October 2012, 20:40:22 »
Fixed in svn.

filux

  • MegaGlest Team
  • Draco Rider
  • ********
  • Posts: 310
  • was OpenSuse x64, is Debian testing x64
    • View Profile
Re: Few more lua functions - a new network scenario
« Reply #7 on: 5 May 2013, 08:07:39 »
Little old topic but I think my post fits perfectly here  ;D.

I played a few times in this scenario via the network with other people as opponents and found out that it has several issues, causes the scenario is unplayable.
funny E.g.
when the two available positions are occupied by people and "human" units themselves decide to attack the enemy unit who captured the flag  :D

A few days ago I decided to dig inside it and if I can improve it and now I say that with the current lua functions I rather can't do it.
I can do a decent local scenario, or a bit poor network scenario, but not a good universal scenario because I need a function/entry which can detect the situation when both players are people (or second player is human...).
E.g. entry: "if humanFaction() == 1 and humanFaction() == 2 then" doesn't do this, because
humanFaction() function returns the faction index of the human player, but take into account players only on my client/computer, and working like "my faction number is -> x".

showMarker lua function have a network issue relies on that:
when we want to display a marker for one player when such as "factionIndex = 2", the second player(opponent) also sees it (it shouldn't), but as the default marker with "factionIndex = -1".

By the way I might add that it would be good to can show a marker for one player(team) but with other than the default color (or shape or something ...) when you have to show more than one marker (similarly situation with the flags),
e.g. of this scenario you can see that the marker with "factionIndex = -1" doesn't fit to the role as a second marker.
« Last Edit: 5 May 2013, 08:22:42 by filux »

 

anything