BSNOOCH.COM

Games & Mods => SMOD & SMOD2 => Topic started by: Monkatraz on November 15, 2013, 12:18:50 PM

Title: Holstering Script FIX-A-THON
Post by: Monkatraz on November 15, 2013, 12:18:50 PM
I have a script that holsters your weapon before it switches to the weapon you chose through the normal cycle menu.

Works like this: When you scroll it binds your mouse1 button to a new bind. When you click it does a holster command (it does a little animation) and then does a +attack, resets the animation, then -attack and rebinds. I have also done all of the other commands, invnext, invprev, phys_swap, lastinv, etc, those work fine. It's just if you select from the menu, it sometimes fire by accident but still switches. It fires like a millisecond before switching.
It's annoying as hell.

If any of you got any ideas, here is the nearly finished script

Code: [Select]
// old code, buggy and too complicated there is a lot of unused alias due to me testing look at the rewrite for better code, look at the old for an idea of what I went through
//alias wsup wsupstart
//alias wsdown wsdownstart
//alias wsupstart "invnext; bind mouse1 wsselectw; alias wsup wsupend"
//alias wsupend "invnext"
//alias wsdownstart "invprev; bind mouse1 wsselectw; alias wsup wsupend"
//alias wsdownend "invprev"
//alias wsholster2 "viewmodel_p 2;w5;viewmodel_p 4;w5;viewmodel_p 6;w5;viewmodel_p 8;w5;viewmodel_p 10;w5;viewmodel_p 12;w5;viewmodel_p 14;w5;viewmodel_p 16;w5;viewmodel_p 18;w5;viewmodel_p 20;w5;viewmodel_p 22;w5;viewmodel_p 24;w5;viewmodel_p 26;w5;viewmodel_p 28;w5;viewmodel_p 30;w5;viewmodel_p 32;w5;viewmodel_p 34;w5;viewmodel_p 39;w5;viewmodel_p 43;viewmodel_p 60;+attack"
//alias wsholster "viewmodel_p 2;wait;wait;viewmodel_p 4;wait;wait;viewmodel_p 6;wait;wait;viewmodel_p 8;wait;wait;viewmodel_p 10;wait;wait;viewmodel_p 12;wait;wait;viewmodel_p 14;wait;wait;viewmodel_p 16;wait;wait;viewmodel_p 18;wait;wait;viewmodel_p 20;wait;wait;viewmodel_p 22;wait;wait;viewmodel_p 24;wait;wait;viewmodel_p 26;wait;wait;viewmodel_p 28;wait;wait;viewmodel_p 30;wait;wait;viewmodel_p 32;wait;wait;viewmodel_p 34;wait;wait;viewmodel_p 39;wait;wait;viewmodel_p 43viewmodel_p 60"
//alias wssettonormal "viewmodel_p 0"
//alias +wsselect "wsholster; +attack; wssettonormal"
//alias -wsselect "-attack; wsrebind"
//alias wsselectw "viewmodel_p 2;wait;wait;viewmodel_p 4;wait;wait;viewmodel_p 6;wait;wait;viewmodel_p 8;wait;wait;viewmodel_p 10;wait;wait;viewmodel_p 12;wait;wait;viewmodel_p 14;wait;wait;viewmodel_p 16;wait;wait;viewmodel_p 18;wait;wait;viewmodel_p 20;wait;wait;viewmodel_p 22;wait;wait;viewmodel_p 24;wait;wait;viewmodel_p 26;wait;wait;viewmodel_p 28;wait;wait;viewmodel_p 30;wait;wait;viewmodel_p 32;wait;wait;viewmodel_p 34;wait;wait;viewmodel_p 39;wait;wait;viewmodel_p 43;viewmodel_p 60; +attack;wssettonormal;w3;-attack;wsrebind"
//alias wsrebind "bind mouse1 +attack; alias wsup wsupstart; alias wsdown wsdownstart"
//alias wslastinv "wsholster; lastinv;w3;wssettonormal;wsrebind"
//alias wsphys_swap "wsholster; phys_swap;w5;wait; wssettonormal;wsrebind;-attack"

