Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Tiberian Technologies / Blackhand Studios » Tiberian Technologies Forum » Commands->Select_Weapon doesn't work clientside.
Commands->Select_Weapon doesn't work clientside. [message #487279] Sun, 20 April 2014 11:13 Go to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Commands->Select_Weapon no longer seems to work client side, it works fine on LAN, but when I was testing on a 4.0 server with 4.0 clients it didn't seem to switch their weapons.

Re: Commands->Select_Weapon doesn't work clientside. [message #487282 is a reply to message #487279] Sun, 20 April 2014 16:25 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
We use that extensively in AR with 4.1 (and previously in 4.0) and it's always worked for us... are you trying to select a weapon in the same engine tick as granting it? I seem to recall that used to be an issue, not sure if it still is, I tend to do things like that after a 0.1 second delayed custom to move it into a different engine tick.

http://steamsignature.com/card/1/76561197975867233.png
Re: Commands->Select_Weapon doesn't work clientside. [message #487293 is a reply to message #487282] Mon, 21 April 2014 14:19 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
danpaul88 wrote on Sun, 20 April 2014 17:25

We use that extensively in AR with 4.1 (and previously in 4.0) and it's always worked for us... are you trying to select a weapon in the same engine tick as granting it? I seem to recall that used to be an issue, not sure if it still is, I tend to do things like that after a 0.1 second delayed custom to move it into a different engine tick.

Nah, I've tried selecting the pistol in the players inventory (exact same code as I use in ECW) however it doesn't switch weapons in base Renegade. Sad


Re: Commands->Select_Weapon doesn't work clientside. [message #487303 is a reply to message #487279] Mon, 21 April 2014 17:18 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
That is a bit odd, perhaps post the code you're using? For reference, all of the following work in 4.0 and 4.1;

Commands->Select_Weapon ( obj, Get_Powerup_Weapon ( Get_Parameter( "veteran_weaponPowerup" ) ) );


Commands->Select_Weapon ( obj, "Weapon_IFV_None" );


// Set the supercharged state
void dp88_AR_Tesla_Coil::setSuperchargedState(GameObject* obj, bool state)
{
  if ( !m_superchargedWeapon.Is_Empty() )
  {
    // If we are setting supercharged to true then switch weapons
    if ( state )
    {
      Commands->Select_Weapon(obj, m_superchargedWeapon);
      primary_maxRange = m_superchargedWeaponRange;
    }
    else
    {
      Commands->Select_Weapon(obj, m_defaultWeapon);
      primary_maxRange = m_defaultWeaponRange;
    }

    m_isSupercharged = state;
  }
}


http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Mon, 21 April 2014 17:19]

Report message to a moderator

Re: Commands->Select_Weapon doesn't work clientside. [message #487359 is a reply to message #487303] Thu, 24 April 2014 16:31 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
We do things like this:
const char *weap = Get_Current_Weapon(obj);
if (weap)
{
    Commands->Select_Weapon(obj,"");
    Commands->Select_Weapon (obj,weap);
}

To disable sniper rifles when a player is moving (it relies on weapon switch time); however, in the Renegade map I'm making that piece of code didn't work and the weapons could still shoot while moving. In the end I had to remove all bullets from the gun to get the somewhat desired effect; however, it is far more confusing for most people.


Re: Commands->Select_Weapon doesn't work clientside. [message #487363 is a reply to message #487279] Fri, 25 April 2014 02:58 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Passing an empty string to Select_Weapon makes them select the first weapon in their weapon bag. If they only have one weapon or the sniper rifle is their primary weapon (index 0) then your code is not causing a weapon switch and thus will not trigger switching time.

void WeaponBagClass::Deselect()
{
   this->Select_Index (0);
}


0 is a valid weapon index, thus they select the weapon at position 0.


http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Fri, 25 April 2014 03:01]

Report message to a moderator

Re: Commands->Select_Weapon doesn't work clientside. [message #487367 is a reply to message #487363] Fri, 25 April 2014 10:13 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
danpaul88 wrote on Fri, 25 April 2014 03:58

Passing an empty string to Select_Weapon makes them select the first weapon in their weapon bag. If they only have one weapon or the sniper rifle is their primary weapon (index 0) then your code is not causing a weapon switch and thus will not trigger switching time.

void WeaponBagClass::Deselect()
{
   this->Select_Index (0);
}


0 is a valid weapon index, thus they select the weapon at position 0.

