AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   wcft 3 item help!! (https://forums.alliedmods.net/showthread.php?t=82847)

joker231 12-30-2008 23:31

wcft 3 item help!!
 
hey guys...so i want a item that u can buy in shopmenu3 (yes...i made a new shopmenu) and basically what it does is allows you 2 see humans if you buy it...can some1 help me with the code?

heres the code 2 make the human invisible in the first place...

Code:

// This should be called on weapon change, on new round, when the user selects a new skill, and after an item is purchased
public SHARED_INVIS_Set( id )
{
  // Do not want to set them as invisible if the player is currently rendering
  if ( !p_data_b[id][PB_CAN_RENDER] || !p_data_b[id][PB_ISCONNECTED] )
  {
      return;
  }

  new iInvisLevel = 0;

  static iSkillLevel;
  iSkillLevel = SM_GetSkillLevel( id, SKILL_INVISIBILITY );

  // If they are Human Alliance with Invisibility lets set the level
  if ( iSkillLevel > 0 )
  {
      iInvisLevel = p_invisibility[iSkillLevel-1];
  }

  // User has a Cloak of Invisibility
  if ( ITEM_Has( id, ITEM_CLOAK ) > ITEM_NONE )
  {
      // Then we are already a little invis, lets give them a little bonus for purchasing the item
      if ( iInvisLevel > 0 )
      {
        iInvisLevel = floatround( float( iInvisLevel ) / INVIS_CLOAK_DIVISOR );
      }
      else
      {
        iInvisLevel = get_pcvar_num( CVAR_wc3_cloak );
      }
  }
 
  // If the player is holding a knife they should be more invisible
  if ( SHARED_IsHoldingKnife( id ) )
  {
      iInvisLevel /= 2;
  }

  if ( iInvisLevel )
  {
      set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransTexture, iInvisLevel );
     
      p_data_b[id][PB_INVIS] = true;
  }

  // User should not be invisible
  else
  {
      set_user_rendering( id );

      p_data_b[id][PB_INVIS] = false;
  }

  return;
}


Hawk552 12-31-2008 00:53

Re: wcft 3 item help!!
 
I've actually done something like this in the past and it is definitely possible.

What you'll need to do is remove all of the code that makes the humans invisible and replace it with a hook to "FM_AddToFullPack". In here, you'll have to set the rendering of the player according to what you want the viewer to see. For example:

Code:
/* NOTE: Pseudocode, don't try and compile this     Host is the person looking at the cloaked guy     Ent is the cloaked guy */ public ForwardAddToFullPack(ES,e,Ent,Host,HostFlags,Player,pSet)     if(is_cloaked(Ent) && !has_my_new_item(Host))     {         set_es(ES,ES_Solid,SOLID_NOT)         set_es(ES,ES_RenderMode,kRenderTransAlpha)         set_es(ES,ES_RenderAmt,0)     }

Everything will work other than "is_cloaked" and "has_my_new_item", so you'll just have to clean that up. You should also add additional conditions to check that the players are alive, connected, etc.

joker231 12-31-2008 00:55

Re: wcft 3 item help!!
 
thank you very much buddy!!!

Hawk552 12-31-2008 00:57

Re: wcft 3 item help!!
 
Sorry, I forgot to mention that the hook for FM_AddToFullPack should be set to post, i.e.:

Code:
register_forward(FM_AddToFullPack,"ForwardAddToFullPack",1)

whosyourdaddy 12-31-2008 01:01

Re: wcft 3 item help!!
 
will this make the player visible to all or just to the person who has the item?

Hawk552 12-31-2008 01:17

Re: wcft 3 item help!!
 
Quote:

Originally Posted by whosyourdaddy (Post 735913)
will this make the player visible to all or just to the person who has the item?

Only the player who has the item, assuming the logic that I posted is used in the final product.

whosyourdaddy 12-31-2008 01:33

Re: wcft 3 item help!!
 
so what function is used to make the person invisible and im guessing the foward pack thing is to make them uninvisble

Hawk552 12-31-2008 01:40

Re: wcft 3 item help!!
 
Quote:

Originally Posted by whosyourdaddy (Post 735925)
so what function is used to make the person invisible and im guessing the foward pack thing is to make them uninvisble

No, what happens is this (assume there are 4 players in the server):

Code:

Player 1: Human with a cloak
Player 2: Human with a cloak
Player 3: Undead with no items
Player 4: NElf with a "new item" (which shows them cloaked humans)

- One networking cycle

    - FM_AddToFullPack is called for Player 1 ON Player 2:
        Player 2 is cloaked so they are set to invisible here
    - FM_AddToFullPack is called for Player 1 ON Player 3:
        The player is not invisible so nothing happens
    - FM_AddToFullPack is called for Player 1 ON Player 4:
        The player is not invisible so nothing happens

    - FM_AddToFullPack is called for Player 2 ON Player 1:
        Player 1 is cloaked so they are set to invisible here
    - FM_AddToFullPack is called for Player 2 ON Player 3:
        The player is not invisible so nothing happens
    - FM_AddToFullPack is called for Player 2 ON Player 4:
        The player is not invisible so nothing happens

    - FM_AddToFullPack is called for Player 3 ON Player 1:
        Player 1 is cloaked so they are set to invisible here
    - FM_AddToFullPack is called for Player 3 ON Player 2:
        Player 2 is cloaked so they are set to invisible here
    - FM_AddToFullPack is called for Player 3 ON Player 4:
        The player is not invisible so nothing happens

    - FM_AddToFullPack is called for Player 4 ON Player 1:
        Player 1 is cloaked BUT Player 4 has an item so nothing happens
    - FM_AddToFullPack is called for Player 4 ON Player 2:
        Player 2 is cloaked BUT Player 4 has an item so nothing happens
    - FM_AddToFullPack is called for Player 4 ON Player 3:
        The player is not invisible so nothing happens

etc.

That happens many times each second, but the important thing is that if you don't specifically state that the player should be rendered invisible, then they're rendered as visible. In other words, the invisibility only lasts as long as the callback for FM_AddToFullPack sets the players as invisible.

whosyourdaddy 12-31-2008 02:05

Re: wcft 3 item help!!
 
lol im lost,
1. do i use set_user_rendering to make them invisible or not
2. if 1 is yes do i use this code to make them visible

Code:


if(p_data_b[ent][PB_INVIS] && ITEM_Has(ITEM_GOGGLES) > ITEM_NONE)
{
        set_es(ES,ES_Solid,SOLID_NOT)
        set_es(ES,ES_RenderMode,kRenderTransAlpha)
        set_es(ES,ES_RenderAmt,0)
}


Hawk552 12-31-2008 02:14

Re: wcft 3 item help!!
 
Quote:

Originally Posted by whosyourdaddy (Post 735936)
lol im lost,
1. do i use set_user_rendering to make them invisible or not
2. if 1 is yes do i use this code to make them visible

Code:


if(p_data_b[ent][PB_INVIS] && ITEM_Has(ITEM_GOGGLES) > ITEM_NONE)
{
        set_es(ES,ES_Solid,SOLID_NOT)
        set_es(ES,ES_RenderMode,kRenderTransAlpha)
        set_es(ES,ES_RenderAmt,0)
}


... Read my explanation. You're repeating your question but I already answered it.

Short answer: No
Long answer: http://forums.alliedmods.net/showpos...28&postcount=8


All times are GMT -4. The time now is 09:16.

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