Skip to content

dotthegod/CS2-Logic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 

Repository files navigation

CS2-Logic

CS2 Entity logic document to people understand

Inputs and Outputs

You will use inputs and outputs to work on the entites.

Output

image

Outputs look like this.

My output named: This is the place you will sellect when your output will be fired. It depends to what is your entity is but OnUserX ones is useable at all entites. OnUserX outputs can be fired with FireUserX input.

Target entities named: Is your target entity that you want to input. !self fires for the entity itself, !activator fires for the who makes this output fire(like if a button pressed by a player and it has this output it the input goes to the player) (it can be different sometimes), !caller also works like !activator but prefer !activator if you dont know what you are doing,

Via this input: Is what do you want that entity to do. It depends on the your target entity.

With a parameter override of: When you use some inputs you need to use a parameter to change at the target entity.

After the delay of: Is the amount of time for it to fire this output.(PSA: If you use 0.01 and rapidly use that output it wont be fired 100 at 1 second. IIRC it fires 66 per second)

Fire once only: This checkbox makes the output fired once in every round

Logic Entites

There is bunch of logic entites out there but we will use few of them:

-logic_auto

-logic_case

-logic_compare

-logic_relay

-logic_eventlistener

logic_auto

logic_auto is a logic entity that does its job auto. We most of the time use it with the OnMapSpawn output with point_servercommand entity to set console commands for our maps (you can also add it to your maps cfg). OnMapSpawn output fires once every round. So you can use it however you need.

logic_case

logic_case is a logic entity that you can use to trigger various outputs from it.

image

It has a randomizing feature which we can use to get random outputs.

I will be telling more about logic_case later on the document.

logic_compare

logic_compare is a logic entity that lets you compare values. It can be useful with point systems.

I will be telling more about logic_compare later on the document.

logic_relay

logic_relay is like a packet of outputs. If you are similar with coding you can think this as functions. If you want some entites to fire same output you can use logic_relay

logic_eventlistener

logic_eventlistener is a logic entity that listens events that happen in the game like anyone dead or shots fired.

!! IT CAN'T LISTEN ANYONE SPESIFIC AND USE AS !activator !!

You can find events that you can use in this website.

