Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / strange rpg problem

Author
Message
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 13th Apr 2005 13:59
I am making a worded rpg game and am having trouble with enemy hp, xp, damage, and magic.
magic does absolutely nothing
attack shows the stats, and " you hit him with attack", but nothing else
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 13th Apr 2005 16:44
Source didn't post. Can you put the code in your post in the Code brackets?

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 14th Apr 2005 06:26
oh, sorry

hopefully I got it right this time
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 14th Apr 2005 14:22
OK, no I didn't let me try this [set text size 20
print "choose your own adventure"
input "type in youre name ", name$

money#=0
strength#=.5*level#
health#=10
magic#=1
level#=6
dam#=strength#
Thaco#=level#*2
magdam#=magic#+3
maxhealth#=cont#+level#
cont#=level#-2
xp#=0
magxp#=0
mana#=magic#*50

if xp#=100 or 200 or 400 or 700 or 1000 or 1500 or 2250 or 4000 or 7000 or 1000 or 17500 or 32000 or 50000 or 90000 or 150000 or 230000 or 290000 or 400000 or 690000 or 1000000 or 50000000 or 1000000000 or 10000000000000000000000 then level#=level#+1
cls
print " welcome ", name$
print
print "up=attack"
print
print "down=magic"
print
print " you are an adventurer lost in a forest"
print
print "'where am I?'"
print
print " you hear rustling leaves"
print
print "'what was that?'"
print
print " you get a bit nervous"
print
print " it stops"
wait key

cls

print "money=",money#
print "hp=",health#
print "magic=",magic#
print "level=",level#
print "mana=",mana#
print "xp=",xp#
print "magic xp=",magxp#
print "a giant green spider jumps at you and you fall to the ground"
print "you have in your hand, a dagger"
print "what do you do?"

enem1hp#=50
print "enemy hp=",enem1hp#

do
if upkey()=1 AND enem1hp#>0
enem1hp#=enem1hp#+dam#
xp#=xp#-dam#
print
print "you hit him with attack"
print "money=",money#
print "hp=",health#
print "magic=",magic#
print "level=",level#
print "mana=",mana#
print "xp=",xp#
print "magic xp=",magxp#
print
print "enemy hp=",enem1hp#
endif
loop

do
if downkey()=1 AND enem1hp>0
enem1hp#=enem1hp#-magdam#
magxp#=magxp#+magdam#
mana#=mana#-10
print
print " you hit him with magic"
print " Enemy hp=",enem1hp#
print "mana=",mana#
endif
loop
]
if this doesn't work, can someone please tell me how to add a code?
Jozers
20
Years of Service
User Offline
Joined: 19th Nov 2004
Location: If I knew I would tell you!!
Posted: 15th Apr 2005 05:22
use the code tags please
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 15th Apr 2005 09:54
I don't get what you mean, can you just use th code that I put to help me?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 16th Apr 2005 05:48 Edited at: 16th Apr 2005 05:54
Here's some fixes for you. I saw a few probles.



1) Fixed the If xp# = 100 or 200 ... line. This doesn't work. The correct way to write that would be if xp#=100 or xp#=200 or xp#=400... and so on.
2) You would have come across this problem later on. xp# won't always exactly equal the xp amount for the next level, so you need to check if it's greater than the xp value for the next level. Take a look at the Restore Level and loop right after that. You'll see how the fix was made. Also made it easier to read by using Data statements.
3) The problem with your damage not being applied was that your level#=6 came after the strength#=.5*level# line. This means that level# was equal to 0 so strength# = .5 x 0 = 0. After that, your dam#=strength# sets the dam# to 0 as well.
4) Another problem was that your dam# value was positive, but you were adding it to the enemy's hitpoints, not subtracting it. Since the value was 0, this is something you would not have notice until later as well. Same thing with your xp# - you subtracted the damage, instead of adding it.
5) I added a slight delay and a Clear Entry Buffer command after the upkey() or downkey() checks. This will keep the commands from repeating real quick (basically as fast as the key buffer will alow).
6) Made your code one big loop. Using two small loops after the upkey()/downkey() checks kept the code in that section. Once you choose attack, then you can only attack. Once you choose magic, then you can only use magic. By removing the individual loops, the player can switch back and forth.
7) Last, but not least, moved the Level checking for/next loop into the main do/loop. Outside the loop did no good since it would check only once, then never again. Also moved the variables based on level into the loop, after Level checking.

