In Game GM Tool Decoration

Post your Custom Scripts or Packages.

Moderator: POL Developer

Post Reply
runtest
Grandmaster Poster
Posts: 194
Joined: Sat Aug 05, 2006 11:43 am

In Game GM Tool Decoration

Post by runtest »

I made this for Pol 97 core. It will work with others but may require some work.

Bug Fixes:
The Z Modifier Is Fixed
Command Now Forces All Locations
Command Now Colors Items You Are Working With
Now Moves Items Then Locks Them Down


Just make a file called "d.src" in your pkg/commands/gm directory, copy and paste the code below in it. Remember to compile. >_<


How To Use:
1. Type .d in game with a command level of GM or greater.
2. Position the gump in a convenient place and create the items you want to manipulate.
3. Click the green arrow to take control of an item. You can take control of multiple items at once. If you are controlling an item it will be marked and the items color will temporarily change.
4. Now use the manipulation buttons. It will manipulate all items that are marked. At anytime to un-mark an item, just click the red arrow. This will un-select all items. Do this when you are finished. The command will automatically restore the hue to 0 and lock the item down.
5. Note: Click the "Delete" button will delete all selected items. Item manipulation is within a 25 block range of the player.

Code: Select all

use uo;
use os;

program textcmd_d( who )

   SendSysMessage( who, "Gump Active.", color := 65 );

   var GFLayout := {
      "page 0",
      "resizepic 100 100 2620 150 150",
      "checkertrans 100 100 150 150",
      "button 200 105 4501 4501 1 0 100", //top right button
      "button 195 195 4503 4503 1 0 200", //bottom right button
      "button 105 195 4505 4505 1 0 300", //bottom left button
      "button 105 105 4507 4507 1 0 400",  //top left corner
      "button 155 125 4500 4500 1 0 500",   //alt up
      "button 155 175 4504 4504 1 0 600",    //alt down
      "button 110 165 5531 5532 1 0 700",   //delete
      "button 255 105 5538 5539 1 0 800",   //uncontrol
      "button 255 135 5541 5542 1 0 900"   //control
   };

   var GFData := {
   };

   var gump := SendDialogGump( who, GFLayout, GFData );

while( gump )
   var buttoncheck;

   foreach button in ( gump.keys )
      buttoncheck := button;
   endforeach

   case( buttoncheck )
      900:
         control_things(who);
         break;
      800:
         uncontrol_things(who);
         break;
      700:
         delete_item( who );
         break;
      600:
         alt_down( who );
         break;
      500:
         alt_up(who);
         break;
      400:
         top_left(who);
         break;
      300:
         bottom_left( who );
         break;
      200:
         bottom_right(who);
         break;
      100:
         top_right( who );
         break;
      default:
         gump := SendDialogGump( who, GFLayout, GFData );
         break;
   endcase
   
   gump := SendDialogGump( who, GFLayout, GFData );
endwhile

SendSysMessage( who, "Gump Deactivated", color := 65 );

endprogram

function control_things( who )
  	var target_item := Target( who );
   	SetObjProperty( target_item, "#Marked", 1 );
   	target_item.color := 1152;
  	SendSysMessage( who, "Item Control On", color := 65 );
	SleepMS( 100 );
endfunction

function uncontrol_things( who )
   foreach thing in ( ListItemsNearLocation(who.x, who.y, who.z, 25, who.realm) )
      if( GetObjProperty( thing, "#Marked" ) == 1 )   
         EraseObjProperty( thing, "#Marked" );
         SendSysMessage( who, "No Control 25 Block Radius", color := 65 );
	   thing.color := 0;
      endif
   endforeach
endfunction   

function delete_item( who )
   foreach thing in ( ListItemsNearLocation(who.x, who.y, who.z, 25, who.realm) )
      if( GetObjProperty( thing, "#Marked" ) == 1 )
         DestroyItem(thing);
         SendSysMessage( who, "Deleted: " + thing.name, color := 65 );
      endif
   endforeach
endfunction      

function top_right( who )
   foreach thing in ( ListItemsNearLocation(who.x, who.y, who.z, 25, who.realm) )
      if( GetObjProperty( thing, "#Marked" ) == 1 )
         moveitem(thing);
         MoveObjectToLocation( thing, thing.x, thing.y-1, thing.z , who.realm, MOVEOBJECT_FORCELOCATION );
         stopitem(thing);
         SendSysMessage( who, "Coords Y: " + thing.y, color := 65 );
      endif
   endforeach
endfunction

function alt_down( who )
   foreach thing in ( ListItemsNearLocation(who.x, who.y, who.z, 25, who.realm) )
      if( GetObjProperty( thing, "#Marked" ) == 1 )
         moveitem(thing);
         MoveObjectToLocation( thing, thing.x, thing.y, thing.z-1, who.realm, MOVEOBJECT_FORCELOCATION );
         stopitem(thing);
         SendSysMessage( who, "Coords Z: " + thing.z, color := 65 );
      endif
   endforeach
endfunction

