Modme Forums

Steps that rise out of the ground using an array.

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: Dextro62

I have made steps that will rise out of the ground when the player walks through a trigger but Im not sure how to make it work using an array.
This is my current code:

function touch_steps1()
{
	trig = GetEnt("step1_trig","targetname");
	clip = GetEnt ("step1_clip","targetname");
	step1 = GetEnt("step1.1","targetname");
	step2 = GetEnt("step1.2","targetname");
	step3 = GetEnt("step1.3","targetname");
	step4 = GetEnt("step1.4","targetname");
	step5 = GetEnt("step1.5","targetname");
	step6 = GetEnt("step1.6","targetname");
	step7 = GetEnt("step1.7","targetname");

	trig waittill ("trigger",player);

	step1 MoveZ (11,1);
	step2 MoveZ (22,2);
	step3 MoveZ (33,3);
	step4 MoveZ (44,4);
	step5 MoveZ (55,5);
	step6 MoveZ (66,6);
	step7 MoveZ (77,7);

	player PlaySound ("d_move_10_steps");
	flag::set (trig.script_flag);
	trig delete();
	wait 7;
	
	clip delete();
	wait 1;
}


ModmeBot:

Reply By: mathfag
You could do something like this:

All the steps would have the targetname"steps" and the clip would be "steps_clip".
To the steps you would need to add another KVP called index and number the steps (first step would be index-0, second would be index-1... (KVP is index, value is an intiger, starting with 0)).

increments*steps[i].index

multiplies the increment variable with the index of the step which makes the whole thing look like stairs.

You could also make the index of each step the value of how much it must rise and change the code to
steps[i] MoveZ(steps[i].index,,[acceleration time],[deceleration time]);

<hr>
function steps()
{
steps = GetEntArray("steps","targetname");
clip = GetEnt("steps_clip","targetname");

increments = 10;

for( i=0;i&lt;steps.size;i++ )="" {="" steps[i]="" movez(increments*steps[i].index,,[acceleration="" time],[deceleration="" time]);="" }="" clip="" movez(,,[acceleration="" time],[deceleration="" time]);=""&gt;&lt;/steps.size;i++&gt;


*Have not tested this.*


ModmeBot:

Reply By: Dextro62
Thanks This worked, I changed a bit of it though. This is what I ended up with:

function steps()
{
	steps = GetEntArray("steps","targetname");
	trig = GetEnt ("steps_trig","targetname"); 

	increments = 11;
	time = 1;
	trig waittill ("trigger",player);

	player PlaySound("d_move_10_steps");

	for( i=0;i&lt;steps.size;i++ )="" {="" steps[i]="" movez="" (increments*steps[i].index,time);="" time="time" +="" 1;="" }=""&gt;&lt;/steps.size;i++&gt;