SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 03-18-2014   #1
Senku Niola
Drifting Golden Swordsman
 
Senku Niola's Avatar
Default Lua Player Weapon Delay

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.
Senku Niola is offline   Reply With Quote
Old 03-18-2014   #2
Monster Iestyn
Fangtastic
Administrator
 
Monster Iestyn's Avatar
Default

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".
__________________
My page stuffed full of MIDI goodness!
The Hitchhiker's Guide to the Robo-Hoodiverse
Timeline of Sonic Robo Blast History!

That's an uppercase i, not a lowercase L, for the record. Also, it's pronounced "Yes-tin".
Monster Iestyn is offline   Reply With Quote
Old 03-18-2014   #3
Senku Niola
Drifting Golden Swordsman
 
Senku Niola's Avatar
Default

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 by Senku Niola; 03-18-2014 at 08:32 PM.
Senku Niola is offline   Reply With Quote
Old 03-18-2014   #4
Senku Niola
Drifting Golden Swordsman
 
Senku Niola's Avatar
Default

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 by Senku Niola; 03-18-2014 at 11:30 PM.
Senku Niola is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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. The time now is 07:37 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.