(I'm not really sure if all of these work)

Point entites

I don't really know how to define this entites but chatgpt says this:

Point entities are non-physical objects placed at a single point in the 3D world. They do not have any physical geometry (brushes or models that block movement) and are often used to control gameplay mechanics, visuals, audio, or logic.

They are called “point” entities because they exist at a specific origin point in the map and are usually represented by a small icon in the editor.

We will be using this entites for basics:

-point_servercommand

-point_teleport

-point_worldtext

-point_soundevent

point_servercommand

point_servercommand lets you use console commands via its Command input.

point_teleport

point_teleport lets you teleport entities. Some people use trigger_teleport to teleport something but i like using point_teleport much more. You put this entity to wherever you want entites to be teleport.

I most of the time use TeleportEntityToCurrentPos output because it lets you change the parameter to whatever you want to teleport to it.

image

Like in this screenshot when entity gets FireUser1 input it teleports ball1 entity to the position of point_teleport.

point_worldtext

point_worldtext lets you write texts to the world. You can use most of the fonts that avaible in Windows.

image

point_soundevent

point_soundevent lets you play sounds in the position of the entity.

Triggers

image

With triggers you can detect:

-If something inside the trigger (trigger_multiple)

-If someone looking to the trigger (trigger_look)

-If you want to damage to someone which inside the trigger (trigger_hurt)

-If you want to push someone in trigger (trigger_push)

-If you want to teleport (trigger_teleport)

(Triggers does not detect other entities than players at start. You need to change it from spawnflag if you want to detect props etc.)

trigger_multiple

With trigger_multiple you can detect/do:

-If player exitted the trigger

-If player entered the trigger

-If is there any player in trigger when TouchTest input fired

-Trigger output for each player inside the trigger when TouchTest input fired (Personal favorite)

For the outputs you can use these:

OnStartTouch: Output fires when entity touches it.

OnEndTouch: Output fires when entity stops touching it.

OnTouching: Output fires when TouchTest input came and someone inside the trigger.

OnTouchingEachEntity: Output fires for each person when TouchTest input came.

OnNotTouching: Output fires when there is nobody inside trigger when TouchTest input came.

trigger_look

You can detect if player looking at an entity while player inside the trigger.

trigger_hurt

You can hurt players when they are inside this trigger. (Also if you hurt them negative it heals the player so you can use this also healing trigger)

trigger_push

You can push entites with this trigger.

trigger_teleport

You can teleport entities with this trigger. In order to teleport players you need to put info_teleport_destination and link it to Remote Destination key in trigger_teleport.

Filters

I want to mention filters because most of the time you will use them with triggers. You can also use them to test the activator. There is some filters that you can use:

-filter_activator_class

-filter_activator_team(You need to add it to the base.fgd)

-filter_activator_context

-filter_activator_name

-filter_activator_model

filter_activator_class

filter_activator_class is a filter that lets you filter by the entities class.

image

filter_activator_team

filter_activator_team is a filter that lets you filter by the entities team. You can use this to test if activator of something (like a button) is a T or CT. It wont be able to use if you don't add it to base.fgd. You need to add it to the base.fgd

filter_activator_context

filter_activator_context is a filter that lets you filter by the if entity has a certain context. I will be explain it a lot at the context part.

filter_activator_name

filter_activator_name is a filter that lets you filter by the targetname of entity. You can't detect player names with this!

image

filter_activator_model

filter_activator_model is a filter that lets you filter by the entities model.

Contexts

Context is like a tag that you give to entity. You can use filter_activator_context to detect contexts of player. I suggest you to watch this video to understand how it works.

For add context to the entites/players you need to use AddContext input. It doesn't shows up at the dropbar but you can use it.

image

When FireUser3 input comes to our entity it will add key context to the prop1 entity.

In order to remove this context from the prop1 we need to use RemoveContext input or ClearContext

RemoveContext removes the spesific context that you add into the parameter.

image

ClearContext removes all of the contexts that entity has.

Math

There is 3 math entites but we use math_counter to do such things. I personally use math_counter a lot. You can use Add, Divide, Multiply,SetValue inputs for math_counter. And you can also dynamicly input its value as parameter to another entites with InValue and it lets you do cool things with it.

math_counter has tons of usages. If you are making a point based map you can keep points in it.(Not between rounds), if you need to have few modes for some entites etc.

I will be showing usages of it more at Systems part of the document.

Useful Console Commands

-cl_lock_camera 1/0: It lets you lock your camera so you can do a lot of things like 2D games, menus, cutscenes and other thing

Systems

In this part of document i will show the logic systems that i use when mapping.

Trigger Cage + cl_lock_camera 1

image

Trigger cage is simply a cage with trigger_multiple's surrounded. All trigger_multiple's (except the top one) teleports player when player triggers. This can be used in various things. I mentioned the cl_lock_camera recently. In this system we lock the camera when player is facing to what will we planning to do, for this case think it like we want person to look at the menu that player will be control. After we lock the camera of the player we teleport it to the point_teleport at the middle of the trigger cage.

At this part we need to use point_servercommand to change some server settings. When the player inside the trigger cage you need to change sv_friction to 35 (default is 5.2) because if you don't do this when player move, it will slide if it wants to stop and it will cause player to trigger the trigger_multiple more and we don't want it. For this screenshot i used this system for driving the cars at our map Counter Racing.

math_counter + logic_case

Sometimes you need to have few modes in something.

image

Like in this menu i made a menu for players to select a racing track for racing. What happens is this:

-It lock the players camera and teleports it to the trigger cage

-At this cage if you move left it triggers the left trigger and it Add's math_counter -1, and if you move left it Add's math_counter 1.

-On math_counter with OutValue(the output that fires auto when value of math_counter changes) it InValue's the logic_case for triggering certain cases and displaying the tracks.

image

-On logic_case I named the cases 1 to 10 so when i InValue the math_counter's value, it will automatically trigger the case that math_counter's value. And in outputs of the logic_case it shows what needs to be shown and disables the rest.

image

About

CS2 Entity logic document to people understand

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published