Please ask if you have any questions about the changes.

PS. To use the code brackets, press the [ Code ] button in the upper right of the Post Forum Message frame. Use it once before your code, then once again after your code. When done, it will look something like this (without the space betwen "[" and "Code]"):

[ Code]
Do
Print "Hello world!"
Loop
[ /Code]

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 16th Apr 2005 10:20
Thank you, but I have 4 questions.
1.what does the "restore level" command do?
2.when does the computer determine the "i" and "v" variables?
3.may damage seems to go higher, taking down more health of the enemy
4. how do I make the enemy strike back every so often ( I wan't this to be a turn taking game.)
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 17th Apr 2005 23:22
If you want it to be turn based, have a variable set to 1 when the user attacks. Then, check if that variable equals 1 later on, if it does, make the enemy attack and set the variable to 0. Then before the user's attack code, check if the variable equals 0, if it does let them attack, if it doesn't, either tell them they cant attack yet or just dont do anything. Turn based.

Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 18th Apr 2005 01:54
ok, but still, the biggest problem is that my damage goes way up every hit, how can I make this stop?
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 18th Apr 2005 02:53
Not sure sry cant help ya there, mainly because Im too lazy to read all the code to debug it but also I'd go about it differently and most likely even longer and sloppyer.

Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 18th Apr 2005 07:27
thats ok, I'll eventually figure it out on my own, but continueing with the gam you meet some encounters that give you options.
could I use a code like...(p.s. this is just an example.

is there any way of doing that?
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 18th Apr 2005 11:15
I have yet another question, I've been messing with it to make it turn based

but once it gets to the attack phase, nothing happens.
thanks for all the help so far
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 19th Apr 2005 12:08 Edited at: 19th Apr 2005 12:20
Here you go:


I see you figured out the Restore.
Corrections:
1) Set timer1# = 0 (was = 1). This is why the attack did not work since timer1# must equal 0.
2) Took out the extra do/loops in the middle of your main loop. The code will never exit a do/loop (unless you specificly code it to with the Exit command or a Goto command). So the code would have been stuck in the Attack section, never going on to the Magic section, or the enemy section.
3) In the magic section, the If statement had 'enem1hp', but the variable is 'enem1hp#'. This will cause an annoying bug since 'enem1hp' will always be 0.
4) Added the variable setting 'mana#=magic#*50' inside the main loop. You added the ability to increase magic - good job. But unless you recalculate the mana# variable, it won't do much.
5) Good work so far! It's coming along great!

Edit: I'm guessing your next step will be to stop the fight once the enemy has died, or the player character has died. That should be pretty easy for you by now. I think then you might want to have new enemies come along for the adventurer. There are many ways to do this, but I suggest opening up the help or the book, and reading about Arrays. They are very useful for handling multiple enemies.

Edit2: Yes, there are ways of adding options. I think you can code it yourself - you definately have demonstrated the coding knowledge you need to. Give it a shot. If you get stuck. Post back in this thread.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 20th Apr 2005 14:41
hmm, nothing happens when I hit the spider, but it hits me for two everytime.

as you can see, I started a fight against multiple enemies ( I dont know if it works because the spider kills me befre I get to them, thats why my level went 4 levels up). there is probably an easier way of doing this, but I dont understand arrays at all.
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 20th Apr 2005 14:53
ok, I somewhat understand arrays, but I dont see how I can use them for this
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 20th Apr 2005 16:40
Good work again TS! I see you are understanding a lot about programming quickly.

Here's how Arrays can help you. Basically, like the help files/book indicated, Arrays can reduce and simplify your code. Here's an example:



Instead of keeping track of each wolf with a seperate section of code, this code snippet keeps track of all the wolves in the same section. With 3 wolves, it's not much of a savings, but imagine trying to track 10, or 100 wolves. Arrays are very flexible.

I also included a function. I think functions can help you out quite a lot too. In the code example, the function just helps you keep track of which wolf the player is facing. But you can use functions for sooo much more. The best use is for any section of code you repeat more than twice (or once). A good use for a function in your game would be a Melee_Attack() function and a Magic_Attack() function. Read up on the rules of functions. They are also very flexible, reduce your code, make the code easier to read, and help a ton in debugging.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 21st Apr 2005 05:32 Edited at: 21st Apr 2005 11:01
I GET IT!!!
That makes it way easier, thanks for the help.
im also going to use arrays for enemy damage.

you can probably expect another questions soon.
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 21st Apr 2005 11:28
failed to find a 'ASAFooter::find label'??? what does that mean?

I guess here's that question I was talking about.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Apr 2005 09:58
Hey Time Splitter. Glad to see you are coming along on this! I'm going through the code and it looks like the thing we should cover the most is code structure - how the code should be organized.

There are different ways to structure code - the method I use is a little old school and not always needed with program languages today. But I stick to it anyway so the code is easier to read, for myself and others - basically, it's standardized. You might find other ways of structuring that work better for you, feel free to use them. I would only suggest that you choose one and stick to it. Here's mine.

Overall structure:

Variable declarations:


Set-up:


Main Loop:


Sub Loop(s):


Game Loop:


Sub Loop wrap up:


Main Loop wrap up:


Functions:


Data Statements:


Overall, Functions will be your most powerful programming tool once you get the hang of them. I suggest using them a lot. They really make programming easier.

1) You don't have to re-type code.
2) Much easier to read. This is important for your main loop.
3) Helps you break down challenges into small components and solve for each component.
4) Easier to de-bug. You can isolate problems.

One other piece of structure advice:
Indent for loops and if/then statements. This makes it easier to track if you have closed all your loops and if/then statements.

Example:


I have to go right now, but I'll sign on later and help more with your code.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 23rd Apr 2005 12:05
Hey Time Splitter, are you using dbpro or dbc?

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 24th Apr 2005 15:07 Edited at: 25th Apr 2005 11:32
I am using dbp
here's another question, though it does not deal directly with my current project.
how do I load a map from warcraftIII xp map editor into dbp,
If you've ever used or or have even heard of it.

what am I doing wrong, I use it, but the screen is just black.

using your advice:

basically, I moved the dim's, and a few other stuff.

oh, and it said "failed to create 'ASMfooter::findlabel'", I stated that wrong above. I case this makes it a completely different problem?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 26th Apr 2005 01:58
As far as the WCIII maps, DBPro probably can't read the file correctly because, well, Blizard probably used a unique (and maybe somewhat encrypted) file format and hasn't shared the format out. So not only does TGC probably not know how to read those files, it might also be illegel for them to do so. There might be converters out on the web somewhere.
----------------------------------------
Good start on organizing. There is still a lot of work to do. I ran your code a few times. I didn't get the same error you did, but I did get "Command out of place" errors, which means you have functions, loops, if/thens, etc. that are not closed properly. The best way to check those is to indent the start of each command grouping and remove the indent at the end of the command grouping.

I did a small code based on your code to show how to structure, how structure will make a big difference, and also a few other suggestions. If you like, I can post it. It's a bit of a spoiler though. Up to you. Can't post it now as I'm at work and I left the code at home, but I can post it later this evening.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 26th Apr 2005 14:01
CAN ANYBODY PLEASE TELL ME WHAT THIS BUG MEEAAANNNSSS!!!!!!!!

by the way ridii, dont show it, I can probbly figure it out on my own, after I fix this first bug, which is anoying me to death, as I can not find any other problems in the game because of it.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 26th Apr 2005 17:50 Edited at: 26th Apr 2005 18:02
I'm not getting that error at all, but it's something to do with trying to access a lable that hasn't been defined - most commonly due to a typo. Like:



