Back to home

Draw With Beams

CXPM5
click to copy
This game is archived.
If you with to unarchive it, click the "restore" button in the options menu.

Category:
Other

Author:
Netux

Rating:
5

Version:
1.0.0

Posted:
18 days ago

Last updated:
10 days ago

Tags:
drawing beam draw beams

Share this workshop!

Options

Warning

Due to limitations with the workshop, up to 116 beams can be created at once. Once the limit is reached, this code will start removing old ones!

Controls

Hold primary fire to start a beam, release it to end it. Press Interact + Crouch to remove your last beam. Hold crouch to move slower.

Examples

Cat Face

rule("Setup player")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	actions
	{
		Disallow Button(Event Player, Primary Fire);
		Set Damage Dealt(Event Player, 0);
		Set Damage Received(Event Player, 0);
	}
}

rule("Set first point when holding Primary Fire")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Button Held(Event Player, Primary Fire) == True;
	}

	actions
	{
		Set Player Variable At Index(Event Player, D, 0, Ray Cast Hit Position(Eye Position(Event Player), Add(Eye Position(Event Player),
			Multiply(Facing Direction Of(Event Player), 2)), Empty Array, All Players(All Teams), False));
		Create Beam Effect(Event Player, Grapple Beam, Value In Array(Player Variable(Event Player, D), 0), Ray Cast Hit Position(
			Eye Position(Event Player), Add(Eye Position(Event Player), Multiply(Facing Direction Of(Event Player), 2)), Empty Array,
			All Players(All Teams), False), White, Visible To Position and Radius);
		Set Player Variable At Index(Event Player, D, 1, Last Created Entity);
	}
}

rule("Set second point when releasing Primary Fire")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Button Held(Event Player, Primary Fire) == False;
		Value In Array(Player Variable(Event Player, D), 0) != Null;
	}

	actions
	{
		Create Beam Effect(All Players(All Teams), Grapple Beam, Value In Array(Player Variable(Event Player, D), 0),
			Ray Cast Hit Position(Eye Position(Event Player), Add(Eye Position(Event Player), Multiply(Facing Direction Of(Event Player),
			2)), Empty Array, All Players(All Teams), False), White, Visible To);
		Set Global Variable At Index(D, Count Of(Global Variable(D)), Append To Array(Append To Array(Empty Array, Last Created Entity),
			Event Player));
		Skip If(Compare(Value In Array(Global Variable(D), 116), ==, Null), 2);
		Destroy Effect(Value In Array(Value In Array(Global Variable(D), 0), 0));
		Set Global Variable(D, Remove From Array(Global Variable(D), Value In Array(Global Variable(D), 0)));
		Destroy Effect(Value In Array(Player Variable(Event Player, D), 1));
		disabled Set Player Variable At Index(Event Player, D, 0, Null);
		Set Player Variable At Index(Event Player, D, 1, Null);
	}
}

rule("Erase last beam on pressing Interact and Crouching at the same time")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Button Held(Event Player, Crouch) == True;
		Is Button Held(Event Player, Interact) == True;
	}

	actions
	{
		Set Player Variable At Index(Event Player, D, 3, Last Of(Filtered Array(Global Variable(D), Compare(Value In Array(
			Current Array Element, 1), ==, Event Player))));
		Skip If(Compare(Value In Array(Player Variable(Event Player, D), 3), ==, Null), 2);
		Destroy Effect(Value In Array(Value In Array(Player Variable(Event Player, D), 3), 0));
		Set Global Variable(D, Remove From Array(Global Variable(D), Value In Array(Player Variable(Event Player, D), 3)));
		Set Player Variable At Index(Event Player, D, 3, Null);
	}
}

rule("Lower movement speed while crouching")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Crouching(Event Player) == True;
	}

	actions
	{
		Set Move Speed(Event Player, 50);
	}
}

rule("Increase movement speed while not crouching")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Crouching(Event Player) == False;
	}

	actions
	{
		Set Move Speed(Event Player, 100);
	}
}

rule("HUD")
{
	event
	{
		Ongoing - Global;
	}

	actions
	{
		Create HUD Text(All Players(All Teams), Null, Null, String("{0} {1}", String("Primary Fire", Null, Null, Null), String("{0}:{1}",
			String("", Null, Null, Null), String("-> {0}", String("{0} {1}", String("Start", Null, Null, Null), String("Drawing", Null,
			Null, Null), Null), Null, Null), Null), Null), Left, 2, White, White, Yellow, Visible To and String, Visible Never);
		Create HUD Text(All Players(All Teams), Null, Null, String("{0} {1}", String("{0} and {1}", String("Interact", Null, Null, Null),
			String("Crouch", Null, Null, Null), Null), String("{0}:{1}", String("", Null, Null, Null), String("-> {0}", String("{0} {1}",
			String("Destroy", Null, Null, Null), String("Final Object", Null, Null, Null), Null), Null, Null), Null), Null), Left, 3,
			White, White, Yellow, Visible To and String, Visible Never);
		Create HUD Text(All Players(All Teams), Null, Null, String("{0} {1}", String("Crouch", Null, Null, Null), String("{0}:{1}", String(
			"", Null, Null, Null), String("-> {0}", String("{0} {1}", String("Slow", Null, Null, Null), String("Down", Null, Null, Null),
			Null), Null, Null), Null), Null), Left, 4, White, White, Yellow, Visible To and String, Visible Never);
	}
}

rule("Beam limit reached HUD")
{
	event
	{
		Ongoing - Global;
	}

	conditions
	{
		Count Of(Global Variable(D)) >= 116;
	}

	actions
	{
		Create HUD Text(All Players(All Teams), Icon String(Bolt), String("{0}, {1}", String("Sorry", Null, Null, Null), String("", Null,
			Null, Null), Null), String("{0} {1}", String("Drawing", Null, Null, Null), String("Limited", String("Limited", Null, Null,
			Null), Null, Null), Null), Left, 1, Red, Red, Red, Visible To and String, Default Visibility);
	}
}