When making any rpg, is it possible to make a character heal over time? Maybe by using verbs this can be accomplished?
mob
verb
Heal(mob/M in view(1))
var/heal = rand(2,hp)
usr << "[usr] heals!"
M.hp += hp
M.Deathcheck()
Would that work or would more have to be added and ho would I show a picture change in the heal after a heal command is entered?
1
2
ID:178955
Mar 13 2002, 4:43 pm
|
|
I would do it something like this:
mob -Lord of Water |
In response to Lord of Water
|
|
You use goto WAY too much, LoW.
mob Simple, no? |
In response to Lord of Water
|
|
oh thats good, thats real good, I didn't test it but looking at it makes my code look infinitesimal.
|
In response to Nadrew
|
|
Wanna see some real 'goto' action?
NPC -Lord of Water |
In response to Nadrew
|
|
geez that seems so easy and yet so good. I need to work on my coding skills.
|
In response to Lord of Water
|
|
Goto is good for long statments like that but when you can make it work better using while() that's usally the way you should go.
|
In response to Canar
|
|
It's untested, but it should work. If it is not, a tiny bit of tweaking should do the trick. Glad I could help!
-Lord of Water |
In response to Nadrew
|
|
I agree. while just works alot better for simple loops, like what he needed.
|
In response to Canar
|
|
Thanks for all the coding help, I am going to test them now. I don't exaclty understand the 'goto' command though, but thanks.
|
In response to Lord of Water
|
|
That's one ugly loop, man. You should be using do-while() instead, which offers the same functionality for less confusion, and I'd set up the whole switch() thing differently anyway.
Lummox JR |
In response to Lummox JR
|
|
Amen to that!
|
In response to Lummox JR
|
|
Nah... I write a lot of things like that, so they are easy enough for me to read. And, I like having the numbers in the switch. What do you suggest changing it to? Thirdly, what makes it 'ugly'? To me, it loops like a purposeful procedure that stays almost all on one line. I could certianly re-arrange the proc so that it does not use 'goto', but to me that would make it even more ugly.
-Lord of Water |
In response to Lord of Water
|
|
Lord of Water wrote:
Nah... I write a lot of things like that, so they are easy enough for me to read. And, I like having the numbers in the switch. What do you suggest changing it to? Thirdly, what makes it 'ugly'? To me, it loops like a purposeful procedure that stays almost all on one line. I could certianly re-arrange the proc so that it does not use 'goto', but to me that would make it even more ugly. For suggestions on changing it, I'd say to simply compare the first part of each item--or to find its index in the list with Find()--and use that. You take the first part and convert it to a number, which means you can't use "Done" in the switch() and have to check for it separately. What makes it ugly is that you're using goto in a place where it's not only not needed, but worse than the alternative. A simple do-while loop would serve you perfectly well and actually save you a line (that line being taken up by one of your labels): do Lummox JR |
In response to Flare0080
|
|
Flare0080 wrote:
Thanks for all the coding help, I am going to test them now. I don't exaclty understand the 'goto' command though, but thanks. goto has been around forever... it basically means "I want to jump to a different place in the code (marked by the label), and I don't care about being able to return to where I jumped from" |
In response to Lummox JR
|
|
I agree... the code example was more than just ugly. Of course I admit to being completely biased against using goto. It is never needed, and I challenge anyone to find a situation that uses goto that I can't rewrite in a clearer fashion without.
But LOW's example is further complicated by putting a goto inside of a for loop that points outside the loop. LOW, do you know whether or not the loop is still executing after the jump? It's all very hard to fathom what process are still hanging at each point in the code. You may think it's easy enough for you to understand since you wrote it, but I bet if you look at it again after three months away, you're going to scratch your head a bit before recalling what it's supposed to do. |
In response to Skysaw
|
|
Skysaw wrote:
I agree... the code example was more than just ugly. Of course I admit to being completely biased against using goto. It is never needed, and I challenge anyone to find a situation that uses goto that I can't rewrite in a clearer fashion without. I disagree on that point: It is needed and should still be used, because C's loop constructs (which have migrated to other languages since) are incomplete; they're particularly bad for nested loops. These situations are hard to think up off the top of your head, but they do exist. I regard the anti-goto sentiment of the programming elite as a kind of snobbish disdain for all things BASIC and for outdated programming methods--but that doesn't mean goto should be eliminated. But, the loop constructs that exist do cover about 98% of situations where goto was needed in the past, and in each and every one of those cases it makes infinitely more sense to use the construct rather than goto. Lummox JR |
In response to Lummox JR
|
|
Lummox JR wrote:
Skysaw wrote: Lummox, I respect you as a top-notch programmer here, so I know if anyone could find an example, it likely would be you. However, the challenge stands :-) |
In response to Skysaw
|
|
If you have a move proc thing add the health check proc to that or something
|
1
2
this is almost right. try this instead...
this is also assuming that the hp is greater than zero or even two and that it is of course already defined. now you just need something to call that proc. If i understand correctly you want it to happen every so often so a loop would be useful.