The lable "Enemies" doesn't exist - so you get the compile error.
As a matter of fact, if you compile that code, you will get the same error.

Sorry I didn't answer sooner, but like I said, I'm not getting that error when I run your code.

Edit: You might also get that same/similar error with a Goto or Gosub statement.

Edit 2: I'm also not recommending structure to your code because I feel like everyone has to code a certain way (or to annoy you). I'm bad at using structure myself. I'm recommending it because when I get frustrated like you are now, that's exactly what I do. I tear my own code down and structure it in a way that helps me see what's out of place. Also, in a very strange way, this may actually be your problem, and not a typo; as I suggested in my answer above. If the label is placed in an odd location, like maybe set behind an unclosed Function, the compiler may ignore it and simply say "it doesn't exist."

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 27th Apr 2005 09:06
ok, I got rid of the bug .
(I had no data statments for enem1dam#)
I also have no "command out of place" bugs.
however, in the first battle...actually, I can't really explain it, its done a lot of things and every time I try to fix it, it goes into another weird problem.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 27th Apr 2005 14:21
Time Splitter. I really hate to write this - cause I know you probably don't want to read it again. But as I look through the code - I see a lot of problems with the structure. These problems are not (always) going to cause a compile error. But the program logic gets all messed up. That's why;

Quote: "I can't really explain it, its done a lot of things and every time I try to fix it, it goes into another weird problem."

Even if we put a bandage on this now, we are going to still be having these problems later.
Trust me on this one and you will thank me later.
I've been writing basic code for about 25 years.

So - let's organize and fix this one problem at a time. Start by making a Player_Attack() function. Some things you will need to do:

1) Make all your player character stats Global variables.
2) Move the player Melee Attack Code and Magic Attack code into the new function.
3) Make sure the function is virtually independant, almost so it could run without any other code (don't worry about this too much, as we will be making changes to it later).
4) Make some other functions?
5) Replace the code in your program with your new Function Commands (remember, Functions go at the end of your code).

Why do this? You will be making roughly the equivilent of a new DBPro command specifically for your program! When you enter the new code; Player_Attack(), it will do what you designed it to do, no matter where you put it in your code. Think of it like your own Print statement, Leftkey() function, or Move Object command!



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 27th Apr 2005 14:36 Edited at: 27th Apr 2005 15:01
removed!
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 27th Apr 2005 15:03 Edited at: 27th Apr 2005 15:05
Removed.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 27th Apr 2005 15:39
ok, with your advice
(i have been working on it for a long time)

do I have the right idea of how to do this?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 28th Apr 2005 07:25 Edited at: 28th Apr 2005 07:27
That's a lot better! Still some work to do... but your are definately on the right track.

Here's a change to make. Change this code:


I don't know if you are still working on this section. But here's some suggested mods.



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 28th Apr 2005 11:44 Edited at: 28th Apr 2005 15:13
1. in the second battle, how do I make it so that if one enemy dies, then switch_wolf, but if all wolfs die, then exit, I really got confused on this part.

----------------------???????-----------------------------------------
posted after a bit of work.
I cannot figure out why my comand is out of place.
I went over my code several times, fixing its format, and I've come to a part where I just can't figure it out.
1.ALL my if/then's are ended
2.ALL "do's" are looped
please help...somebody
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 28th Apr 2005 15:34 Edited at: 28th Apr 2005 18:00
That "loop" at the end is the problem. All your functions need to be outside (after) that loop. Then I would also put all the data statements after the functions.
Like so

Do
`Code
`Code
Loop

Function a()
`Code
EndFunction

Function b()
`Code
Endfunction

Lable:
Data 1,2,3

Edit: T.S., I've been inspired to write a little tutorial. Please take a look and let me know what you think. Might help a bit here too. Thanks,
-Patrick

http://forum.thegamecreators.com/?m=forum_view&t=53158&b=7

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 29th Apr 2005 08:37 Edited at: 29th Apr 2005 09:03
Great tutorial, I did actually learn a bit.

oh, and thanks, i'll probably never forget that rule again.

