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

Getting BF2 comrose events into python!

Recommended Posts

I know that some people want to find cool things out and then say "ooooh I know how to do something cool, but I'm not telling YOU", I'm not like that, if I find something cool I will tell everyone, the more we share the more we make, and the more fun we can have playing either eachother's mods or our own. Not sharing unfinished code is understandable, but if you figure something out that would really help a bunch of people you should share it. /rant

Ok, this is very very very very dirty, but it works!!

If you want to use the comrose to trigger python events you must be:

-making your own mod

-not caring about the comrose you break

If that is your situation then you are in luck!! All you have to do is go inside your EA GAMESBattlefield 2modsMODNAMEmenu_server.zipHUDHudSetupCommunication folder. If you don't have this file in your mod you can steal it from vanilla, just make sure to copy it over and not move. You'll have to search around a bit for the comrose that you want to breakuse. In my case I want to use the squadleader's comrose, so I went into the HudElementsSquadLeaderComm.con.

Now you have access to all of the comrose actions(what each one does when you click it) you will see a bunch of hudBuilder.blahblah commands. The ones that you are interested in are the

hudBuilder.setButtonNodeConCmd

commands.

Now all you have to do is create your own command, this is like typing in console, but a little different. The only console command that would be of any use(custom text sent into python) that you can use (*grinds teeth at EA/DICE) is the rcon command. Hopefully this doesn't scare EA/DICE into breaking more of our commands.

hudBuilder.setButtonNodeConCmd      "rcon test" 0

I'm pretty sure that you would want to set the number at the end to 0. By the looks of the rest of the code 1 seems to be triggered when the person puts the mouse over the selection, which you may want to do.

Now all you have to do is grab the command in python using the 'RemoteCommand' Reference event. You get the player's Id and what command was sent. They don't have to be logged in as an admin(unless something funky was going on with my game) and no one sees the command.

Oh, and if you want to break the comrose so that the function isn't run anymore when people use the comrose I think you can go into SquadLeader.con(or whatever comrose you are editing) and just change the stuff inside of the quotations. I haven't tested this yet but it should work.

This has been tested on a dedicated server(albeit run off the same computer as the tester). Once I get a little more work done I will take this into full testing, I'll report back how it works under stress but it seems that it should work fine!

Hope this helps some people, I know it will be very usefull to me...

Share this post


Link to post
Share on other sites

I've just been playing around with this, and have come across a problem - game.sayAll doesn't work client side on a dedicated server, meaning it can't be run on a button click.

Share this post


Link to post
Share on other sites

If you can get it to send "rcon <command>" as a console command, then you can catch the RemoteCommand event.

Test and report back. :)

Share this post


Link to post
Share on other sites

Came to the same conclusion as the above while trying to figure out what command would I be able to use to send custom text to python.

Updated first post with proper instructions.

Now on to custom comroses...

Share this post


Link to post
Share on other sites

Yeah, this works great. Hadn't ever thought of using rcon...

Looks like I'm off to do some hud redesign then. :)

Share this post


Link to post
Share on other sites

If you don't want people doing this:

"ooooh I know how to do something cool, but I'm not telling YOU"

Than I would suggest more liberal use of these words:

"Thank you"

Share this post


Link to post
Share on other sites

lol, well thanks, then :)

One thing to note though - you only get a useful value for the player ID on a dedicated server - if you're relying on being able to find which player triggered it then it won't work local or singleplayer.

Share this post


Link to post
Share on other sites
One thing to note though - you only get a useful value for the player ID on a dedicated server - if you're relying on being able to find which player triggered it then it won't work local or singleplayer.
Wow, that's an interesting reversal ;) Also, thanks to Milton for the info... gj

Share this post


Link to post
Share on other sites

Im new to that python thing so i got a little question:

What can i do with that stuff? Can i spawn vehicles?

How hard would that be by using the above button thing?

It would rock :P

Share this post


Link to post
Share on other sites

