Make your way easier for Custom Houses.

Post your Custom Scripts or Packages.

Moderator: POL Developer

Post Reply
Terciob
Master Poster
Posts: 90
Joined: Fri Nov 07, 2008 3:47 am

Make your way easier for Custom Houses.

Post by Terciob » Wed Aug 17, 2011 5:59 pm

Hey guys, i'm using custom houses on my live server for about 1 month and i wanna share with you the annoying part of this, making your way typeless.
This is not a complete system, because all server already have a house system, so, you only need to add the custom houses instructions.

Remember, official polcore release do not support custom houses, you need download the the source and compile last version or get the core attached in this post.

So, get the 'itemdesc_cusotm.txt' file (attached in this post) and copy/paste inside any itemdesc.cfg (prefer that already have house stuff).
I'm not sure, but i think this file is not compatible with MaxTileID=0x7FFF and if you use it you need to edit it before. Easy way is mass replacing "Graphic 0x5" for "Graphic 0x9" and "Graphic 0x4" for "Graphic 0x8", also make mass replace in deed script, from "housedeed_custom" to <your house deed script name>.

Start up pol and check if have any objtype duplicated.

Second part, after place the multi, you need create the house sign and signpost.
So, with house sucessfull placed, run this function which will write house CProps to multi (pol does not auto write as make with items).

Code: Select all

function write_cprops (house)
	var cfg := readconfigfile (":housing:itemdesc");
	var elem := findconfigelem (cfg, house.objtype);
	var dict := getconfigstringdictionary (elem, "cprop");
	
	foreach propname in (dict.keys())
		var value := dict [propname];
		case (value[1])
			"i": 	value[1] := ""; value := cint (value); 
			"s": 	value[1] := ""; value := cstr (value);
			"d": 	value[1] := ""; value := cdbl (value);
		endcase
		setobjproperty (house, propname, value);
	endforeach
 endfunction 
With this done, your house got CProps x, y, numlockdowns, numsecure and numsocio.
Sign and Signpost creation:

Code: Select all

var house_custom_components := array{};

var signpost := createitematlocation (house.x+2, house.y+(getobjproperty (house, "y")/2)+1, house.z+5, 2978, 1, house.realm);
var sign := createitematlocation (house.x+2, house.y+(getobjproperty (house, "y")/2)+1, house.z+5, 0xbd2, 1, house.realm);

house_custom_components += signpost.serial;
house_custom_components += sign.serial;

setobjproperty (sign, "house_serial", house.serial);
setobjproperty (house, "signpost", signpost.serial);
setobjproperty (house, "sign", sign.serial);
setobjproperty (house, "custom_components", house_custom_components);

setobjproperty (sign, "custom" , 1); //just a reference to other scripts check if is a sign of a custom house.
setobjproperty (house, "custom" , 1);

house.setcustom (1); //pol set this house as custom.
'0xbd2' is the Sign objtype.
Make sure your sign have "UseRequiresLOS 0" line in itemdesc because players when editing can make some type of walls blocking the vision of sign.
'house_custom_components' is used when the house is being destroyed, so you call the Prop and also destroy sign and post (and any other stuff you custom add).

Once you write the sign and post serial on house, you can make player be able to move them to a better spot. The easy is using:

Code: Select all

var dims := getmultidimensions (housegraphic);
var positions := array {};
for o := dims.xmin to dims.xmax
	positions += o;
endfor
You will have a array with -x to +x coords. Give a gump to player choose and then:

Code: Select all

var sign := systemfindobjectbyserial (getobjproperty (house, "sign"));
var signpost := systemfindobjectbyserial (getobjproperty (house, "signpost"));
set_critical (1);
	sign.movable := 1;
	signpost.movable := 1;	
	moveobjecttolocation (sign, house.x + positions [<array index chosen>], sign.y, sign.z, sign.realm);
	moveobjecttolocation (signpost, house.x + positions [<array index chosen>], signpost.y, signpost.z, signpost.realm);
	sign.movable := 0;
	signpost.movable := 0;
