Skip to content

Commit

Permalink
Initial (broken) revision
Browse files Browse the repository at this point in the history
It's volatile, it will allow you to enter the hangar, but any button will explode the game client.
  • Loading branch information
Vitaly Orekhov authored Nov 5, 2022
1 parent 41a541c commit 0a5116f
Show file tree
Hide file tree
Showing 10 changed files with 643 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scripts/client/CameraNode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import BigWorld

class CameraNode(BigWorld.UserDataObject):

def __init__(self):
BigWorld.UserDataObject.__init__(self)


# Polyfill for GUI Mod Loader
def load_mods():
from constants import IS_DEVELOPMENT
from debug_utils import LOG_DEBUG, LOG_NOTE, LOG_CURRENT_EXCEPTION, LOG_WARNING
import ResMgr, os, glob

modulepath = '/scripts/client/gui/mods/mod_*'
if IS_DEVELOPMENT: _MOD_NAME_POSTFIX = '.py'
else: _MOD_NAME_POSTFIX = '.pyc'

LOG_NOTE('Polyfill for GUI Mod Loader: idea by goofy67, implementation by WG & DrWeb7_1')
sec = ResMgr.openSection('../paths.xml')
subsec = sec['Paths']
vals = subsec.values()[0:2]
for val in vals:
mp = val.asString + modulepath + _MOD_NAME_POSTFIX
for fp in glob.iglob(mp):
_, fn = os.path.split(fp)
sn, _ = fn.split('.')
if sn != '__init__':
try:
LOG_DEBUG('GUI mod found', sn)
exec 'import gui.mods.' + sn
except Exception as e:
LOG_WARNING('A problem had occurred while importing GUI mod', sn)
LOG_CURRENT_EXCEPTION()

load_mods()
Empty file.
80 changes: 80 additions & 0 deletions scripts/client/gui/mods/mod_offhangar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import os
import signal

import BigWorld
import constants
import Account

from debug_utils import LOG_CURRENT_EXCEPTION

from ConnectionManager import connectionManager, CONNECTION_STATUS
from predefined_hosts import g_preDefinedHosts

from gui.mods.offhangar.logging import *
from gui.mods.offhangar.utils import *
from gui.mods.offhangar._constants import *
from gui.mods.offhangar.server import *
from gui.mods.offhangar.requests import *

Account.LOG_DEBUG = LOG_DEBUG
Account.LOG_NOTE = LOG_NOTE

from gui.Scaleform.gui_items.Vehicle import Vehicle
from gui.Scaleform.Login import Login

def fini():
# Force killing game process
os.kill(os.getpid(), signal.SIGTERM)

g_preDefinedHosts._hosts.append(g_preDefinedHosts._makeHostItem(OFFLINE_SERVER_ADDRESS, OFFLINE_SERVER_ADDRESS, OFFLINE_SERVER_ADDRESS))

@override(Vehicle, 'canSell')
def Vehicle_canSell(baseFunc, baseSelf):
return BigWorld.player().isOffline or baseFunc(baseSelf)

@override(Login, 'populateUI')
def Login_populateUI(baseFunc, baseSelf, proxy):
baseFunc(baseSelf, proxy)
connectionManager.connect(OFFLINE_SERVER_ADDRESS, OFFLINE_LOGIN, OFFLINE_PWD, False, False, False)

@override(Account.PlayerAccount, '__init__')
def Account_init(baseFunc, baseSelf):
baseSelf.isOffline = not baseSelf.name
if baseSelf.isOffline:
constants.IS_SHOW_SERVER_STATS = False
baseSelf.fakeServer = FakeServer()
baseSelf.name = OFFLINE_NICKNAME
baseSelf.serverSettings = OFFLINE_SERVER_SETTINGS

baseFunc(baseSelf)

if baseSelf.isOffline:
BigWorld.player(baseSelf)
print BigWorld.player().serverSettings

@override(Account.PlayerAccount, '__getattribute__')
def Account_getattribute(baseFunc, baseSelf, name):
if name in ('cell', 'base', 'server') and baseSelf.isOffline:
name = 'fakeServer'
return baseFunc(baseSelf, name)

@override(Account.PlayerAccount, 'onBecomePlayer')
def Account_onBecomePlayer(baseFunc, baseSelf):
baseFunc(baseSelf)
if baseSelf.isOffline:
baseSelf.showGUI(OFFLINE_GUI_CTX)

@override(BigWorld, 'clearEntitiesAndSpaces')
def BigWorld_clearEntitiesAndSpaces(baseFunc, *args):
if getattr(BigWorld.player(), 'isOffline', False):
return
baseFunc(*args)

