Spawn an item on top of a placeable?

Funny, I tested spawning on an invisible placeable for a range of items, including weapons. Those I tried worked.

Maybe some items lack a vital geometry element? Likewise, not all placeables seem to allow items to spawn on them.

1 Like

@Proleric i’d love to duplicate your results, it would make for some very cool possibilities !
maybe i’m scripting this wrong ?

to be clear, i was referring to the standard bioware placeable ‘Invisible Object’ [tag=InvisibleObject] in the ‘miscellaneous’ category, and leaving its checkbox at ‘static’. i place it in the toolset at a location w/z=2.0 and spawn the item programmatically :

object o = GetObjectByTag("InvisibleObject");
if (!GetIsObjectValid(o)) {
    SendMessageToPC(GetFirstPC(), "no invisible object !");
    return;
}
showloc(o);
location l = GetLocation(o);
object a = GetAreaFromLocation(l);
float f = GetFacingFromLocation(l);
vector v = GetPositionFromLocation(l);
v.z += 2.0;     // spawn it 2m directly above the placeable
l = Location(a, v, f);
o = CreateObject(OBJECT_TYPE_ITEM, "nw_wswmls002", l);
showloc(o);
DelayCommand(1.0, showloc(o));

the showloc() routine simply displays location data to the console.

do you notice if i’ve made some sort of mistake here ?
if not, i suppose it’s dependent on specific items. :confused:
i am personally ZERO on model building, but if that’s the case, i bet one of the modelers might have a constructive answer.

My approach was identical, except that the invisible object has the tag zTest, and the item is spawned at the invisible object. This script, run in Debug Mode, spawns a floating item:

void main()
{

  CreateObject(OBJECT_TYPE_ITEM, "nw_wswmls002", GetLocation(GetObjectByTag("zTest")));

}

// EDIT, nevermind, I didn’t see it was an item, thought you meant a placeable. I have no idea if it works with items…

I’ve done this a couple of times.
I Place an object in the toolset, where I want to spawn a new placeable, for example a copy of the placeable you want to spawn. Adjust height, facing etc.

Then have a script store the location of the placeable as a LocalLocation on some object, destroy the placeable and use the location again when you spawn the placeable via a script.
Example: From an trigger when entering area:

    object globe1 = GetObjectByTag("base_dummyglobe1");
    object pied1 = GetObjectByTag("piedestal_strong");
    SetLocalLocation(pied1,"globe",GetLocation(globe1));
    DestroyObject(globe1);
   
    (Yes, piedestal is wrong spelling...)

Then in the script that should spawn the placeable (Here it’s a conversation with the “piedestal_strong”)

object oPC = GetPCSpeaker();
location lglobe = GetLocalLocation(OBJECT_SELF,“globe”);
CreateObject(OBJECT_TYPE_PLACEABLE,“place_powerglobe”,lglobe,FALSE,“energy2_ready”); // Giving the globe the tag “energy2_ready” //

I hope this helps you.

/Pap