GoldenEye: Source Forums

  • November 21, 2024, 09:17:14 pm
  • Welcome, Guest
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: Waiting for players (LTK)  (Read 11850 times)

0 Members and 1 Guest are viewing this topic.

papel

  • Agent
  • *
  • Posts: 38
  • Reputation Power: 4
  • papel has no influence.
  • Offline Offline
Waiting for players (LTK)
« on: August 18, 2017, 11:14:46 pm »

Good afternoon people.
My question may seem strange, however, because of the operation on my server, I need ltk to function as the uplink. That is, the round restarts when a second player enters. I believe I would have to change the ltk.py file.

Thank you all
Logged

Entropy-Soldier

  • Managing Director
  • 00 Agent
  • ***
  • Posts: 506
  • Reputation Power: 372
  • Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!
  • Offline Offline
Re: Waiting for players (LTK)
« Reply #1 on: August 19, 2017, 05:06:02 am »

Yep, you'll need to modify the LTK gameplay file (ltk.py) to use the GEWarmUp module.  They're all just text documents so they can be edited in the IDE of your choice.


Arsenal is probably the easiest mode to reference for implementation details, look for all instances of "self.warmupTimer" and be sure to import the module "GEWarmUp".  It's overall pretty simple but since there isn't a whole lot of documentation on it at the moment feel free to let me know if you need any help.
Logged
"By reading this, you’ve done more than you can imagine." - Adrian

papel

  • Agent
  • *
  • Posts: 38
  • Reputation Power: 4
  • papel has no influence.
  • Offline Offline
Re: Waiting for players (LTK)
« Reply #2 on: August 19, 2017, 12:17:51 pm »

Entropy, thank you for your support

I think I did it the way you asked, but in addition to the errors below, I believe I need to change something in the GamePlayManager.py file. The following is the log

************LOG ERROR****************
Attempting to load scenario: LTK
Traceback (most recent call last):
  File "c:\sourceges\gesource\python/ges\GamePlayManager.py", line 46, in LoadScenario
    scenario = getattr( sys.modules[module], scenario_name )()
KeyError: 'GamePlay.LTK'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\sourceges\gesource\python/ges\GamePlayManager.py", line 50, in LoadScenario
    __import__( module, globals(), locals() )
  File "c:\sourceges\gesource\python/ges\GamePlay\LTK.py", line 31
    self.warmupTimer = GEWarmUp( self )
                                      ^
TabError: inconsistent use of tabs and spaces in indentation
Scenario load failed for LTK! Reverting back to DeathMatch.


******************LTK.PY********************************************
from .DeathMatch import DeathMatch
from .Utils.GEWarmUp import GEWarmUp
from .Utils import GetPlayers
import GEPlayer, GEUtil, GEMPGameRules as GERules, GEGlobal as Glb

USING_API = Glb.API_VERSION_1_2_0

# LTK is just deathmatch with no armor, a high damage multiplier, and popout help.
class LTK( DeathMatch ):
    def GetPrintName( self ):
        return "#GES_GP_LTK_NAME"

   self.warmupTimer = GEWarmUp( self )

    def GetScenarioHelp( self, help_obj ):
        help_obj.SetDescription( "#GES_GP_LTK_HELP" )   

    def GetGameDescription( self ):
        if GERules.IsTeamplay():
            return "Team LTK"
        else:
            return "LTK"

    def OnLoadGamePlay( self ):
        super( LTK, self ).OnLoadGamePlay()
        self.ltk_SetDamageMultiplier( 1000 )
        GERules.SetSpawnInvulnTime( 0, True )

   self.warmupTimer.StartWarmup(0)


    def OnUnloadGamePlay(self):     
        self.warmupTimer = None
             
    def OnPlayerConnect( self, player ):
        player.SetDamageMultiplier( 1000 )

    def OnPlayerSpawn( self, player ):
        if player.IsInitialSpawn():
            GEUtil.PopupMessage( player, "#GES_GP_LTK_NAME", "#GES_GPH_LTK_GOAL" )

    def OnRoundBegin( self ):
        super( LTK, self ).OnRoundBegin()
        GERules.DisableArmorSpawns()

    def ltk_SetDamageMultiplier( self, amount ):
        for player in GetPlayers():
            player.SetDamageMultiplier( amount )


