Aller au contenu

Photo

CreateObject -.2 down the Z axis


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

#1
GIANTSWORD

GIANTSWORD
  • Members
  • 88 messages

PC adds firewood to their fire turning the campfire placeable into a bonfire placeable.

 

Is it possible to spawn it in the exact location of the old campfire but bring it down -.2 the Z axis?

 

Here is what I have so far.  The bonfire placeable just isn't appearing at all.  Thanks in advance!

 

location lTarget;
location lTarget1;
object oTarget;
object oItem;
 
#include "nw_i0_2q4luskan"
void main()
{
object oPC = GetPCSpeaker();
if (GetItemPossessedBy(oPC, "wood_firewood")!= OBJECT_INVALID)
    {
    AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0f, 5.0f));
    oItem = GetItemPossessedBy(oPC, "wood_firewood");
    if (GetIsObjectValid(oItem))    DestroyObject(oItem);
 
    oTarget = GetObjectByTag("FIRE");
    DelayCommand(3.0, DestroyObject(oTarget, 0.0));
 
    lTarget = GetLocation(oTarget);
    vector vCurrentPosition = GetPosition(oTarget);
    vector vNewPosition = Vector();
    vNewPosition.x= vCurrentPosition.x;
    vNewPosition.y= vCurrentPosition.y;
    vNewPosition.z= vCurrentPosition.z - 0.20;
    location lTargetl= Location(OBJECT_SELF, vNewPosition, 0.0);
 
    DelayCommand(1.5, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "bonfireflame", lTarget));
    DelayCommand(3.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "bonfire", lTarget1));
    DelayCommand(3.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_smokeb", lTarget));
    DelayCommand(3.0, FloatingTextStringOnCreature("The fire begins to roar!", oPC));
    }
else
    {
    SendMessageToPC(oPC, "You don't have any firewood");
    }
}


#2
Proleric

Proleric
  • Members
  • 2 359 messages

What you're doing with the z-axis is fine. Your code could be simplified, but I suspect that the big problem is Location(OBJECT_SELF, vNewPosition, 0.0). The first parameter should be the area (e.g. GetArea(oPC)).



#3
GIANTSWORD

GIANTSWORD
  • Members
  • 88 messages

Changed it to the area and still no dice.



#4
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

I've always done my vectors a little different. Maybe try it like so?

 

 

#include "nw_i0_2q4luskan"
void main()
{
    object oPC = GetPCSpeaker();
    object oWood = GetItemPossessedBy(oPC, "wood_firewood");

    if (oWood != OBJECT_INVALID)
    {
        object oFire = GetObjectByTag("FIRE");
        object oArea = GetArea(oFire);
        vector vCurrentPosition = GetPosition(oFire);
        float fX = vCurrentPosition.x;
        float fY = vCurrentPosition.y;
        float fZ = vCurrentPosition.z - 0.2;
        vector vNewPosition = Vector(fX, fY, fZ);
        location lTarget = Location(oArea, vNewPosition, 0.0);

        AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0f, 5.0f));
        DestroyObject(oWood);
        DestroyObject(oFire, 3.0);
        DelayCommand(1.5, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "bonfireflame", lTarget));
        DelayCommand(3.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "bonfire", lTarget));
        DelayCommand(3.0, CreateObjectVoid(OBJECT_TYPE_PLACEABLE, "zep_smokeb", lTarget));
        DelayCommand(3.0, FloatingTextStringOnCreature("The fire begins to roar!", oPC));
    }

    else
    {
        SendMessageToPC(oPC, "You don't have any firewood");
    }
}

 

 

Hope it helps.



#5
Proleric

Proleric
  • Members
  • 2 359 messages

What object / event is running the script? Does everything work except for the bonfire placeable? Have you checked that its resref (not tag) is "bonfire"?



#6
GIANTSWORD

GIANTSWORD
  • Members
  • 88 messages

The event is a conversation that appears when you click a campfire.  Adding wood runs the script above.  The resref is correct and works when I take out the vector part of the script.  So it does spawn in correctly until I try to mess with the Z axis using vectors.

 

GhostOfGod, thank you.  I'll try that version and see if it works.



#7
WhiZard

WhiZard
  • Members
  • 1 204 messages

 


        location lTargetl= Location(OBJECT_SELF, vNewPosition, 0.0);

 

 

 

This is your problem.  You defined lTargetl and never used it.  (You used lTarget and lTarget1 which were also defined).



#8
GIANTSWORD

GIANTSWORD
  • Members
  • 88 messages

Thanks WhiZard!



#9
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

I've always done my vectors a little different. Maybe try it like so?
 
 
...
      
        vector vCurrentPosition = GetPosition(oFire);
        float fX = vCurrentPosition.x;
        float fY = vCurrentPosition.y;
        float fZ = vCurrentPosition.z - 0.2;
        vector vNewPosition = Vector(fX, fY, fZ);
        location lTarget = Location(oArea, vNewPosition, 0.0);

...       
 
Hope it helps.

 
 
This is not a correction. But I do my vectors a little different also.  
Instead of taring the vector apart to adjust it. I find it simpler to just add the vector of change to it.  
like so:
 
...
      
        vector vCurrentPosition = GetPosition(oFire);
        vector vNewPosition = vCurrentPosition + Vector(0.0, 0.0, -0.2);
        location lTarget = Location(oArea, vNewPosition, 0.0);

...

 

Or simply

 

    vector vNewPosition = GetPosition(oFire) + Vector(0.0, 0.0, -0.2);

    location lTarget = Location(oArea, vNewPosition, 0.0);

 

 

Just another way to look at it. 


  • kalbaern et GhostOfGod aiment ceci