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.
recall script
#1
Posté 07 septembre 2014 - 05:48
#2
Posté 07 septembre 2014 - 07:12
How will you be determining what the waypoint is? Is it static or dependent on a variable?
#3
Posté 07 septembre 2014 - 07:14
its static
#4
Posté 07 septembre 2014 - 08:23
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);
}
#5
Posté 07 septembre 2014 - 09:14
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?
#6
Posté 07 septembre 2014 - 05:09
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?
#7
Posté 07 septembre 2014 - 08:03
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.
#8
Posté 07 septembre 2014 - 10:42
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.
#9
Posté 09 septembre 2014 - 08:10
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.
#10
Posté 11 septembre 2014 - 11:13
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);
}





Retour en haut






