RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

[RunUO 2.0 SVN] Movable Addons and Flying Carpets

Fenn

Wanderer
[RunUO 2.0 SVN] Movable Addons and Flying Carpets

Overview

Movable addons are a collection of items that look and behave similar to the well-known Addon class. A collection of component items define the movable addon, and when the addon moves, the components move with it like a unified body. What distinguishes movable addons from the traditional addons is that a "direction" is defined both in the movable addon and its components. This direction is used to negotiate rotation considerations, as well as player control. In a sense, a movable addon is almost like a hybrid between an addon and a boat.

The movable addon class itself is abstract, and can be extended to suit your needs. This project includes an extension of the movable addon to a magic flying carpet. Because of the versatility of the movable addons, a considerable amount of customization is available.

For players

Flying carpets! Need I say more?
  • You get these magic lamps, and use them to produce your carpet. You can drive your carpet with commands similar to boats (additional commands include "up", "down", "take off", "land", and "fast" prefix command to tear up the skies!).
  • Double-click your "genie" (carpet version of a tillerman) to bring up a navigation control panel, as well as keep him well powered (magic carpets need fuel too!)
  • Store your carpet by doubleclicking your genie while you're not on the carpet.
  • Single-click your magic lamp to bring up the carpet customization window. Collect magic thread to effect modifications to your carpet design and size. Acquire a carpet dye tub to rehue your carpet to your liking!
  • Double-click your lamp when you are off the carpet to recall back onto it.
  • Amaze your friends! Land on your enemies!

For developers

The following constructable items are provided in this package:
  • FlyingCarpetMagicLamp
  • FlyingCarpetDyeTub
  • MagicThread
As with my other projects, I provide no mechanism for these to be implemented in your shard. I leave it up to you to decide if it is a craftable, purchasable, vet reward, quest reward, or whatever.

There are numerous modifiable settings for the flying carpet, and movable addons in general. This includes fuel source, carpet size, renovation resource, renovation costs, max/min carpet sizes, etc.

Compatibility

NOTE: this system requires the CliLoc Handler project to function. After that, this has been tested and proven to work on a fresh download of the following:
  • RunUO 2.0 SVN 300
  • RunUO 2.0 RC1 ( see this link for details on setting it up)

Note that there are no client patches required to use this. I had made a previous attempt at flying carpets some time ago, which required a modified Multi's file. This project does not need this at all!

Details

Changelog is listed following this post.
Details are located in the file notes.txt in the main directory of the provided file.

Dedication

I would like to dedicate this script release to Ednyved, former head developer of the BES Oasis shard. In the battle between real life and UO commitments, real life has won, and he will be missed. He as been a great leader and provider, as well as a great friend to chat with and exchange ideas. I wish him the best with his endeavors outside the world of UO!
 

Attachments

  • Movable Addons - 2008-10-08.rar
    27.2 KB · Views: 482

Fenn

Wanderer
Upgrade Notes

If you haven't done anything to change this script, then simply paste the latest version overtop the old one.

Changelog

Version: Last modified Wednesday, October 8, 2008

Version 2008-10-08
  • fixed a crash bug when trying to place the carpet in a Multi (thanks Lord_Greywolf!)


Version 2008-10-07
  • modified code a bit so this will work on RunUO 2.0 RC1 (thanks Gargouille!)

Version 2008-10-06
  • Initial release.
 

Liacs

Sorceror
There is another flying carpet somewhere in the script archives... but I think it needs a mod to PlayerMobile.cs...

Nice job! I will have a look tonight.
 

Fenn

Wanderer
Lord_Greywolf;778261 said:
lost modified 3 days from now - wow - modifying into the future - you are good :eek:

Woops! I was setting my clock ahead to test the energy consumption and the out of energy condition. Just glanced at the day of the week and didn't think!

Liacs said:
There is another flying carpet somewhere in the script archives... but I think it needs a mod to PlayerMobile.cs...

