Game Development Community

Hat items wont work

by Dennis Lamers · in Torque Game Engine · 03/19/2016 (4:22 am) · 8 replies

Hey all,

A time ago I ported the Blockland Vanilla (0002) game to a newer Torque Game Engine. I did this because the old engine was very limited with stuff for my modification. The most annoying thing that has occurred is that the hat items wont work. I tried to change a bit of code but it still wont work. The console doesn't give me errors either. I've searched a lot on Google but haven't found anything to solve the problem.

What is the difference between this code from TGE version 1.1 and 1.5.2?

//capHat.cs

//cap Hat- lets you have fun?

//////////
// item //
//////////


datablock ItemData(capHat)
{
	category = "Item";  // Mission editor category

	equipment = true;	//for gui messages

	//its already a member of item namespace so dont break it
	//className = "Item"; // For inventory system

	 // Basic Item Properties
	shapeFile = "fps/data/shapes/cap.dts";
	mass = 1;
	density = 0.2;
	elasticity = 0.2;
	friction = 0.6;
	emap = true;

	 // Dynamic properties defined by the scripts
	pickUpName = 'a cap hat';
	invName = 'Cap';
	image = capHatImage;
};

//function capHat::onUse(%this,%user)
//{
//	//mount the image in the right hand slot
//	%user.mountimage(%this.image, $HeadSlot);
//}
///////////
// image //
///////////
datablock ShapeBaseImageData(capHatImage)
{
	// Basic Item properties
	shapeFile = "fps/data/shapes/cap.dts";
	emap = true;

	// Specify mount point & offset for 3rd person, and eye offset
	// for first person rendering.
	mountPoint = 5;
	offset = "0 0 0";
	
	renderFirstPerson = false;

	// Add the WeaponImage namespace as a parent, WeaponImage namespace
	// provides some hooks into the inventory system.
	className = "ItemImage";

	item = capHat;
};

function capHatImage::onUnmount(%this, %obj)
{
	//cant have a feather without a cap hat
	%obj.unmountImage($VisorSlot);
}

#1
03/19/2016 (10:51 pm)
Can you explain some more details? What is it not doing specifically? Also, you may want to consider porting over to the newest version of Torque and then solving problems that will occur otherwise you may be wasting your time, especially if technology gets to a point where it will no longer support this engine version for development. This is the site where the current developers are at now http://torque3d.org/start/
#2
03/20/2016 (2:39 am)
Thanks for your reply Dream. The rest of the stuff in the game works (building bricks, changing player color, adding a cape or backpack behind the player, joining or starting servers, etc). This port, Blockland Classic Mod is like Return To Blockland a large modification that adds a lot of new features. This are the only problems that I got:

- An item that you can put on your head doesn't work. I think the mountPoint (5) doesn't work anymore. Items like the cape and backpack can still be mounted to the player in v1.5.2. If I look at the cape and hats script file I see no difference, the code is the same.
- Saving builds of players doesn't work. It wont output the save file in the missions folder. In the original engine v1.1 it worked, even in an empty tutorial.base v1.3 exe file the saving builds work.

Thanks.
#3
03/20/2016 (8:58 am)
I believe the difference is in the limitation of ShapeBaseImageData that you can mount to a player. I switched to mounting StaticShapeData (mainly for armor) instead, and reserved the 3 ShapeBaseImageData instances for two weapons and wings. There was a resource to extend the ShapeBaseImageData but I cannot find it all of a sudden. You can have mount points 0, 1, 2, 3, and 4. Your hat is mount point 5 which is probably why it no longer shows up. I think that A F explains it very well in this post:
http://www.garagegames.com/community/forums/viewthread/132321

The saving "builds of your players" is another issue. Can you give some more details like how it worked in the past game, and any errors the console may be generating in order to get some clues to what is causing these differences? I will see if I can help with that one next.
#4
03/20/2016 (4:03 pm)
In Torque version 1.1 and 1.3 it doesn't give any errors and it works. However when I do the same in Torque version 1.5.2, still no errors. But when I try to load the 'saved' persistence file, it is missing.

The problem is; it wont output the save file. The saving problem has been posted in a different thread right here; http://www.garagegames.com/community/forums/viewthread/143112

Here are some screenshots of the console. Not much I can see, only 'save is finished'.
s28.postimg.org/3ksz0ubdp/Blockland_00017.pngs28.postimg.org/qas3ttul9/Blockland_00018.png
#5
03/20/2016 (9:28 pm)
See if this works. I use this process to write a file in Torque.
Your code above has this for saving:

===================================
function saveBlocks(%filename)
{
// Let's add some brick "persistence".
%file = new FileObject();
%file.openForWrite(%filename);
=======================================

This is what I typically use in Torque, It will also provide a few more checks along the way.
===================================================
%file = new FileStreamObject(); // This is a different method
%fileName = expandFileName( %filename );
echo( "Attempt to open " , %fileName);
%file.open(%fileSelector,"write");
echo( "Open for Read for naming and creating character" , (%fileIsOpen ? "succeeded" : "failed" ) );
===============================================
#6
03/21/2016 (1:30 am)
Seems like that %file.writeLine is not correct. I've changed the process, it gave me soms errors about the %file.writeLine.

^(tens of errors about the writeLine thing)^
fps/server/scripts/persistence.cs (209): Unable to find object: '0' attempting to call function 'writeLine'
fps/server/scripts/persistence.cs (211): Unable to find object: '0' attempting to call function 'close'
Save finished.

Edit: I figured it out, tried your code but it didn't worked, then I looked to the path where it stores the file. I then tried to remove the "./" line in saveBlocks function and it worked. Thanks for your help and reply! :-)
function savePersistence($UniquePersistName)
{
	messageAll("MsgPersistence", "c4Blocks are being saved to c3" @ $UniquePersistName @ ".persistencec4. please be patient...");
	saveBlocks($Server::MissionFile @ "_" @ $UniquePersistName @ ".persistence");
	saveLists();
}
#7
03/21/2016 (9:08 pm)
Awesome I am glad you figured it out. Please update on your progress as it looks like a really cool project.
#8
04/16/2016 (4:34 am)
I got hats working now. The game is now playable without bugs. The next thing is to fix lagging bricks. In the original Blockland Retail the brick render system was coded as a series of angles with textures on it.

For now there is an Editor Wand to change the scale of the bricks. Whenever the brick count hits 900, the lag begins slowly.