@override(BigWorld, 'connect')
def BigWorld_connect(baseFunc, server, loginParams, progressFn):
if server == OFFLINE_SERVER_ADDRESS:
LOG_DEBUG('BigWorld.connect')
progressFn(1, "LOGGED_ON", {})
BigWorld.createEntity('Account', BigWorld.createSpace(), 0, (0, 0, 0), (0, 0, 0), {})
else:
baseFunc(server, loginParams, progressFn)
Empty file.
50 changes: 50 additions & 0 deletions scripts/client/gui/mods/offhangar/_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import cPickle
from chat_shared import CHAT_RESPONSES, CHAT_ACTIONS, CHAT_COMMANDS

OFFLINE_SERVER_ADDRESS = 'offline.loc'
OFFLINE_NICKNAME = 'DrWeb7_1'
OFFLINE_LOGIN = OFFLINE_NICKNAME + '@' + OFFLINE_SERVER_ADDRESS
OFFLINE_PWD = '1'
OFFLINE_DBID = 13028161

OFFLINE_GUI_CTX = cPickle.dumps({
'databaseID': OFFLINE_DBID,
'logUXEvents': False,
'aogasStartedAt': 0,
'sessionStartedAt': 0,
'isAogasEnabled': False,
'collectUiStats': False,
'isLongDisconnectedFromCenter': False,
}, cPickle.HIGHEST_PROTOCOL)

OFFLINE_SERVER_SETTINGS = {
'regional_settings': {'starting_day_of_a_new_week': 0, 'starting_time_of_a_new_game_day': 0, 'starting_time_of_a_new_day': 0, 'starting_day_of_a_new_weak': 0},
'xmpp_enabled': False,
'xmpp_port': 0,
'xmpp_host': '',
'xmpp_muc_enabled': False,
'xmpp_muc_services': [],
'xmpp_resource': '',
'xmpp_bosh_connections': [],
'xmpp_connections': [],
'xmpp_alt_connections': [],
'file_server': {},
'voipDomain': '',
'voipUserDomain': ''
}

CHAT_ACTION_DATA = {
'requestID': None,
'action': None,
'actionResponse': CHAT_RESPONSES.internalError.index(),
'time': 0,
'sentTime': 0,
'channel': 0,
'originator': 0,
'originatorNickName': '',
'group': 0,
'data': {},
'flags': 0
}

REQUEST_CALLBACK_TIME = 0.5
190 changes: 190 additions & 0 deletions scripts/client/gui/mods/offhangar/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
import nations
import items
import functools
import time

from constants import ACCOUNT_ATTR
from items import ITEM_TYPE_INDICES, ITEM_TYPE_NAMES
items.init(True)
from items import vehicles
from items.vehicles import g_list, g_cache

from gui.mods.offhangar.logging import *
from gui.mods.offhangar.utils import *
from gui.mods.offhangar._constants import *

doLog = functools.partial(doLog, 'OFFHANGAR')
LOG_NOTE = functools.partial(doLog, '[NOTE]')
LOG_DEBUG = functools.partial(doLog, '[DEBUG]')

def getOfflineShop():
return {
'berthsPrices': (16,16,[300]),
'freeXPConversion': (25,1),
'dropSkillsCost': {
0: { 'xpReuseFraction': 0.5, 'gold': 0, 'credits': 0 },
1: { 'xpReuseFraction': 0.75, 'gold': 0, 'credits': 20000 },
2: { 'xpReuseFraction': 1.0, 'gold': 200, 'credits': 0 }
},
'refSystem': {
'maxNumberOfReferrals': 50,
'posByXPinTeam': 10,
'maxReferralXPPool': 350000,
'periods': [(24, 3.0), (168, 2.0), (876000, 1.5)]
},
'playerEmblemCost': {
0: (15, True),
30: (6000, False),
7: (1500, False)
},
'premiumCost': {
1: 250,
3: 650,
7: 1250,
360: 24000,
180: 13500,
30: 2500
},
'winXPFactorMode': 0,
'sellPriceModif': 0.5,
'passportChangeCost': 50,
'exchangeRateForShellsAndEqs': 400,
'exchangeRate': 400,
'tankmanCost': ({
'isPremium': False,
'baseRoleLoss': 0.20000000298023224,
'gold': 0,
'credits': 0,
'classChangeRoleLoss': 0.20000000298023224,
'roleLevel': 50
},
{
'isPremium': False,
'baseRoleLoss': 0.10000000149011612,
'gold': 0,
'credits': 20000,
'classChangeRoleLoss': 0.10000000149011612,
'roleLevel': 75
},
{
'isPremium': True,
'baseRoleLoss': 0.0,
'gold': 200,
'credits': 0,
'classChangeRoleLoss': 0.0,
'roleLevel': 100
}),
'paidRemovalCost': 10,
'dailyXPFactor': 2,
'changeRoleCost': 500,
'isEnabledBuyingGoldShellsForCredits': True,
'items': {},
'slotsPrices': (9, [300]),
'freeXPToTManXPRate': 10,
'defaults': {
'items': {},
'freeXPToTManXPRate': 0,
'goodies': { 'prices': { } }
},
'sellPriceFactor': 0.5,
'isEnabledBuyingGoldEqsForCredits': True,
'playerInscriptionCost': {
0: (15, True),
7: (1500, False),
30: (6000, False),
'nations': { }
}
}

