Author Topic: Encounters not working when PC teleports to the area  (Read 540 times)

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Encounters not working when PC teleports to the area
« on: November 28, 2013, 08:14:31 pm »


               Hello again,
I want to have a small pirate village in which pirates are hostile to the player unless a pirate ship brings him there.
In other words, I have a script that increases reputation with pirate fraction and teleports the player to the new area.


location lTarget;object oTarget;

void main(){
object oPC = GetPCSpeaker();
if (GetGold(oPC) >= 1000)   {
   oTarget = GetWaypointByTag("islandpiratebay");
   lTarget = GetLocation(oTarget);
   if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
   AssignCommand(oPC, ClearAllActions());
   AssignCommand(oPC, ActionJumpToLocation(lTarget));
   AssignCommand(oPC, TakeGoldFromCreature(1000, oPC, TRUE));
            if (GetLocalInt(oPC, "piraterep")== 0)            {            object oReptarget = GetObjectByTag("pirate_object");
            AdjustReputation(oPC, oReptarget, 15);
            SetLocalInt(oPC, "piraterep", 1);
            }
   }else   {   AssignCommand(GetObjectByTag("piratesailor"), ActionSpeakString("No gold, no sailin'!"));
   }
}


The pirates themselves are supposed to appear via encounters (to make them respawn), but the problem is, whenever I arrive in the village by teleporting there (with the above script), no pirates appear at all.
They do appear, though, if I set the starting point in this area, or if I come here from another area (without the script).

I have no idea what might cause this, so if anyone could help, I'd appreciate it.

Thanks. ':?'
               
               

               


                     Modifié par Grani, 28 novembre 2013 - 08:18 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Encounters not working when PC teleports to the area
« Reply #1 on: November 29, 2013, 02:59:27 am »


               Just to be clear, you're teleporting the PC INTO the encounter trigger and this does not work?  But having them START in the encounter trigger does work?

Also, try commenting out the reputation stuff and seeing what happens.
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Encounters not working when PC teleports to the area
« Reply #2 on: November 29, 2013, 05:57:44 am »


               

MagicalMaster wrote...

Just to be clear, you're teleporting the PC INTO the encounter trigger and this does not work?  But having them START in the encounter trigger does work?

Also, try commenting out the reputation stuff and seeing what happens.


Pretty much.
I tried both making the encounter triggers cover the waypoint PC is teleported to and not cover it (so that PC doesn't trigger it when they are teleported, but soon afterwards if they move).
It didn't work either way.

I'll try commenting rep part off when I come back from university today and report if it's helped or not.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Encounters not working when PC teleports to the area
« Reply #3 on: November 29, 2013, 06:22:18 am »


               What faction are the encounters.   is there a difference between the faction of the encounter and the faction of the pirates.  If there is not, with what you are trying to do, there should be. The faction of the encounter is only used to determine if it spawns or not.  It will only spawn if the creature stepping into it is hostile to the faction.   The faction of the encounter does not effect the faction of the creatures it spawns.
               
               

               
            

Legacy_Grani

  • Hero Member
  • *****
  • Posts: 1040
  • Karma: +0/-0
Encounters not working when PC teleports to the area
« Reply #4 on: November 29, 2013, 02:00:38 pm »


               I found the culprit.

While the faction of the encounters was set to default hostile one, and not to the pirate one, Lightfoot8's comment helped me realize that maybe I forgot to change the fraction of the object that is used to determine which fraction the reputation should be gained with (tagged "pirate_object").

And, indeed, its fraction was set to "Hostile" and not "Pirate".
Thanks for help!
               
               

               


                     Modifié par Grani, 29 novembre 2013 - 02:00 .