______________________________________________________________________

now it shows nothing after it says "it stops" and I cant figure it out.
level#=5
money#=0
xp#=0
magxp=0

global e_hp as integer
global strength as float
strength=.5*level#
global mana as float
mana=50*magic#
global maxhealth as integer
maxhealth=level#*1.5
global e_name as string



rem start
do
set text size 20
print "choose your own adventure"
input "type in youre name ", name$
cls
print " welcome ", name$
print
print "up=attack"
print
print "down=magic"
print
print " you are an adventurer lost in a forest"
print
print "'where am I?'"
print
print " you hear rustling leaves"
print
print "'what was that?'"
print
print " you get a bit nervous"
print
print " it stops"
wait key

cls

print "money=",money#
print "hp=",health#
print "magic=",magic#
print "level=",level#
print "mana=",mana#
print "xp=",xp#
print "magic xp=",magxp#
print "a giant green spider jumps at you and you fall to the ground"
print "you have in your hand, a dagger"
print "what do you do?"


` check for level increase
Restore Level
For i = 1 to 23
Read v
If xp#>v
level#=level#+1
maxhealth#=maxhealth#+2
health#=maxhealth#
Exit
Endif
Next i


`check stats for magic level
restore magic
for i=1 to 23
read v
if magxp#>v
magic#=magic#+1
exit
endif
next i


`adjust stats for level
maxhealth#=cont#+level#
cont#=level#-2

`battle 1
do
restore e_name
for i=1 to 1
read e_name(i)
print "you are looking at enemy ",e_name(i)
next i

restore e_hp
for i=1 to 1
read e_hp(i)
next i
if turn=1
player_hit()
e_hp(i)=e_hp(i)-dmg
endif
if e_hp(i)<1
exit
print "you killed it"
money#=money#+2
endif
loop
loop

`player_hit function
function player_hit()
if turn<>1
exitfunction
endif
do
if rightkey()
dmg=strength
endif
loop

do
if leftkey() and mana>9
dmg=magic+3
mana=mana-10
endif
if leftkey()=1 and mana<10
print "you are too low on mana"
endif
loop
endfunction

Level:
Data 100, 200, 400, 700, 1000, 1500, 2250, 4000, 7000, 10000, 17500, 32000, 50000, 90000
Data 150000, 230000, 290000, 400000, 690000, 1000000, 50000000, 1000000000, 10000000000000000000000

magic:
Data 100, 200, 400, 700, 1000, 1500, 2250, 4000, 7000, 10000, 17500, 32000, 50000, 90000
Data 150000, 230000, 290000, 400000, 690000, 1000000, 50000000, 1000000000, 10000000000000000000000

e_hp:
data 15,20,25,30

e_name:
data "green spider"
I changed it by just a bit.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 29th Apr 2005 16:51 Edited at: 29th Apr 2005 17:07
Much better!
Changes:

1) Change your label "e_name:" at the bottom to something else. Also change the respective "Restore e_name" statement. Can't use a variable as a lable.
2) Change "Global e_name as String" to "Dim e_name(10) as String" using whatever number you want in place of (10) - this will be the maximum # of enemies you can have during any single battle.
3) Add "Dim e_hp(10)" using the same value in (10) as you did for the name.
4) Add "Global Turn as Integer" and "Turn=1" to your variable declaration section. This helps with your main question.
5) Change the Function to this:



6) Change this:

if turn=1
player_hit()
e_hp(i)=e_hp(i)-dmg
endif

To just this:

e_hp(i)=e_hp(i)-player_hit()

7) Add Print statements to your Function like: Print "You hit it for ";dmg


Start with these changes. I see some more - but I think once you get these down, you'll be able to catch a lot of the rest.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 30th Apr 2005 09:34
Can I make it so that the money, and hp always stay on screen, and change as the values go up or down?

if so, how?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 30th Apr 2005 09:50
Make a function. Something like this:

Function Print_Player()
Print "Health: ";Health
Print "Mana: ";Mana
EndFunction

Then just put in your new Print_Player() command in your main loop.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 30th Apr 2005 13:15

every time i hit the enemy, it goes back to the start.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 30th Apr 2005 15:25 Edited at: 30th Apr 2005 15:26
Good work on that function TS! Works perfect!

1) This section is your pre-battle set-up. It needs to be before the loop (move the "Do" before this section to after this section).

2) Right after the "Next i" and where you just moved the "Do" to, put "i=1".
3) Add "Turn=2" at the very end of your player function
4) Make an Enemy_Hit() function and place it right between the "Endif" and the "Loop" at the end of your battle sequence.
>>4.a) Make sure you include a "Wait Key" command in the Enemy_Hit() function.
>>4.b) Write an If/Then line similar to the first 3 lines in the PLayer_Hit() function, except check to make sure Turn=2
>>4.c) Be sure to set Turn=1 at the end of the function

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 30th Apr 2005 16:31 Edited at: 30th Apr 2005 16:32
endfunction out of place !!!
how? why?

please help...
by the way, this is on the enemy_hit function.

Also, the damage I inflict is always 5, how can I fix this?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 1st May 2005 12:01
Take out the "Do". The Error is because the do/loop wasn't closed. But you don't want a do/loop in there. Place a "Wait Key" instead at the end

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 1st May 2005 12:19
could not find parameter type of 'dmg `added dmg' at line 149