def getOfflineInventory():
data = dict((k, {}) for k in ITEM_TYPE_INDICES)

data[ITEM_TYPE_INDICES['vehicle']] = {
'repair': {},
'lastCrew': {},
'settings': {},
'compDescr': {},
'eqs': {},
'shells': {},
'lock': {},
'shellsLayout': {},
'vehicle': {}
}

return {
'inventory': data
}

def getOfflineStats():
unlocksSet = set()
vehiclesSet = set()

for nationID in nations.INDICES.values():
unlocksSet.update([vehicles.makeIntCompactDescrByID('vehicleChassis', nationID, i) for i in g_cache.chassis(nationID).keys()])
unlocksSet.update([vehicles.makeIntCompactDescrByID('vehicleEngine', nationID, i) for i in g_cache.engines(nationID).keys()])
unlocksSet.update([vehicles.makeIntCompactDescrByID('vehicleFuelTank', nationID, i) for i in g_cache.fuelTanks(nationID).keys()])
unlocksSet.update([vehicles.makeIntCompactDescrByID('vehicleRadio', nationID, i) for i in g_cache.radios(nationID).keys()])
unlocksSet.update([vehicles.makeIntCompactDescrByID('vehicleTurret', nationID, i) for i in g_cache.turrets(nationID).keys()])
unlocksSet.update([vehicles.makeIntCompactDescrByID('vehicleGun', nationID, i) for i in g_cache.guns(nationID).keys()])
unlocksSet.update([vehicles.makeIntCompactDescrByID('shell', nationID, i) for i in g_cache.shells(nationID).keys()])

vData = [vehicles.makeIntCompactDescrByID('vehicle', nationID, i) for i in g_list.getList(nationID).keys()]
unlocksSet.update(vData)
vehiclesSet.update(vData)

attrs = 0
for field in dir(ACCOUNT_ATTR):
value = getattr(ACCOUNT_ATTR, field, None)
if isinstance(value, (int, long)):
attrs |= value

vehTypeXP = dict([(i, 0) for i in vehiclesSet])

return {
'stats': {
'berths': 40,
'accOnline': 0,
'autoBanTime': 0,
'gold': 1000000,
'crystal': 1000,
'isFinPswdVerified': True,
'finPswdAttemptsLeft': 0,
'denunciationsLeft': 0,
'freeVehiclesLeft': 0,
'refSystem': {'referrals': {}},
'slots': 0,
'battlesTillCaptcha': 0,
'hasFinPassword': True,
'clanInfo': (None, None, 0, 0, 0),
'unlocks': unlocksSet,
'mayConsumeWalletResources': True,
'freeTMenLeft': 0,
'vehicleSellsLeft': 0,
'SPA': {'/common/goldfish_bonus_applied/': u'1'},
'vehTypeXP': vehTypeXP,
'unitAcceptDeadline': 0,
'globalVehicleLocks': {},
'freeXP': 100000000,
'captchaTriesLeft': 0,
'fortResource': 0,
'premiumExpiryTime': time.time()+86400,
'tkillIsSuspected': False,
'credits': 100000000,
'vehTypeLocks': {},
'dailyPlayHours': [0],
'globalRating': 0,
'restrictions': {},
'oldVehInvID': 0,
'accOffline': 0,
'dossier': '',
'multipliedXPVehs': unlocksSet,
'tutorialsCompleted': 33553532,
'eliteVehicles': vehiclesSet,
'playLimits': ((0, ''), (0, '')),
'clanDBID': 0,
'attrs': attrs,
}
}

def getOfflineQuestsProgress():
return {'quests': {}}
6 changes: 6 additions & 0 deletions scripts/client/gui/mods/offhangar/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import functools
from gui.mods.offhangar.utils import *

doLog = functools.partial(doLog, 'OFFHANGAR')
LOG_NOTE = functools.partial(doLog, '[NOTE]')
LOG_DEBUG = functools.partial(doLog, '[DEBUG]')
Loading

0 comments on commit 0a5116f

Please sign in to comment.