|
Hyper.nl Unreal Services The forum of Hyper.nl Unreal Services and the semi-offical resource for Winged Unicorn's Unreal mods
|
View previous topic :: View next topic |
Author |
Message |
Winged Unicorn
Joined: 22 Jan 2004 Posts: 87
|
Posted: Mon Feb 02, 2004 1:04 pm Post subject: HOWTO add new commands |
|
|
This small tutorial will briefly show you how to add new custom commands in MCoop 2 I will use a couple of JCoop's commands as example, of course all credits for the two functions go to Joss
Before anything else, let me remind you that you can use your new extra commands from in-game this way:
Com <new command>
(for the ones who have played UT, this works exactly like the Mutate command)
Let's start with the fun...
- Create a new package class. In this example, I will call it JCoopCommands.
Then, open the folder you have just created and create a new folder named Classes.
- Go to your brand new package Classes folder and create a new UnrealScript file. Again, in this example the package Classes folder will be Unreal\JCoopCommands\Classes\ and I will create a new UScript file called JCoopCommands.uc.
- Open the new UnrealScript file you just created, and add the following lines (of course, replace MyCustomCommands with the name of your class):
Code: | //=============================================================================
// My custom commands for MCoop 2
//=============================================================================
class MyCustomCommands expands MCoopExtraCommands;
function Com(string Command, MCoopUnrealIPlayer Requester)
{
}
|
As you can see, the new file MUST extend MCoopExtraCommands. Also, there is a core function called Com. It will get two inputs:
- Command: this is the string command that will be entered by the user from in-game (for example, if during the game you type "com kni" the Command string will "kni")
- Requester: this is basically the player who has executed the new command
Modify the Com function, adding the support for your new functions. In this case, the new functions are JCoop's kni and knp, so I will just have to check the Command string looking for one of them. Remember also to pass the Command to the next element of the linked list too, so it can get valuated by other ExtraCommands actors as well.
Code: | function Com(string Command, MCoopUnrealIPlayer Requester)
{
if ( Command ~= "kni" )
kni( Requester );
else if ( Command ~= "knp" )
knp( Requester );
if ( NextCommands != None )
NextCommands.Com(Command, Requester);
}
|
NOTE: the Command string has contains any extra parameters that has been eventually entered by the user. So, if your new functions have one or more inputs, you will have to grab them manually from the string...
Add the new custom commands that you wanted to add. For this tutorial, I will just add JCoop's kni and knp, like this:
Code: | // this is JCoop's kni function. all credits go to Joss.
function kni(MCoopUnrealIPlayer Requester)
{
local Inventory Inv;
// if the Requester is not an admin, nor an admin child nor an admin baby -> don't execute this function!
if ( !Requester.bAdmin && !Requester.bAdminChild && !Requester.bAdminBaby )
return;
foreach VisibleCollidingActors(class'Inventory', Inv, 100, Requester.Location, True)
{
if ( Inv.IsInState('Pickup') || Inv.IsInState('Sleeping') )
Inv.Destroy();
}
}
// this is JCoop's knp function. all credits go to Joss.
function knp(MCoopUnrealIPlayer Requester)
{
local Pawn P;
// if the Requester is not an admin, nor an admin child nor an admin baby -> don't execute this function!
if ( !Requester.bAdmin && !Requester.bAdminChild && !Requester.bAdminBaby )
return;
foreach VisibleCollidingActors(class'Pawn', P, 100, Requester.Location, True)
{
if ( !P.IsA('PlayerPawn') )
P.Destroy();
}
}
|
Please remember that you will HAVE to eventually check for admin privilegies if you don't want your new functions to be executed by everyone!
[NEW] Add a description of the commands you have just implemented in the default properties. You may want to do that by adding this line at the bottom of the script:
Code: | defaultproperties
{
CommandsDesc(0)="kni - destroy all the Inventory actors near you"
CommandsDesc(1)="knp - destroy all the Pawn actors near you"
}
|
That's it for the coding part! Now you will have to compile your new class, by adding MCoop2 and JCoopCommands to the EditPackages list. Once you're done with that, you should have a whole new package with your brand new commands
For this example, here's the complete JCoopCommands UnrealScript file:
Code: | //=============================================================================
// JCoopCommands for MCoop 2.2
//=============================================================================
class JCoopCommands expands MCoopExtraCommands;
function Com(string Command, MCoopUnrealIPlayer Requester)
{
if ( Command ~= "kni" )
kni( Requester );
else if ( Command ~= "knp" )
knp( Requester );
if ( NextCommands != None )
NextCommands.Com(Command, Requester);
}
// this is JCoop's kni function. all credits go to Joss.
function kni(MCoopUnrealIPlayer Requester)
{
local Inventory Inv;
if ( !Requester.bAdmin && !Requester.bAdminChild && !Requester.bAdminBaby )
return;
foreach VisibleCollidingActors(class'Inventory', Inv, 100, Requester.Location, True)
{
if ( Inv.IsInState('Pickup') || Inv.IsInState('Sleeping') )
Inv.Destroy();
}
}
// this is JCoop's knp function. all credits go to Joss.
function knp(MCoopUnrealIPlayer Requester)
{
local Pawn P;
if ( !Requester.bAdmin && !Requester.bAdminChild && !Requester.bAdminBaby )
return;
foreach VisibleCollidingActors(class'Pawn', P, 100, Requester.Location, True)
{
if ( !P.IsA('PlayerPawn') )
P.Destroy();
}
}
defaultproperties
{
CommandsDesc(0)="kni - destroy all the Inventory actors near you"
CommandsDesc(1)="knp - destroy all the Pawn actors near you"
} |
The final step is telling MCoop 2 to use your extra commands in-game. This can be easily done by editing the MCoop2.ini settings file: just look for the gametype you would like to apply the new commands to and add a new ExtraCommands entry, by typing the full path of the new classes you created (<package name>.<class name>). For this small tutorial, it's JCoopCommands.JCoopCommands.
Code: | [MCoopMutator2.Coop]
bNoEndingMap=False
AdvancedNetwork=(bOptimizeMaxPlayers=False,bOptimizeConnection=False,ServerUploadSpeed=16000,DefaultMinClientRate=2600,DefaultMaxClientRate=10000)
PlayerOptions=(bDenyNameChange=False,bSetDefaultInventory=False,bSetDefaultHealth=False,bSetDefaultInvCharge=False,bSetDefaultAmmo=False)
bAlwaysPickUp=False
bAlwaysReconnect=True
RespawnOptions=(bRespawnAmmo=False,bRespawnHealth=False,bRespawnInventory=False,bRespawnWeapon=False,RespawnTimeAmmo=2.000000,RespawnTimeHealth=10.000000,RespawnTimeInventory=5.000000,RespawnTimeWeapon=1.000000)
bCustomMapList=False
>>> ExtraCommands=JCoopCommands.JCoopCommands <<<
|
Please note that ExtraCommands can be chained together, so you can have virtually infinite new commands!!
...you're finally done! It's been easy huh? >;)
Now start the game and have fun with your new custom commands!
-----------------------------------------------------------------
You can download the JCoopCommands package shown in this tutorial (already compiled and working) here ;D _________________ Ride to the starlight... there, where heroes lie
Last edited by Winged Unicorn on Sat Jun 26, 2004 10:42 am; edited 5 times in total |
|
Back to top |
|
|
Winged Unicorn
Joined: 22 Jan 2004 Posts: 87
|
Posted: Wed Mar 10, 2004 2:30 pm Post subject: |
|
|
I updated this tutorial to reflect the changes in MonsterCoop v2.1 _________________ Ride to the starlight... there, where heroes lie |
|
Back to top |
|
|
Winged Unicorn
Joined: 22 Jan 2004 Posts: 87
|
Posted: Sat Jun 26, 2004 10:42 am Post subject: |
|
|
Tutorial updated once again, I also added a link to the compiled package for the lazy of you _________________ Ride to the starlight... there, where heroes lie |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|