Jump to content
Official BF Editor Forums
Sign in to follow this  
Freeze

Working On A Server-Side Mod

Recommended Posts

Well after getting shafted and my scripts "stolen", I've decided to go down the route of making my own server-side mod.

Apart from all the Python jazz, such as changing projectiles on the fly, gravity, dropping herds of pods onto poor enemies, detecting tbags, etc, I've hit jackpot on this latest script I've made.

Using some trigonometry, I can spawn any object on the map again and again, wherever I want... Here's some pictures. :lol:

screen246.th.pngscreen247l.th.pngscreen248.th.png

screen249.th.pngscreen250.th.pngscreen251.th.png

screen252.th.png

So yeah, it can be done on 2142. No download required to hop right in. Will post more as it progresses.

Update...

screen253.th.png

Edited by Freeze

Share this post


Link to post
Share on other sites

Nice build out...

But, you may have to keep it under 1024 total (including all the other vehicles and crap going on in the map)... I've found exceeding that, makes the server become very, very crashy. I added about 250 statics, doing such things, and for 3 years wondered why the !@#$%^ my server was so crashy. Pulling them all out, its back to smooth as butter. Well, not really, demo still crashes, but now its once ever 12 hours, not once every 15 minutes.

It would be nice to be able to get the current number of networkable objects in play, on the fly...

Repost of a post by Rhino... see 3&5


1. Does a higher number of static objects affect performance?

2. Does a higher number dynamic or destroyable objects affect performance?

3. What kind of objects increase the risk of a server crash?

4. What is the maximum number of statics you can place on a map.

5. What are "networkables"?

6. What are the things that could lower performance on a map.

1. Yes, the more objects have have to be "drawn" can drastically affect performance. Its easier for the CPU/GPU to process one huge static than lots and lots of small statics making up the same size of object. So avoid using the "Afghan" statics that have each wall in there own bit etc and building "unique statics" with lots of blocks of concrete stacked up together etc. You will also find lots of small objects are much harder to lightmap. Try to following the motto "less is more" in a lot of cases, trying to use as few objects as possible to archive what you want.

2. Yes, "destroyable objects" (including dest objects that have been made into "non-destroyable" via code) really class as two statics in one, since you have two models for them, the complete model (before its destroyed) and the wreck model which is shown once its been destroyed (although some dest objects like explosive barrels dont have a wreck model and vanish from the map after they are destroyed). Both the complete and wreck models need there own lightmaps, so a destroyable object needs twice as much lightmap space as a normal static of the same size and complication, which also isn't good for performance. All in all, try and only use destroyable objects where your going to have a real gameplay advantage from them.

3. & 5. you can only have up to 1024 networkables on a map before the server will crash (although exceeding 1024 networkables is fine for local servers, but not good if you want to play the map online ). Networkables are basically things the server needs to keep track of, vehicles, players, destroyable objects etc. We advise you keep your destroyable/dynamic objects below 350 to leave room for all the other networkables. The lower your networkables, the better.

4. No limit, but keep note of point 1.

6. Use as few "types" of static as possible. For example, dont start mixing Middle-East statics with Russian statics, as they both use there own unique texture pallets and its a really bad move to start mixing the two as then the player needs to load many more textures into his ram and also the CPU needs to process many more draw calls. Try and use as few unique objects and different type of objects as possible, only using a type of object if your going to be using that type of object a lot and its necessary for the map. Also like I said in point 1, dont use lots of little statics to make big statics, one big unique object is far better than lots of small tiny objects making up the same thing. Also only really place down objects that are going to mean something to the map and or its gameplay, dont place down things just because they look cool. Think about what there purpose is and are they really worth having etc. Try and just keep your map as simple as possible in terms of the statics you use and how you use them and always think is there a better way I could be doing this?

Edited by cobrachoppergirl

Share this post


Link to post
Share on other sites

Nice build out...

But, you may have to keep it under 1024 total (including all the other vehicles and crap going on in the map... badnews: that number probably includes all the bullets and projectiles in play at the moment as well, drastically limiting it)... I've found exceeding that, makes the server become very, very crashy. I added about 250 statics, doing such things, and for 3 years wondered why the !@#$%^ my server was so crashy. Pulling them all out, its back to smooth as butter. Well, not really, demo still crashes, but now its once ever 12 hours, not once every 15 minutes.

It would be nice to be able to get the current number of networkable objects in play, on the fly...

Repost of a post by Rhino... see 3&5


1. Does a higher number of static objects affect performance?

