This article's documentation is for anything that uses the Source engine. Click here for more information.

keyframe_rope/move_rope

From Valve Developer Community
(Redirected from Move rope)
Jump to: navigation, search
English (en)Translate (Translate)

keyframe_rope/move_rope is a point entity available in all Source Source games.

Class hierarchy
CRopeKeyframe
CBaseEntity
rope.cpp

It is an entity that marks a point in a rope. This entity can be shown as keyframe_rope or move_rope, but the two are completely identical in code.

First entity in a rope chain should be move_rope with Next Keyframe being set to some keyframe_rope. That way the rope will be properly visualized in Hammer and shift-dragging keyframe_rope will properly connect to the previous one.

Note.pngNote:Only Hammer requires a move_rope followed by a keyframe_rope, the game itself doesn't care which combination is used. Hammer++ Hammer++ removes this limitation.
Tip.pngTip:Holding Shift while moving a properly named keyframe_rope will create a new keyframe_rope entity that is automatically connected to the previous keyframe. Also, deleting a keyframe_rope within a connected series will update the other entities to re-connect to the next entity in the series.
Note.pngNote:In Team Fortress 2 and Counter-Strike: Global Offensive, this entity will automatically have festive lights applied to its model during the winter holiday season. These lights are purely cosmetic and do not emit light. This can be disabled in Team Fortress 2 via tf_gamerules.
Todo: See if this can also be disabled in Counter-Strike: Global Offensive
Icon-Important.pngImportant:This is a preserved entity in Counter-Strike: SourceHalf-Life 2: DeathmatchPortalTeam Fortress 2Portal 2Counter-Strike: Global Offensive.
  • On a new round entities with this classname will intentionally not reset. You can use logic_auto to emulate resetting it.
  • Killing it removes it forever, as it is not respawned on a new round.
  • It cannot be spawned with a point_template.
  • Parenting this with non preserved entities may have undesirable effects.
Warning.pngWarning:This entity cannot be parented in multiplayer titles as it is a preserved entity. In Team Fortress 2, this can be fixed with VScript by assigning the following script to any rope entity that needs to move.

if (!("RopeFix" in getroottable()))
{
	::RopeFixListener <- SpawnEntityFromTable("logic_eventlistener", 
	{ 
		eventname    = "teamplay_round_start",
		IsEnabled    = true,
		OnEventFired = "worldspawn,RunScriptCode,RopeFix.SpawnRopes(),-1,-1",
	});
	RopeFixListener.KeyValueFromString("classname", "move_rope"); // preserve
	::RopeFix <-
	{
		SpawnRopes = function()
		{
			local table = {}		
			local len = ropes.len();
			for (local i = 0; i < len; i++)
				table[i] <- { move_rope = ropes[i] };
			SpawnEntityGroupFromTable(table);
		},
		ropes = [],
	};
}

function OnPostSpawn()
{
	local kv = 
	{
		origin       = self.GetOrigin(),
		angles       = self.GetAbsAngles(),
		targetname   = NetProps.GetPropString(self, "m_iName"),
		parentname   = NetProps.GetPropString(self, "m_iParent"),
		spawnflags   = NetProps.GetPropInt   (self, "m_spawnflags"),
		NextKey      = NetProps.GetPropString(self, "m_iNextLinkName"),
		Slack        = NetProps.GetPropInt   (self, "m_Slack"),
		TextureScale = NetProps.GetPropFloat (self, "m_TextureScale"),
		Subdiv       = NetProps.GetPropInt   (self, "m_Subdiv"),
		ScrollSpeed  = NetProps.GetPropFloat (self, "m_flScrollSpeed"),
		RopeMaterial = NetProps.GetPropString(self, "m_strRopeMaterialModel"),
	}
	
	local segments = NetProps.GetPropInt(self, "m_nSegments");
	if (segments == 10)
		kv.Type <- 0;
	else if (segments == 4)
		kv.Type <- 1;
	else if (segments != 5)
		kv.Type <- 2;
		
	local lockedpoints = NetProps.GetPropInt(self, "m_fLockedPoints");
	if (!(lockedpoints & 2))
		kv.Dangling <- 1;
		
	local flags = NetProps.GetPropInt(self, "m_RopeFlags");
	if (flags & 32)
		kv.NoWind <- 1;
	if (flags & 16)
		kv.Breakable <- 1;
	if (flags & 4)
		kv.Collide <- 1;
	if (flags & 2)
		kv.Barbed <- 1;
	
	RopeFix.ropes.append(kv);
	
	self.KeyValueFromString("classname", "kill_rope"); // don't preserve
}

Keyvalues

Name (targetname) <string>
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Next KeyFrame (NextKey) <targetname>
Name of the next keyframe along this keyframe path.
Slack (Slack) <integer>
How much extra length the rope has (by default it has the length between its two endpoints in the editor).
Type (Type) <choices>
Rope type.
  • 0 : Rope
  • 1 : Semi-rigid
  • 2 : Rigid
Subdivision (Subdiv) <integer>
Number of subdivisions between each rope segment. Maximum value is 8. Higher values make smoother ropes, but are slower to render.
Barbed (Barbed) <boolean>
Test effect that makes the rope look sharper and more barbed.
Width (1-64) (Width) <string>
Width of the rope. Decimal values lower than 1 may also be used.
Texture Scale (TextureScale) <string>
This changes the texture resolution. The default resolution is 4 pixels per inch. Larger values stretch the texture and smaller values scrunch it up.
Collide with world (Collide) <boolean>
If set, the rope collides with world. Ropes never collide with anything else.
Start Dangling (Dangling) <boolean>
If set, the rope starts out detached from its target endpoint.
Breakable (Breakable) <boolean>
If set, the rope can be detached from either endpoint when shot.
Note.pngNote:If collide with world is set, the rope will not appear to break if the endpoint touches world geometry. This includes touching vertices and edges of brushes as well as being placed inside them.
Rope Material (RopeMaterial) <material>
The material to use when rendering the rope.
Note.pngNote:Source will not render ropes using the cable/chain.vmt material.
UseWind (UseWind) <boolean> (in all games since Left 4 Dead)
When set to yes, the rope sways with the settings specified in the env_wind entity. Replaces "Disable Wind" in games post Alien Swarm.
This is very expensive, and when overused can cause the world to not render properly, while the console continuously spews out "Scene is too complex".
If you need to have swinging ropes, it might be less expensive to make a model of a rope, that is animated via bones.
Disable Wind (NoWind) <boolean> (only in Day of Defeat: Source)
If set, the rope will no longer act as though it's being affected by wind.
Position Interpolator (PositionInterpolator) <choices>
Curve Type. Currently only type 2 (Rope) is fully supported.
  • 0 : Linear
  • 1 : Catmull-Rom Spline
  • 2 : Rope
Note.pngNote:This is only in the FGD for move_rope, but is functional on both entities.
Note.pngNote:This keyvalue is shown, but is locked in all games with TeamSpen's Hammer Addons TeamSpen's Hammer Addons installed

Flags

  •  Auto Resize : [1]
          Allows the rope to "stretch" as the entity moves.

Inputs

SetScrollSpeed <float>
Set the speed at which the texture scrolls.
SetForce <string>
Apply a force instantaneously to the rope. The parameter should be a vector containing the force to be applied (X Y Z).
Break
Break the rope, if it's marked to do so.