Aller au contenu

Photo

Simple scripting needs help


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

#1
Leyf

Leyf
  • Members
  • 28 messages
 I have a trigger, a Drow, 2 Waypoints and a Player.

I want to enter the trigger with my PLAYER, and have the DROW, move across 2 WAYPOINTS.

How can I make this happen? I know its simple, but I couldnt seem to get it to work.. please help

#2
Morbane

Morbane
  • Members
  • 1 883 messages
//This script goes in the OnEnter of a trigger

void main()

{

object oPC = GetEnteringObject();



object oDrow = GetObjectByTag("drowTag");



location lLoc = GetLocation(GetWaypointByTag("wapointTag"));



AssignCommand(oDrow, ActionMoveToLocation(lLoc));

}

#3
Leyf

Leyf
  • Members
  • 28 messages
Excellent! If I want to change this creature to lets say a Fairy, do I have to Hard-Edit the script? Like change all of the oDrow to oFairy?

#4
MasterChanger

MasterChanger
  • Members
  • 686 messages

Leyf wrote...

Excellent! If I want to change this creature to lets say a Fairy, do I have to Hard-Edit the script? Like change all of the oDrow to oFairy?


The best thing if you're going to use this more than once would probably be to have a generic script that you put in the triggers' OnEnter events. Then, you put a variable on each specific trigger that tells the tag of the creature you want to move in this particular case, and a variable that tells it which waypoint you want it to move to.

Knightmare's tutorial talks about storing and retrieving Local variables.

#5
Leyf

Leyf
  • Members
  • 28 messages
Could you supply this "Generic Script" Im still new at this and I dont want to mess anything up..

#6
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Something like so:

void main()
{
    string sCreature = GetLocalString(OBJECT_SELF, "creature1");
    string sWaypoint = GetLocalString(OBJECT_SELF, "waypoint1");
    object oCreature = GetObjectByTag(sCreature);
    object oWaypoint = GetWaypointByTag(sWaypoint);

    AssignCommand(oCreature, ActionMoveToObject(oWaypoint));
}


You would put 2 string variables on the trigger in the toolset. One for the creature you want to move (creature1) and one for the waypoint to move to (waypoint1).

#7
Morbane

Morbane
  • Members
  • 1 883 messages
so the variables would be named "creature1" and "waypoint1" and they would have a string that is the tag of the creature and the waypoint thusly:

string creature1 = somecreaturetag

string waypoint1 = somewaypointtag

#8
Leyf

Leyf
  • Members
  • 28 messages
Thank you very much for justifying that Morbane. Im still a bit new with Variables and Scripts. But im getting better!