// rewrite of code old code too buggy, this may not fix it though
alias wsup "invnext; bind mouse1 wsselect"
alias wsdown "invprev; bind mouse1 wsselect"
alias wsholster "viewmodel_p 2;w3;viewmodel_p 4;w3;viewmodel_p 6;w3;viewmodel_p 8;w3;viewmodel_p 10;w3;viewmodel_p 12;w3;viewmodel_p 14;w3;viewmodel_p 16;w3;viewmodel_p 18;w3;viewmodel_p 20;w3;viewmodel_p 22;w3;viewmodel_p 24;w3;viewmodel_p 26;w3;viewmodel_p 28;w3;viewmodel_p 30;w3;viewmodel_p 32;w3;viewmodel_p 34;w3;viewmodel_p 39;w3;viewmodel_p 43;viewmodel_p 60"
alias wsselect "wsholster; +attack; wssettonormal; w5; -attack; wsrebind"
alias wsrebind "bind mouse1 +attack"
alias wssettonormal "viewmodel_p 0"
alias wslastinv "wsholster; lastinv; wssettonormal; wsrebind; -attack"
alias wsphys_swap "wsholster; phys_swap; wssettonormal; wsrebind; -attack"
// and after testing it didn't. If anyone has an idea how to fix it you can try, its randomly firing when you switch sometimes
// phys swap and lastinv don't do that. The only real way to do this is sadly a custom selection system
// right now this is the best solution for universal weapon selection

Bind mwheelup to wsdown
Bind mwheeldown to wsup
Bind your gravity gun key to wsphys_swap
Bind your last weapon key to wslastinv
And that sets it up, hope someone finds a good solution to this

Here is a little grenade throw script to go along with it (bug free)

Code: [Select]
alias throwgrenade throwgrenade_on
alias throwgrenade_on "wsholster; use weapon_frag; wssettonormal; alias throwgrenade throwgrenade_off"
alias throwgrenade_off "wslastinv; alias throwgrenade throwgrenade_on"

Here is the waits script you need for it, shamelessly stolen from Crylife
Code: [Select]
alias w1 "wait"
alias w2 "wait;wait"
alias w3 "wait;wait;wait"
alias w5 "wait;wait;wait;wait;wait"
alias w7 "w5;wait;wait"
alias w10 "w5;w5"
alias w15 "w5;w5;w5"
alias w20 "w5;w5;w5;w5"

The +wsselect was the most reliable version but you MUST hold it down to switch and YOU MUST hold it down if you don't want it to look bad so it wasn't really an option, so wsselect as standard works best.
I've tried different wait times so I don't think it's that. I think it's something to do with it being held down too short or too long, I honestly can't track it down. So that's why I request help, experiment around with the script.
Title: Re: Holstering Script FIX-A-THON
Post by: Pepsifan04 on November 15, 2013, 01:46:03 PM
I think the best way to do it, is to use mapadd ent as counters (ent. with "delay" set to 1 and calling a command "wsrebind" and similar)
so when player switches gun it'll give a second to press mouse1 (or use alias attack1_relay, it's more reliable) and after that, regardless if player pressed M1 or not it'll call "wsrebind". that's for 1,2,3,4,5,6 keys weapon selection without custom system

Code: [Select]
alias wsselect "wsholster; +attack; wssettonormal; w2; -attack"  <--- REMOVED WSREBIND FROM HERE
alias wsrebind  "alias attack1_relay wsselect"
alias wsdefault "alias attack1_relay +attack"

alias slot1_relay "slot1;wsrebind;ent_fire slot_timer onuser1"

example code for 1,2,3,4,5,6 keys weapon selection
MAPPADD ENT
Code: [Select]
"point_servercommand"   <--- or clientcommand
{
"keyvalues"
{
"targetname" "cmd"
}
}

"logic_relay"
{
"keyvalues"
{
"targetname" "slot_timer"
"StartDisabled" "0"
"Onuser1" "cmd,Command,wsdefault,1,-1"
}
}



