Newsflash


JOIN BASHandSlash.com's STEAM GROUP.

STEAM GROUP: bashandslash

 
CoD4: Promod Tutorials
Written by raf1 (edited by JY)   
Monday, 13 October 2008

We had dedicated a section of our forums to raf1 to house his Promod information. However, as he has decided to get on with his real-life and leave gaming behind, I thought I would shut down the Promod forum in the BASH Boards and transfer his tutorials here.

Raf1's tutorials help scripters and modders with techniques they can use to mod CoD4. While this site is dedicated mainly for players, not scripters (mycallofduty.net would be the better place to go for that), with Raf1's permission - I thought that keeping this information may inspire future Raf1's out there.

The first of these two tutorials deal with allowing players to bind keys to your mod's functions.

The second deals with preventing players from using toggles in your mod. Yes, I realize the irony of this tutorial - given that we have a huge section in our forums on how to create toggles, now we're telling you how to stop people from using them. This topic is still in keeping with our philosophy that any knowledge is good.

Raf1's preamble:

I have created a tutorials section to pass on some of the work I have done to existing modders. I doubt any of the articles here will help new modders, but the odd pieces may be useful to other people. You need to have the mod tools set up to use this, as it relies on retrieving files from your /raw folder.

You do not have to credit me when using any of this, but it is good courtesy to do so, and will also keep your integrity as a modder.

 

BINDING KEYS TO FUNCTIONS

- raf1 Sep 08

This tutorial explains how to let players bind keys to your mod functions. I have not used localization in it, but you could easily adapt it to.

For my example, I am going to use part of the fictional mod 'Killstreak Warfare'.

1) First of all, you need to create or edit a menu to do this in. I used the existing 'Multiplayer Controls', which is in your mod tool folder : raw\ui_mp\controls_multi.menu

2) You will see a list of existing bind macro's, which look like the following:

CHOICE_BIND( 22, "@MENU_VOTE_YES", "vote yes", ; )
CHOICE_BIND( 23, "@MENU_VOTE_NO", "vote no", ; )
CHOICE_SEPARATOR( CHOICE_SEP_1 )
CHOICE_BIND( 24, "@MENU_VOICE_CHAT_BUTTON", "+talk", ; )
CHOICE_BIND( 25, "@MENU_CHAT", "chatmodepublic", ; )
CHOICE_BIND( 26, "@MENU_TEAM_CHAT", "chatmodeteam", ; )
CHOICE_BIND( 27, "@MENU_QUICK_CHAT", "mp_QuickMessage", ; )

 

3) Add your custom functions to the menu, assuming you do not require or have the resources available for localization. Use the specific command 'openscriptmenu (menu_name) (command_name)'. My example menu is 'killstreak_commands' and my example commands are 'destruct_chopper' and 'cancel_airstrike'

CHOICE_BIND( 29, "Self-Destruct Chopper", "openscriptmenu
killstreak_commands destruct_chopper", ; )
CHOICE_BIND( 30, "Cancel Air-Strike", "openscriptmenu
killstreak_commands cancel_airstrike ", ; )

 4) Now open your mods maps\mp\gametypes\_menus.gsc, scroll to the function init(), and add precaching for your menu_name. Remember the physical menu does not have to actually exist in the game to use the reference.

game["killstreak_commands"] = "killstreak_commands";
precacheMenu(game["killstreak_commands"]);

5) Now scroll to the function onMenuResponse(), and add a hook to your custom handler

else if(menu == game["killstreak_commands"])
   maps\mp\gametypes\killstreak_menu_handler::command(response);

6) In your

maps\mp\gametypes\ folder,

create a file called 'killstreak_menu_handler.gsc', and place the following example code inside it.

 

command(response)
 {
  if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" )
      return;
      switch(response)      
      {
       case "destruct_chopper":
       //Checks that the helicopter exists would go here
       //Checks that the player owns the helicopter would go here
         self iPrintLNBold("Helicopter Self-Destructing...");
       //Helicopter self-destruct code goes here
         break;

 7) Now compile your mod, open your multiplayer controls, and try binding a key to either function, and trying it out
Client side files changed : ui_mp\controls_multi.menu
Server side files changed : maps\mp\gametypes\_menus.gsc
Server side files added : maps\mp\gametypes\killstreak_menu_handler.gsc

 

 

2. ANTI TOGGLE SCRIPT

 - raf1 Sep 08

This doesn't deal with the problem directly, but can deal with the side effect cvars. It cant work against printscreen, but can work against quick '10 maxpackets' toggles.

Toggles are when a player quickly does something, like lag bind across a street, or use a higher fps than usual for a short time, before Punkbuster catches on to it and issues a warning.

Since you can't use getClientDvar in this game, the only way to read a client side dvar and give a response is via the client side menu files. You can hook in on the menu visibility or on the menu text itself or rectangle. Unfortunately this is about as far as it will let you use the dvars.

My solution was to create an instaneous response on a pre-opened menu to any manipulation of connection settings, etc.

I used it in Promod to punish people who tried to use lag scripts. Since on connect the players maxpackets were set to 100, only a script or toggle bind could lower it. When a player lowers it after connect, his screen becomes blurred so he cannot see, and the sound of the bomb exploding will loop at a very fast rate, deafening him if he continues

The file you need to edit is ui_mp\hud.menu, which will initially be in your 'raw' folder

I scrolled down to the redundant element in my mod, 'amitalking', and replaced the section with the following

//   raf1s Dvar Punisher
menuDef
{
   name         "amitalking"
   blurworld       16
   soundloop       "exp_suitcase_bomb_main"
   rect 0 45 1 1 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER
   fullScreen 0
   visible when ( dvarint( com_maxfps ) > 250 ||
   dvarint(
com_maxfps ) < 40 ||
   dvarint( cl_maxpackets ) < 100 || dvarint( rate)
< 25000 )
     [EDIT: REMOVED A COUPLE OF LESSER KNOWN ONES TO KEEP

      THEM LOW PROFILE];
      itemDef
    {
  rect -300 45 1 1 HORIZONTAL_ALIGN_CENTER
  VERTICAL_ALIGN_CENTER

    origin      0 0
    forecolor   1 0 0 1
    backcolor   1 0 0 1
    exp text   ( "One of your dvars is currently out of limits!");
    textfont   UI_FONT_OBJECTIVE
    textscale   0.90
    textalign   ITEM_ALIGN_LEFT
    textstyle   ITEM_TEXTSTYLE_SHADOWEDMORE
    visible    1
    decoration
      }
   }

This short little addition will mean that you can have some extra protection on your server from malicious scripts, without having to wait for the very low chance punkbuster will pick up on it at exactly the right second.

You can extend being inventive with the menus for other applications. Initially I had my server start game button being replaced with a fake replica, that was only visible if you had the compass cheat on, and if you did, the server would recieve the known fake start button instead of the real one when the player clicked it, and automatically kick that player from the server

If you are going to apply this to potential stock dvars, you may want to remove the noise deterrant 'soundloop "exp_suitcase_bomb_main"'

 
< Prev   Next >

BASHandSlash Network

 
monkeybiz_icon.jpg
 

BASH on YouTube

bashyoutube1.jpg

The BASHandSlash Forums

bsboards_v2.jpg
original solarflare design by rhuk
lunarized by joomlashack