Jump to content

[战地2]单人模式隐藏武器入手方法


K.泰莎

Recommended Posts

singleplayer模式里直接拿到ONLINE升级才拿得到的武器

  游戏目录\EA GAMES\Battlefield 2 Demo\python\bf2\stats

  打开里面的unlocks.py

  第44行

  def onPlayerConnect(player):  defaultUnlocks = [0, 0, 0, 0, 0, 0, 0]

  host.pers_plrSetUnlocks(player.index, defaultUnlocks, defaultUnlocks)

  把里面defaultUnlocks = [0, 0, 0, 0, 0, 0, 0]的0全部改为1即可.武器多半是欧系,狙击嘛,大家自己去看吧^-^

  千万要记住是defaultUnlocks = [0, 0, 0, 0, 0, 0, 0] ,而不是别的

Link to comment
Share on other sites

  • 4 weeks later...

import host

import bf2.PlayerManager

from bf2.stats.constants import *

from bf2 import g_debug

# map gamespy item ids to kits

unlockItemMap = {

11 : 0,

22 : 1,

33 : 2,

44 : 3,

55 : 4,

66 : 5,

77 : 6,

88 : 1,

99 : 2,

111 : 3,

222 : 4,

333 : 5,

444 : 0,

555 : 6,

}

sessionPlayerUnlockMap = {}

def init():

# Events

host.registerHandler('PlayerConnect', onPlayerConnect, 1)

if bf2.serverSettings.getUseGlobalUnlocks():

host.registerHandler('PlayerUnlocksResponse', onUnlocksResponse, 1)

# Connect already connected players if reinitializing

for p in bf2.playerManager.getPlayers():

onPlayerConnect(p)

if g_debug: print "Unlock module initialized"

class UnlockSet: pass

def onPlayerConnect(player):

defaultUnlocks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

host.pers_plrSetUnlocks(player.index, defaultUnlocks, defaultUnlocks)

if not player.isAIPlayer():

id = player.index

reconnect = id in sessionPlayerUnlockMap

# always get new unlocks on reconnect/map restart/map change etc

if reconnect:

del sessionPlayerUnlockMap[id]

newUnlockSet = UnlockSet()

newUnlockSet.unlockLevel = {}

for i in range(0, NUM_KIT_TYPES):

newUnlockSet.unlockLevel = 0

sessionPlayerUnlockMap[id] = newUnlockSet

player.unlocks = sessionPlayerUnlockMap[id]

if bf2.serverSettings.getUseGlobalUnlocks():

if player.getProfileId() > 2000:

success = host.pers_plrRequestUnlocks(player.index, 1)

if not success:

if g_debug: print "Failed requesting unlocks"

else:

if g_debug: print "Player %d had no profile id, can't request unlocks" % player.index

if g_debug: print "Added player %d to unlock checking" % (player.index)

def onUnlocksResponse(succeeded, player, unlocks):

if not succeeded:

print "Unlocks request failed for player %d %d: %s" % (player.index, player.getName(), unlocks)

return

# print "Unlocks received for player ", player.getName(), "(",player.index, ") : ", unlocks

# translate gamespy item vector into a kit-based unlock vector handled by game

kitUnlocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

for item in unlocks:

if item in unlockItemMap:

kitUnlocks[unlockItemMap[item]] = 1

if g_debug: print "Kit unlocks: ", kitUnlocks

#We do not yet support giving different unlocks to different teams

host.pers_plrSetUnlocks(player.index, kitUnlocks, kitUnlocks)

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

为什么我改了用不了。。。。按照你说的那样改的。。。。郁闷。。。难道有版本限制?不能吧??。。。。。。。

import host

import bf2.PlayerManager

from bf2.stats.constants import *

from bf2 import g_debug

# map gamespy item ids to kits

unlockItemMap = {

11 : 0,

22 : 1,

33 : 2,

44 : 3,

55 : 4,

66 : 5,

77 : 6,

88 : 1,

99 : 2,

111 : 3,

222 : 4,

333 : 5,

444 : 0,

555 : 6,

}

sessionPlayerUnlockMap = {}

def init():

# Events

host.registerHandler('PlayerConnect', onPlayerConnect, 1)

if bf2.serverSettings.getUseGlobalUnlocks():

host.registerHandler('PlayerUnlocksResponse', onUnlocksResponse, 1)

# Connect already connected players if reinitializing

for p in bf2.playerManager.getPlayers():

onPlayerConnect(p)

if g_debug: print "Unlock module initialized"

class UnlockSet: pass

def onPlayerConnect(player):

defaultUnlocks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

host.pers_plrSetUnlocks(player.index, defaultUnlocks, defaultUnlocks)

if not player.isAIPlayer():

id = player.index

reconnect = id in sessionPlayerUnlockMap

# always get new unlocks on reconnect/map restart/map change etc

if reconnect:

del sessionPlayerUnlockMap[id]

newUnlockSet = UnlockSet()

newUnlockSet.unlockLevel = {}

for i in range(0, NUM_KIT_TYPES):

newUnlockSet.unlockLevel = 0

sessionPlayerUnlockMap[id] = newUnlockSet

player.unlocks = sessionPlayerUnlockMap[id]

if bf2.serverSettings.getUseGlobalUnlocks():

if player.getProfileId() > 2000:

success = host.pers_plrRequestUnlocks(player.index, 1)

if not success:

if g_debug: print "Failed requesting unlocks"

else:

if g_debug: print "Player %d had no profile id, can't request unlocks" % player.index

if g_debug: print "Added player %d to unlock checking" % (player.index)

def onUnlocksResponse(succeeded, player, unlocks):

if not succeeded:

print "Unlocks request failed for player %d %d: %s" % (player.index, player.getName(), unlocks)

return

# print "Unlocks received for player ", player.getName(), "(",player.index, ") : ", unlocks

# translate gamespy item vector into a kit-based unlock vector handled by game

kitUnlocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

for item in unlocks:

if item in unlockItemMap:

kitUnlocks[unlockItemMap[item]] = 1

if g_debug: print "Kit unlocks: ", kitUnlocks

#We do not yet support giving different unlocks to different teams

host.pers_plrSetUnlocks(player.index, kitUnlocks, kitUnlocks)

你看这样。。。。进去不能用解锁武器。。。。再怎么调??

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 3 weeks later...
  • 4 weeks later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

访客
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 创建新的...