PDA

View Full Version : Code review: Individual construction distance.



Higor
07-24-2012, 07:19 PM
Point is, allow certain constructions to appear at greater or shorter distances, this will allow better ForceField and SContainer placements, more or less Teleporter possibilities, and reduce exploits like Explosives through walls, without even using trace checks.
It will also take the player's standing or crouching state into consideration for the construction.

PD: We will also fix the teleporters not being able to accept players if placed on small nooks/map edges.

Data to consider:
Player eye height (standing) = 27.
Player eye height (ducking) = 0.
Player eye height (air) = 18,9.
Player collision cylinder: Diameter=34, Height=78.
Player BSP collision block (6 faced solid, aligned to x,y,z axis): 37 (estimate) x 37 x 81.
Building placing formula: PlayerCenter - vect(0,0,8) + aim(normalized to 1) * 45.


======
Intentions:

sgTeleporter:
CollisionHeight property - change from 32 > 39

sgBuilding:
Add a new property: BuildDistance > default is 45
Subclasses of sgBuilding will have other defaults, ForceField for example should default to 70, Platform to 50, RocketCannon to 35.

sgConstructor:
Modify a line in the function PlaceIt()
Original:

test = Spawn(type, Owner,, Owner.Location - vect(0,0,8) +
vector(Pawn(Owner).ViewRotation) * 45, Pawn(Owner).ViewRotation);


New one:

test = Spawn( type, Owner, Owner.Location + vect(0,0,1) * fMax(0,Pawn(Owner).BaseEyeHeight) - vect(0,0,10) + vector(Pawn(Owner).ViewRotation) * Type.Default.BuildDistance, Pawn(Owner).ViewRotation );

The new function allows to build 2 units further down if player is crouching, higher if player is jumping (16 units further if aiming up), or to build next or beyond a ceiling if a player is standing on a platform (25 units further if aiming up) .
That is only the origin point, the sgBuilding new property will determine the distance away in the facing direction.

Gameplay changes:
Crouching and standing will now make a difference in where you're building, jumping will make buildings appear a little higher.
Distance values can be used to tweak what things we want to build further away from the player, allowing them whether to go through thick walls or not.
ViewRotation value added to spawn function, for future uses (directed cannons, directional boosting, etc)

If you consider the extra upwards and downwards distance shouldn't be greater, simply modify here ... + vect(0,0,1) * ... to ... + vect(0,0,0.7) * ...