Right, I remember spotting it before I started this project, but I have yet to download it and try it out. I didn't know that it needed any distribution file mod's, but if that's the case, I can sell mine on the fact that it's drop-in compatible!
 

Gargouille

Sorceror
Thank you. That's magic ;o)

[EDIT and remove]In order to make it fly on my RunUO 2.0 RC1-sahrd-test-without-ClilocHandler, I make some easy changes .
Here's a distro for RC1 (all changes are comment //ClilocHandler)
 

Fenn

Wanderer
Gargouille;778285 said:
In order to make it fly on my RunUO 2.0 RC1-sahrd-test-without-ClilocHandler, I make some easy changes .
Here's a distro for RC1 (all changes are comment //ClilocHandler)

I'm looking through your modifications, and I'm sorry to say I can't recommend these. Some of the changes are fine, as they replace the CliLoc's GetName method with a simpler (albeit less accurate) naming method. But others could cause a server crash.

Example: in your copy of MovableAddonConfigGump, line 47, you reference resource.Name, but this code can be executed if resource is null.

Example: in MovableAddon.cs, you cut out the serialization/deserialization of the _Extrema Rectangle3D. Doing this will mean the carpet won't properly negotiate collisions when you do a server reset.

I would recommend you use the CliLoc handler system to provide the user with the best possible name for the item, and provide the developer with the best possible flexibility to customize the item type. As for compatibility with RunUO 2.0 RC1, I'll spend some time with a fresh RC1 server and see what I can do.
 

Fenn

Wanderer
Ok, I set up a RC1 test shard, and addressed the problem regarding (de)serializing Rectangle3D data. If you are using RC1, then do the following:

  • Open the file MovableAddon.cs
  • Find line # 2 where it reads
    Code:
    //#define RunUORC1
  • Uncomment this, so it reads
    Code:
    #define RunUORC1
  • Try booting again

Also, regarding the CliLoc Handler project, I noticed that there was a typo that caused it to fail compile if you don't have the Universal Storage Keys project installed. I've since fixed that so the CliLoc thing can work standalone. I would highly recommend using it, unless someone can suggest a more succinct way of grabbing an item's proper name (if the item's Name property is null, Gargouille's suggestion will not give a proper result).

darkjesse13;778322 said:
does it work with runuo 2.0 rc2?

I developed this on SVN 286, and from what I remember, #286 came before RC2. If this is true, then it should work fine on RC2. If you're using RC2, then how about you give it a whirl and tell me if it works?
 
just tried this out,
and went to post compile error and notics fix lol
so compiled fine

BUT

went to use genie - clicked on spot in green acres, says it was an invalid location
then went into a house and tried to set up in there and crash
looks like a few more checks are needed :)

Code:
Server Crash Report
===================

RunUO Version 2.0, Build 3182.21161
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 2
.NET Framework: 2.0.50727.832
Time: 10/7/2008 6:21:51 PM
Mobiles: 1217
Items: 4147
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Spells.SpellHelper.CheckTravel(Mobile caster, Map map, Point3D loc, TravelCheckType type)
   at Server.Spells.SpellHelper.CheckTravel(Map map, Point3D loc, TravelCheckType type)
   at Solaris.Addons.MovableAddon.CanMoveTo(Point3D p, Map map)
   at Server.Items.MovableAddonKey.FinishCreation(Mobile from, Point3D point)
   at Server.Items.FlyingCarpetMagicLamp.FinishCreation(Mobile from, Point3D point)
   at Server.Items.MovableAddonKey.PlaceMovableAddonTarget.OnTarget(Mobile from, Object targeted)
   at Server.Targeting.Target.Invoke(Mobile from, Object targeted)
   at Server.Network.PacketHandlers.TargetResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)

*edited - tried again outside a dungeon on a road and it crashed again there also
had the same crash report
 

Fenn

Wanderer
Thanks for the crash report Lord_Greywolf. Based on your trace, the problem is coming from the distribution script SpellHelper.cs. I'm looking at mine (stock script from SVN version 300) and from what I can tell, the Mobile caster is null (which was expected) and is causing the problem. I don't think Map, Point3D, or an enumerator can be declared null.

