Direction settings in all.spawn.

Discussions on Modding of S.T.A.L.K.E.R. SoC & Clear Sky

Direction settings in all.spawn.

Postby EggChen on 06 Nov 2008 22:12

Anyone actually understand these? The direction I get from the ZRP function returns two values (dx and dz)... now in all.spawn a direction has three values (x,y and z presumably).

The x and z numbers from ZRP do not change when you look up or down, they only change when you turn left or right, and both change.

However, no matter how I use these in all.spawn the item does not seem to point where I want it to. I have only managed through much trial and error, which is a pain starting a new game every time!!

In all.spawn I have learnt that you only need alter the 2nd value to turn things on a horizontal plane. So for example 0,1,0 and 0,1.2,0 would work.

Thing is if you go too high with the middle number (somewhere over 2.5) acdc will not compile properly.

Is there a simple key?? Like 0 = north, 0.9 = east, etc, etc. at least then I would know roughly what figure to start with.
User avatar
EggChen
Moderator
 
Posts: 1016
Joined: 13 Sep 2008 00:44
Location: Birmingham, UK

Re: Direction settings in all.spawn.

Postby Victim on 24 Nov 2008 14:29

EggChen wrote:Thing is if you go too high with the middle number (somewhere over 2.5) acdc will not compile properly.


My memory has faded so far as SoC is concerned so these CS values may not actually work as you desire in SoC:

direction = 0,0,0

0,0,0 = facing East
0,1.5,0 = facing North
0,-1.5,0 = facing South
0,3,0 = facing West


And I generally try to place everything on a flat surface because the rotational values are mind-bendingly sensitive.

This object is standing vertically upright:

direction = -9.99999974737875e-006,0,9.99999997475243e-007

The one below is lying flat on the floor:

direction = -4.30000019073486,0,2.5

It's a bottle - IIRC it isn't the -4.3 which 'tips' the bottle but is actually the 2.5 - so how 90degrees is translated from 9.99 to 2.5 is anybodies guess.

And then stuff like this:

direction = 2.49999993684469e-005,-1.05120003223419,-1.49999996210681e-005

That just makes my brain hurt - and you're dead right: having to start a new game a dozen times just to nail the right position for many of the games items is incredibly painful. I quite often just let gravity do it's thing now by spawning some stuff slightly above the terrain/mesh where I'd like it to be.

EDIT/ Just to mention that in CS a 'smart_cover' will take priority over any NPC position, including directions, so if you create an NPC and assign it a smart_cover, it'll ignore its own creation settings in favor of the cover settings. It's not relevant to SoC though.

EDIT#2/ Just looking at this for a minute: so how 90degrees is translated from 9.99 to 2.5 is anybodies guess.

I wondered if this is how it actually works: (rounding 9.999)

----->----10----v
-------7.5-------2.5
-----^----5----<

Probably way off but I'll have to try it out sometime now to know for sure.
Victim
Senior Resident
 
Posts: 19
Joined: 22 Nov 2008 11:57

Re: Direction settings in all.spawn.

Postby EggChen on 24 Nov 2008 22:26

Victim wrote:My memory has faded so far as SoC is concerned so these CS values may not actually work as you desire in SoC:

direction = 0,0,0

0,0,0 = facing East
0,1.5,0 = facing North
0,-1.5,0 = facing South
0,3,0 = facing West


Thanks, I'll give that a try.

It doesn't really matter with mutants or NPC's, but some objects do, like APC's for example.

The reason I asked is I was trying to get a megaphone on a wall in the Bandit base in DarkValley, I got it eventually, but the minor tweaks needed were hurting my head too!! Your right, the rotational settings were bad, but I think I struck lucky when I copied the position for the megaphone in Cordon as a base.

The sum of all this was, Bandit radio is on air!!

Thanks again.
User avatar
EggChen
Moderator
 
Posts: 1016
Joined: 13 Sep 2008 00:44
Location: Birmingham, UK

Re: Direction settings in all.spawn.

Postby NatVac on 30 Nov 2008 05:46

Victim wrote:direction = 0,0,0

0,0,0 = facing East
0,1.5,0 = facing North
0,-1.5,0 = facing South
0,3,0 = facing West

That's useful info, Victim. Thanks for posting it.