Calling it by itself does indeed work, however that doesn't leave them holding the original weapon.

Calling this:
const char *weap = Get_Current_Weapon(obj);
if (weap)
{
    Commands->Select_Weapon(obj,"");
    Commands->Select_Weapon (obj,weap);
}

Works in both 3.4.4, and 4.1 single player LAN, it only doesn't work in 4.1 when on-line (as a client to the server).


[Updated on: Fri, 25 April 2014 10:38]

Report message to a moderator

Re: Commands->Select_Weapon doesn't work clientside. [message #487370 is a reply to message #487279] Fri, 25 April 2014 16:09 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3555
Registered: February 2003
Karma: 0
General (3 Stars)

The script M00_Select_Empty_Hands does this
Commands->Select_Weapon(obj,0);
Passing 0 to Select_Weapon will cause WeaponBagClass::Deselect to be called. I should point out that index 0 in a WeaponBagClass is always empty (i.e. "No weapon") because of the code in the WeaponBagClass constructor.
Try passing 0 instead of "" and see what happens. (although from a reading of the code for WeaponBagClass::Select_Weapon_Name it may not make much difference)

Also you could try calling Select_Weapon once, then Send_Object_Update (from engine_tt.cpp) on the object then Select_Weapon another time. Although I dont know how it would work...


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: Commands->Select_Weapon doesn't work clientside. [message #487372 is a reply to message #487370] Fri, 25 April 2014 16:29 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
jonwil wrote on Fri, 25 April 2014 17:09

The script M00_Select_Empty_Hands does this
Commands->Select_Weapon(obj,0);
Passing 0 to Select_Weapon will cause WeaponBagClass::Deselect to be called. I should point out that index 0 in a WeaponBagClass is always empty (i.e. "No weapon") because of the code in the WeaponBagClass constructor.
Try passing 0 instead of "" and see what happens. (although from a reading of the code for WeaponBagClass::Select_Weapon_Name it may not make much difference)

Also you could try calling Select_Weapon once, then Send_Object_Update (from engine_tt.cpp) on the object then Select_Weapon another time. Although I dont know how it would work...


I tried select "0" and that didn't have any effect (I almost feel like the first select weapon gets ignored and the second one just happens, almost as if the code was optimized in such a way that it goes "Oh hey look, he selected another weapon right after this select, ignore the first and do the second).

I will give that Send_Object_Update a try later, I'd do it right now but my router just decided to be a piece of shit and isn't letting me negotiate the firewall lol.


Re: Commands->Select_Weapon doesn't work clientside. [message #487448 is a reply to message #487372] Thu, 01 May 2014 07:33 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Send_Object_Update does work; however, it works better than it did in 3.4.4, and you actually start to see the weapon switch animations, whereas in 3.4.4 there was no indication that the server was switching your weapons besides the weapon icons on the hud lighting up and being unable to fire.

Beings it now tries to animate switching the weapons (thus making it look like your a spazz) I decided to go with it just switching you to the pistol when you move if your holding a sniper rifle (beings I can't get a clean weapon disable and 0 ammo confused people too much).


Re: Commands->Select_Weapon doesn't work clientside. [message #487450 is a reply to message #487279] Thu, 01 May 2014 09:05 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Why not just select weapon index 0 (empty hands) until they stop running? Then you only get the switch animation when they stop and it re-selects their weapon (plus you get some free post-running cooldown before shooting is allowed for free this way!)

http://steamsignature.com/card/1/76561197975867233.png
Re: Commands->Select_Weapon doesn't work clientside. [message #487453 is a reply to message #487450] Thu, 01 May 2014 09:53 Go to previous message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
danpaul88 wrote on Thu, 01 May 2014 10:05

Why not just select weapon index 0 (empty hands) until they stop running? Then you only get the switch animation when they stop and it re-selects their weapon (plus you get some free post-running cooldown before shooting is allowed for free this way!)

Oh its only sniper rifles I was disabling, I'm fine with other weapons, sniper rifle you can walk slowly with, and n00b jet you have to remain stationary.

I'm just not a fan of people back peddling away from bears that only have melee for attack and firing the n00bjet through multiple bears as they do, have to make sure some skill is required.


Previous Topic: tdbedit.exe fails to list the strings I have under the default tab in my strings file.
Next Topic: Possibly memory leak SSGM
Goto Forum:
  


Current Time: Thu Apr 25 16:48:37 MST 2024

Total time taken to generate the page: 0.00826 seconds