Mysteries

From BF2 Technical Information Wiki
Jump to: navigation, search

Here's an ongoing list of things that we're wondering about; please feel free to add to this list!

On the other hand, if you see something on this list that you know something about, please add your knowledge to the wiki in an appropriate place (including creating a new page, if that makes sense!). As "mysteries" get solved and the information is incorporated into the appropriate places in this wiki, items will be deleted from this page.


Mysteries Looking for Answers

  • Any ideas on a spawn invulnerability? setDamage() only works up to the armor.maxHitPoints. I can set the maxHitPoints higher in the tweak file, but then it messes up the health bar in game. I've tried using setMaxDamage() but it doesn't seem to exist. --Cpt.Wacky 19:40, 14 Oct 2005 (MDT)
  • I am trying to lock a vehicle via python script so that only certain player classes can enter and use the vehicle. I am currently having trouble finding any methods to force a player exit a vehicle. --Hailo 14:49, 26 Sep 2005 (MDT)
    • I'm fairly sure that the only way to do this is to blow up a vehicle when someone gets in it, or something. I can think of a couple of ways to inplement this code, most of which are dirty, dirty hacks that should never be spoken of aloud. --dst 07:33, 27 Sep 2005 (MDT)
    • Ok, how about disabling the controls in the vehicle so they cant use it? --Hailo 13:07, 29 Sep 2005 (MDT)
  • Does anybody has information about output of selectunlock.aspxpid=<yourid>&id=<values 11-22-33 ~ 77? --SatcomNL 09:38, 29 Jul 2005 (MDT)
  • host.sgl_sendTextMessage(playerId, 12, 1, message, 0) (Santala)
    • In my earlier research I thought I had found out the following: Send a server message to one player. Options for the "1": 0-1 = server message, 2 = player chat message, 3 = nothing printed, 4-5 = crashes the game. Changing the "12" seemed to resulted in no message shown and changing the "0" seemed to make no difference.
    • However, when I tried to use the host.sgl_sendTextMessage() in my landot AAS mod the results were quite unpredictable. It seems there wasn't actually a way to send a private message to just one player. Everyone was getting the messages, sometimes under someone else's name. Really weird stuff. Currently it looks like host.sgl_sendTextMessage() is pretty much useless, unless someone figures out how it really works...
    • channel 14 (Player) seems to work fine, at least in BF2 v1.5. Haven't tested any others yet. --Jmuhlich 17:05, 24 January 2010 (MST)
    • My research regarding the sql_sendtextMessage function:
CHANNELS (PARAMETER 2), host.sgl_sendTextMessage(playerId, channel, param3, message, param5):
1 Team
2 Commander
3 Squad
4 SquadLeader
5 SquadId
6 LocalTeamMedic
7 LocalGroundVehicle
8 LocalAirVehicle
9 Local
10 LocalTeam
11 Vehicle
12 ServerMessage
13 ServerTeamMessage
14 Player
15 LocalRevive
16 LocalRevive
17 TeamAndLocalEnemies
18 SquadAndLocalEnemies
19 Invalid
I haven't got any of them working except parameter 12. --=Mad= 13:12, 18 Jul 2005 (MDT)
  • Is there a way to change the weapon of a player when he switches firing mode? This may sound weird, but I try to implement a USP Tactical with an optional silencer. So I was thinking about adding two identical firemodes ( single fire twice ), but as far as I know there is no way to change the weapon settings ( sounds, deviation, damage ) for a particular firing mode, especially not when they are identical ... So maybe there is a way to catch the switch-firing-mode event and redirect it to replacing the weapon through the silenced one - and the other way around if the unsilenced one was selected before. I know this may be impossible or be possible a lot easier by just giving the pistol two weapon slots (silenced and unsilenced), but I like it the way cstrike did it, so if anyone knows how to do this or at least how to catch the switch-firing-mode event and replace the weapon ... that would be very helpful! thanks in advance! -- Muued

Answers in Progress (feel free to comment!)

  • How can I display a text message in the center of the game screen? Game.sayall is too easily missed by players.
    • A really cheap fix for this is to just put something like a "." and then a bunch of spaces while using the Game.sayall command, it puts the text towards the middle of the screen and people tend to notice it when I do that--Milton 18:18 Aug 2 2005 (MDT)
  • If you do a player.getKit(), and then do a getChildren() method on the kit you just returned, you get two instances back. Doing a .templateName on these items returns one of them as 'recycle bin'. Anybody know what this is?
    • Well, "no", I don't know what it means yet, but I've been exploring the same places; check out my page on BF2 Object Containment to see some of the bizarre things that are inside BF2. I see the "recycle bins" you're talking about, and a LOT more. At the moment the big mystery for me is why these objects are so bizarrely complex. --Woody 16:11, 16 Jul 2005 (MDT)
    • Thanks for pointing me to your containment page, it helped clear some stuff up about these recycle bins. I'm still not sure what they are or how they are used, but I sure have a better understanding of them now. From what I have seen so far, each 'recycle bin' has a child, which is the unlock gun for that class. In the case of the assault class there are two children of the 'recycle bin' because the unlocked assault gun doesn't have a grenade launcher, so the other child is normal grenades. Considering that the only other child I get when doing a getChildren() after a player.getKit() has to do with unlocks('UnlockUSAssault' for example), I'd say it and the 'recycle bin' form some kind of system for dealing with unlocks. Although idle speculation, I would say from what I've seen so far, the 'recylce bin' is a holding zone for unlocks, so that every kit instance has its unlock already in it, its just in this holding zone. --King of Camelot 01:44, 17 Jul 2005 (MDT)

