Raised This Month: $ Target: $400
 0% 

wcft 3 item help!!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joker231
Junior Member
Join Date: Dec 2008
Old 12-30-2008 , 23:31   wcft 3 item help!!
Reply With Quote #1

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;
}
joker231 is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-31-2008 , 00:53   Re: wcft 3 item help!!
Reply With Quote #2

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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
joker231
Junior Member
Join Date: Dec 2008
Old 12-31-2008 , 00:55   Re: wcft 3 item help!!
Reply With Quote #3

thank you very much buddy!!!
joker231 is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-31-2008 , 00:57   Re: wcft 3 item help!!
Reply With Quote #4

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)
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 12-31-2008 , 01:01   Re: wcft 3 item help!!
Reply With Quote #5

will this make the player visible to all or just to the person who has the item?
whosyourdaddy is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-31-2008 , 01:17   Re: wcft 3 item help!!
Reply With Quote #6

Quote:
Originally Posted by whosyourdaddy View Post
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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 12-31-2008 , 01:33   Re: wcft 3 item help!!
Reply With Quote #7

so what function is used to make the person invisible and im guessing the foward pack thing is to make them uninvisble
whosyourdaddy is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-31-2008 , 01:40   Re: wcft 3 item help!!
Reply With Quote #8

Quote:
Originally Posted by whosyourdaddy View Post
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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
whosyourdaddy
Senior Member
Join Date: Apr 2008
Old 12-31-2008 , 02:05   Re: wcft 3 item help!!
Reply With Quote #9

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)
}
whosyourdaddy is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 12-31-2008 , 02:14   Re: wcft 3 item help!!
Reply With Quote #10

Quote:
Originally Posted by whosyourdaddy View Post
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
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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