2. Does a higher number dynamic or destroyable objects affect performance?

3. What kind of objects increase the risk of a server crash?

4. What is the maximum number of statics you can place on a map.

5. What are "networkables"?

6. What are the things that could lower performance on a map.

1. Yes, the more objects have have to be "drawn" can drastically affect performance. Its easier for the CPU/GPU to process one huge static than lots and lots of small statics making up the same size of object. So avoid using the "Afghan" statics that have each wall in there own bit etc and building "unique statics" with lots of blocks of concrete stacked up together etc. You will also find lots of small objects are much harder to lightmap. Try to following the motto "less is more" in a lot of cases, trying to use as few objects as possible to archive what you want.

2. Yes, "destroyable objects" (including dest objects that have been made into "non-destroyable" via code) really class as two statics in one, since you have two models for them, the complete model (before its destroyed) and the wreck model which is shown once its been destroyed (although some dest objects like explosive barrels dont have a wreck model and vanish from the map after they are destroyed). Both the complete and wreck models need there own lightmaps, so a destroyable object needs twice as much lightmap space as a normal static of the same size and complication, which also isn't good for performance. All in all, try and only use destroyable objects where your going to have a real gameplay advantage from them.

3. & 5. you can only have up to 1024 networkables on a map before the server will crash (although exceeding 1024 networkables is fine for local servers, but not good if you want to play the map online ). Networkables are basically things the server needs to keep track of, vehicles, players, destroyable objects etc. We advise you keep your destroyable/dynamic objects below 350 to leave room for all the other networkables. The lower your networkables, the better.

4. No limit, but keep note of point 1.

6. Use as few "types" of static as possible. For example, dont start mixing Middle-East statics with Russian statics, as they both use there own unique texture pallets and its a really bad move to start mixing the two as then the player needs to load many more textures into his ram and also the CPU needs to process many more draw calls. Try and use as few unique objects and different type of objects as possible, only using a type of object if your going to be using that type of object a lot and its necessary for the map. Also like I said in point 1, dont use lots of little statics to make big statics, one big unique object is far better than lots of small tiny objects making up the same thing. Also only really place down objects that are going to mean something to the map and or its gameplay, dont place down things just because they look cool. Think about what there purpose is and are they really worth having etc. Try and just keep your map as simple as possible in terms of the statics you use and how you use them and always think is there a better way I could be doing this?

Share this post


Link to post
Share on other sites

I know the 1024 cap, I've hit that many times on Sandbox. :lol:

In Sandbox you can get the number, but that's because all of the spawnable objects are networkable and a list is maintained. You could probably do a similar setup in 2142 by using the getObjectsOfType and checking thru each object spawner, soldier, kit, etc.

But I don't plan to go near that.

** Update: APC can now pod at max height all the time regardless if near a titan or not.

Edited by Freeze

Share this post


Link to post
Share on other sites

At what point in the python code (what.py ?) during game initialization are you spawning these? I assume the most logical place would be, somewhere right after GamePlayObjects.con and StaticObjects.con are read. And these two are called from a new game init script of sorts. Or read by the C+ engine, which is why these two files are not in python, as they bloody should be (!@#$%^).

I have some mines in my map, that I would like to randomize their position each game. Have a table of all valid positions for mines, and then pick randomly from those. No problem to do that in python, but wondering where I should locate it.

I did something similiar in BF2 demo, where I used conditional ifs inside of GamePlayObjects to randomize the game objects, control points, spawnlocations, etc, every new game. Slick as hell. No python at all, it was all done in Gameplayobjects.con file

Love to have a teabag script, never even thought that was possible, seems like a lot of overhead. Douchebag turd noobs think its funny to to teabag me after they kill CHOPPERGIRL on my server. I think its rude and disrespectful as hell, esp. after all the work I've done for them to have a great gaming experience, so I come back and kill them with extra extreme brutal violence. No, not just kill them, I want them to jump back from their monitor. I'll find them and crush their body against a wall with the nose of my gunship, or come up behind them and knife them.

Edited by cobrachoppergirl

Share this post


Link to post
Share on other sites

I know about the BF2 method, much easier than 2142's. I tried it but apparently DICE "fixed" that way and it became a huge pain. I found out the same thing can be achieved using gamelogic.createobject <name> (and invoking the networkable at the same time), but that function will spawn the object based on a player's position and camera (with exactly 10 distance away). It's also just about impossible to detect which player is the one it will spawn from. So what I did was made a formula with some trig and calculated where the player should be to spawn the object where I want it to be.

Which means I have to relocate all the players since I don't know who is the "active" one. Fortunately, if you relocate them somewhere, spawn the object, then relocate them to the exact spot they were (on the same instance), nothing malicious will happen. Which means I can spawn objects on the fly whenever I want (don't need a specific point in the game to spawn them). I have it set up to do it at the start of each round, though. Something seems safer about relocating the freecam than a guy in a walker...

