How to add resources to non-static items.

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

How to add resources to non-static items.

Post by Damien. »

Hello :)

I got two questions:
[First question] How to put resources, in other words logs, in one of my non-static trees? This is how the objtype and properties of the item:

Code: Select all

Item 0x5004
{
	Name		peachtree1
	Desc 		peach tree
	Graphic		0xDA2
	Movable 	0
	DoubleClickRange	1
	UseRequiresLOS 		0
	Resource	wood	15
	WoodType	log
	ControlScript	:lumberjacking:treeRegen/control
	Script		:nature:peachTrees/peachtree1
}
I also added the objtype to the regions/wood.cfg file, however it still wont let me chop any wood. It gives me the error:
Unable to creaste 0 -> A parameter was invalid.

[Second question] I created items with the graphic of a tree... When you doubleclick the tree it will give you some fruits and then change graphic from a (e.g.) peachtree with fruits 'till a peachtree without fruits for an X amount of seconds until it changes back and you can pick fruits again.. but there is a problem with the big peachtree, the EMPTY big peachtree uses Contextmenu(or tooltip?) and it will change the graphic to that tree but the empty peachtree will go z+1 when it should only go z. How can I change an staticitem to not use a contextmenu, because that's perhaps why the empty peachtree decides to go z+1..
Picture:
Image

Thank you :)
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: How to add resources to non-static items.

Post by Pierce »

To reply to the first question. If you put something to the wood.cfg file you'll find wood on every coordinate you set as rectangle there. Some bugusers may use this to chop wood even if there is no static or whatever tree there (using e.g. easyuo). You'll have to avoid this in your lumber scripts. So i'm quite astonished that you don't find any wood.

The second question is perhaps a tiledata problem. Is the peach tree without fruit really put to z+1, meaning you can read this z+1 value (which should be in a script) or is that just a visible problem. In the last case it could be a different heigth inside the tiledata definition between the fruit leaves graphic and the normal graphic. Just an idea ;)
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: How to add resources to non-static items.

Post by Damien. »

Thanks. I'll suppose it's a tiledata problem, because the Peachtree with fruits is spawned in X, Y, Z-location and when you doubleclick the tree everything it does is to change graphic for certain amount of seconds. I'll see what I can do.
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: How to add resources to non-static items.

Post by Damien. »

I did use UOFiddler to change the weight of the empty peachtree to 255 (it was 0) because I found it odd that all other trees except this one had the weight 255... However it made no success.. The height of the tree is 2 like any other tree, but just to test out I lowered it to 0, however then, while converting, it gave me this error:

Code: Select all

Initializing files: Execution aborted due to: Error opening file realm/britannia/maptile.dat: ios failure
So I changed back the height to 2 and it worked to convert again...

so I am still in need of help in both question one and two :blush:
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Re: How to add resources to non-static items.

Post by Gnafu »

I think that error comes up because you are keeping UOFiddler open while converting.
Make sure nothing is using the files uoconvert is trying to convert.
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: How to add resources to non-static items.

Post by Damien. »

Thanks for your reply and you was right.. it did convert without having UOFiddler opened, but it still didnt fix the problem :(
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: How to add resources to non-static items.

Post by Pierce »

I took a look at our peach tree and it shows the same behaviour ;)
If you set the tiledata height of one of these two graphics to 1 it should
fix the problem.

I think your first problem may be caused by TargetCoordinates(who).
For statics it gives another result as it does for normal items.

var targ := TargetCoordinates(who);

You probably have to work with: targ.item.objtype for items and targ.objtype for statics.
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: How to add resources to non-static items.

Post by Damien. »

