[Tool] Effect creator and sphere collision

I made this code to help me place sphere effects so I could create off-limits areas. I figured it might be useful for other people, so I’m sharing the code:
BXMWV

NOTE: This is just a basic tool, I didn’t want to spend too much time making it as I found it useful enough like this

What it does:

It lets you place effects and resize them, and save their position and radius to global arrays so you can screenshot the values in the workshop inspector.
I also included a code for detecting collision with spheres and pushing the player away from them.

in-game controls:

Read the custom game description after importing the code

How do I make the effects I place spawn every time the map loads?

  1. place an effect
  2. hold crouch for a second to save it’s position
  3. open the workshop inspector
  4. click the dropdown menu and select “global”
  5. screenshot the global variables (A is the current map, B is the position of your effects, C is the radius)
  6. Look at the rule for Horizon lunar colony, and do the same thing that’s done there. At the top there are some initializing actions, then the same 5 actions are just copy pasted over and over, with the position and radius in the X and Y variables changed. The condition of the rule contains a number which is the map index.
  7. If you come here in the future, go to this page for the latest map identifier script by Xerxes.

For sphere collision, look at the bottom two rules. One is to initialize a variable, the other is to continuously check for collisions and push the player away from the spheres.

Special thanks to Xerxes for creating the map identifier script. Without it, I probably wouldn’t have made this.

6 Likes

thx for sharing (: how do i activate sphere colusion thing?

1 Like

Thank you, it’s really helpful and that saves time.

1 Like

A short answer to your question:
To get collisions to work, you have to create an array of positions in Global Variable X, and an array of radiuses in Global Variable Y, and then create your effect using those variables for position and radius. Check the “horizon lunar colony” rule to see how it’s done.


A longer answer:

There won’t be any collision with the spheres you create during gameplay, since that’s just meant to be an interactive way to get a good position and radius for your effects.

The collision detection is separate from the effect creator tool.
Maybe I should go ahead and clarify exactly what each rule is used for. (my apologies, this is way more than you asked for)

There are 4 “parts” to the code (can’t post images, so copy paste this into your browser and fix the dot):

dropbox (DOT) com/s/g2qtsqr43gr6h3o/effect_creator_components.png

Map identifier:
This sets Global Variable A to a different number depending on which map is currently active

Effect creator:
This is what lets you place spheres, change their position and radius, and when you hold crouch for a second it will store the position of the last created sphere in Global Variable B, and it’s radius in Global Variable C.

Example of how to permanently place the effects:
This is what actually places effects every time the map is loaded, and you have to add actions here for every effect you want to place. This example places 2 spheres on horizon lunar colony, and at the bottom (grayed out) is what you need to copy-paste to create additional effects. Then you need to adjust the position and radius in the actions that append to the X and Y variables, and change the effect type to the one you want in the “create effect” action.

Collision detection:
The big condition of the first rule is what detects that the player is inside any sphere. The actions try to push the player away from the center of the sphere that the player is currently inside.
If you want to do something other than push the player away, you can delete every action in the rule, and the 2nd condition, leaving you with no actions and the condition that starts with “is true for any
For example, if you want to just kill a player who steps inside any sphere, you can delete both collision detection rules and paste this to the workshop:

rule("Kill player when they step inside sphere")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is True For Any(Global Variable(X), Compare(Distance Between(Position Of(Event Player), Current Array Element), <, Add(1.500,
			Value In Array(Global Variable(Y), Index Of Array Value(Global Variable(X), Current Array Element))))) == True;
	}

	actions
	{
		Kill(Event Player, Null);
	}
}

Hey there :slight_smile:

Really awesome tool like, man ! Will be life saving for sure :smiley: I have some questions though, as a French dude whose english is not perfect, I ain’t even sure I understand the whole thing :’)

I get that the tool is just a helper to get the position of the spheres I want to create, but, is the collision automatically working as soon as I create the spheres myself with “Create Effect” ?
And is it working for all the spheres at the same time ?

And also, is it exclusively working on Horizon right now ? Or does it work on other maps ? (Because for now, it doesn’t generate collision on my spheres on Chateau Guillard).

Thanks a lot, and sorry for the big bunch of questions, I’m a real potato when it goes into coding and script logic :sweat_smile:

No. They are just colorful balls you can easily walk through.

The “collision” effect needs a seperate rule to work, that applies an impulse (direction: center of the sphere --> event player) to push the player away as soon as he enters the sphere (distance between(event player, sphere center) < radius).