Please or Register to create posts and topics.

Useful console commands for mappers.

PreviousPage 5 of 6Next

Try turning on noclip and moving only one player?

Falsi sumus crusto!

Nah movement's just completely locked : Only teleporting works, and even then you sort of half die (though you can't lose health) if you tele too far.

I believe this happens because the MapPostLoaded() script isn't run as it is a singleplayer map.

post44624.html?#p44624

?????????????????????????????TWP Releases | My Workshop

Aah, thanks ChickenMobile!

I did have a good look at that function and its counterpart but it seems that since MapPostLoaded() is a stub function for a native call, that it's not actually available after all the OnMapSpawn() functions have been completed.

I.e. you can't force it manually, even on @glados even if you do something like

ent_fire @glados runscriptfile "debug_scripts/mp_coop_transition_list.nut"

or
ent_fire red runscriptfile "debug_scripts/mp_coop_transition_list.nut"
ent_fire red runscriptcode "MapPostLoaded()"

ent_fire blue runscriptfile "debug_scripts/mp_coop_transition_list.nut"
ent_fire blue runscriptcode "MapPostLoaded()"

So it looks like it would still work with the commentary mods at least!

Can't you run scripts directly through other scripts though using DoIncludeScript? - namely mapspawn.nut.

Check out post87670.html

Remember you can also spawn entities within the game through scripts even with cheats off.

*EDIT* I realised the main problem could be you are referencing the singleplayer glados and not the multiplayer one. Correct me if I'm wrong.

?????????????????????????????TWP Releases | My Workshop

I've given that a shot Chicken, but no luck. Few details.

Loading order:
-Mapspawn.nut
-glados.nut (@cave)
-glados.nut (@glados)
-commentary .txt file
-sp_transition_list.nut (@transition_script)
-players are created around this point ('red' and 'blue')
-puzzlemaker assets
-mapspawn.nut.

Note: mapspawn.nut is farily useless to us due to having access only to a limited subset of squirrel functions/packages. E.g. No entity system, so no fires, no SendToConsole, no self for scope, etc.

So let's say you have a map called sp_whatver, and you want to run it with ss_map sp_whatever *mp.
You could add coop info_coop_spawn points with the right teams, a script running mp_coop_transitionlist.nut and a logic_auto set to runscriptcode "MapPostLoaded()" on the script entity on "OnMapSpawn". That would work peachy.

But in fact:
-Any entity running mp_coop_transition_list.nut will do
-You never need to call MapPostLoaded();
-You can even delete MapPostLoaded() from the .nut file and you'll be fine.

Essentially the game's looking for an entity which already has mp_coop_transition_list.nut loaded and ready immediately after the commentary .txt file is loaded.

For example paste the following into sp_a3_03_commentary.txt

Code: Select all
   entity
   {
      "id" "4372"
      "classname" "logic_script"
      "angles" "0 0 0"
      "origin" "0 0 0"
      "targetname" "@misterpickles"
      "vscripts" "debug_scripts/mp_coop_transition_list.nut"

   }

then from the console:

Code: Select all
-"commentary 1"
-"ss_map sp_a3_03 *mp"

It'll work perfectly aside from both players starting in the same spot. (noclip will fix it).

But if we try to create this manually via vscript, we run into some problems, mainly because a lot of the steps required to create a logic_script and assign the mp_coop_transition_list.nut to it are queued, and the IO system doesn't start processing them properly until sp_transition_list.nut is finished, which is too late, and OnMapSpawn() funcs are called even later.

You can set up a logic_auto via vscript at this point, and even trigger its OnMapSpawn naturally very successfully, but as far as I can tell, at this point, the game has already looked for an entity running mp_coop_map_spawn.nut and not found it.

-DoIncludeScript(mp_coop_transition_list.nut) into glados.nut (@cave and @gladods) makes no difference.
-Pasting mp_coop_transition_list.nut into glados.nut makes no difference.
-myEntity.__KeyValueFromString("vscripts", "debug_scripts/mp_coop_transition_list.nut" ); doesn't work;
-EntFireByHandle( myEntity, "addoutput", "vscripts debug_scripts/mp_coop_transition_list.nut", 0 , null, null ); doesn't work.
-EntFireByHandle( myEntity, "runscriptFile", "debug_scripts/mp_coop_transition_list.nut", 0 , null, null ); doesn't work.
-renaming glados_coop.nut to glados.nut doesn't work.
-Validating the script scope doesn't force earlier execution.
-Mapspawn.nut doesn't work for reasons mentioned earier
-ForceGunOnSpawn should be off, so that they will show automatically if this randomly starts working
-Doing logicauto.onmapspawn -> my_logic_auto runscriptfile debug_scripts/mp_coop_transition_list.nut does not work either.

If there was a way to create the entity pre-setup, like with the commentary file, this would be pretty easy, but even using __KeyValueFromString doesn't seem to do the job thoroughly enough or fast enough.

If you are using the commentary .txt hack, or have created an mp_coop_transition_list.nut entity, then the following script will create a pair of coop spawn points near to the original, and the players will spawn there instead of inside eachother. Eww.
The second half of the script is just there as a proof of concept and doesn't really work other than showing that OnMapSpawn is being called.

