ID:261390
![]() Feb 17 2002, 10:22 pm
|
|
I need to know where to put a sleep in my attack code or what I have to do to it. I want it so that you can't attack many times in a row.
|
![]() Feb 17 2002, 10:24 pm
|
|
I have this problem too in Kemet as you've noticed..
If you look at the controler for slowing down your walking speed, it should be able to work for attacking as well, I just haven't gone in and lookse at my code since my attack is based off of bump'ing, and if bump'ing is controlled by movement that should be all the code I need. But apparently its not, looks like I'm going to have to do something for attacking as well. LJR |
Thanks m8, I'll revisit my attack code again ;)
With speed being such an issue it'd be nice if BYOND offered some kind of incoded process to control the number of times and item can be clicked or used before its allowed again. As I'm finding errors in anything you do in a game if you try to do it too fast. LJR |
No errors but it doesn't sleep
code: ____________________________________________________________ mob verb Attack(mob/M as mob in oview(1)) var/damage = rand(1,5) if(damage <= 0) usr << "[M] easily dodges your attack!" M << "You easily dodge [usr]'s attack." else M.HP -= damage view() << "[usr] attacks [M] for [damage] HP!" M:deathcheck() if(usr.attacked) usr.attacked = 1 sleep(20) usr.attacked = 0 |
Not positive but I think I see the problem. Try this but dont rely on it, I'm not as good as some others that could help you.
mob verb Attack(mob/M as mob in oview(1)) if(usr.attacked == 1) sleep(20) usr.attacked = 0 else usr.attacked = 1 var/damage = rand(1,5) if(damage <= 0) usr << "[M] easily dodges your attack!" M << "You easily dodge [usr]'s attack." else M.HP -= damage view() << "[usr] attacks [M] for [damage] HP!" M:deathcheck() |
Ok I think this should work... I've been working with some complex procs for a game and my heads all messed up. But I'm pretty sure this will work.
--------------------- mob verb Attack(mob/M as mob in oview(1)) if(usr.attacked == 1) usr << "You can't attack again" else usr.attacked = 1 var/damage = rand(1,5) if(damage <= 0) usr << "[M] easily dodges your attack!" M << "You easily dodge [usr]'s attack." else M.HP -= damage view() << "[usr] attacks [M] for [damage] HP!" M:deathcheck() sleep(20) usr.attacked = 0 --------------------- -Raven- |
I error....
Attack(mob/M as mob in oview(1)) Mobs.dm:60:error:else :'else' clause without preceding 'if' statement |
Tab that else in 1 more time and it should be fixed, it musta happened when you copy/pasted it, because I have the code right here and it didnt have the else there. So just tab it once and it should be fixed
[edit] Actually I see a few indentation errors in the code you just showed me, but they aren't like that here. I have an idea, I'll show ya how it should look. If your game is run-able, then add this verb: mob verb Code(message and message) world << "[usr] says, [Message]" Then run your game. |
Attack(mob/M as mob in oview(1)) Mobs.dm:60:error:else :'else' clause without preceding 'if' statement Mobs.dm:60:error::missing expression |
Hmm. Wouldn't that just make it sleep for a while, then execute all of the attacks? Like if i held down a macro, it would sleep 20, then start spamming the attacks? I havn't tested it out, but thats what it looks like.
-Rcet |