Delay a Creature Spawn



  • Something isn't working with this, which should be an OnEnter script that creates a creature after set delay.

    void CreateObjectVoid(int nObjectType, string sCreature, location lTarget, int bUseAppearAnimation = TRUE)
    {
        CreateObject(OBJECT_TYPE_CREATURE, sCreature, lTarget, bUseAppearAnimation);
    }
    
    void main()
    {
    
        // Create Creature
        string sCreature = GetLocalString(OBJECT_SELF, "sCreature");
        // Create it at point.
        location lTarget = GetLocation(GetWaypointByTag("sWP"));
        // Wait for it....
        float fDelay = GetLocalFloat(OBJECT_SELF, "fDelay");
        // Will work - we use new void declared function.
        DelayCommand(fDelay, CreateObjectVoid(OBJECT_TYPE_CREATURE, sCreature, lTarget, TRUE));
    }
    


  • float fDelay = GetLocalFloat(OBJECT_SELF, "fDelay");

    What is OBJECT_SELF? What is calling this function? If this script is being executed by another script for example, then fDelay would default to 0 / garbage value.



  • A trigger, you enter it. The script should fire.



  • [23:37:59] /forum/viewtopic.ph ... c95335c943 Related to that. He needs to ensure the sCreature is a proper resref of the creature spawned, that sWP is a placed waypoint in the game (or set up the reference properly) and that fDelay along with the rest are set on the triggers. Script is working.
    [23:38:13] ah ok
    [23:38:18] This is a message from Talir
    [23:38:22] on EFU
    [23:38:37] okey dokey
    [23:38:38] thanks



  • Yeah, I did that….
    Hence my bafflement. Thanks for trying.



  • // Create it at point.
        location lTarget = GetLocation(GetWaypointByTag("sWP"));
    

    sWP is not defined.

    Edit: Oh.



  • I assume - 'oh' Means you realised its a string referencing the tag, and not a variable that needs to be defined.

    Moloch, have you put in SendMessageToAllDMs(); everywhere so it spits out tags and stuff? It looks fine to me



  • Think you should change GetLocalFloat to GetLocalInt and provide an integer value, then make a cast on it to become float. I recall that NWN had a terrible manner with float variables being set manualy on the toolset.

    Cheers



  • Yeah, I got this working eventually. It was one of those incredibly ridiculous problems where you look at a line of code a dozen times before you realize you did one simple obvious thing wrong.


Log in to reply