And why yours script makes weapon sometimes shoot:
That's because you're pressing Mouse1 twice or more;"wait" command is not very reliable, it's useful for spacing rebinding and similar scripts,
 but using it as "timer" causes weird bugs, because everything you'll do while wait is being executed, will be executed after it'll end
(w2 is enough for engine to apply changes from previous part of the script)
Title: Re: Holstering Script FIX-A-THON
Post by: Monkatraz on November 15, 2013, 02:11:15 PM
Alright thanks. I was never good with mapadd so I wouldn't know that, I'll give it a try.
Title: Re: Holstering Script FIX-A-THON
Post by: Monkatraz on November 15, 2013, 10:55:39 PM
Either I'm doing it wrong or it isn't working, or you did something wrong.
As far as I can tell wsrebind is not the issue and I'm not exactly timing, if I take wsrebind out of the script it still sometimes fires. Also all it does is this, holster, switch to normal. attack waits 5 frames (w2 w3 make it worse) -attack, then rebind back to normal. if I take rebind out it still fires, and that's the end of it.
Title: Re: Holstering Script FIX-A-THON
Post by: Monkatraz on November 16, 2013, 11:13:17 AM
Yay, triple post. This is I'm pretty sure the final version of the script. I feel like that +attack bug is something hardcoded, I've been checking around.

So I did a system similar to Crylife however it's way more universal and not ( I think ) controlled my mapadd.

Code: [Select]
alias wsup null
alias wsdown null
alias wsholster "viewmodel_p 2;w3;viewmodel_p 4;w3;viewmodel_p 6;w3;viewmodel_p 8;w3;viewmodel_p 10;w3;viewmodel_p 12;w3;viewmodel_p 14;w3;viewmodel_p 16;w3;viewmodel_p 18;w3;viewmodel_p 20;w3;viewmodel_p 22;w3;viewmodel_p 24;w3;viewmodel_p 26;w3;viewmodel_p 28;w3;viewmodel_p 30;w3;viewmodel_p 32;w3;viewmodel_p 34;w3;viewmodel_p 39;w3;viewmodel_p 43;viewmodel_p 60"
alias wssettonormal "viewmodel_p 0"
alias wslastinv "wsholster; lastinv; wssettonormal; wsrebind; -attack"
alias wsphys_swap "wsholster; phys_swap; wssettonormal; wsrebind; -attack"

alias wsslot1 "hud_fastswitch 1; wsholster; wssettonormal; slot1"
alias wsslot2 "hud_fastswitch 1; wsholster; wssettonormal; slot2"
alias wsslot3 "hud_fastswitch 1; wsholster; wssettonormal; slot3"
alias wsslot4 "hud_fastswitch 1; wsholster; wssettonormal; slot4"
alias wsslot5 "hud_fastswitch 1; wsholster; wssettonormal; slot5"
alias wsslot6 "hud_fastswitch 1; wsholster; wssettonormal; slot6"
Title: Re: Holstering Script FIX-A-THON
Post by: Pepsifan04 on November 16, 2013, 06:58:24 PM
my fault. I've messed up the ent_fire part, it shoud be:
Code: [Select]
alias slot1_relay "slot1;wsrebind;ent_fire slot_timer fireuser1"
that's for my method.

And you've got me wrong with the shooting part.
I'm not saying that you should put w2 after changing gun position, I'm saying that  your animation is a bit too long, also replace "w5" from wsselect to something shorter, like "w2" ;)

Your method is not mapadd controlled :D but if forces to use hud_fastswitch
Title: Re: Holstering Script FIX-A-THON
Post by: Monkatraz on November 16, 2013, 10:48:02 PM
I've tested W2, it makes the issue so much worse. w5 seems a lot more stable than w2. I do not know why.

This is a source related bug, so I can't fix it. I've had friends tell me +attack is buggy as hell in code. I could try to find a fix but right now this is the most reliable way to do it, I could make an actually mapadd controlled mouse cycle thingy. That WOULD work.
SimplePortal 2.3.6 © 2008-2014, SimplePortal