Aller au contenu

Photo

Trying to 'teleport', get stuck on black loading screen


  • Veuillez vous connecter pour répondre
10 réponses à ce sujet

#1
Valgreon

Valgreon
  • Members
  • 9 messages
So here's the code, the part that does not work is commented out, and the code that works has an extra step involved in getting to correct location. Currently the return trip requires two uses of the tome - and getting to The Cheat's Lair requires only one use.

case EVENT_TYPE_UNIQUE_POWER:
{
    //Teleport user depending on where he is.
    object oItem = GetEventObject(ev, 0);

    if (GetTag(oItem) == "tome_of_the_cheat")
    {
        object oArea = GetArea(oPC);
        if (GetTag(oArea) != "tome_cheat_area")
        {
            if (FetchInteger(TOME_CHEAT_CACHE, "nReturned") == TRUE && GetTag(oArea) == FetchString(TOME_CHEAT_CACHE, "sArea"))
            {
                ReturnToLocation();
            }
            else
            {
                location lPC = GetLocation(oPC);
                string sArea = GetTag(oArea);
                object [] oWP = GetNearestObjectToLocation(lPC, OBJECT_TYPE_WAYPOINT);
                string sWP = GetTag(oWP[0]);
                StoreLocation(TOME_CHEAT_CACHE, "lPC", lPC);
                StoreString(TOME_CHEAT_CACHE, "sArea", sArea);
                StoreString(TOME_CHEAT_CACHE, "sWP", sWP);
                DoAreaTransition("tome_cheat_area", "tome_cheat_target");
            }
        }
        else
        {
            ReturnToArea();
            /* Attempt at making this work more elegantly
            // (avoiding the need for third use of the tome every cycle).
            while (GetGameMode() == GM_LOADING) {}
            ReturnToLocation();
            */
        }
    }
    break;
}

Oh, and yes, I'm using Graff's variable storage, found it extremely useful after trying in vain to figure out other ways to store the location and area tag for transitions and jumping around.

Modifié par Valgreon, 07 février 2010 - 07:27 .


#2
Baracuda6977

Baracuda6977
  • Members
  • 353 messages
tell me how this goes as i am planning on making a teleport spell later, and some help on it would be greatly appreciated

#3
Craig Graff

Craig Graff
  • Members
  • 608 messages
Your current problem is the line

while (GetGameMode() == GM_LOADING) {}



All this does is create an infinite loop which creates a TMI (Too Many Instructions) error and stops the rest of your code from running. If you want to jump the player back to their location once they have returned to their original area, just use a PRCSCR script using the logic that you currently have for the second use of the tome.

#4
Valgreon

Valgreon
  • Members
  • 9 messages
Thanks. I'll look into it.



Baracuda, basically you get an area tag and waypoint tag from that area and then do the area transition - but currently I know of no way to acquire area tags dynamically (except for the one the player is currently in). Tags are even harder to find, as they can be for anything in the area. Skipping triggers by teleporting might break the game.



Teleporting within the area is done by jumping (CommandJumpToObject or CommandJumpToLocation) and jumping to objects is always preferable (easier to actually get where you want to get). Interesting challenge would be to make a spell that teleports the caster behind the target for flanking/backstabbing purposes...


#5
Valgreon

Valgreon
  • Members
  • 9 messages

Craig Graff wrote...

Your current problem is the line
while (GetGameMode() == GM_LOADING) {}

All this does is create an infinite loop which creates a TMI (Too Many Instructions) error and stops the rest of your code from running. If you want to jump the player back to their location once they have returned to their original area, just use a PRCSCR script using the logic that you currently have for the second use of the tome.


That I do believe, but that was my last-ditch effort at avoiding the problem. I suppose that when I earlier did ReturnToArea and ReturnToLocation one after another without anything between (they were actually one function in the first version of the script) the engine attempted to relocate the character while the area was still loading?

#6
BrotherJason

BrotherJason
  • Members
  • 99 messages
You'll get a EVENT_TYPE_AREALOAD_PRELOADEXIT when the Loading screen is about to disappear and a EVENT_TYPE_AREALOAD_POSTLOADEXIT the moment it's gone. If any of these are fired the area is done loading and it's safe to do whatever you want.

#7
Valgreon

Valgreon
  • Members
  • 9 messages

BrotherJason wrote...

You'll get a EVENT_TYPE_AREALOAD_PRELOADEXIT when the Loading screen is about to disappear and a EVENT_TYPE_AREALOAD_POSTLOADEXIT the moment it's gone. If any of these are fired the area is done loading and it's safe to do whatever you want.


Fun facts, but don't help any - they aren't fired into the module and I'm not going to change anything in the core. Also, as you might have guessed from the variable names, this is a cheating tool, if a rather fancy one at that. It really needs to be able to function in the official single player campaign.

#8
Baracuda6977

Baracuda6977
  • Members
  • 353 messages
what if it was a two step process, once to set an object at your current location ( or force it to where you want it manually) and then another step to jump back to that object



thats how im planning on executing mine

#9
Valgreon

Valgreon
  • Members
  • 9 messages
Craig, the PRCSCR script worked perfectly. I just had some problems with M2DA itself, as I use OpenOffice. Took some time to figure out how to compile it to GDA. Answer was relatively simple - I needed to simply add it as a new sheet to one of the provided .xls files - creating a new one and saving it in Excel format did not work. Neither did uploading to Google Docs and downloading it as an Excel file.



Baracuda, now I don't quite follow what you mean... Where are you trying to teleport with the spell? Creating a new object dynamically at your current location would simply serve as a beacon for teleporting you back to that location - it would not help you teleport anywhere else. Of course you could then move it to where you wanted to teleport, but you'd still have to get that position/location somehow. Perhaps the spell system's area effect targeting could be of use here?


#10
Craig Graff

Craig Graff
  • Members
  • 608 messages
You may also want to try SetPosition or UT_LocalJump rather than CommandJumpToLocation.



Another thing to keep in mind is that some areas of the main campaign have very specific scripting for the EVENT_TYPE_AREALOAD_* events, so you may want to limit your cheat tool to not work in those areas (it might take a bit of figuring to know which areas that would be a problem for).

#11
Valgreon

Valgreon
  • Members
  • 9 messages
Is this one of the situations where I have to actually try it everywhere and then add the area into a constant variable? There's so much that could have been done better with this script...



The cheating tool development is taking a break as I need to figure out what to do with it now that it works. I'm planning to expand the story behind The Cheat (the spirit who is responsible for the cheats) and possibly even include a quest (although, as this is already a cheating tool, figuring out the reward is going to be interesting). Mainly the tool is just a practice platform for various things I want to learn to do with the toolset.