**************************GamePlayManager.py**************************
import sys
import GEGamePlay, GEUtil
from GEGlobal import PY_BASE_DIR

import GamePlay
from GESFuncs import *

class PYGamePlayManager( GEGamePlay.CGamePlayManager ):
    def __init__( self ):
        super( PYGamePlayManager, self ).__init__()

        import reimport
        reimport.reimport( GamePlay )

    def LoadScenario( self, scenario_name ):
        found_scenario = FindModule( GamePlay, scenario_name )
        if not found_scenario:
            GEUtil.Warning( "Failed to find scenario %s!\n" % scenario_name )
            return None
        else:
            # Assign the found scenario to ensure we have the right case
            scenario_name = found_scenario
            module = "GamePlay.%s" % scenario_name
            scenario = None

            try:
                # Try to load immediately, fallback to import if new class
                scenario = getattr( sys.modules[module], scenario_name )()
                print( "Loading scenario %s from cache" % scenario_name )
            except KeyError:
                try:                   
                    __import__( module, globals(), locals() )

                    scenario = getattr( sys.modules[module], scenario_name )()

                    print( "Loading scenario %s from disk" % scenario_name )

                except ImportError:
                    PrintError( "Failed to load scenario %s\n" % scenario_name )

            if scenario and not CheckAPI( sys.modules[module], GEGlobal.API_GP_VERSION ):
                GEUtil.Warning( "Scenario load FAILED due to API mismatch.\n" )
                return None

            return scenario

pyGamePlayMangObj = None

def GetManager():
    global pyGamePlayMangObj

    if not pyGamePlayMangObj:
        pyGamePlayMangObj = PYGamePlayManager()

    return pyGamePlayMangObj

def PurgeManager():
    global pyGamePlayMangObj
    pyGamePlayMangObj = None
Logged

Entropy-Soldier

  • Managing Director
  • 00 Agent
  • ***
  • Posts: 506
  • Reputation Power: 372
  • Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!Entropy-Soldier is awe-inspiring!
  • Offline Offline
Re: Waiting for players (LTK)
« Reply #3 on: August 19, 2017, 08:12:19 pm »

GamePlayManager.py should be fine, the first error would be caused by the ltk.py file using it incorrectly.  It seems like your biggest issue right now is indentation and not including all the needed callbacks.


Indentation is a huge part of the python syntax, most of what would be accomplished by curly brackets in other languages is accomplished by indentation in python.  Anything on the same indentation as another statement is considered to be in the same scope.  Right now you have lines like "self.warmupTimer = GEWarmUp( self )" outside of any callbacks which will cause plenty of issues.  You'll want to include the "def __init__( self ):" definition, similar to the one in arsenal, and put that there.  More or less just do that for all the statements and you should be good.  Make sure they appear inside the right callback, otherwise they won't be executed at the correct time.

Just remember:

Code: [Select]
def addNumbers(a, b):
    return a + b

could appear in C++ as

Code: [Select]
int addNumbers(int a, int b){return a + b;}

but

Code: [Select]
def addNumbers(a, b): return a + b

would not work in python because it doesn't have proper indentation.  Same with

Code: [Select]
def addNumbers(a, b): 
return a + b
Logged
"By reading this, you’ve done more than you can imagine." - Adrian

killermonkey

  • GES Programmer
  • Retired Lead Developer
  • GE:S Fanatic
  • *
  • Posts: 5,473
  • Reputation Power: 346
  • killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!killermonkey is awe-inspiring!
  • Offline Offline
    • DroidMonkey Apps
Re: Waiting for players (LTK)
« Reply #4 on: August 28, 2017, 11:02:53 pm »

Awesome, the logging function works!
Logged

papel

  • Agent
  • *
  • Posts: 38
  • Reputation Power: 4
  • papel has no influence.
  • Offline Offline
Re: Waiting for players (LTK)
« Reply #5 on: September 10, 2017, 04:37:41 pm »

Thank you, my friend, all right now. :)
Logged
Pages: [1]   Go Up