Hmm.. must admit I feel kinda stupid.. I tried to chop ANY other tree, not custom made, and it gives me the same result:
Unable to Create 0 -> A Parameter was invalid. So I suppose this must be a system not included yet, and will probably be with the 098Distro (I'm using the 098 Core).. Or maybe just the Team forgot to add this? If so this is a note ;)

I did not have time to check about the peachtree hight, but I'll do it now.. I changed the height in the tiledata tho but it gave no success.
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: How to add resources to non-static items.

Post by Pierce »

It's really hard to say without actually seeing the script ;)

The peach tree problem is caused by the 2 leaves pictures. They have a different
hight. The one with peaches has a hight of 180 pixel, the one without has 181 pixel.
I don't know why setting a smaller tiledata hight don't help, but you're right.

What is helping is cut the second picture also to 180 pixels and patch it to the art.mul.
I added the bmp below.
Attachments
peach tree leaves 0x0d9d.rar
(14.84 KiB) Downloaded 273 times
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm

Re: How to add resources to non-static items.

Post by CWO »

Damien, where in the code are you getting the objtype of what to create? Because apparently its returning 0.
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: How to add resources to non-static items.

Post by Damien. »

Pierce: That surerly fixed the height problems.. Thanks! :D
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: How to add resources to non-static items.

Post by Damien. »

CWO helped me out in #POL and this was the error:
skills/lumberjacking/include/lumberjacking.inc

Code: Select all

function LJ_PickWoodType(realm, x_pos, y_pos)
	var wood_cfg := ReadConfigFile(":lumberjacking:wood-"+realm);
	if ( !wood_cfg )
		return GetObjTypeByName("Log");
	endif

	var wood_found := array{"Log"};
	foreach region_name in ( GetConfigStringKeys(wood_cfg) )
		var region_elem := wood_cfg[region_name];
		if ( !LJ_InRect(x_pos, y_pos, region_elem.Rect) )
			continue;
		endif

		var wood_types := GetConfigStringArray(region_elem, "WoodType");
		if ( wood_types.Size() >= 1 )
			wood_found := wood_found+wood_types;
		endif
		SleepMS(2);
	endforeach

	var selected_wood := wood_found[RandomInt(wood_found.Size())+1];
	selected_wood := GetObjTypeByName(selected_wood);
	if ( !selected_wood )
		return GetObjTypeByName("Log");
	endif

endfunction
must be changed to:

Code: Select all

function LJ_PickWoodType(realm, x_pos, y_pos)
	var wood_cfg := ReadConfigFile(":lumberjacking:wood-"+realm);
	if ( !wood_cfg )
		return GetObjTypeByName("Log");
	endif

	var wood_found := array{"Log"};
	foreach region_name in ( GetConfigStringKeys(wood_cfg) )
		var region_elem := wood_cfg[region_name];
		if ( !LJ_InRect(x_pos, y_pos, region_elem.Rect) )
			continue;
		endif

		var wood_types := GetConfigStringArray(region_elem, "WoodType");
		if ( wood_types.Size() >= 1 )
			wood_found := wood_found+wood_types;
		endif
		SleepMS(2);
	endforeach

	var selected_wood := wood_found[RandomInt(wood_found.Size())+1];
	selected_wood := GetObjTypeByName(selected_wood);
	if ( !selected_wood )
		return GetObjTypeByName("Log");
	else
	return selected_wood;
	endif

endfunction
Notice the return ;) the selected_wood was never returned.
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: How to add resources to non-static items.

Post by Damien. »

hmm I still got one problem with the big peachtree. After clicking the peachtree it does change graphic and everything works fine, but the empty peachtree graphic is not really working like an static because it will allow you to select the empty peachtree and you can kindof drag it, but it's like it is locked down. I tried to set item.movable := 0; after the graphic change, but it still wont work... this will only happen to the big empty peachtree and not any other tree.
You can see here how I draged the item, but it says it is locked down:
http://i44.tinypic.com/wbsx3o.jpg

Anyone knows how to do so you will not be able to drag the empty peachtree or to make it un-selectable just like a normal static?
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: How to add resources to non-static items.

Post by Pierce »

You'll have to set the tiledata weight of 0xd9d to 255 or higher and
of course do a uoconvert tiles with the new tiledata.mul afterwards ;)
Damien.
Journeyman Poster
Posts: 63
Joined: Thu Feb 08, 2007 11:14 am

Re: How to add resources to non-static items.

Post by Damien. »

oh, that was simple! :D It also made the AOS Tooltip vanish from the tree.. Thanks!
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm

Re: How to add resources to non-static items.

Post by Yukiko »

OK. Forgive my frankness but WHY HASN'T DAMIEN'S FIX BEEN ADDED TO THE DISTRO??!!

Here we are moving on to POL Core 0.99 and we still do NOT have a working Distro. There's still debug messages being sent to the character when trees are chopped.

It's bad enough for those of us who are having to relearn the post 0.96 script reorganization and then on top of that we're still in need of a working Distro.

Now I'll admit that we are all responsible for helping the Distro get up to snuff but this lumberjackung error has been known for over TWO (2) @#%$ing years and it is still not fixed in the 0.99 SVN Distro!

I really love POL. It pains me to see the lack of priorities with its development. I've said this before and I guess I'll say it again, you cannot expect new people to come and want to use POL if they cannot download a basic WORKING shard. I realize it's more fun to add goodies to the Core but if you want POL to grow (and it's not growing) you've got to make it easy for new people to get involved and have something to play with right away.

Anyway, I'll post the patch for lumberjack.inc on the Distro patch forum now that I've said my piece.
Post Reply