Code: Select all
printl("*x*x*x*x*x*x  coop modifications begin" );
if ( IsMultiplayer()  ){
   
   //DoIncludeScript("debug_scripts/mp_coop_transition_list", self.GetScriptScope());

   
   //prints out this entity, usually @glados and @cave
   printl("*x*x*x*x*x*x glados.nut is " + self );

   //Will contain the position of the original info_player_start
   //Store as primitives, 'cause nonprimitives (Vectors etc) are static
   px <- 0;
   py <- 0;
   pz <- 0;

   //Find the original info_player_start, store its position and kill it.
   //Note: Since ent_fire * kill takes another tick, both @glados and @cave can read
   //and work with this before the object is actually removed from the level.
      
   originalStart <- Entities.FindByClassname( null, "info_player_start" );
   EntFire("info_player_start" , "addoutput" , "targetname originalStart" );
   printl("Found originalStart - " + originalStart + "  " + originalStart.GetOrigin() );
   px = originalStart.GetOrigin().x
   py = originalStart.GetOrigin().y
   pz = originalStart.GetOrigin().z      
   EntFireByHandle( originalStart, "kill", "", 0, null, null );

   //spawn an info_coop_spawn where the original info_player start was
   startBlue <- Entities.CreateByClassname("info_coop_spawn");
   EntFireByHandle( startBlue, "addoutput", "startingTeam 2", 0, null, null);   
   EntFireByHandle( startBlue, "addoutput", "enabled 1", 0, null, null);      
   EntFireByHandle( startBlue, "addoutput", "targetname startBlue", 0, null, null);      
   startBlue.SetOrigin( Vector( px,py,pz ) );   

   //spawn the second player's spawn, just over a bit.
   startRed <- Entities.CreateByClassname("info_coop_spawn");
   EntFireByHandle( startRed, "addoutput", "StartingTeam 3", 0, null, null);      
   EntFireByHandle( startRed, "addoutput", "Enabled 1", 0, null, null);      
   EntFireByHandle( startRed, "addoutput", "targetname startRed", 0, null, null);      
   startRed.SetOrigin( Vector( px + 40, py + 40, pz + 100 ) );

   //Demonstration of OnMapSpawn working - other than that, this doesn't do much.
   
   //Create a logic_script to contain mp_coop_transition_list.nut
   transitionScript <- Entities.CreateByClassname("logic_script");
   EntFireByHandle( transitionScript, "addoutput", "targetname transitionscript", 0 , null, null  );
   transitionScript.__KeyValueFromString("vscripts", "debug_scripts/mp_coop_transition_list.nut" );   
   EntFireByHandle( transitionScript, "addoutput", "vscripts debug_scripts/mp_coop_transition_list.nut", 0 , null, null  );   
   EntFireByHandle( transitionScript, "runscriptFile", "debug_scripts/mp_coop_transition_list.nut", 0 , null, null  );   

   //Create a logic_auto to use OnMapSpawn
   lauto <- Entities.CreateByClassname("logic_auto");
   EntFireByHandle( lauto, "addoutput", "targetname lauto", 0 , null, null  );
   EntFireByHandle( lauto, "addoutput", "spawnflags 1", 0 , null, null  );

   //Set the OnMapSpawn callbacks   
   EntFireByHandle( lauto, "addoutput", "OnMapSpawn transitionscript,runscriptcode,MapPostLoaded(),0,-1" , 0, null, null );
   EntFireByHandle( lauto, "addoutput", "OnMapSpawn @glados,runscriptcode,lautoDebug()" , 0, null, null );
   
   //Visual confirmation that lauto has fired the OnMapSpawn
   function lautoDebug(){
      printl("-----------The logic_auto's OnMapSpawn fired on @glados or @cave ------------------");
   }
   

}
printl("*x*x*x*x*x*x  coop modifications end" );

As an alternative, I tried creating the file skill1.cfg and adding the following:

Code: Select all
sv_cheats 1
echo ---___---___---___--- THIS RAN ---___---___---___---
ent_create logic_script
ent_fire logic_script addoutput "vscripts debug_scripts/mp_coop_transition_list.nut"

But this can be more crashy than helpful and appears to execute far to early.
Running this sort of thing from SendToConsole plain doesn't work during loading and by calling "@command, command, runscriptcode", etc, the target entity is never modified, though the "echo"s are.
Edit:
Using @command or a point_clientcommand or SendToConsole to run an external .cfg with the above code doesn't work from sp_transition_list, or glados.nut either :

Any ideas?

I think we should leave sp maps to sp and mp maps to mp. haha

?????????????????????????????TWP Releases | My Workshop

Yeah, screw it. lol :p

Seems like !picker always referrs to the blue player.
I tried to avoid that using cmd2, ent_fire red/!player/!player_orange, but none of them worked.
I also used aliases to avoid double quotes.

e.g.:
alias pickerkill "ent_fire !picker kill"
cmd2 "pickerkill"

I'm out of ideas :/ Any suggestions?

!picker is only for singleplayer. I'm surprised it worked at all.

Falsi sumus crusto!
PreviousPage 5 of 6Next