AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   New Semiclip Method (https://forums.alliedmods.net/showthread.php?t=69728)

skyjur 04-10-2008 06:16

New Semiclip Method
 
3 Attachment(s)
I have found a very good way of making semiclip (I think it is new). The main idea is to add SOLID_NOT flag for a player on a right moment.

Lets start with the simplest example.
PHP Code:

plugin_init()
{
      
register_forward(FM_PlayerPreThink"preThink")
      
register_forward(FM_PlayerPostThink"postThink")
}
public 
preThink(id)
{
      if(
pev(idpev_movetype) == MOVETYPE_NOCLIP) return

      
set_pev(idpev_solidSOLID_SLIDEBOX)
}
public 
postThink(id)
{
      if(
pev(idpev_movetype) == MOVETYPE_NOCLIP) return

      
set_pev(idpev_solidSOLID_NOT)


This little example is good enough for a KZ or Surf server. Player during the Think is SOLID_SLIDEBOX, so it means it will Touch all entities. In the same time all other players are SOLID_NOT, so you will go trough them without a touch.

It works pretty nice on KZ servers. Even better than the old way. It is ~5 lines of code and you don't have to worry about trigger_teleport and other stuff bicouse everything works fine. All what has left is to add a transparcy rendering.

The dis advanced of this example is that player is SOLID_NOT almost always. So bullets wont touch the player.

The second example is a bit more recourses consuming, compared to the first one. Now I will change every player to SOLID_NOT (accept 1) before a Think, and put things back to normal after Think.
PHP Code:

new maxplayers
new plr_solid[33]

plugin_init()
{
      
register_forward(FM_PlayerPreThink"preThink")
      
register_forward(FM_PlayerPostThink"postThink")
      
maxplayers get_maxplayers()
}
public 
preThink(id)
{
      if(
pev(idpev_movetype) == MOVETYPE_NOCLIP) return

      for(new 
i=1<= maxplayersi++)
      {
            if(!
pev_valid(i) || == id) continue
            
plr_solid[i] = pev(ipev_solid)
            
set_pev(ipev_solidSOLID_NOT)
      }
}
public 
postThink(id)
{
      if(
pev(idpev_movetype) == MOVETYPE_NOCLIP) return

      for(new 
i=1<= maxplayersi++)
      {
            if(!
pev_valid(i) || == id) continue
            
set_pev(ipev_solidplr_solid[i])
      }


This part of code has a 1 big dis advanced. Everything works fine on the server. However client thinks that everyone is SOLID_BBOX. This gives a very uncomfortable effect for a player when he is going trough others. To manage this problem we will have to use FM_AddToFullPack, which is very resources consuming function bicouse it is called very often.

This is all about the main idea. All the rest are enchantments/optimizations.


In the attachment you will find a fully working semiclip plugin for general-cs/hns/kz/surf. Other mods should work well too. Plugin will make your teammates transparent and you will be able to walk thought them without a touch. At the same time opposite team will be solid, you will be able to shoot them. (note that you should use mp_friendlyfire 0 with this plugin or else you can hurt your team)

Hawk552 04-10-2008 07:05

Re: New Semiclip Method
 
That's pretty cool, I'll probably update my stuff to use this. Good job.

Orangutanz 04-10-2008 08:39

Re: New Semiclip Method
 
SOLID_SLIDEBOX is for players, not SOLID_BBOX

Alka 04-10-2008 08:52

Re: New Semiclip Method
 
Quote:

Originally Posted by Orangutanz (Post 609176)
SOLID_SLIDEBOX is for players, not SOLID_BBOX

SOLID_BBOX works perfect too.

SchlumPF* 04-10-2008 10:40

Re: New Semiclip Method
 
nice

Orangutanz 04-10-2008 11:20

Re: New Semiclip Method
 
Quote:

Originally Posted by Alka (Post 609177)
SOLID_BBOX works perfect too.

That maybe the case but it's best to comply with standards/best practices.
We don't exactly want another ScreenFade dilemma on our hands, where people didn't understand the correct flags to use due to someone giving/using bad information!

skyjur 04-10-2008 13:56

Re: New Semiclip Method
 
Quote:

Originally Posted by Orangutanz (Post 609176)
SOLID_SLIDEBOX is for players, not SOLID_BBOX

Tnx Orangutanz, I have changed it to SOLID_SLIDEBOX not to mix peoples.

merong 04-14-2008 04:19

Re: New Semiclip Method
 
When i use this method,

(Surf) Server is usually crash

skyjur 04-14-2008 11:37

Re: New Semiclip Method
 
Quote:

Originally Posted by merong (Post 611309)
When i use this method,

(Surf) Server is usually crash

Given code is just an idea. There should be more checks done before changing pev_solid for player. Because player might be a spectator, or dead player. That could mess some things. If you have just copy pasted some code it might not work.

I have everything working on my kz server. But the semiclip part is build into other plugin so I can not post it.

I will fix and update attached plugin in a few days.

FatalisDK 04-17-2008 09:39

Re: New Semiclip Method
 
Very nice.


All times are GMT -4. The time now is 20:43.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.