Custom Collissions Override



  • Hi there guys kinda ran into a problem here. Im wrote up some a collisions function to match the rules for CS:S so when we are playing on a ze map these collision rules apply over the ones in survival here is the code below. I did add the AddCSLua to the init file and did the include in shared but the collisions do not change is their something Im missing or will this method not work. Thanks in advance - Brain

    function GM:ShouldCollide( ent1, ent2 )
    
     if GAMEMODE.ZombieEscape then
    	-- CS:S Collision Rules
    	local collisionGroup0 = ent1:GetCollisionGroup()
    	local collisionGroup1 = ent2:GetCollisionGroup()
    
    	if collisionGroup0 > collisionGroup1 then
    		local old = collisionGroup0
    		collisionGroup0 = collisionGroup1
    		collisionGroup1 = old
    	end
    
    	if collisionGroup0 == COLLISION_GROUP_PLAYER_MOVEMENT and 
    		collisionGroup1 == COLLISION_GROUP_WEAPON then
    		return false
    	end
    
    	if (collisionGroup0 == COLLISION_GROUP_PLAYER or collisionGroup0 == COLLISION_GROUP_PLAYER_MOVEMENT) and
    		collisionGroup1 == COLLISION_GROUP_PUSHAWAY then
    		return false
    	end
    
    	if collisionGroup0 == COLLISION_GROUP_DEBRIS and collisionGroup1 == COLLISION_GROUP_PUSHAWAY then
    		return true
    	end
    end
    	return self.BaseClass:ShouldCollide( ent1, ent2 )
    
    end
    
    hook.Add( "OnEntityCreated", "CSSCustomCollisions", function( ent )
    	ent:SetCustomCollisionCheck(true)
    end )
    


  • Hi there guys kinda ran into a problem here. Im wrote up some a collisions function to match the rules for CS:S so when we are playing on a ze map these collision rules apply over the ones in survival here is the code below. I did add the AddCSLua to the init file and did the include in shared but the collisions do not change is their something Im missing or will this method not work. Thanks in advance - Brain

    function GM:ShouldCollide( ent1, ent2 )
    
     if GAMEMODE.ZombieEscape then
    	-- CS:S Collision Rules
    	local collisionGroup0 = ent1:GetCollisionGroup()
    	local collisionGroup1 = ent2:GetCollisionGroup()
    
    	if collisionGroup0 > collisionGroup1 then
    		local old = collisionGroup0
    		collisionGroup0 = collisionGroup1
    		collisionGroup1 = old
    	end
    
    	if collisionGroup0 == COLLISION_GROUP_PLAYER_MOVEMENT and 
    		collisionGroup1 == COLLISION_GROUP_WEAPON then
    		return false
    	end
    
    	if (collisionGroup0 == COLLISION_GROUP_PLAYER or collisionGroup0 == COLLISION_GROUP_PLAYER_MOVEMENT) and
    		collisionGroup1 == COLLISION_GROUP_PUSHAWAY then
    		return false
    	end
    
    	if collisionGroup0 == COLLISION_GROUP_DEBRIS and collisionGroup1 == COLLISION_GROUP_PUSHAWAY then
    		return true
    	end
    end
    	return self.BaseClass:ShouldCollide( ent1, ent2 )
    
    end
    
    hook.Add( "OnEntityCreated", "CSSCustomCollisions", function( ent )
    	ent:SetCustomCollisionCheck(true)
    end )
    

  • Administrators

    I don’t  get what you’re trying to do but doing it in ShouldCollide is a horrible method.



  • @JetBoom:

    I don’t  get what you’re trying to do but doing it in ShouldCollide is a horrible method.

    To elaborate when we are on a Zombie Escape map the collision rules that I made above will overwrite the collision rules that you made. The reason Im doing this is because some props on escape maps have collisions that shouldnt have collisions. It also will fix issues with map weapons having collisions with the player when they shouldnt Id thought Id edit your collisions code but I dont wanna break things. Hope you have a better understanding now.


  • Administrators

    If you want something to not have collisions then set their collision groups to debris or debris trigger.



  • @JetBoom:

    If you want something to not have collisions then set their collision groups to debris or debris trigger.

    Alright thanks. Im just having trouble trying to find the file that is causing the issue making the map prop entities like prop_dynamic have collisions. Didnt really know anyone else to ask but the developer himself.



  • @Braintwistah @JetBoom Hi, I’m the creator of the Zombie Escape gamemode this code snippet was taken from (source). I figured it would be worth mentioning that these rules were ported from the CS:S source code. A lot of zombie escape maps depend on this behavior to function properly, notably boss-related entities and weapons collisions.

    I don’t believe calling ENT.SetCollisionGroup will solve the problem due to the special behavior required.



  • @Sam ZE as in source ZE? CSGO ZE or the creator of it entirely?




Log in to reply
 

16
Online

10975
Users

15257
Topics

297327
Posts

Looks like your connection to NoXiousNet was lost, please wait while we try to reconnect.