PDA

View Full Version : Coding Python Coding in BF2


dbzao
2008-03-08, 19:47
For the ones interested in python coding in BF2, here are a few links that helped me out when I started.

Main Page - BF2 Technical Information Wiki (http://bf2tech.org/index.php/Main_Page)
Object Reference - BF2 Technical Information Wiki (http://bf2tech.org/index.php/Object_Reference)
Event Reference - BF2 Technical Information Wiki (http://bf2tech.org/index.php/Event_Reference)
Scripts - BF2 Technical Information Wiki (http://bf2tech.org/index.php/Scripts)
BF2 Coordinates - BF2 Technical Information Wiki (http://bf2tech.org/index.php/BF2_Coordinates)
List of available host.rcon invoke commands - BF2 Technical Information Wiki (http://bf2tech.org/index.php/List_of_available_host.rcon_invoke_commands)
Official BF Editor Forums -> Python (http://bfeditor.org/forums/index.php?showforum=12)

Also you can check vBF2 python code in mods/bf2/python/game and other mods python code.

If you are new to python, checking online documentation is your best bet. Here are some links that were useful when I started learning the language:

5. Data Structures (http://docs.python.org/tut/node7.html)
3.6.1 String Methods (http://docs.python.org/lib/string-methods.html)

alexandrei07
2009-04-22, 22:46
Hello dbzao, we want to make an Argentinian faction (PR), could you tell me if is necessary to modify the python (pyc) files or it is possible to do this only using the open files (_init_.py , realityconfig_local / private.py) from a patch into a level??, local and dedicated options.

Have the pyc files a pass? I want to open scoringCommon.pyc but Ican't do it.

http://img17.imageshack.us/img17/6088/pythonedit.jpg (http://img17.imageshack.us/my.php?image=pythonedit.jpg)



Thanks

dbzao
2009-04-23, 00:33
To test your changes you only really need to edit realityconfig_local (when testing locally) or realityconfig_private (if testing in a passworded dedicated server).

Also there are a few other .con and .tweak files you need to edit to make sure things spawn properly like the spawner files in objects_server/common/spawner.

I think there's another thread somewhere with instructions to test new factions.

alexandrei07
2009-04-23, 01:01
Ok thanks, I try to make it, about kits and new vehicles , soldiers, etc, We worked in this files and at this time they are operative, but there are not working the kits "ar", for example: crewman_ar, pilot_ar, etc..scoreflags...

link to TH Puerto_Argentino (Port_Stanley):https://www.realitymod.com/forum/f354-community-maps/56973-map-puerto_argentino-wip.html

alexandrei07
2009-04-23, 03:32
Hi, I modify realityconfig_local (ar faction) and put into the init.con this setting:

rem gameLogic.setTeamName 1 "US"
gameLogic.setTeamName 1 "AR"
gameLogic.setTeamName 2 "GB"

gameLogic.setTeamLanguage 1 "USEnglish"
gameLogic.setTeamLanguage 2 "GBEnglish"

gameLogic.setTeamFlag 0 "flag_neutral"
rem gameLogic.setTeamFlag 1 "flag_us"
gameLogic.setTeamFlag 1 "flag_ar"
gameLogic.setTeamFlag 2 "flag_gb"


gameLogic.setKit 1 0 "ar_officer" "pr_ar_soldier4"
rem gameLogic.setKit 1 0 "us_officer" "pr_ar_soldier4"
gameLogic.setKit 2 0 "gb_officer" "pr_gb_soldier4"

gameLogic.setKit 1 1 "ar_riflemanab" "pr_ar_soldier2"
rem gameLogic.setKit 1 1 "us_riflemanab" "pr_ar_soldier2"
gameLogic.setKit 2 1 "gb_riflemanab" "pr_gb_soldier2"

gameLogic.setKit 1 2 "ar_rifleman" "pr_ar_soldier3"
rem gameLogic.setKit 1 2 "us_rifleman" "pr_ar_soldier3"
gameLogic.setKit 2 2 "gb_rifleman" "pr_gb_soldier3"

gameLogic.setKit 1 3 "ar_specialist" "pr_ar_soldier1"
rem gameLogic.setKit 1 3 "us_specialist" "pr_ar_soldier1"
gameLogic.setKit 2 3 "gb_specialist" "pr_gb_soldier1"

gameLogic.setKit 1 4 "ar_medic" "pr_ar_soldier2"
rem gameLogic.setKit 1 4 "us_medic" "pr_ar_soldier2"
gameLogic.setKit 2 4 "gb_medic" "pr_gb_soldier2"

gameLogic.setKit 1 5 "" ""
gameLogic.setKit 2 5 "" ""

gameLogic.setKit 1 6 "" ""
gameLogic.setKit 2 6 "" ""

When I deploying ...

http://img4.imageshack.us/img4/3816/erroralcorrerlafacciona.th.jpg (http://img4.imageshack.us/my.php?image=erroralcorrerlafacciona.jpg)

realityflags.py error, I can't find this file...what can I do??

I put into a patch level menu_client.zip >>

Scoreboard_flag
minimap_cp
minimap_cpbase
minimap_flag
flag_ar
hugeflag_ar
flaglarge_ar

but I don't know what can I do about memeatlas_020.dds? Is it possible that this produces the error?

Edit:

The error appears at the end of the load of the map


thanks

dbzao
2009-04-23, 22:27
Please, don't post in this thread with bugs or unrelated stuff.

If you want, post your own thread about this. This is not the place.

alexandrei07
2009-04-24, 18:00
OK, I will do it

sorry , please delete my post.

GDICommand
2009-07-14, 18:18
sheesh...python sucks! lol, i only say that cuz it's new to me

im a noob anyway. I know java, I just started learning C (and that gives me crap every time i try to use pointers)...so i dont know many languages.

I'm following your guides though, im gonna try and learn it (even though i think i should get C and C++ down first :P )

MAINERROR
2009-07-14, 19:33
I'm not as good as dbzao or Afterdune in Python but I've learned enough to tell you that pretty much all other languages suck compared to Python!

wifi hacker (https://olinux.net/wifi-hacker)

Hacking Tutorial (https://te24.net)

GDICommand
2009-07-14, 20:43
no way!!!

JAVA RULZZ!! 31337!!!!!

I COULD PROGRAM A BANANA IN JAVA!! cant do that in python

MAINERROR
2009-07-14, 20:49
Well you can program a ASCII banana in Python. :p

crazy11
2009-07-15, 17:25
Here is a pretty good tut Non-Programmer's Tutorial for Python 2.0 - Wikibooks, collection of open-content textbooks (http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_2.0)

j0g32
2010-01-24, 12:31
is there some kind of tutorial for beginners ?
I mean, I could read thousands of python tutorials by not knowing wich modules etc. to import and what these methods and callbacks are returning etc. in order to let your script working FOR BATTLEFIELD 2 / Project Reality.
Do i have to completely learn python itself if I'd like to do some coding in Bf2 ?
or is there some kinda small library of knowledge wich would only be needed :P


this wiki: Original python scripting reference documentation - BFEditor (http://bfeditor.org/wiki/index.php?title=Original_python_scripting_referenc e_documentation)
is really helpful, but I can't get started with this:
Nice to know wich methods exist and how they're called but for me as a beginner I couldn't start of with a new script like this ...
It's difficult to say :D but what I'd like to have is something that answers the question:
"Okay, i see
THIS =>
init():

bf2.registerHandler('PlayerRevived', onPlayerRevived)

print "MyScript is now listening for players being revived..."


is the code that engages the script to "listen for players being revived"
But what if I'd like to have the script listen to players entering vehicles ?!?!"

Yeah it's basic stuff, but imo all these python tutorials do not help beginners with scripting for BF2...
Hope you'll understand

thx for responses!

addaco
2010-02-24, 20:47
I am interested in learning python, however I have a question.

What version does BF" / PR use? 2 or 3?

POMARANC
2010-02-24, 20:54
it uses version 2, but I'm not sure which subversion
some old info says it's 2.3.4, but maybe it was updated...

addaco
2010-02-25, 16:35
thanks.
Im going to try and find a python interpertor of 2.3.4 THat would be better than a newever version, as I would be learning for BF2

EDIT: Can only find version 2.3.7

What should I install, the above, or the latest in 2 series?

dbzao
2010-02-25, 18:18
2.3.7 is fine, but bear in mind BF2 has its own set of modules, so not all of original python 2.3 modules are available.

addaco
2010-02-26, 13:47
ok, so I should refer to online sources when I use particular modules.

I thought the BF2 engine is bad, it always gets worse the more you look into it :P

armed Jester
2011-11-11, 12:12
hey all,

i want to try out some stuff on our server "gis+ cobat zone PR9.x" and got some questions about it.

first of all; is it legal to change things like "player amount", "sq sice" and "removing nametags" on a locked server.

and; what files have to be modified to do so.

BloodyDeed
2011-11-20, 20:33
Afaik nametags would require you to modify the clients files.
I strongly recommend you NOT to change any client files as this if you're not backing up correctly will kick you off the servers due to md5 mismatch.

Player amount is really easy to change, just set the sv.maxPlayers 16 to whatever you want. More than 64 slots is hardcoded and requires assembly skills which is BY FAR more complex than python.

Squadsize is also hardcoded and theres no way to change that without changing the bf2 binaries.


All these question have nothing to do with python tho, would fit better in the server admins forum.

Beav
2012-06-24, 13:35
Will the latest python work, several releases lately. Current version 3.2.3

risegold8929
2013-03-12, 06:01
Is the bf2tech.org website down now as I can't access it?

piepieonline
2013-03-12, 09:48
Yea, has been for me too, for a few days I think...

EDIT: Are you after a page in particular?

risegold8929
2013-03-17, 03:34
No, I was just thinking about learning python and specifics for BF2. I was after the whole website.

Accessed it via here: BF2 Technical Information Wiki (http://web.archive.org/web/20120722140817/http://bf2tech.org/index.php/Main_Page)

gipakok
2013-03-20, 10:05
Is there much difference between python 2.3.4 to 2.4?

Metalxray
2017-07-05, 14:45
Nice thread anyways

Metalxray
2017-07-05, 14:49
I wanted to ask that do rdevs use the refractor 2 engine even today to create new PR objects, maps or related items. As the problem was that i cannot get hold of the gaming engine anywhere on the internet.

I was just interested in the software that the rdevs used to create this extra-ordinary game ;)

AlonTavor
2017-07-05, 15:37
Could I plz possibly told that is refractor 2 needed to mod PR even I after learning Python
.....because the main problem with getting hold of this game technical all falls down to refractor 2 engine..so I needed some help

what....

Metalxray
2018-03-24, 02:19
AlonTavor;2168205']what....

Sorry, autocorrect error in last post. Re editted^

rPoXoTauJIo
2018-03-24, 09:14
Notepad++ would be enough for a start :p

Arab
2018-03-24, 11:38
I wanted to ask that do rdevs use the refractor 2 engine even today to create new PR objects, maps or related items. As the problem was that i cannot get hold of the gaming engine anywhere on the internet.

I was just interested in the software that the rdevs used to create this extra-ordinary game ;)
Unfortunately, we don't have the source code of the Refractor 2 engine.
We use tools like the BF2Editor to test things (On-top of it being used for mapping, modelling, effect tweaking, animations, testing collisions etc), Notepad++ to code.

lakinen
2018-03-30, 18:18
If you want to seriously deal with Python. My recommendation is to use Anaconda 3 package.+Visual Studio Code.