Aller au contenu

Photo

Problem with create object location


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
Nebril2

Nebril2
  • Members
  • 59 messages

Hi all!!

 

 

 

Im trying to create a item wich summons a placeable of a wall (muro) and two copies in each side of it so its longer.

 

 

#include "x2_inc_switches"
#include "X0_I0_POSITION"
void main()
{
 
int nEvent =GetUserDefinedItemEventNumber();
if(nEvent !=  X2_ITEM_EVENT_ACTIVATE)return;
 
 
  object oPC = GetItemActivator();
 
  location oL = GetItemActivatedTargetLocation();
 

object oMuro = CreateObject(OBJECT_TYPE_PLACEABLE,"muroarcano", oL);

  vector vMuro1 = GetPosition(oMuro);
 
 
 
 
 
 object oMuro2 = CreateObject(OBJECT_TYPE_PLACEABLE,"muroarcano", Location(GetArea(oPC), GetChangedPosition(vMuro1,5.5,180.0), GetFacing(oMuro)));
 
 
 
  
 
  object oMuro3 = CreateObject(OBJECT_TYPE_PLACEABLE,"muroarcano", Location(GetArea(oPC), GetChangedPosition(vMuro1,-5.5,180.0), GetFacing(oMuro)));
  
 

 

So, this is suppoused to create a wall and then another wall on each side.

 

 

But in game,  depends where the player is facing in the map where it puts the walls. Some times aside as i want, but in other positions it puts in diferent angles.

 

This is what i want:

|

|

|

 

Other results depending on the facing of character:

 

| | |

 

|

 |

  |

 

etc.

 

why is that?

 

 

 

 



#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

I did not have your placeble available.   So I changed it to one I could test.    Try it like this and adjust vOffsetA and nOffsetB as needed. 

#include "x2_inc_switches"
void main()
{

int nEvent =GetUserDefinedItemEventNumber();
if(nEvent !=  X2_ITEM_EVENT_ACTIVATE)return;

  object oPC = GetItemActivator();

  location oL = GetItemActivatedTargetLocation();

  object oMuro = CreateObject(OBJECT_TYPE_PLACEABLE,"x0_cagewall", oL);
  object oAreaMuro  =  GetArea(oMuro);
  vector vMuro1 = GetPosition(oMuro);
  float  fMuro1 = GetFacing (oMuro);
  // Distance offset
  float vOffsetD = 5.5;
  // offset of angle.
  int   nOffsetA = 90;

  vector vDrawOffset = AngleToVector( fMuro1+nOffsetA) * vOffsetD;

  object oMuro2 = CreateObject(OBJECT_TYPE_PLACEABLE,"x0_cagewall", Location(oAreaMuro ,vMuro1+vDrawOffset  , fMuro1));

  object oMuro3 = CreateObject(OBJECT_TYPE_PLACEABLE,"x0_cagewall", Location(oAreaMuro ,vMuro1-vDrawOffset  , fMuro1));
}