Author Topic: recall script  (Read 348 times)

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
recall script
« on: September 07, 2014, 06:48:19 am »


               

I need a simple recall script where an item with unique power is used and it sends the player to a particular waypoint. It is one-way and doesn't have to send the player back. 



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
recall script
« Reply #1 on: September 07, 2014, 08:12:18 am »


               

How will you be determining what the waypoint is?  Is it static or dependent on a variable?



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
recall script
« Reply #2 on: September 07, 2014, 08:14:46 am »


               

its static



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
recall script
« Reply #3 on: September 07, 2014, 09:23:58 am »


               

This should work as long as the PC is TRYING to teleport -- if you're trying to teleport the PC against their will we need additional safeguards.


 


#include "x2_inc_switches"

void main()
{
    int nEvent = GetUserDefinedItemEventNumber(); // Which event triggered this
    object oPC;                                      // The player character using the item

    int nResult = X2_EXECUTE_SCRIPT_END;

    switch (nEvent)
    {
        case X2_ITEM_EVENT_ACTIVATE:
            oPC = GetItemActivator();             // The player who activated the item
            AssignCommand(oPC, ClearAllActions());
            AssignCommand(oPC, ActionJumpToLocation(GetLocation(GetObjectByTag("wp_teleport"))));
            break;
    }

    // Pass the return value back to the calling script
    SetExecutedScriptReturnValue(nResult);
}


               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
recall script
« Reply #4 on: September 07, 2014, 10:14:53 am »


               

thanks. but how do you make it so they cant use it in combat and also use it automatically after activation without having to click again? 



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
recall script
« Reply #5 on: September 07, 2014, 06:09:32 pm »


               

That depends on how you want to define being in combat -- they could be fleeing from 50 mobs chasing them but as long as they haven't been actually attacked in like 6 seconds they'll drop the combat state according to the game engine.  Is that fine for you or do you also want to check something like make sure there's no enemies within 10 yards?


 


And I'm not sure what "also use it automatically after activation without having to click again" means?



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
recall script
« Reply #6 on: September 07, 2014, 09:03:02 pm »


               

As long as they have not been attacked in 6 seconds is fine, regardless of how many mob is chasing them. And about the second thing you know how when you cast fireball by pressing say f5 on the quickbar you have to click again on a target to release the fireball. well in this case i used the recall item and it wants me to click somewhere before i get recalled. I want it so that you get recalled instantly after using it without clicking again. thats what i meant. 



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
recall script
« Reply #7 on: September 07, 2014, 11:42:14 pm »


               

For the former part...


 


#include "x2_inc_switches"

void main()
{
    int nEvent = GetUserDefinedItemEventNumber(); // Which event triggered this
    object oPC;                                      // The player character using the item

    int nResult = X2_EXECUTE_SCRIPT_END;

    switch (nEvent)
    {
        case X2_ITEM_EVENT_ACTIVATE:
            oPC = GetItemActivator();             // The player who activated the item

            if (GetIsInCombat(oPC))
            {
                FloatingTextStringOnCreature("You cannot recall while in combat!", oPC, FALSE);
                return;
            }

            AssignCommand(oPC, ClearAllActions());
            AssignCommand(oPC, ActionJumpToLocation(GetLocation(GetObjectByTag("wp_teleport"))));
            break;
    }

    // Pass the return value back to the calling script
    SetExecutedScriptReturnValue(nResult);
}

 


The latter is done by having the power be "Unique Power Self Only" -- that has nothing to do with the script itself.



               
               

               
            

Legacy_fumm

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
recall script
« Reply #8 on: September 09, 2014, 09:10:47 am »


               

thank you so much again. I need another script for an item with unique power self only. This time if the item is used it teleports the player character to the party leader and will not work if they have attacked or been attacked in the last 6 seconds. note that inside the module i already have the recall item with unique power that  teleports the player back to home town. 



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
recall script
« Reply #9 on: September 12, 2014, 12:13:20 am »


               

This should work:


 


#include "x2_inc_switches"

void main()
{
    int nEvent = GetUserDefinedItemEventNumber(); // Which event triggered this
    object oPC;                                      // The player character using the item

    int nResult = X2_EXECUTE_SCRIPT_END;

    switch (nEvent)
    {
        case X2_ITEM_EVENT_ACTIVATE:
            oPC = GetItemActivator();             // The player who activated the item

            if (GetIsInCombat(oPC))
            {
                FloatingTextStringOnCreature("You cannot recall while in combat!", oPC, FALSE);
                return;
            }

            AssignCommand(oPC, ClearAllActions());
            AssignCommand(oPC, ActionJumpToLocation(GetLocation(GetFactionLeader(oPC))));
            break;
    }

    // Pass the return value back to the calling script
    SetExecutedScriptReturnValue(nResult);
}