string msg_server_only$ = "This command only works on the host machine"; void NotifyPlayers$( string msg$ ) { //to announce something to all players, route the message through the chat console... console$.SetText( MakeStringF( "[CONSOLE] %s", msg$ ) ); Messenger.Notify( "console_submit_text", console$ ); } void NotifyParty$( string msg$ ) { Go party$ = Server.GetScreenParty(); if ( party$ == NULL ) { Report.Screen( msg$ ); return; } int index$ = party$.Children.Size - 1; Go member$; while ( index$ > -1 ) { member$ = party$.Children.Get( index$ ); if ( member$.HasActor() ) { //sanity check if ( member$.Actor.IsHero ) { Report.SScreen( member$.machineId, msg$ ); } } index$ -= 1; } } bool ProcessCommandMP$( string command$, string input$, int elements$ ) { string bang$ = StringTool.Left( command$, 1 ); if ( bang$ == "/" ) { command$ = StringTool.Mid( command$, 1 ); if ( StringTool.SameNoCase( command$, "give", 3 ) ) { if ( elements$ > 1 ) { //use GetDelimitedString instead of Mid to trim away the whitespace string pcontent$ = StringTool.GetDelimitedString( input$, 1, ' ', "" ); if ( pcontent$ == "" ) { Report.Screen( msg_params_need$ ); } else { GoCloneReq req$ = MakeGoCloneReq( pcontent$ ); Go player$ = Server.ScreenHero; req$.FadeIn = true; req$.SnapToTerrain = true; req$.StartingPos = player$.Placement.Position; if ( player$.HasMind() ) { //sanity check if ( AIQuery.FindSpotRelativeToSource( player$, .25, .5, 2, player$.Mind.TempPos1 ) ) { req$.StartingPos = player$.Mind.TempPos1; } } GoDb.RSCloneGo( req$ ); string player_name$; player$.Common.GetScreenName( player_name$ ); NotifyPlayers$( MakeStringF( "%s attempted to clone %s", player_name$, pcontent$ ) ); } } else { Report.Screen( msg_params_need$ ); } return true; } else if ( StringTool.SameNoCase( command$, "ghost", 3 ) ) { if ( elements$ > 1 ) { command$ = StringTool.GetDelimitedString( input$, 1, ' ', "" ); if ( command$ == "" ) { Report.Screen( msg_params_need$ ); } else if ( StringTool.SameNoCase( command$, "gettimer", 1 ) ) { int duration$ = GameAuditor.Db.GetInt( "ui_ghosttimer" ); if ( duration$ > -1 ) { Report.ScreenF( "Ghost timeout duration was changed to %d seconds", duration$ ); } else { Report.ScreenF( "Ghost timeout duration was not changed during this game session" ); } } else if ( ( elements$ > 2 ) && IsServerLocal() ) { if ( StringTool.SameNoCase( command$, "settimer", 1 ) ) { float duration$ = StringTool.GetDelimitedFloat( input$, 2, ' ', -1.0 ); if ( duration$ > -1.0 ) { int dur$ = Math.ToInt( duration$ ); //rounding...probably flooring Server.SSetGhostTimeout( Math.ToFloat( dur$ ) ); GameAuditor.RCSet( "ui_ghosttimer", dur$ ); //communicate change to all NotifyPlayers$( MakeStringF( "Ghost timeout duration changed to %d seconds", dur$ ) ); } else { Report.Screen( msg_params_bad$ ); } } else { Report.Screen( msg_params_bad$ ); } } else { Report.Screen( msg_params_bad$ ); } } else { Report.Screen( msg_params_need$ ); } return true; } else if ( StringTool.SameNoCase( command$, "name", 3 ) ) { if ( !IsServerLocal() ) { Report.Screen( msg_server_only$ ); } else if ( elements$ > 1 ) { //enforce the 14 character limit string name$ = StringTool.Mid( StringTool.Mid( input$, 6 ), 0, 14 ); elements$ -= 1; //the nested StringTool.Mid command strips away the first element //detect characters that are normally excluded in the character creation edit box..."<>:/\|?*.%; if ( !IsSanitaryText$( name$ ) ) { Report.Screen( "Your name cannot contain any of the following characters: \"<>:/\|?*.%;" ); } else { string oldname$; Go player$ = Server.ScreenHero; player$.Common.GetScreenName( oldname$ ); player$.Common.SSetScreenName( name$ ); NotifyPlayers$( MakeStringF( "%s changed %s name to %s", oldname$, ( player$.Actor.IsMale ? "his" : "her" ) , name$ ) ); } } else { Report.Screen( msg_params_need$ ); } return true; } else if ( StringTool.SameNoCase( command$, "inventory", 3 ) ) { if ( elements$ > 1 ) { command$ = StringTool.GetDelimitedString( input$, 1, ' ', "" ); if ( command$ == "" ) { Report.Screen( msg_params_need$ ); } else if ( StringTool.SameNoCase( command$ , "delete", 3 ) ) { Go player$ = Server.ScreenHero; GopColl contents$ = ( player$.HasMind ? player$.Mind.TempGopColl1 : AIQuery.TempGopColl1 ); //sanity check player$.Inventory.ListItems( IL_MAIN, contents$ ); int index$ = contents$.Size - 1; int count$ = 0; Go item$; while ( index$ > -1 ) { item$ = contents$.Get( index$ ); if ( item$ != NULL ) { if ( !item$.IsEquipped() ) { //weird, il_main includes equip slots... GoDb.RSMarkGoAndChildrenForDeletion( item$, true, false, false ); count$ += 1; } } index$ -= 1; } Report.ScreenF( "Deleted %d items from inventory", count$ ); } else if ( StringTool.SameNoCase( command$, "drop", 3 ) ) { Go player$ = Server.ScreenHero; GopColl contents$ = ( player$.HasMind ? player$.Mind.TempGopColl1 : AIQuery.TempGopColl1 ); //sanity check player$.Inventory.ListItems( IL_MAIN, contents$ ); int index$ = contents$.Size - 1; int count$ = 0; Go item$; while ( index$ > -1 ) { item$ = contents$.Get( index$ ); if ( item$ != NULL ) { if ( !item$.IsEquipped() ) { //weird, il_main includes equip slots... player$.Inventory.RSRemove( item$, true ); count$ += 1; } } index$ -= 1; } Report.ScreenF( "Dropped %d items from inventory", count$ ); } else if ( StringTool.SameNoCase( command$, "unlock", 3 ) ) { Server.ScreenHero.Inventory.RCEndUse(); Report.Screen( "Attempted to end all inventory locks..." ); } else { Report.Screen( msg_params_bad$ ); } } else { Report.Screen( msg_params_need$ ); } return true; } else if ( StringTool.SameNoCase( command$, "gold", 3 ) ) { if ( elements$ > 1 ) { int amount$ = StringTool.GetDelimitedInt( input$, 1, ' ', 0 ); if ( amount$ > 0 ) { Server.ScreenHero.Inventory.RSAddGold( amount$ ); Report.ScreenF( "Increased gold balance by %d", amount$ ); } else { Report.Screen( msg_params_bad$ ); } } else { Report.Screen( msg_params_need$ ); } return true; } else if ( StringTool.SameNoCase( command$, "camera", 3 ) ) { if ( elements$ > 1 ) { command$ = StringTool.GetDelimitedString( input$, 1, ' ', "" ); if ( command$ == "" ) { Report.Screen( msg_params_need$ ); } else if ( StringTool.SameNoCase( command$, "test", 2 ) ) { //the "test" preset range SiegeEngine.Camera.SetMinDistance(0); SiegeEngine.Camera.SetMaxDistance(20); SiegeEngine.Camera.SetMinAzimuth(-50); SiegeEngine.Camera.SetMaxAzimuth(90); } else if ( elements$ > 2 ) { if ( StringTool.SameNoCase( command$, "azimuth", 1 ) ) { int min_azimuth$ = StringTool.GetDelimitedInt( input$, 2, ' ', -88 ); if ( min_azimuth$ < -87 || min_azimuth$ > 90 ) { Report.ScreenF( "Camera min azimuth (%d) must be between -87 and 90 inclusive", min_azimuth$ ); } else { Report.ScreenF( "Camera min azimuth was set to %d", min_azimuth$ ); SiegeEngine.Camera.SetMinAzimuth( min_azimuth$ ); } if ( elements$ > 3 ) { int max_azimuth$ = StringTool.GetDelimitedInt( input$, 3, ' ', 91 ); min_azimuth$ = Math.MaxInt( 0, min_azimuth$ ); if ( max_azimuth$ < min_azimuth$ ) { Report.ScreenF( "Camera max azimuth (%d) must be between %d and 90 inclusive", min_azimuth$ ); Report.ScreenF( "Camera max azimuth was set to %d", min_azimuth$ ); SiegeEngine.Camera.SetMaxAzimuth( min_azimuth$ ); } else if ( max_azimuth$ > 90 ) { Report.ScreenF( "Camera max azimuth (%d) must be between -87 and 90 inclusive", max_azimuth$ ); Report.ScreenF( "Camera max azimuth was set to 90" ); SiegeEngine.Camera.SetMaxAzimuth( 90 ); } else { Report.ScreenF( "Camera max azimuth was set to %d", max_azimuth$ ); SiegeEngine.Camera.SetMaxAzimuth( max_azimuth$ ); } } } else if ( StringTool.SameNoCase( command$, "distance", 1 ) ) { int min_distance$ = StringTool.GetDelimitedInt( input$, 2, ' ', -1 ); if ( min_distance$ < 0 ) { Report.Screen("Camera min distance must be greater than or equal to 0"); } else { SiegeEngine.Camera.SetMinDistance( min_distance$ ); } if ( elements$ > 3 ) { int max_distance$ = StringTool.GetDelimitedInt( input$, 3, ' ', -83775638 ); if ( max_distance$ < min_distance$ ) { if ( min_distance$ < 1 ) { Report.Screen( "Camera max distance must be greater than or equal to 1" ); } else { Report.ScreenF( "Camera max distance must be greater than or equal to %d", min_distance$ ); if ( max_distance$ != -83775638 ) { Report.ScreenF( "Camera max distance was set to %d", min_distance$ ); SiegeEngine.Camera.SetMaxDistance( min_distance$ ); } } } else { Report.ScreenF( "Camera max distance was set to %d", min_distance$ ); SiegeEngine.Camera.SetMaxDistance( max_distance$ ); } } } else { Report.Screen( msg_params_bad$ ); } } else { Report.Screen( msg_params_bad$ ); } } else { Report.Screen( msg_params_need$ ); } return true; } else if ( StringTool.SameNoCase( command$, "party", 3 ) ) { if ( !IsServerLocal() ) { Report.Screen( msg_server_only$ ); } else if ( elements$ > 2 ) { command$ = StringTool.GetDelimitedString( input$, 1, ' ', "" ); if ( StringTool.SameNoCase( command$, "add", 1 ) ) { string template$ = StringTool.GetDelimitedString( input$, 2, ' ', "" ); if ( !IsSanitaryText$( template$ ) ) { Report.Screen( "The party member template name cannot contain any of the following characters: \"<>:/\|?*.%;" ); } else { GoCloneReq req$ = MakeGoCloneReq( template$ ); Go player$ = Server.ScreenHero; req$.FadeIn = true; req$.SnapToTerrain = true; req$.StartingPos = player$.Placement.Position; if ( player$.HasMind() ) { //sanity check if( AIQuery.FindSpotRelativeToSource( player$, player$.Mind.PersonalSpaceRange * 0.25, player$.Mind.InnerComfortZoneRange * 0.5, 2.0, player$.Mind.TempPos1 ) ) { req$.StartingPos = player$.Mind.TempPos1; } } Goid member$ = GoDb.SCloneGo( req$ ); if ( member$.IsValid ) { member$.Go.Aspect.SSetIsVisible( false ); if ( player$.OwningParty != NULL ) { player$.OwningParty.Party.AddMemberNow( member$.Go ); string player_name$; player$.Common.GetScreenName( player_name$ ); string member_name$; member$.Go.Common.GetScreenName( member_name$ ); member$.Go.Aspect.SSetIsVisible( true ); Report.ScreenF( "%s added %s to the party", player_name$, member_name$ ); } else { string player_name$; player$.Common.GetScreenName( player_name$ ); GoDb.SMarkGoAndChildrenForDeletion( member$ ); Report.ScreenF( "%s doesn't have a party...", player_name$ ); } } else { Report.ScreenF( "Party member addition failed: no such template (%s)", template$ ); } } } else { Report.Screen( msg_params_bad$ ); } } else { Report.Screen( msg_params_need$ ); } return true; } } return false; }