Page 1 of 3
What's wrong with my code?
Posted: Thu Jun 22, 2006 2:27 pm
by FYNDR
For the final fight in my upcoming game Myseri, you sword fight this evil shadow wizard. The way it is supposed to work, if you are in contact with him for more than a few moments, you are stabbed and you die. However, if you touch him before then, it says CLANG! on the screen and your opponent sort of steps back before making another pass. Now, if you touch him on any side that isn't the front (i.e. from any place other than the direction he is going), it kills him. For whatever reason, it doesn't work this way:
@Dethcloak
/i/i/i/i
#send battle
#end
:battle
#cycle 1
#go seek
#if contact then flap
#send battle
#end
:flap
/i/i
#if contact then kill
#send flee
#end
:kill
#endgame
#end
:flee
#go opp seek
#go opp seek
#go opp seek
#if contact then flee
#send battle
#end
:touch
#if not blocked flow then win
Clang!
/i/i
#send flee
#end
:win
#die
#end
The coding is fairly simple, as you can see. I think the problem lies in the
#if not blocked flow then win statement because he isn't actually moving in any direction when he is in contact with you. Therefore, he cannot be
killed. Can anyone come up with any alternate coding for this that I've not thought of? Thanks.
~FYNDR
Posted: Thu Jun 22, 2006 3:50 pm
by Commodore
flow, i think, works only if you use #walk to move. I think that last #if statement is always going to be false because you're not using #walk.
Posted: Fri Jun 23, 2006 2:08 pm
by FYNDR
Yes, that was what I suspected... any ideas as to how to go about fixing it? I like having the idles in there so that you have time to dodge his attacks if need be, but perhaps there's another way?
~FYNDR
Posted: Fri Jun 23, 2006 2:47 pm
by Ellypses
Code: Select all
@Dethcloak
/i/i/i/i#send battle
:battle
#cycle 1
#walk seek
/i#if contact then flap
#send battle
:flap
#walk idle
/i/i#if contact then kill
#send flee
#end
:kill
#endgame
:flee
/opp seek/opp seek/opp seek
#if contact then flee
#send battle
:touch
#if not blocked flow then win
Clang!
/i/i#send flee
:win
#die
It would be cool if you have that mean ass vain slicing samurai thingy when you win an engagement. 3 boulders opp seek, turn boulder to red fake, /i/i#die or whatever.
Posted: Fri Jun 23, 2006 2:53 pm
by MadTom
#send is redundant, just use #battle, #flap, etc.
Posted: Fri Jun 23, 2006 11:56 pm
by FYNDR
Jur: Thanks! Now it works superfine, though it's a little easy to kill him. I'll just tweak it up a bit and see what I can do about the samurai blood thing.
Tomsacold: My middle name is Redundancy. Actually, it's Glenn.
~FYNDR
Posted: Sat Jun 24, 2006 12:58 am
by Dr. Dos
Madtom it's just a style.
Everybody has habits in their code. A lot of times i'll have something like
:loop
blah blah
#loop
#end
:touch
blah blah blah
#loop
#end
Even though both ends aren't needed.
Posted: Sat Jun 24, 2006 2:31 am
by MadTom
Yeah, that's true, I formed it as a habit early on when I was looking for ways to minimise memory usage in code. The 20,000 byte limit on boards was always really easy to break for me.
I suppose you could argue it's a tidier way of presenting the code, for one thing.
Posted: Sat Jun 24, 2006 3:59 am
by Alexis Janson
Tomsacold wrote:Yeah, that's true, I formed it as a habit early on when I was looking for ways to minimise memory usage in code. The 20,000 byte limit on boards was always really easy to break for me.
I suppose you could argue it's a tidier way of presenting the code, for one thing.
What good is tidy code in a GODLESS UNIVERSE?
That's right, I went there!
Posted: Sat Jun 24, 2006 11:12 pm
by mania-[ker]
Flimsy Parkins wrote:Tomsacold wrote:Yeah, that's true, I formed it as a habit early on when I was looking for ways to minimise memory usage in code. The 20,000 byte limit on boards was always really easy to break for me.
I suppose you could argue it's a tidier way of presenting the code, for one thing.
What good is tidy code in a GODLESS UNIVERSE?
That's right, I went there!
well, assuming god doesn't exist, then yes, tidy code as we know it is a largely futile exercise. if god does exist, then he obviously would want us to be happy, or at least for him to be happy. it has been revealed several times that god is a pretty organized guy; he got pissed when adam and eve messed up his cool tree of knowledge, and every church or synagogue i've ever been is a pretty tidy place. so, it can be confirmed that if god exists, he would want tidy code, and if god doesn't exist, then tidy code is a mere creature comfort for our own good, and it doesn't matter either way.
now, there are two ways we can look at the situation: with god, and without god. if we have no way of proving that god is really there short of dying, it would make sense to have tidy code even in a godless universe. if god doesn't exist, we have tidy code to make ourselves happy, and if god does exist, we have tidy code not only to make ourselves happy, but to win favor with god. tidy code, god or not, will ensure us that upon our deaths we are comfortable knowing that if indeed there is a god then we are in his good light, and if there is no god, we at least pleased ourselves.
Posted: Sun Jun 25, 2006 2:15 am
by FYNDR
...or maybe I just do it like that because that's how I learned it from the ZZT Editor Help and I lust for structure in all things?
Answer: Mmmmmm...... structure.....
~FYNDR
Posted: Sun Jun 25, 2006 2:34 am
by MadTom
FYNDR: I made this guide to saving memory a while ago here:
http://zzt.org/?p=gtsm
It's a bunch of ways to code more efficiently, along with some old tricks. I don't think it's been of much use to anyone but myself so far, but take a looksee anyhow
Posted: Sun Jun 25, 2006 2:39 am
by Dr. Dos
don't try to salvage the user articles page.
Posted: Sun Jun 25, 2006 2:42 am
by MadTom
that's funny coming from the ONLY OTHER GUY WHO WROTE ONE
Yeah, I know it's dead! But the forums are basically the only part of the site that isn't, nowadays.
Posted: Sun Jun 25, 2006 3:32 am
by Ando
Tomsacold wrote:But the forums are basically the only part of the site that isn't, nowadays.
That's sort of an exageration.