Game Development Community

Use a different skin of my player to a different mission

by CIMO · in General Discussion · 09/03/2006 (9:22 am) · 16 replies

Example...
I have a "urban mission" and i would my character use a "urban skin"
and when a player select a different mission..for example a "desertic mission" my character use a "desertic skin"
It's possible? thanks =D

#1
09/03/2006 (9:37 am)
It's possible and pretty easy to implement.
%client.setSkinName( "urban " );
Do a search for "changing skin" for more information on how to use the function.

There are a number of ways you could retrieve the mission type in order to apply the appropriate skin. Look inside startMission.gui to get you started.
#2
09/03/2006 (1:00 pm)
Going along with what Tim said, you can also place script/instructions at the end of specific .MIS files which will run as if they were in a .CS file. Pretty cool stuff.
#3
09/03/2006 (2:48 pm)
Ehm....I try a change skin with this resource:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8639

I use a this in file mission:
new ScriptObject(MissionInfo) {
         name = "Mage's Keep";
         desc0 = "The Mage is studying the effects of fire and you";
         descLines = "2";
     -----> MapType = "DM"; 
   };

and i put this in game.cs
if(MapType == "DM")
   {
		%player.setSkinName("desert");
   }
if(MapType == "RB")
   {
		%player.setSkinName("forest");
   }

But not function...Why?
#4
09/04/2006 (12:42 am)
You're almost there. You'll need to obtain the MapType now. As I said, look inside of startMission.gui for some examples of how to retrieve info from .map files.
#5
09/04/2006 (3:16 am)
I try but never succes....Obviously i modify the resource for the thiferent mission but my player not change a skin....Someone knowledge like making?
#6
09/04/2006 (5:55 am)
Common\client\missionDownload.cs
function clientCmdMissionStartPhase1(%seq, %missionName, %musicTrack)
{
   // These need to come after the cls.
   echo ("*** New Mission: " @ %missionName);
   echo ("*** Phase 1: Download Datablocks & Targets");
   onMissionDownloadPhase1(%missionName, %musicTrack);
   commandToServer('MissionStartPhase1Ack', %seq);

   switch$(%missionName)
   {
      case "starter.fps/data/missions/desert.mis":
         $MapType = "DM";
      case "starter.fps/data/missions/forest.mis":
         $MapType = "RB";
   }
}
server\scripts\game.cs
function GameConnection::createPlayer(%this, %spawnPoint)
{
   if (%this.player > 0)  {
      // The client should not have a player currently
      // assigned.  Assigning a new one could result in 
      // a player ghost.
      error( "Attempting to create an angus ghost!" );
   }

   // Create the player object
   %player = new Player() {
      dataBlock = PlayerBody;
      client = %this;
   };
   MissionCleanup.add(%player);

   switch$($MapType)
   {
      case "DM":
         %player.setSkinName("desert");
      case "RB":
         %player.setSkinName("forest");
   }

   // Player setup...
   %player.setTransform(%spawnPoint);
   %player.setShapeName(%this.name);
   
   // Starting equipment
   %player.setInventory(crossbow,1);
   %player.setInventory(crossbowAmmo,200);
   %player.mountImage(crossbowImage,0);

   // Update the camera to start with the player
   %this.camera.setTransform(%player.getEyeTransform());

   // Give the client control of the player
   %this.player = %player;
   %this.setControlObject(%player);
}

You'll have to rename things to suit your mission names.
#7
09/04/2006 (7:48 am)
Thanks i modify the script for my use and now function!! =) =) very thanks!!
#8
09/04/2006 (9:42 am)
I am tring this out but mission files will not load. I check it seem everything is place.
#9
09/04/2006 (9:50 am)
Check your clientCmdMissionStartPhase1 function. I bet you made a typo somewhere which is causing a syntax error. What does the console report?

If you want post me your clientCmdMissionStartPhase1 function and I'll take a look.
#10
09/04/2006 (10:21 am)
I check but do see anything. The mission freeze on the Lighting Mission.
function clientCmdMissionStartPhase1(%seq, %missionName, %musicTrack)
{
// These need to come after the cls.
echo ("*** New Mission: " @ %missionName);
echo ("*** Phase 1: Download Datablocks & Targets");
onMissionDownloadPhase1(%missionName, %musicTrack);
commandToServer('MissionStartPhase1Ack', %seq);
switch$(%missionName)
{
case "starter.fps/data/missions/desert.mis":
$MapType = "DM";
case "starter.fps/data/missions/forest.mis":
$MapType = "RB";
}
}

From the console it look like it has aproblem with the AIGuard resource.
Object 'AIGuardMarker' is not a member of the 'GameBaseData' data block class
Starter.fps/data/mission/desert.mis (0): Register object failed for Object (Null) of class staticshape
#11
09/04/2006 (10:33 am)
Everything is get the same as AIGaurd, particleemitter, etc.
#12
09/04/2006 (10:34 am)
Ok. If it's getting to lighting it must be something in your GameConnection::createPlayer function.

I hope you didn't change your .mis file names to suit this code, you were supposed to adjust the code to suit your .mis file names.
#13
09/04/2006 (11:40 am)
I found that my game.cs was not compile to dso. So I change this and it does now.
switch$($MapType)
{
case "DM": // Change here
%player.setSkinName("Map1");
case "RB": // Change here
%player.setSkinName("prewer");
}

But now I have new problem the mis file is not show up in the gui. With this change above it is working now. I had to delete Map1_4f4eb97c.ml files to get mis file show up, not sure why but it work. Now to next problem which is the skin is not changing.
#14
09/04/2006 (12:59 pm)
Change this to get the skins to change with the mission.
switch$($MapType)
{
// Change MAP1 to same as your mis file
case "DM":
%player.setSkinName(Map1); // I took out the quotes
case "RB":
%player.setSkinName(prewer);
}

Now it works very well. Thanks!
#15
09/04/2006 (1:53 pm)
Wow conversation in progres =P
I think use a select team ONLY in my TEAM CASE
I try with this:

In "default.bind.cs" i put this:
function selectTeam()
{
    if ($SinglePlayerMap == false)
        return;

    Canvas.pushDialog(TeamSelectDlg);
}

moveMap.bindCmd(keyboard, "ctrl t", "selectTeam();", "");

and in "command.cs" put this
function serverCmdJoinTeam(%client, %teamid)
{
  	if ($SkinType == "Team")
	%client.joinTeam(%teamid);
}

But not function ...... Why?
#16
09/05/2006 (7:35 am)
Never person say how make function this code?
Never person have a idea?