function alt_up( who )
   foreach thing in ( ListItemsNearLocation(who.x, who.y, who.z, 25, who.realm) )
      if( GetObjProperty( thing, "#Marked" ) == 1 )
         moveitem(thing);
                        MoveObjectToLocation( thing, thing.x, thing.y, thing.z+1, who.realm, MOVEOBJECT_FORCELOCATION );
         stopitem(thing);
         SendSysMessage( who, "Coords Z: " + thing.z, color := 65 );
      endif
   endforeach
endfunction

function top_left( who )
   foreach thing in ( ListItemsNearLocation(who.x, who.y, who.z, 25, who.realm) )
      if( GetObjProperty( thing, "#Marked" ) == 1 )
         moveitem(thing);
         MoveObjectToLocation( thing, thing.x-1, thing.y, thing.z, who.realm, MOVEOBJECT_FORCELOCATION );
         stopitem(thing);
         SendSysMessage( who, "Coords X: " + thing.x, color := 65 );
      endif
   endforeach
endfunction

function bottom_left( who )
   foreach thing in ( ListItemsNearLocation(who.x, who.y, who.z, 25, who.realm) )
      if( GetObjProperty( thing, "#Marked" ) == 1 )
         moveitem(thing);
         MoveObjectToLocation( thing, thing.x, thing.y+1, thing.z , who.realm, MOVEOBJECT_FORCELOCATION );
         stopitem(thing);
         SendSysMessage( who, "Coords Y: " + thing.y, color := 65 );
      endif
   endforeach
endfunction

function bottom_right( who )
   foreach thing in ( ListItemsNearLocation(who.x, who.y, who.z, 25, who.realm) )
      if( GetObjProperty( thing, "#Marked" ) == 1 )
         moveitem(thing);
         MoveObjectToLocation( thing, thing.x+1, thing.y, thing.z , who.realm, MOVEOBJECT_FORCELOCATION );
         stopitem(thing);
         SendSysMessage( who, "Coords X: " + thing.x, color := 65 );
      endif
   endforeach
endfunction

function moveitem( thing )
   thing.movable := 1;
endfunction

function stopitem( thing )
   thing.movable := 0;
endfunction
If you have any suggestions please post them here. I am trying to get this distro worthy.
Last edited by runtest on Thu Sep 18, 2008 1:54 pm, edited 6 times in total.
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: In Game GM Tool Decoration

Post by CWO »

runtest wrote:One last thing. The Z modifier does NOT work. I have NO clue why. If someone fixes it. PLEASE submit it. Just post the fix here. Oh, and yes, my code is awkward.
I haven't tried it but looking at it, are you talking about moving things up and down on the Z axis? If so, you want the MOVEOBJECT_FORCELOCATION flag inside of MoveObjectToLocation().
POLDocs wrote:Notes: If MOVEOBJECT_FORCELOCATION is not passed with flags, z-coordinate passed is used as a hint. The object will be placed on the the ground, or on an item, or on a ship. If it is set, the z location of the object is forced.
runtest
Grandmaster Poster
Posts: 194
Joined: Sat Aug 05, 2006 11:43 am

Re: In Game GM Tool Decoration

Post by runtest »

I tried that already. For kicks I also tried the normal flag.
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: In Game GM Tool Decoration

Post by CWO »

are you SURE? The script was unloaded, the flag was put in the correct place... That's exactly how you get the z to float up or go down...
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: In Game GM Tool Decoration

Post by Pierce »

Ecompile should give an error because two params are missing, but doesn't do this :D

Code: Select all

   MoveObjectToLocation( thing, thing.x, thing.y, thing.z-1, who.realm, MOVEOBJECT_FORCELOCATION );
You should also add these 2 params to the other MoveObjectToLocation commands.
Then it works fine ;)
runtest
Grandmaster Poster
Posts: 194
Joined: Sat Aug 05, 2006 11:43 am

Re: In Game GM Tool Decoration

Post by runtest »

Whoops! I put thing.realm. Ha! Does this work for anyone now? I am at work and can not test it at the moment.
runtest
Grandmaster Poster
Posts: 194
Joined: Sat Aug 05, 2006 11:43 am

Re: In Game GM Tool Decoration

Post by runtest »

Hey thanks Pierce. That did it. The Z works great. I hope someone else can get use out of this. I was tired of not being able to mass manipulate objects that were scattered about.
runtest
Grandmaster Poster
Posts: 194
Joined: Sat Aug 05, 2006 11:43 am

Re: In Game GM Tool Decoration

Post by runtest »

I made some big bug updates and added a video tutorial. I just found out from some of my staff that this tool can confuse people at first. The video tutorial link can be found at the top of the first post.
Luth
Former Developer
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am

Re: In Game GM Tool Decoration

Post by Luth »

I tried watching the video tutorial. It takes forever to load! I think my work computer is too lame to play it, because after 3 minutes or so, it just stops. >_<

You might consider compressing the video and audio to make it a more manageable file size...
runtest
Grandmaster Poster
Posts: 194
Joined: Sat Aug 05, 2006 11:43 am

Re: In Game GM Tool Decoration

Post by runtest »

Will do.
Post Reply