Hahahaha. I made the TBag script for a Christian server, but they kind of stole my work and banned me. :angry:

Not gonna point fingers but from what I know, you know who I'm talking about.

What it does is basically record the position of the helmet and when you crouch and un-crouch in a short period of time it will classify that as a t-bag. It's not perfect though, and they have to do it twice (don't want someone getting nagged for crouching and picking up a kit really fast). Sometimes the ragdoll will fall off a building or something and it only records where the player died, not where their actual ragdoll head is. I might modify it to look for the kit, but that creates more problems when a player picks up the kit. Would be great to find a way to detect the ragdoll...

I made it when I was a novice at Python, so it's not as clean as my new standards. When I wipe it off I'll post it/pm you.

Also have some other projects like detecting an aimbotter and disabling his weapon's projectile so he fires blanks at everyone and is basically a walking duck. Just need to find an aimbotter to develop the script ... Along with getting that new Molokai titan map to work in conquest. Works fine when loading it, but the moment I add a controlpoint clients will crash, which makes it kind of useless when the players can't spawn. Might have an editor mode where I'll let players spawn things and have a floating soldier follow the freecam. Not sure.

Just on the top of my head, other scripts include server-side squadleader unlocks, where random blank pods are dropped when using a beacon to confuse the enemy, squad based SAT track, and I'm trying to get a personal UAV to work but it always reverts to a single point on the map instead of where I want it to go.

Also, just messing around, the move ordermarker (squadleader move to this position) can be spawned, like I expected, but there are two other ordermarkers. The attack ordermarker and defend ordermarker. The move ordermarker is an annoying, bleeping yellow light. For some reason the attack and defense ordermarkers aren't actually used, but they are loaded, and when using my script to spawn them I get two orange and purple flashing lights. I have no real use for them but maybe you could find one for your demo server.

Edited by Freeze

Share this post


Link to post
Share on other sites

Can you not getObjectsOfTemplate on that template type (eliminating ones at position (0.0,0.0,0.0) - which are cached and not active), spawn it, and then the next frame have it do the same and compare the tuples? That way any non-zero-position objects that have been spawned of that template type will be gotten by the python, which can then move it.

I think that may only work for networkables though, unless BF2142's network system is different to BF2's.

Share this post


Link to post
Share on other sites

Can you not getObjectsOfTemplate on that template type (eliminating ones at position (0.0,0.0,0.0) - which are cached and not active), spawn it, and then the next frame have it do the same and compare the tuples? That way any non-zero-position objects that have been spawned of that template type will be gotten by the python, which can then move it.

I think that may only work for networkables though, unless BF2142's network system is different to BF2's.

Yep, networkables only. I already have a system for spawning vehicles that works pretty decently. The method I described earlier is to spawn non-networked objects which can be done but is a lot more difficult.

Share this post


Link to post
Share on other sites

Moving all the players just to place an object... traversing through all your objects, though I'm sure it works, sounds like one messed up way to do things. Seems like some of the players who hit ESC in order to quickly enter the game after a map change, instead of waiting through the splash screen, would watch the entire rebuild process as their character hops around, and if their character turns out to be the hot, in focus one, may even throw your build process off by moving their mouse around real fast.

~

One thing you could do with the teabag script, is convert teabagging into a revive. So that teabagging your dead teammates would revive them. Lot of sick necrophiliac little s**tkickers out there, particularly on my server.

I know if I were dead and someone tried to teabag me, I'd for sure wake from the dead just to put a bullet in their douche bag little skull.

Edited by cobrachoppergirl

Share this post


Link to post
Share on other sites

The spawning is all instanced, and I force rotation on the same instance, so they can't move against it. I could also just disable the freecam.

And since it's instanced you only see the view point of the last object spawned, but I'm going to set it up to reset to where the user was before spawning occurred.

Might even try that revive. :lol:

Just curious. Some guys in Battlefield Heroes found out how to make the server banner play a sound by encoding it in the image or something too complicated for me. Any of you have any info on this and know if it's possible on the older games?

Edited by Freeze

Share this post


Link to post
Share on other sites

