Lua Player Weapon Delay

Status
Not open for further replies.

Senku Niola

Drifting Golden Swordsman
Back during the various builds of 2.1 I had this working just fine, but once 2.1 released I can't seem to make this work right anymore.

My specific problem is that player.weapondelay = x just wont work; I'm trying to make the weapon delay longer so I tried 6*$1/4 and that didn't work it made me able to throw 1 ring then never able to throw another ever again. I tried replacing $1 with TICRATE and was completely unable to throw rings. I even tried to copy Knuckles' code over of TICRATE*2/3 and yet it still didn't work right.
 
I take it the hook you're probably running them ("ThinkFrame" I suspect?) is one that runs every single tic, so whatever you're doing will equally be repeated every single tic. Keep that in mind.

What's going wrong in each case is that player.weapondelay = 6*$1/4 or similar is just going to continously increase the weapondelay once it is a value other than 0 (6*0/4 = 0), meaning once you've fired something weapondelay shoots up without stopping! Meanwhile player.weapondelay = 6*TICRATE/4 will make the player.weapondelay always that value, meaning it's impossible to fire because player.weapondelay is *never* 0 when that happens. Helps to realise what you're doing really.

So what you basically need to do is set the new starting weapondelay once and once only. Maybe create a new global variable that starts somewhere, like "local isdelayset" which is set to 0 "if player.weapondelay == 0", and turns on when "if not isdelayset and player.weapondelay > 0".
 
MobjThinker actually and I'll try your idea out, still not fully used to lua yet..

EDIT: Ok, yeah that did work..though why did it used to work in older builds of 2.1 and now in the released one it was doing this?
 
Last edited:
Sorry to repost, but it just triggered another problem. It's affecting ALL rings, they all have the same firerate now, I was trying to make it so it would make all the rings take their original delays and slow them down the same percentage or so.


EDIT: Nevermind found the issue, it was cause I wasn't using $1 anymore and replaced it with FRACUNIT, now it works right with 3*$1 for example. Thanks for the help anyways.
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 0, Members: 0, Guests: 0)

Back
Top