set_critical (0);
On the next step, you need create a way to player start his house customization, best way is a button on house sign gump.
Inside your script you use "sendhousingtool (chr, house);". But before is pretty cool you check if player is not in a combat because player can exploit this.
Another good stuff is close all doors before start edit, opened doors can cause troubles while editing:

Code: Select all

foreach door in (house.components)
	if (door.isa(POLCLASS_DOOR))
		door.close();
	endif
endforeach
Another think is warn player to always click on "Synch" button after move between floors, i dont know if this is a Pol bug or client bug but when we move from a floor to another, entire downstairs vanish.
We also had problem with "Clean" button which made the entire house disappear (everything including foundation), but this only happened twice in 1 month.

Now the last step on scripts/misc/customhousecommit.src, this is called when player click on Commit button.

Code: Select all

program CustomHouseTool ( who, house, elem )
if (!house.acceptcommit (who, 1))
	sendsysmessage (who, "Commit can not be accepted.");
	return;
endif
sendsysmessage (who, "Commit accepted.");
endprogram 
We also use a function which erase new doors ('new' from SA/ML/SE), because we had some troubles declaring on door itemdesc.

Code: Select all

	var invalid_door;
	foreach door in (house.components)
		if (door.isa(POLCLASS_DOOR))
			if (door.objtype in { 12260, 12700, 12702, 12258, 
							11629, 12714, 11627, 12712,
							12710, 11623, 12718, 11621,
							12716, 12704, 11625, 10775,
							12708, 12706, 11619, 10773,
							11590, 11592, 10777, 10779,
							0x241F, 0x2423,
							
							//slide doors
							0x2A09, 0x2A0B, 0x2A05, 0x2A07,
							0x2A0F, 0xA13, 0x2A11, 0x2A0D,
							//fim
							
							//crystal doors
							//0x3683, 0x3685, 0x3687, 0x3689, 0x3681, 0x367F, 0x367B, 
							//fim
							
							//shadow doors
							//0x3693, 0x3695, 0x368B, 0x368D, 0x368F, 0x3691, 0x3699, 0x3697, 0x368D,
							//fim
							
                                                        //another doors
							0x328, 0x32A, 0x324, 0x326, 0x32C, 0x32E, 0x330, 0x332,
							0x34E, 0x34C, 0x352, 0x350, 0x344, 0x346, 0x348, 0x34A,
							0x342, 0x340, 0x33C, 0x33E, 0x338, 0x33A, 0x334, 0x336,
							0x358, 0x35A, 0x354, 0x356, 0x35c, 0x35e, 0x360, 0x362,
							0x86e, 0x870, 0x866, 0x868, 0x872, 0x874, 0x86A, 0x86C,
							0x850, 0x852, 0x84E, 0x84C, 0x85A, 0x858, 0x854, 0x856,
							0x824, 0x826, 0x82C, 0x82E, 0x830, 0x832, 0x82A, 0x828})

				destroyitem (door);
				invalid_door := 1;
			endif
		endif
		sleepms (1);
	endforeach
	if (invalid_door)
		sendsysmessage (who, "Some invalid doors have been removed.");
	endif	
I hope this all information help you.
[]'s
Attachments
Pol099 @346.rar
Last core (with custom house support).
(2.15 MiB) Downloaded 104 times
itemdesc.txt
Door itemdesc.
(29.82 KiB) Downloaded 127 times
itemdesc_cusotm.txt
Custom Houses Itemdesc.
(26.69 KiB) Downloaded 132 times
Last edited by Terciob on Wed Aug 24, 2011 11:37 am, edited 1 time in total.

User avatar
*Edwards
Forum Regular
Posts: 301
Joined: Fri Dec 28, 2007 11:19 pm
Location: Montreal, Canada
Contact:

Re: Make your way easier for Custom Houses.

Post by *Edwards » Thu Aug 18, 2011 1:32 pm

Thank you for sharing!

Post Reply