When I look at my code for CheckTravel( Mobile caster, Map map, Point3D loc, TravelCheckType type ), I can't see any reason a null reference exception can be caused. Do you have a modified version of this script?

To compare, I'm posting a copy of this method:
Code:
		public static bool CheckTravel( Mobile caster, Map map, Point3D loc, TravelCheckType type )
		{
			if( IsInvalid( map, loc ) ) // null, internal, out of bounds
			{
				if( caster != null )
					SendInvalidMessage( caster, type );

				return false;
			}

			m_TravelCaster = caster;
			m_TravelType = type;

			int v = (int)type;
			bool isValid = true;

			for( int i = 0; isValid && i < m_Validators.Length; ++i )
				isValid = (m_Rules[v, i] || !m_Validators[i]( map, loc ));

			if( !isValid && caster != null )
				SendInvalidMessage( caster, type );

			return isValid;
		}

This is called by the method:
Code:
		public static bool CheckTravel( Map map, Point3D loc, TravelCheckType type )
		{
			return CheckTravel( null, map, loc, type );
		}

Note that I have never had this problem. In your case, have you ever been able to place a carpet, or does it consistently crash? Has anyone else had a problem like this? Could you post your version of CheckTravel from SpellHelper.cs if yours looks considerably different than mine?
 

Gargouille

Sorceror
Fenn, I edit my post,changes I've done were just a way to make it run on RC1 and have a look, but I don't distribute it no more ;)
 
ok - i did have a thing in there to stop people from marking, etc in green acres, fixed that

but still got crash when trying to add it in a house - here is the report on it (it is slightly different i do believe) :rolleyes:
and it looks like maybe something in the targeting

Code:
Server Crash Report
===================

RunUO Version 2.0, Build 3182.21161
Operating System: Microsoft Windows NT 5.1.2600 Service Pack 2
.NET Framework: 2.0.50727.832
Time: 10/7/2008 11:54:47 PM
Mobiles: 1217
Items: 4147
Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Solaris.Addons.MovableAddon.CanMoveTo(Point3D p, Map map)
   at Server.Items.MovableAddonKey.FinishCreation(Mobile from, Point3D point)
   at Server.Items.FlyingCarpetMagicLamp.FinishCreation(Mobile from, Point3D point)
   at Server.Items.MovableAddonKey.PlaceMovableAddonTarget.OnTarget(Mobile from, Object targeted)
   at Server.Targeting.Target.Invoke(Mobile from, Object targeted)
   at Server.Network.PacketHandlers.TargetResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)
 

Fenn

Wanderer
Lord_Greywolf;778349 said:
but still got crash when trying to add it in a house

Ok, thanks for that report. I had overlooked something that I had come across in my last attempt at this. Very simple fix. The new version is up, but if you would rather modify your existing file than download the new package (RC1 people may prefer this!), here is the change instructions:

  • Open up MovableAddon.cs
  • Go to line 409, where it should read:
    Code:
    				ItemData itemData = TileData.ItemTable[ item.ItemID ];
  • Change it to read the following:
    Code:
    				ItemData itemData = TileData.ItemTable[ item.ItemID & 0x3FFF ];

It has something to do with multi's having tiledata itemid's higher than the span of actual items. I forget now what the purpose of it was, but the 0x3FFF mask cleans that up for ya.

Gargouille;778348 said:
Fenn, I edit my post,changes I've done were just a way to make it run on RC1 and have a look, but I don't distribute it no more ;)

Yep, and I appreciate your effort! I didn't know if the code was compatible with RC1, and you helped me sort that out.

If people have any more crash errors, questions, or comments, feel free to post em here.
 
well that fixed the problem :) no crashes (so far lol)
Glad i was able to help you test it ;)