The recycle bin is a holding area used when a player picks up another kit type. It holds the old kit that was being "discarded" in favor of the newly picked up kit.

  • How can I kill a player? I've yet to see something like bf2.PlayerManager.Player.kill(). I don't know how it'd be useful, but I'm sure I could think of something fun. I think I'll play with 'vehicleObject.setDamage()' for a little bit this week and dig what I can dig. --dst 23:35, 31 Jul 2005 (MDT)
    • You were right to look into vehicleObject.setDamage(damage). I've found a simple way to kill a player is to do player.getDefaultVehicle().setDamage(0.0). There is a slight catch to this solution though. The game really doesn't seem to like you messing with an occupied vehicle's damage, or the damage of the player inside said vehicle. It seems that modifying either one's damage to 0.0 will cause a CTD. A way around this would be detecting whether or not the player is in a vehicle, and then if they are just setting the vehicle damage to 1.0(low enough to cause the vehicle to explode). That should be fairly easy to implement. I thought I should point out some odd quarks that player.getDefaultVehicle().setDamage(damage) has. If you set damage to -1000.0, it puts the player into a sort of limbo between life and death. The player dies in the sense that they fall over and lose the ability to use weapons, but the game doesn't see them as dead, and they can still do things such as supply drops from the commander screen while in this state. The only way to get out of this state is to suicide(kinda funny suiciding something thats supposed to be dead). It also seems that if you do a player.getDefaultVehicle().setDamage(damage) twice(first damage should be 0.0 or below, and the second should probably be below the first damage) it puts the player into a state somewhere between living and the state I mentioned before. Here the counter counts down till spawn, and they will respawn, but they can still do commander tasks and such. The game is seeing the player as dead, but dead with privileges. Hopefully that all helped you, atleast a little.--King of Camelot 01:08, 1 Aug 2005 (MDT)
    • I kind of studied the player kill "feature" in BF2 and found at least some solutions.

To kill a player on foot: Script: player.getDefaultVehicle().setDamage(0) I tried many other values of the damage, anything from 0 down to -319 will do it. The -320 will create the "limbo" state. Note that this will actually WOUND the player, not kill, because when player is killed it changes from soilder template to FreeMultiplayerCamera template. Any attempts to setDamage on the wounded player will not make any difference. The solution I found in the PR mod is to set player.setTimeToSpawn(0) right after the setDamage(), so the player will get instantly killed after being wounded by the script.

To kill a player in vehicle ... hmmm this one's tough: Basically, you can't. You can use the code: player.getVehicle().setDamage(0.0000001), which will set the vehicle prior to explosion, but this will not work on IGLAs for example (they do not burn) and also, this will not work for a gunner in heli or gunner in tank, because you are trying to destroy a part of a vehicle, not the entire vehicle. In the second case, you can run a recursion on the vehicle's parents (tank turret's parents) and attempt to destroy them. Here is the complete code:

def kill(target):
   if target.getDefaultVehicle() == target.getVehicle():
       target.getDefaultVehicle().setDamage(0) 
   else:
       _killVehicle(target.getVehicle())
   target.setTimeToSpawn(0);
def _killVehicle(vehicle):
   while vehicle is not None:
       try:
           vehicle.setDamage(0.000000001) 
           return
       except:
           try:
               vehicle = vehicle.getParent()
           except:
               return

Still not 100%, but at least close to it ... Hope this one helps! --=BiA=Diskobolos 16:23, 25 March 2007 (MDT)

Solved, Awaiting Confirmation From Others (after which the info will be moved to the appropriate section of the wiki)

  • How do you activate Fragalyzer logging?
    • Have a look at BF2Stats at http://www.bighamster.de/ We use the fragalyzer for making our own stats. See the patch file how it works (we do a bf2.stats.fragalyzer_log.enable() in the stats.py when the game changes to PLAYING state).
  • How do you catch print commands from Python?
  • bf2.__init__ tries to initialize bf2.stats.snapshot and bf2.stats.medals. . . but there are no such modules/files. . . what's this all about?
    • They are scripts for ranked servers. --Dackz 21:03, 17 Jul 2005 (MDT)
  • I would like to know how to change a players kit or weapon on the "onPickupKit(player, kit)" event. --Hailo 03:01, 23 Aug 2005 (MDT)
    • You can't--there are methods for finding out what kit a player is using, but nothing to let you change the kit to something else. The only possible hope I can see if if there were a method we don't know about inside the PhysicalObject class that would let you manipulate the containment hierarchy of of a PhysicalObject. . . but like I said, there is no such method known. The BF2 game engine, unfortunately, just doesn't expose everything inside itself to the Python interface. --Woody 11:53, 23 Aug 2005 (MDT)
    • In the "playerManager.py" file you will see some methods using "host.pmgr_p_set". I am wondering if "host.pmgr_p_set("kit",playerID,kitNameString)" would work? --Hailo 03:20, 24 Aug 2005 (MDT)
      • If you do that, you'll just get this error: RuntimeError: attribute not implemented: kit --Dackz 10:34, 24 Aug 2005 (MDT)
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox