Author Topic: Problem with create object location  (Read 400 times)

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Problem with create object location
« on: September 10, 2015, 04:54:20 pm »


               

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?


 


 


 


 



               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Problem with create object location
« Reply #1 on: September 11, 2015, 02:43:58 am »


               

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));
}