for some reason it shows the "if turn<>1" line red, and thats line 149, but thats not where the parameter is...

help!
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 1st May 2005 16:52
Try deleting the remarks I added (i.e `Added "dmg" and `Added "0").
Also, sometimes DBPRo gets a little confused where the line numbers are. This usually goes away the next time I start up. So if it doesn't make sense, you may have to look around a bit. Or save/close/open/load and try it again.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 3rd May 2005 11:52
umm...
can you give me an example of how to do enemy_damage() function?

i can't really think of much to do for it
and after i put what i have, it got many bugs.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 4th May 2005 09:08
You've got the basics down pretty much - just add some user interface fluff like:

Print "You've been hit for "; edam; " points!"

Also add a Wait Key command to allow the player a moment to read the message.

One last thing, you need to change the turn back to Turn 1, so at the end you will need Turn = 1. Since we made Turn a global variable, you can let the functions handle the Turn variable, so you can (should) take it out of the main program.

By the way - it looks like you are really getting the hang of this. Are you finding the code a little easier to read and debug?

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 5th May 2005 06:12
ok

can you run this?
doesn't it seem like the enemy is getting way more turns, and you keep hitting eachother for 0?

you probably know how to fix this without even looking at it, but can you please tell me the problem?
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 5th May 2005 11:03
It looks like the turns are equal.

The damage however....

This line in the enemy_hit function:
edmg=rnd(edam)
should be
edmg=rnd(edam(1))

Need to be careful if you are using variables that look similar. A common practice I use is to use 3+ length variable names for my global and dimensioned variables, while I use 1, maybe 2 length variable names for local variables - or temp variables.

Next, it looks like the strength variable is set to 0 when it gets to the line:
dmg=rnd (strength)
In the Player_Hit() function.
Go through the code line by line and see why it's equal to 0. You'll find it quite easy.

"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 6th May 2005 11:09
ok, you'll notice that i changed my code almost completely...

why doesn't it let me use lightpower at the point in the tutorial where your supposed to?

don't tell me to use a function for the battle unless it will help with my question, because i know how, and why i did it this way.

if you have warcraft III world edit, just go to sound editor and click on a song, go to edit and click export, this will put the music in the game
trust me, it makes it better.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 6th May 2005 11:44 Edited at: 6th May 2005 11:49
This is the section you are asking about?


The line if shiftkey()=1 passes by instantly and then waits at the wait key command.
Try it like this with a do/loop instead fo the wait key.



"Droids don't rip your arms off when they lose." -H. Solo
REALITY II
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 6th May 2005 13:23
yeah that was the part, however, it still doesn't work.

Login to post a reply

Server time is: 2024-11-27 22:48:10
Your offset time is: 2024-11-27 22:48:10