![]() |
|
[Tutorial] Ultimate Black Ops Modding - Printable Version +- ItsMods (https://www.itsmods.com) +-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html) +--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html) +--- Thread: [Tutorial] Ultimate Black Ops Modding (/Thread-Tutorial-Ultimate-Black-Ops-Modding.html) |
Ultimate Black Ops Modding - d0h! - 01-03-2011 Credits: iHc James edited by d0h! Contents: Fastfile Editing: Getting Started
Programs
Zombie "use" Strings Fastfile Editing: Getting Started: Editing Black Ops Files: The Fastfile (.ff) contains numerous files, Think of it as a .zip / package. The most popular file within a Fastfile is the GSC, Idk wtf that stands for, Game Script Code or something :D? Anyway on the list to the left of either of the programs will be the GSC's inside they fille be formatted in folders. The recommended GSC to edit is the _challenges.gsc which is located: PHP Code: maps/mp/_challenges.gsc
Now you can edit the code. Once you have that mastered, You are ready to continue :D Coding Basics for Black Ops: Functions: Functions are a group of code, you can execute them from other function and even send them values A function looks like this PHP Code: FunctionName( Argument1, Argument2, Argument3 )
{
}
Calling a function means starting it. Arguments - Argument is a value that can be passed to the function when calling it, Arguments can be found between the () after the function name, Each argument is seperated by commas. You don't have to use arguments, a function without arguments would look like: PHP Code: FunctionName()
{
}
Comments: Comments are a section within coding that will get ignored, to start a comment just type: PHP Code: //
You can also make group comments, group comments start with: PHP Code: /*
PHP Code: */
PHP Code: /* Here is a comment group
Remember groups dont end after a new
line it will only end when it finds */
Function1()
{
//Heres a line comment
}
It will look like this: PHP Code: onPlayerConnect()
{
for(;;)
{
level waittill( "connected", player );
// The Code Differs Here
}
}
PHP Code: level waittill( "connected", player );
you are able to make a function that will execute whenever you spawn by: Adding: PHP Code: player thread OnPlayerSpawn();
So it will look like this: PHP Code: onPlayerConnect()
{
for(;;)
{
level waittill( "connected", player );
// The Code Differs Here
player thread OnPlayerSpawn();
}
}
PHP Code: onPlayerSpawn()
{
for(;;)
{
self waittill( "spawned_player" );
// Code Here gets executed on spawn
}
}
You will reference to yourself as "player" But elsewhere you will reference yourself as "self" At the top of GSC's is a function with the name init, This is the initialization function, which will load/prepare stuff for the game, such as caching models (loading models), In the init function may notice: PHP Code: level thread onPlayerConnect();
Endon Function: To stop your functions messing up when you die / disconnect you can add either of these to the start of a function: PHP Code: self endon ("disconnect");
self endon ("death");
Wait: Wait is a simple line of code that will wait however long you want like so: PHP Code: wait 1; //Waits 1 second
wait 0.5;
wait 0.05;
Calling Functions: you can call a function like so: PHP Code: level thread functionName(); //Use this whenever
player thread functionName(); //Use this OnPlayerConnect
self thread functionName(); //Use this in your own functions
You can call functions from other GSC's by: PHP Code: self maps\mp\location\_gscname::Function();
Variables: A variable is a stored value that you can set and get. You can create a variable with a piece of simple code like this: PHP Code: String = "This Is The Value";
Integer = 5;
Boolean = true;
Array = ( 100, 200, 500 );
Array2 = ( "hello", "hey", "hi" );
Integer - Integers will only hold a numeric value Boolean - Booleans are a true/false value Array - Arrays is a group of values If I create a variable within a function, I am unable to access it from another function: PHP Code: function1()
{
MyVariable = ( 0, 0, 0 ); // Sets the Varaible named MyVariable
}
function2()
{
self thread CallingAFunction( MyVariable ); // Tries to call a function with MyVariable as an argument
//This wont work as it wont have access to the variable as its within another function.
}
You can save Variables to a self, player or level. by simply adding it like so: PHP Code: self.Variable = "Hey";
level.Variable = "Oh Hai Der";
player.Variable = 1337;
If Statements: An If statement if a group of code that will only execute if the check matches heres the structure: PHP Code: if ( check )
{
}
PHP Code: if ( self.Variable == 1 )
{
//This will only execute if self.Variable = 1
}
PHP Code: == // If its equal to
!= // If its not equal to
< // If its less than
<= // If its less than or equal to
> // If its more than
>= // If its more than or equal to
heres an example of an if with an else: PHP Code: if ( self.Variable == 1 )
{
//This will only execute if self.Variable = 1
}
else
{
//This will only execute if self.Variable != 1
}
Select Case Statements: The select statement is your #1 solution for not using lots of if statements, for example: PHP Code: if ( self.Variable == 0 )
{
// 0
}
if ( self.Variable == 1 )
{
// 1
}
if ( self.Variable == 2 )
{
// 2
}
PHP Code: switch( self.Variable )
{
case 0:
//0
break;
case 1:
//1
break;
case 2:
//2
break;
}
While Statements: A While statement is a group of code that will repeat forever, or until you want it to stop While statements look like so: PHP Code: while ( Boolean )
{
}
heres an example of a continously running while statement: PHP Code: while ( 1 )
{
//Repeated Code
wait 0.05; //You need to put a short wait so it dont work like a b****
}
For Statements: A For statement is like a while, but has my precise repeating checks PHP Code: for( i=1; i<=3; i++ )
{
//This code will get executed 3 times, with a 3 second delay between
wait 3;
}
for(i=1; i<=3; i++) i=1; - Will declare the variable i, value 1 i<=3; - This is like the while check, if i is less than or equal to 3 it will execute i++ - Wether the variable will increase or decrease every time it repeats ( i-- is to decrease ) Final: Heres an example using some of the stuff above, PHP Code: onPlayerConnect()
{
for(;;)
{
level waittill( "connected", player );
// The Code Differs Here
player thread OnPlayerSpawn();
}
}
onPlayerSpawn()
{
for(;;)
{
self waittill("spawned_player");
self.Variable = false;
self thread Function1();
self thread Function2();
}
}
Function1()
{
self endon ("disconnect");
self endon ("death");
wait 10;
self.Variable = true;
}
Function2()
{
self endon ("disconnect");
self endon ("death");
while ( 1 )
{
if (self.Variable = true)
{
self.origin = self.origin + ( 0, 100, 0 );
}
else
{
self.origin = self.origin + ( 0, 250 ,0 );
}
wait 1;
}
}
What that will do, Is every second, it will make your origin 100 units higher, until 10 seconds in, Then every second, it will make your origin 250 units higher, Can you figure that out? Hope this part has helped some people :D HUD / Text: Working with _hud_util.gsc - Creation Creating a bar: This will create a box with gradient, youll have to try to see what I mean, until I take a screenshot. Function Header: PHP Code: createBar( color, width, height, <optional> flashFrac )
PHP Code: BarName = self createBar( "black", 300, 10 ); // Creates a Black box, Size: 300w, 10h
//Dont Forget to setPoint
Create a font string, this will create a text element which you can display on screen Function Header: PHP Code: createFontString( font, fontScale )
PHP Code: StringName = self createFontString( "objective", 1 ); // Creates a Font String, Font is Objective, and Scale is 1
//Another font is "default" without quotes
setPoint Sets the point (location) of the element that calls it Function Header: PHP Code: setPoint( point, relativePoint, xOffset, yOffset, moveTime )
PHP Code: ElementName setPoint( "TOP LEFT", "TOP LEFT", 0, 50 ); // Sets Elements Point to 0,50 from the Top Left
//point references: TOP, BOTTOM, LEFT, RIGHT
Hides the element that calls it Usage: PHP Code: ElementName hideElem(); // Hides Element
Shows the element that calls it Usage: PHP Code: ElementName showElem(); // Shows Element
Destroys the element that calls it Usage: PHP Code: ElementName destroyElem(); // BOOM
Sets the width of the element that calls it Function Header: PHP Code: setWidth( width )
PHP Code: ElementName setWidth( 500 ); // Sets Elements width to 500
Sets the height of the element that calls it Function Header: PHP Code: setHeight( height )
PHP Code: ElementName setHeight( 500 ); // Sets Elements Height to 500
Sets the width and height of the element that calls it Function Header: PHP Code: setSize( width, height )
PHP Code: ElementName setSize( 250, 300 ); //Sets Elements width to 250, and height to 300
Sets the parent of the element that calls it Function Header: PHP Code: setParent( element )
PHP Code: ElementName setParent( level.uiParent ); // Sets Elements parent to level.uiParent
Returns the parent of the element that calls it Usage: PHP Code: ElementName setParent(); // Returned value is parents name
Sets the text of the element that calls it Function Header: PHP Code: setText( Text )
PHP Code: ElementName setText( "Text" ); // Sets Elements Text
Example Bar Creation Creates a black bar, size 250w, 250h PHP Code: BarExample = self createBar( "black", 250, 250 );
BarExample setPoint( "TOP LEFT", "TOP LEFT", 30, 50 );
Creates a Font String, Font as Objective, Scale as 1 Sets the point to 50, 50 from the top left of the screen Sets the text to "Text" PHP Code: FontStringExample = createFontString("objective", 1 );
FontStringExample setPoint( "TOP LEFT", "TOP LEFT", 50, 50 );
FontStringExample setText( "Text" );
oldNotifyMessage Modern Warfare 2 Styled Notify Message Function Header: PHP Code: oldNotifyMessage( titleText, notifyText, iconName, glowColor, sound, duration )
PHP Code: self maps\mp\gametypes\_hud_message::oldNotifyMessage( "Main Text", "Sub Text", "rank_prestige15", "black", "mp_level_up", 5);
Typewriter Styled Text Function Header: PHP Code: hintMessage( hintText, duration )
PHP Code: self maps\mp\gametypes\_hud_message::hintMessage( "Text", 5 );
Notify Message, Like Challenge Unlock You have to spawn the struct and pass it as an argument Function Header: PHP Code: notifyMessage( notifyData )
PHP Code: notifyData = spawnStruct();
notifyData.titleText = "Main Text";
notifyData.notifyText = "Sub Text";
notifyData.iconName = "rank_prestige15";
notifyData.glowColor = "black"
notifyData.sound = "mp_level_up";
notifyData.duration = 5;
self maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
PHP Code: ShowMessage( titleText, notifyText, iconName, glowColor, sound, duration )
{
notifyData = spawnStruct();
notifyData.titleText = titleText;
notifyData.notifyText = notifyText;
notifyData.iconName = iconName;
notifyData.glowColor = glowColor;
notifyData.sound = sound;
notifyData.duration = duration;
self maps\mp\gametypes\_hud_message::notifyMessage( notifyData );
}
iPrintln Shows text at bottom left of screen Usage: PHP Code: self iPrintln("Text");
Shows text at top of screen Usage: PHP Code: self iPrintlnBold("Text");
Pre Cache / Loading: Sometimes you will need to Pre Cache / Load something before you can use it PHP Code: preCacheItem( item );
preCacheModel( model );
PreCacheString( string );
PreCacheShader( shader );
PreCacheVehicle( vehicle );
PreCacheRumble( rumble );
loadFx( fx );
loadTreadFx( treadfx );
Example: PHP Code: preCacheModel( "mp_supplydrop_boobytrapped" );
DVARS: Using Dvars: setDvar Sets a Dvars value Function Header: PHP Code: setDvar( name, value );
PHP Code: self setDvar( "cg_thirdperson", 1 );
Sets a Clients Dvars value inside the lobby and for clients outside the lobby Function Header: PHP Code: setClientDvar( name, value );
PHP Code: self setClientDvar( "cg_thirdperson", 1 );
Dvar Dump (w/ Descriptions): //the complete dvardump can be found by using the boardseach Models: Basics: Spawning a Script Model: PHP Code: ScriptModel = spawn( "script_model", self.origin ); // Spawns a Script Model at Your Origin (Location)
PHP Code: ScriptModel setModel( "name" ); // Sets the Model of the Script Model - Where name = The Model Name
Origin - Sets or Gets the Origin of the Script Model Structure: ( X, Y, Z ) PHP Code: ScriptModel.origin = ( 0, 0, 0 ); // Sets the Origin to 0, 0, 0
ScriptModel.origin = ( 0, 100, 0 ); //Sets the Origin to 0, 100, 0
ScriptModel.origin = self.origin; //Sets the Origin to match yours
ScriptModel.origin = self.origin + ( 0, 100, 0 ); //Sets the Origin to match yours + 0, 100, 0
self.origin = ScriptModel.origin; //Gets the ScriptModel's Origin, And sets your Origin to it
Structure: ( X, Y, Z ) PHP Code: ScriptModel.angles = ( 0, 0, 0 ); // Sets the Angles to 0, 0, 0
ScriptModel.angles = ( 0, 100, 0 ); //Sets the Angles to 0, 100, 0
ScriptModel.angles = self.angles; //Sets the Angles to match Your Characters
ScriptModel.angles = self.angles + ( 0, 100, 0 ); //Sets the Angles to match Your Characters + 0, 100, 0
self.angles = ScriptModel.angles; //Gets the ScriptModel's Angles, And sets your Angles to it
Show Shows The Model PHP Code: ScriptModel show();
Hides The Model PHP Code: ScriptModel hide();
Makes the model solid PHP Code: ScriptModel solid();
Makes the model not solid PHP Code: ScriptModel notsolid();
Some Model Names: PHP Code: "mp_supplydrop_ally" // Ally Care Package
"mp_supplydrop_axis" // Enemy Care Package
"mp_supplydrop_boobytrapped" // Black Care Package with Red Skull and Crossbones
"weapon_claymore_detect"
"weapon_c4_mp_detect"
"t5_weapon_acoustic_sensor_world_detect"
"t5_weapon_scrambler_world_detect"
"t5_weapon_camera_spike_world_detect"
"t5_weapon_camera_head_world_detect"
"t5_weapon_tactical_insertion_world_detect"
"t5_weapon_camera_head_world"
Sounds: Playing Sounds Functions to Play Functions you can use to play sounds PHP Code: playLocalSound( "name" ); //Plays sound local to the caller
playSound( "name" ); //Plays sound once
playLoopSound( "name" ); //Continuously Plays a sound
PHP Code: self playLocalSound("mpl_player_heartbeat");
//Plays Heartbeat Sound, Local to you Character
PHP Code: ScriptModel = spawn( "script_model", self.origin );
ScriptModel playSound ( "mpl_kls_napalm_exlpo" );
ScriptModel playLoopSound ( "mpl_kls_napalm_fire" );
//Spawns a Script Model, At your origin
//Plays Napalm Explosion Sound
//Loops Burning Sound
Some Sound Names: PHP Code: "mpl_player_heartbeat" //Heartbeat Noise
"mpl_kls_napalm_exlpo" //Napalm Explosion
"mpl_kls_napalm_fire" //Napalm Burning
Weapons: giveWeapon Give weapon to player Function header: PHP Code: giveWeapon( name );
PHP Code: self giveWeapon( "crossbow_explosive_mp" );
Switch players current weapon Function header: PHP Code: switchToWeapon( name );
PHP Code: self switchToWeapon( "crossbow_explosive_mp" );
Disables weapons PHP Code: self _disableWeapon();
Enabled weapons PHP Code: self _enableWeapon();
return ( !self.disabledWeapon ); PHP Code: WeaponTest = self isWeaponEnabled();
PHP Code: "crossbow_explosive_mp"
"m1911_mp"
"python_mp"
"cz75_mp"
"m14_mp"
"m16_mp"
"g11_lps_mp"
"famas_mp"
"ak74u_mp"
"mp5k_mp"
"mpl_mp"
"pm63_mp"
"spectre_mp"
"cz75dw_mp"
"ithaca_mp"
"rottweil72_mp"
"spas_mp"
"hs10_mp"
"aug_mp"
"galil_mp"
"commando_mp"
"fnfal_mp"
"dragunov_mp"
"l96a1_mp"
"rpk_mp"
"hk21_mp"
"m72_law_mp"
"frag_grenade_mp"
"claymore_mp"
"china_lake_mp"
"knife_ballistic_mp"
Button Binding: OnPlayerConnect: PHP Code: player thread MonitorButtons();
PHP Code: MonitorButtons()
{
self endon("disconnect");
for(;;)
{
if(self ActionSlotOneButtonPressed()) self notify("dpad_up");
if(self ActionSlotTwoButtonPressed()) self notify("dpad_down");
if(self ActionSlotThreeButtonPressed()) self notify ("dpad_left");
if(self ActionSlotFourButtonPressed()) self notify ("dpad_right");
if(self SecondaryOffHandButtonPressed()) self notify("LB");
if(self FragButtonPressed()) self notify("RB");
if(self MeleeButtonPressed()) self notify("RS");
if(self ADSButtonPressed()) self notify ("left_trigger");
if(self AttackButtonPressed()) self notify ("right_trigger");
if(self JumpButtonPressed()) self notify("button_a");
if(self UseButtonPressed()) self notify ("button_x");
if(self ChangeSeatButtonPressed()) self notify ("button_y");
if(self ThrowButtonPressed()) self notify ("button_b");
wait 0.05;
}
}
// all PC buttons are PHP Code: bind TAB "+scores"
bind ESCAPE "togglemenu"
bind SPACE "+gostand"
bind 1 "weapnext"
bind 4 "+smoke"
bind 5 "+actionslot 3"
bind 6 "+actionslot 4"
bind 7 "+actionslot 2"
bind A "+moveleft"
bind B "mp_QuickMessage"
bind C "togglecrouch"
bind D "+moveright"
bind E "+leanright"
bind F "+melee"
bind G "+activate"
bind Q "+leanleft"
bind R "+reload"
bind S "+back"
bind T "chatmodepublic"
bind V "+melee"
bind W "+forward"
bind X "+actionslot 1"
bind Y "chatmodeteam"
bind Z "+talk"
bind PAUSE "toggle cl_paused"
bind CTRL "toggleprone"
bind SHIFT "+breath_sprint"
bind F1 "vote yes"
bind F2 "vote no"
bind F3 "toggleview"
bind F10 "acceptinvitation"
bind F12 "screenshotJPEG"
bind MOUSE1 "+attack"
bind2 MOUSE1 "+vehicleattack"
bind MOUSE2 "+toggleads_throw"
bind MOUSE3 "+frag"
bind2 MOUSE3 "+vehicleattacksecond"
bind MWHEELDOWN "weapnext"
bind MWHEELUP "weapnext"
PHP Code: self waittill("+actionslot 1");
self waittill("+actionslot 2");
self waittill("+actionslot 3");
self waittill("+actionslot 4");
self waittill("+melee");
self waittill("forward");
self waittill("crouch");
self waittill("back");
self waittill("talk");
//all possible keybinds can be used! Function Example: PHP Code: actionslot 1()
{
self endon("disconnect");
for(;;)
{
self waittill("+actionslot 1");
//Code Executed On X Press
wait 0.05;
}
}
Small Mods: giveKillstreak Gives you a Killstreak Function Header: PHP Code: giveKillstreak( killstreakType, streak, suppressNotification, noXP )
PHP Code: self maps\mp\gametypes\_hardpoints::giveKillstreak( "dogs_mp" );
//Where dogs_mp is Killstreak given
PHP Code: radar_mp
dogs_mp
rcbomb_mp
helicopter_comlink_mp
helicopter_player_firstperson_mp
helicopter_gunner_mp
supplydrop_mp
minigun_drop_mp
Misc Functions: Here are some misc functions that are already in the game: cointoss() return RandomInt( 100 ) >= 50 ; PHP Code: CoinTossTest = self cointoss();
return GetTime() < self.flashEndTime; PHP Code: FlashedTest = self isFlashed();
Delays the code in seconds PHP Code: wait( 2 ); //Waits 2 Settings
Delays the code in seconds PHP Code: realWait( 2 ); //Waits 2 Settings
Returns how long the game is PHP Code: TimeTest = self getGameLength();
return 70; Useless, but if you wanna make you code look nice you can use it somewhere PHP Code: HeightTest = self get_player_height();
Detatch your head :o PHP Code: self detachAll();
Some Variables: Here are some misc variables that may come in helpful Self self.name Gets / Sets the Name of the player (Profile Name / Gamertag) PHP Code: GetName = self.name;
self.name = "James";
Gets / Sets the health of the player PHP Code: GetHealth = self.health;
self.health = 9999;
level.hostname Gets / Sets Name of the game host (Profile Name / Gamertag) PHP Code: GetHostName = level.hostname;
level.hostname = "James";
Username Check Checks the Username PHP Code: if ( self.name == "iHc James" )
{
// Your Name is iHc James
}
Checks the Username PHP Code: if ( level.hostname == "iHc James" )
{
// You Have a Cool Host!?
}
Checks the Username PHP Code: if ( level.hostname == self.name )
{
// You are the Host!
}
Programs: Here are some programs ItsModsLoader Use this to load custom maps into Call of Duty Black Ops http://www.itsmods.com Notepad++ Notepad++ is a program that always comes in handy, Just a nice notepad to use. http://notepad-plus-plus.org/ Other: Zombie "use" Strings Some Interesting Ones :) //add this into the config.cfg at the end || a full list of weapons can be found by using the boardsearch PHP Code: bind O "god"
bind 8 "sf_use_ignoreammo 1"
bind 9 "player_sustainammo 1"
bind 0 "give thundergun_upgraded_zm"
RE: Ultimate Black Ops Modding - d0h! - 01-04-2011 edited and public now RE: Ultimate Black Ops Modding - Eekhoorn - 01-04-2011 very beast tut. Good job d0h! RE: Ultimate Black Ops Modding - d0h! - 01-04-2011 you know where i got this from, i only edited a few things (xbox->pc) RE: Ultimate Black Ops Modding - Devilmaster666 - 01-04-2011 I think this here is also helpful. It was made by Treyarch. http://wiki.treyarch.com/wiki/Scripting_Syntax_And_Grammar#What_Is_GSC.3F Some people may think, why do I have to put sometimes a "wait" of 0.05 ?? This is the answer. "GSC runs once every server frame, and there are 20 server frames per second. Script can not run indefinitely each server frame and still maintain a solid 60FPS, so the wait command is offered to force execution of a given thread to cease for 1 or more frames. The wait command takes a float value as a parameter representing the number of seconds to wait: PHP Code: wait 0.05; // waits 1/20th of a second, or 1 server frame
wait 0.5; // waits half a second, or 10 server frames
wait 1; // waits 1 second, or 20 server frames
Of special note is the script error "script runtime warning: potential infinite loop in script", which occurs when the game determines that a thread has run for too long during a single thread. This occurs either when script tries to do too many operations all at once, which can be fixed by inserting wait statements to break up the tasks across multiple frames, or when an infinite for or while loop (discussed later) run without hitting a wait statement, and again the solution is to add a wait statement." RE: Ultimate Black Ops Modding - SuperNovaAO - 01-05-2011 That's their problem with their 20 Server FPS... A normal Source-Engine Server (also based on Quake, just like CoD) used to run on 100, nowadays it's 66 I think, still more than those lousy 20, also explains you the retarded hit-recognition. And most competition servers in CS:S run on 1000 server FPS. W00t. RE: Ultimate Black Ops Modding - alistair3149 - 01-05-2011 (01-04-2011, 18:33)d0h! Wrote: you know where i got this from, i only edited a few things (xbox->pc)I can see it from monitor weapon ![]() RE: Ultimate Black Ops Modding - skyfire - 01-11-2011 none of that keybinding stuff work for the pc.. the only thing i've been able to get working were the OnWhateverButtonPressed() functions |