was wondering, is there a way to turn off the "shadow" - maybe make it a choice on the carpet for it, or just a straight on/off switch in the scripts?
reason being, is that can cause lag after a while, not just for the players there, but shard wide if many are using them

and a simple question - at a height of 60 - can monsters with rang attack still attack them and can they attack the critters?

and an other question - i "took" off (i think was right button - top left one) and instantly went to z+50 or 60 - shouldn't it be more like z +10 and then up/downs go in inc of 10 (or 5 or what ever) to the max z height?
(i did not see any difference in z heights using the up/down keys)

But this is a great script, and i look forward to seeing more from you :)
 

Fenn

Wanderer
Lord_Greywolf;778372 said:
was wondering, is there a way to turn off the "shadow" - maybe make it a choice on the carpet for it, or just a straight on/off switch in the scripts?
reason being, is that can cause lag after a while, not just for the players there, but shard wide if many are using them

Other than going in and commenting out the shadow-generating line, there's no current way to turn them off. But I could put a property in the scripts that are easy to access if you'd like. Regarding your argument about lag though, I don't think it's much of a concern. The shadow is rendered client-side as an effect, sorta like the sparkly effects when you use a spell or hit monsters with magical area damage. Considering the number of shadow tiles thrown out by a carpet per second are on par or less than the number of area damage effects during a champion spawn with area weapons/spells, I do not think it would be very noticeable. If anything, the collision detection and content moving code is probably the most resource-intensive part of this - and this collision detection code is considerably simpler than that of boats.

Regardless, I would recommend keeping the shadow on, as it gives the carpet user depth perception and a better understanding of what they are flying over.

and a simple question - at a height of 60 - can monsters with rang attack still attack them and can they attack the critters?

Last I checked, the server makes no accounting for z-height, as long as there's a line of sight. Carpets do not block line of sight, and so monsters can hit players flying way up in the air, and vice versa. Probably better this way, as it would open up the possibility of "death from above" exploitation in places where developers did not expect this.

and an other question - i "took" off (i think was right button - top left one) and instantly went to z+50 or 60 - shouldn't it be more like z +10 and then up/downs go in inc of 10 (or 5 or what ever) to the max z height?
(i did not see any difference in z heights using the up/down keys)

I might need to doublecheck the gump buttons to make sure they're wired correctly (I just realised I put in the altitude adjustment buttons and never tested them!). However, this is a summary of the vertical commands, which should have a corresponding button in the control panel:
  • "Up (slow/fast)": causes your carpet to increase z-height up to the maximum altitude, with a speed based on your speed command
  • "Down (slow/fast)": causes your carpet to decrease z-height until it collides with ground, statics, multi's, items, or mobiles (assumes all mobiles have a height of 14 I think).
  • "Take off": launches your carpet to the maximum possible z-height. This command is intended as a way to get to the maximum height, regardless of if the carpet is on the ground or not
  • "Land": brings the carpet to the minimum possible z-height. Note that even though you have "landed", your carpet may still be able to skim along the ground (depends on the terrain and any possible obstacles).
 
i did do some double checking while not up here on line :)

yes maonsters and you attack both with melee & range attacks
many spells that check for z level though could be exploited (from 3rd party - like ring of fire checks z, etc)
and you can fish from it lol

did notice you could "fall" off the carpet and then have to shrink it down etc to get back to it :) that is great - ooops i fell (might have to increase fall damage muhahahahahaha)(can not fall off over water - which is semi good lol)

and the z up/down does work - was 1 at time though, and thought i was set to "standard" - but was continious movement, so is probably working
might want to seperate the launce and land buttons a little more on the gump - might make it look better - just a suggestion

but being able to turn shadow on/off (specialy if the player could) would be good idea
might be generated on client side, but packets still have to be sent for it - and that combined, if they are using at a champ spawn (if body stays on it - could really help there lol) - would help those with lag at them from systems that are not quite so fast :)
 
ps looking forward to chariots, wagons, attack towers and many other things your mind (or others) can dream up !!!!!

great job again
 
Top