Author Topic: Change Map Trigger?  (Read 1772 times)

Does anyone know how to make a trigger when entered change the map to a particular map? Example, Player walks into a trigger box and the level changes to "level2". I'm trying to figure a way to make this Co-op mini-game.

I think you should just be able to do something like this:

Code: [Select]
loadMission("base/data/missions/slate.mis");
or something. I'm not sure if there's any clean-up code i'm missing that is normally in the servercmdChangeMap function, though.

Thanks for that line, I'll try working on the trigger tomorrow.

I don't know if you ever got around to doing this but, if not(Ephi said exactly right) ;
Code: [Select]
function YourTrigger::onEnterTrigger(%this,%trigger,%obj)
{
   messageAll('','\c2Standby ... Loading next level.');
   loadMission("base/data/missions/yourmission.mis");
}

Ok what am I doing wrong here, it crashes when I walk into it.
Quote
Console:

*** ENDING MISSION
*** LOADING MISSION: base/data/missions/planetcave.mis
*** Stage 1 load
Mission Name: Planetcave
Mission SaveName: planetcave
Mission Description:
   Name: Planet cave
   Author: Packer
*** Stage 2 load
Executing base/data/missions/planetcave.mis.
*** Mission loaded
The script, active though Add-ons list (Maybe bad?)
Code: [Select]
script_triggers.cs

datablock TriggerData(NextMap)
{
category = "NextMap";
tickPeriodMS = 1000;
};

function NextMap::onEnterTrigger(%this,%trigger,%obj)
{
   messageAll('','\c2Standby ... Loading next level.');
   loadMission("base/data/missions/planetcave.mis");
}

What the Hell. The console code you've just given us says its worked perfectly 0_0.
Try replacing:
Code: [Select]
loadMission("base/data/missions/planetcave.mis");With:
Code: [Select]
loadMission('base/data/missions/planetcave.mis');And if that doesn't work:
Code: [Select]
loadMission(base/data/missions/planetcave.mis);And also I believe you don't need the category there,
Code: [Select]
datablock TriggerData(NextMap)
{
tickPeriodMS = 1000;
};
« Last Edit: April 28, 2008, 02:11:29 AM by Destiny/Zack0Wack0 »

It'll be some cleanup thing we're missing, nothing the guy above said.

I'll toy with it in a bit.

For a second I thought it would load the mission then load it again, like an infinite loop making it crash. But I doubt it.

Unless it's a blockland-specific thing, I doubt there's anything wrong with loading a new map without cleaning up the server (although if you wanted you could delete bricks and MissionCleanup objects).

When I run your code in the blockland demo it works fine. I don't know what could be causing you to crash. (For me it just says 'Unknown Map' because I don't have your map file... the crash could be from some error in your map).

The only thing I would really be worried about is if two people entered the trigger at the same time. If I were you, I'd keep the trigger ticking every 100ms, but make a checker in your onEnterTrigger() function to keep your server from trying to load a map twice:
Code: [Select]
datablock TriggerData(NextMap)
{
   category = "NextMap";
   tickPeriodMS = 100;
};

function NextMap::onEnterTrigger(%this, %trigger, %obj)
{
   if( !$loadedPlanetCave )
   {
      $loadedPlanetCave = true;
      messageAll('', '\c2Standby ... Loading next level.');
      loadMission("base/data/missions/planetcave.mis");
   }
}

Did the same thing on the Blockland demo for me
Code: [Select]
*** ENDING MISSION
*** LOADING MISSION: base/data/missions/planetcave.mis
*** Stage 1 load
Mission Name: Planetcave
Mission SaveName: planetcave
Mission Description:
   Name: Planet cave
   Author: Packer
*** Stage 2 load
Executing base/data/missions/planetcave.mis.
*** Mission loaded
However I did use the same map, this doesn't make a heap of sense seeing as I've tried it on the Bedroom.

Hmm... wish Badspot could enlighten but I don't see why it would crash both Demo and full version for me... I better reinvestigate more.

After reading some more of the console I noticed the game seems to check with the master server (Or what ever you calls it), I've bolded the area I'm talking about.
Quote
*** LOADING MISSION: base/data/missions/RRcavern1.mis
*** Stage 1 load
Mission Name: RR Cavern One
Mission SaveName: RR Cavern One
Mission Description:
   Name: RR Cavern One
   Author: Packer
*** Stage 2 load
Executing base/data/missions/RRcavern1.mis.
*** Mission loaded
Connect request from: IPX:696E6752:616E67650032:48
  lan name = Blockhead
  net name = Badspot
Connection established 4646
AUTHCHECK: 4647
    LAN server, LAN client, loading
CADD: 4647 local
 +- bl_id = LAN
Error: Could not open file "key.dat" (reading)
 +- AUTO SUPER ADMIN

*** Sending mission load to client: base/data/missions/RRcavern1.mis
*** New Mission: base/data/missions/RRcavern1.mis
*** Phase 1: Download Datablocks & Targets
*** Phase 2: Download Ghost Objects
Ghost Always objects received.
Client Replication Startup has Happened!
*** Phase 3: Mission Lighting
Failed to load resources for object.  Skipped.
Mission lighting done
Executing base/config/client/Favorites.cs.
*** Initial Control Object
Activating DirectInput...
Perhaps this may have some thing to do with it crashing?
« Last Edit: April 30, 2008, 10:05:41 PM by Packer »

Try going on a map and just putting this in the console:

Code: [Select]
loadMission("base/data/missions/planetcave.mis");
If that crashes, we know its not a problem with the trigger. If it does crash, its a trigger problem and we'll come to that later.

So if it does crash, try doing:

Code: [Select]
loadMission("base/data/missions/bedroom.mis");
If it doesn't crash, you've got a problem with your planetcave.mis file, if it continues to crash, Try on a new install. If it stops crashing, you borked your BL.

Both work perfectly, I think we're messing some thing impotent. :D

Impotent = sterile/unable to have babies...

Are you saying that when you loaded planetcave.mis using that command, it worked fine, but if you load that map using the trigger, it borks?

Impotent = sterile/unable to have babies...

Are you saying that when you loaded planetcave.mis using that command, it worked fine, but if you load that map using the trigger, it borks?
Yes, that's exactly what I'm telling you. Has an Uber fail if its used via trigger.