Welcome to
Mod The Sims
Online: 1912
News:
Have an account? Sign in:
pass:
If you don't have an account, why not sign up now? It's free!
Other sites: SimsWiki
Reply  Replies: 1 (Who?), Viewed: 971 times.
Search this Thread
Old 18th Oct 2011, 12:57 PM DefaultCancelling a hand tool drag attempt #1
JT`
Original Poster

Lab Assistant

Join Date: Oct 2011
Posts: 180
Thanks: 352 in 11 Posts
4 Achievements


I'd like to make a mod which reads World.HandToolPickupEventArgs to see if the player is attempting to drag and drop a newspaper, garbage item, or other item over a trash can in order to cancel the drag-and-drop and push a Recycle/Dispose event to the currently selected sim, but I'm aside from a fair understanding of high-level programming (i.e., high-level above the CPU via a compiler, rather than low-level assembly) I'm still completely new and oblivious to TS3 scripting. (Eventually I intend to expand this for putting items away on bookshelves and putting laundry into hampers as well.)

So, I had a couple questions before diving in headlong:

Object IDs are evidently ulongs -- how do I reference objects in the game tables to determine what type they are?
[edit] Apparently what I'm looking for are things derived from IThrowAwayable, but don't yet know how to check to see how objects are derived from a given class/interface.

By the time the user has already picked up the item, the damage seems to be done. There appears to be an enumeration called (gah, Hungarian notation) "eEditTypeHandTool" with a value kEditTypeCancelled, but I can't figure out if I can force that or if that reacts solely to user input. Is there a way to push an event into the game that simulates a user cancelling a hand-tool action?

If not, is there a cheap and easy way to force the user to Undo?
[edit] Actually, scratch that... seems like that'd only work in Edit Mode, not Live Mode...

The sticky post warning mentions the answer to "is X possible?" is "find out yourself", but I was hoping that people had some experience with this so I don't wind up disheartening myself by biting off more than I can chew with my first project, like I did with GTAIV scripting. ;-)


[edit]
Further disjointed ramblings follow:

Add a delegate to World.IsInLiveDragModeEventHandler which evidently triggers when beginning to drag an object?
World.OnHandToolPickup?
World.HandToolGetObjectHeld()?

The simplest solution would be to disable live mode and edit mode dragging for those objects. But that doesn't push an event; it requires clicking an interaction menu and essentially cripples the existing drag-and-drop feature that's way more physically intuitive and fun. It also doesn't allow you to move stuff temporarily, like putting old newspapers on new table slots to make sure they're not obstructing the serving of food you're trying to give out.
Last edited by JT` : 18th Oct 2011 at 01:56 PM.
Old 18th Oct 2011, 02:02 PM #2
JT`
Original Poster

Lab Assistant

Join Date: Oct 2011
Posts: 180
Thanks: 352 in 11 Posts
4 Achievements


Huh!

(Directly ripped from game code and not modified yet, of course.)
Code:
		public override bool HandToolAllowDragDrop(IGameObject objectToDrop)
		{
			return !this.IsCanFull() && objectToDrop is IThrowAwayable;
		}

		// Sims3.Gameplay.Objects.Miscellaneous.Trashcan
		public override void OnHandToolDragDrop()
		{
			this.TrashUnitsUsed += this.TrashUnitsUsedByLiveDragging;
			IGameObject gameObject = LiveDragHelperModel.Singleton.ConsumeDraggedObjectsTopObject(true);
			gameObject.Destroy();
		}



Now all I need is to find out how to override an existing function from the existing libraries. I guess that requires Core modding? Or I suppose the whole tricksy change-trashcans-into-other-object-types-and-hide-originals thing.
Reply


Section jump:


Powered by MariaDB Some icons by http://dryicons.com.