Sorry if this is a little off topic, but how were you able to force the players rotations? I had been trying to do almost the exact same thing you have here a few months ago, but could never get the rotations down. Actually, I wasn't able to change rotations at all. I tried using playerObject.getDefaultVehicle().setRotation(), which I expected would at least change something, and "rcon exec object.rotation" on the object itself, which I didn't really expect to do anything visibly, and of course, it didn't. I was using the same format for the args of setRotation() as of setPosition() ( which did work fine ), should I have been using a different format for the args? Or is there something obvious I'm missing?

Share this post


Link to post
Share on other sites

I was wondering when you'd show up.

The soldiers rotation can be set, but it will not be visible online. :( You can change it around (not tilted or upside down; soldier will reset those), but it's client based and the player and other players will not see the update (but it is still changed, so this script would still work even though the client is looking somewhere completely different). It works fine in local, though.

But if the soldier is in a vehicle (freecam is a vehicle, in a way), the server can force it with playerObject.getVehicle().setRotation((0.0, 0.0, 0.0)) and the client will update as well.

Edited by Freeze

Share this post


Link to post
Share on other sites

Just curious. Some guys in Battlefield Heroes found out how to make the server banner play a sound by encoding it in the image or something too complicated for me. Any of you have any info on this and know if it's possible on the older games?

I tried putting a BELL ascii character (control-G) in the community and sponser text messages, hoping it would make a sound, but with no luck. It also does nothing printed in the in game chat. I have not tried printing it to the server console... that *might* make the computer your server is running on beep... but I doubt it. Could be useful for knowing when the server reboots or to alert you of some other important event on a headless or KVM'd server.

What images can be displayed... PNG and JPG as far as I know, and maybe GIF. Has anyone ever tried an animated GIF (don't think it works)?

~

As for your build out in BF2142, the big litmus test is, does it crash the client when you do an (rcon exec) admin.runnextlevel to load the next map. Any time I make statics networkable and spawn them, sure, they show up fine, and everything is grovy, until the game ends, and then when the next level is loaded... any game clients connected CTD.

VIDEO:

VIDEO:

I made these a long time ago... its no problem to do this on the BF2 side (indeed, I made a huge built out one time on BF2 demo), but the same method CTDs the game clients on the 2142 demo side.

Edited by cobrachoppergirl

Share this post


Link to post
Share on other sites

I've been able to load a new map without crashing when playing with a friend in the server and offering to edit Minsk.

I'm not sure why yours CTDs. The only difference is that I spawn everything in-game as the round begins as opposed to editing map files.

Have you had any luck playing on a game mode other than the preexisting ones? I tried that new Molokai map on conquest (new map - no conquest mode?) but I need a controlpoint to spawn. And as you can imagine making a control point will crash clients. So it will load but freecam is all you can do there.

Edited by Freeze

Share this post


Link to post
Share on other sites

I'm reviving this. The goal is to make it solely through Python rather than changing server.zip files. Which presents a problem when you want to tweak vehicles...

If tweaking vehicles via Python it will not affect vehicles already spawned or in the cache. (Cached vehicles means you need to spawn a bunch before any changes even occur)

Editing .zip files modifies all vehicles as you would expect.

Not good enough. I had to invent a new method to do it with Python. Modify vehicles while the map is loading = CTD for players joining. Which meant the only safe time is the instance after the map has loaded and before the vehicles initially spawn (a very small time frame).

There isn't an event handler for this - the game is in 'Pregame' when this occurs, but is also in 'Pregame' when the map is loading. :angry:

But the events happen in a specific order, so knowing this I made a new "GameStarting" event.

Then I discovered initially spawned vehicles are cached and consequently can't be modified. So I made another function to recycle these before they are spawned.

tl;dr this was a seemingly simple task that became really difficult.

I succeeded. Server automatically modifies vehicles before they're spawned, like .zip edits but w/ Python.

So several hours later... A fun mod to the speeder:

http://www.xfire.com/video/5c9e47/

Press flare button to hover up. No mod required to join server. :)

Edited by Freeze

Share this post


Link to post
Share on other sites

Actually, that didn't work as expected. Since 2142 recycles vehicles, the non-modified ones return once again when the vehicles respawn (and modified ones after another respawn).

So it would be possible to have modified vehicles for individual players, just rather difficult to maintain.

Which puts me back at square one. The only way to modify the vehicles before they're created would be to put a command in GamePlayObjects.con but that isn't ideal if doing it strictly through Python.

Edited by Freeze

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×