You will have to learn a bit more python in order to understand what you can do with this, but basically you can make this event trigger anything python can do (spawning vehicles doesn't work quite right, but there are ways around and other interesting things you can do with python). I suggest you start reading around these forums and the bf2 wiki(bf2.fun-o-matic.org) so that you can start to see what is actually possible with python.

Share this post


Link to post
Share on other sites

Good idea. A little tip: if you use a PID of 255 when the RemoteCommand handler sends you one of -1, then it will work properly on singleplayer as well as on a dedi server.

Share this post


Link to post
Share on other sites

Interestingly I found we use this same method to limit the types of kits on the battlefield. When someone selects the kit the button press is identical to if they pressed a commrose button. As such you just assign the code in there to notify python. Then just increase that person's spawn time to something rediculously high (like 999). The only issue atm is I have no way of telling them why they can't spawn, they just get the abnormally high number. I haven't bothered thinking about it any more as we don't actually need this function in FirstStrike, but I thought I may mention it for anyone who does need ot limit kits for any various reason.

Edited by [SFaith] Woodrow

Share this post


Link to post
Share on other sites
Interestingly I found we use this same method to limit the types of kits on the battlefield. When someone selects the kit the button press is identical to if they pressed a commrose button. As such you just assign the code in there to notify python. Then just increase that person's spawn time to something rediculously high (like 999). The only issue atm is I have no way of telling them why they can't spawn, they just get the abnormally high number. I haven't bothered thinking about it any more as we don't actually need this function in FirstStrike, but I thought I may mention it for anyone who does need ot limit kits for any various reason.

very useful idea, thanks!

Edited by [FH]ctz

Share this post


Link to post
Share on other sites

Milton I think its great that you are someone that enjoys sharing new discoveries with the world but unfortunately you had nothing to do with this one. You were also under a Non-Disclosure Agreement that you signed in confidence. You have unfortunately exploited the hard work of a more successful developer than yourself at his expense and the expense of the Developer Group that you have breached a trust with.

I think the rest of the Dev Community should be aware that Milton will exploit any and all knowledge that he gains from w/e group he may infiltrate with no regard nor respect for the Team that he may be damaging or hurting. I see it as no crime to hold back on sharing intellectual property when you have a specific goal. In this case it was the Goal of a Zero-G Mod that our team has been working on for 2 years now.

My advice..... If you are currently engaged in Developing a Mod.... be very careful of who you get involved with your team. TRUST is the Backbone of DEVS. When you disregard this then you disregard the very fabric that supports a successful team.

Share this post


Link to post
Share on other sites

Post retracted due to being incorect information.

Edited by Ells

Share this post


Link to post
Share on other sites

I think he should have consulted with the Dev Team before doing so to get feedback from the rest of the Group he was a part of before volunteering information. And yes it does breach the NDA. It is neither trivial nor unreasonable. My response is based upon the reaction from the Dev Team upon discovering this thread.

Not consulting with the Dev Team is a direct breach of NDA

How hard would it have been to consider the feelings of the other Team Members regarding this?

This wasn't public flaming it was simply 'case and point'. I have nothing against Milton I just think it was 'careless' of him not to consider the 'cause and effect' of his actions.

Share this post


Link to post
Share on other sites

Ok, I see your point Surge and didn't fully understand the situation, my apologies.

I should have kept my mouth shut and thought about what I typed.

Edited by Ells

Share this post


Link to post
Share on other sites
...I see it as no crime to hold back on sharing intellectual property when you have a specific goal. In this case it was the Goal of a Zero-G Mod that our team has been working on for 2 years now.

Wow, what is the name of your mod so I know which one to inform the fanbase not to play? That callous belief you have over modding knowledge has definately won you a blackballing in my books. This information has been of great benefit to multiple mods and by sharing it he has made the BF2 modding world a better place. These boards are dedicated to those willing to share information and resources, and frankly that kind of attitude means you have no place here nor any right to use these boards to seek out info. If anything I'd ask for milton to stay and for you to walk. None of us need to help each other, but if we didn't then no mods get made. And in that respects, I hope yours doesn't now if you feel you have the right to only take from this community and not give back

Edited by [SFaith] Woodrow

Share this post


Link to post
Share on other sites
Wow, what is the name of your mod so I know which one to inform the fanbase not to play? That callous belief you have over modding knowledge has definately won you a blackballing in my books. This information has been of great benefit to multiple mods and by sharing it he has made the BF2 modding world a better place. These boards are dedicated to those willing to share information and resources, and frankly that kind of attitude means you have no place here nor any right to use these boards to seek out info. If anything I'd ask for milton to stay and for you to walk. None of us need to help each other, but if we didn't then no mods get made. And in that respects, I hope yours doesn't now if you feel you have the right to only take from this community and not give back

Sfaith I believe you are taking things out of context. I'm not saying that I am not willing to share information, what I am saying is that the when a Dev is apart of a 'Team' then the 'Team' should come first. Making decisions without giving your 'Dev Teammates' a say in what one would like to share is inconsiderate to say the least. It pretty much goes against the definition of 'TEAM'.

Share this post


Link to post
Share on other sites

There's something a bit bigger than "team" here, and that's "community." If the rest of the teams here decided to all hold on to their "intellectual property" in the manner you see fit then there wouldn't be any mods because no one would be able to get past all the hurdles modding this game creates. From what we can tell it doesn't sound like a very pleasant team to work for if you have disregard for the community that has made your team and work even possible.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...