>> direction = -9.99999974737875e-006,0,9.99999997475243e-007

I always round those. The floating point exponent can be misleading. Here it means "times ten to the minus 6" for the first value, and "times ten to the minus 7" for the third. That becomes:

direction = -0.00000999999974737875,0,0.000000999999997475243

Essentially, that means it's "direction = 0, 0, 0". So it's not 9.99 that is followed by 2.5, but 0.0 -- the way you expected.

Ergo: You're not crazy. But you might be blind. :)
NatVac
Resident
 
Posts: 152
Joined: 16 Sep 2008 00:13
Location: Texas

Re: Direction settings in all.spawn.

Postby Victim on 01 Dec 2008 08:09

NatVac! Unfortunately the name brings back a memory of a promise not kept...I recall making some HUD/Inventory/UI? adjustments for you that I never completed - I offer my most humble apologies for letting you down - I think that real life had caught up with me at about the time that I'd started making those changes. If you need a favor in the future, just ask and I'll make sure that it's done. :)

On topic: With regards to NPC direction - it seems as though using direction settings other than '0,0,0' are ignored (or rather, are not reliable) when an NPC is spawned to a position from which it will not move. Example: You spawn an NPC at point 'X' with direction settings '0,-1.1,0' and it'll only sometimes face the desired direction [saving and loading tends to alter the direction as can any other number of variables] so I've found that the easiest way to be sure that an NPC will always be facing the desired direction is to spawn it slightly offset in an opposite direction to the one in which you want it to be facing - then you'd simply set your "_look" position to the true position in the "way..." file. This will ensure that when the NPC is spawned, it will then turn and move to the "_look" position as that overrides the actual spawning position.
Victim
Senior Resident
 
Posts: 19
Joined: 22 Nov 2008 11:57

Re: Direction settings in all.spawn.

Postby NatVac on 04 Dec 2008 11:27

Victim, I don't remember you making any promises. I think I'd said that if you supplied one, I'd include it in the ZRP distribution. You did get me into image editing with GIMP (that is an amazing program), so I'm thankful for that.

On the direction stuff: Here's what I think:

Think right-hand rule: point your right-hand thumb in the positive direction of the axis in question, and the fingers will curl in the positive direction for the rotation. The directive "direction = x, y, z" means apply rotation about the specified axes according to the values. The values x, y, z are in radians, and there are 2π (2*pi, ~6.28) radians in a circle.

For live NPCs, only the Y-axis is pertinent. To adapt your diagram, this is looking down on the NPC from above:
-------<----- 0 ----^
-------1.57-------4.71
-------v----3.14---->

You can also use negative values, so pointing south would be either 3.14 or -3.14 (+3 or -3 rounding), east would be -1.57 and west -4.71. 1.57079637050629 is the common value used in the all.spawn file for west-facing objects (e.g., the switch that frees Shaggy), but you might see 1.5722... or 15712... -- and the actual value of pi/2 (90 degrees) is closer to 1.570796327.

You can look at the bottles of vodka in the bandit armory in the all.spawn file. Only the Y-axis value is changed on the direction to rotate the bottle so that the label faces in realistically different ways.

For objects like anomalies, you can apply rotation to the other axes. This was done for one of the Electro anomalies just south of the SoC Army Warehouses village, but not another, so that one sticks out of the hillside (fixed for next ZRP release). To tilt it so it slants down to the northeast, use a small negative X value like -0.33 and a small positive Z value. Again, think right-hand rule. Point thumb to east for X value; tilting north would then be negative.

Also, while I think your "look" approach is pretty neat (it enforces the correct direction even when you don't know the rotation scheme), I suspect that the original numbers were misread. Recall that "-9.99e-006" is -0.00000999, or essentially zero. The upright object has a direction that is, for all practical purposes, 0, 0, 0. Meanwhile, I'll have to look at the rotations for the bottle lying on the floor. It might have fallen from a wonky rotation position that was not "upright".

Think how much grief we could have avoided with some good SDK documentation. ](*,)
NatVac
Resident
 
Posts: 152
Joined: 16 Sep 2008 00:13
Location: Texas


Return to Modding Techniques

Who is online

Users browsing this forum: No registered users and 17 guests