Special Battle System [Solved]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
Destiny
Veteran
Posts: 468
Joined: Thu Jun 14, 2012 2:00 pm
Projects: Cards of Destiny, Sky Eye
Location: Germany
Contact:

Special Battle System [Solved]

#1 Post by Destiny » Sun Jun 17, 2012 3:20 pm

Solved:
Here is the working card battle scipt :D
Thanks again to KimiYoriBaka for the script, the help and the many hours that he/she (I'm not sure xD) invested in helping me!
game.zip
(1.65 KiB) Downloaded 71 times
___________________________________________________________________________________________


I'm not sure how to find a good name, so I just hope, I can explain it good enough.

I want a special battle system.
I found different scripts, but they don't seem to work with each other or the changes I do won't work.
First the three steps how it's supposed to work:

1)
The hero has 22 cards. each card does a different thing (two hurt the hero, ten protect him and ten attack the enemy.
The player can only choose between three cards from these 22. These should be called at random.
So that in round one he gets 2, 15 and 21; in round two he gets 13, 15 and 18; in round three he gets 4, 11 and 22; etc.
So I want a script that calls three of these choices at random.
I only found THIS SCRIPT, but I guess I don't understand it, since I can't write use it so that it works.

2)
I want, that these choices are shown with pictures.
I guess, the most fitting way should be a image map where the cards themself are seen and easier to remember.
But the problem with the random script is still there.
OR maybe it could be solved with the normal choices, when there is a command to let a image instead of a choice appear.
But if that would work, then I'm just too bad in searching since all the "show image"-scripts I found do not work but produce errors.

3)
The HP-Bar
i use THIS as battle code right now and have simpley ereased all the abilitys out. I guess the codes for the things above could be inserted in this.
BUT it's missing a HP bar. It tells how much HP hero and enemy have left, but I want it visible through the battle.
I tried inserting this code somehow: CLICK
But it just shows the HP of the hero and I am too much of a noob to get it so it also shows the enemys HP (on the left side would be perfect)


I'm not even sure if the stuff can be done the way I want, but any help would be very appreciated :)
Last edited by Destiny on Tue Jul 31, 2012 12:26 pm, edited 2 times in total.
Image
Cards of Destiny (WIP) / Sky Eye (WIP)

User avatar
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Special Battle System

#2 Post by KimiYoriBaka » Sun Jun 17, 2012 4:12 pm

as long as it doesn't require too hefty of graphics, it can be done. It's just a matter of how complex it needs to be.

if it's turn-based you can do it entirely in screen language (as opposed to live-action which would probably need pygame).

answering the specific questions:

1) there are two functions that are good for this
renpy.random.choice which takes a list containing all the possible choices and returns one of them
renpy.random.randint which takes a min and max and returns an integer.

for what you've described, I would suggest the former, as it makes it easier to ensure that you don't get repeats.
using the numbers in your example, it would look like this:

Code: Select all

label draw3:
    python:
        deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20. 21, 22, 23]
        for i in range(3):
            newcard = renpy.random.choice(deck)
            deck.remove(newcard)
            hand.append(newcard)
if you need to change the number to draw, just change the value in range. if you need to change how the cards are represented just change the contents of deck

2) generally, if you have picture choices that are too dynamic for an image map, then you should use imagebuttons instead. it's a bit more complex, but a lot more versatile.
for combining this with the code for question 1, it might be helpful to use image names or filenames for images instead of numbers, but numbers work too. an example using numbers would be:

Code: Select all

screen playerhand:
    for a in range(len(hand)):
         if a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:   #assuming 1-10 as attack cards     
             imagebutton (str(a) + ".png"):
                 action Jump('attack')
                 xpos (100 + a * 50) ypos 600
         if a in [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]:
             imagebutton (str(a) + ".png"):
                 action Jump('defend')
                 xpos (100 + a * 50) ypos 600
         if a in [21, 22]:
             imagebutton (str(a) + ".png"):
                 action Jump('hurtplayer')
                 xpos (100 + a * 50) ypos 600
the positional number are of course arbitrary.

3) somehow at the moment, I can't think of a better way to explain it other than, "just add another bar." oh to have it based on the enemy's hp just change value and range.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 752
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Special Battle System

#3 Post by Milkymalk » Mon Jun 18, 2012 12:18 am

Short note:
You don't need a list to get a random number between x and y:

Code: Select all

$ my_number = int(renpy.random.random*maximum)+1[code]
works as well. [i]renpy.random.random[/i] picks a random float number with 0<=number<1; multiply that with your desired maximum and you get a number with 0<number<maximum. [i]Int[/i] rounds that down, so you need +1 to make it between 1 and your maximum.

You can then make a list that actually contains the card names or file names or whatever and address the elements of the list by their index, that being the number.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
Destiny
Veteran
Posts: 468
Joined: Thu Jun 14, 2012 2:00 pm
Projects: Cards of Destiny, Sky Eye
Location: Germany
Contact:

Re: Special Battle System

#4 Post by Destiny » Mon Jun 18, 2012 3:30 am

Thanks for answering so far :)

Well, I try my best to understand Phyton and the Ren'Py language, but it sometimes confuses me more then anything.

I inserted your two parts, KimiYoriBaka.
But I get two errors:

Code: Select all

expected a keyword argument, colon, or end of line.
      imagebutton ->(str(a) + "card1.png"):
and

Code: Select all

invalid syntax
      deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21->, 22, 23]
Also, I have a question about the placing.
I placed the draw3-label at the top, made the script call it and inserted a "jump battle" at the end of draw3 to make the battle itself start.
Of course, because the other two errors make the game impossible to test I don't know if this is correct or will cause some strange happenings.

Also, as I said, I have a problem about question 3 making the frame LEFT.
I had the value changed already but it is above the hero frame. And xalign and yalign only make the frame a few pixel longer, nothing else. I just don't get it, how to make it MOVE to the left border. Whenever I try to insert a xborder and yborder I get errors, so I guess, they are placed at the wrong place or something.

@milkymalk
When I try yours, I also get a error

Code: Select all

TypeError: unsupported operand type(s) for*: 'instancemethod' and 'int'
Maybe I misunderstood your explanation?
Heres my code

Code: Select all

    $ my_number = int(renpy.random.random*22)+1
Also how exactly do I make the code recognize the images in the numbers?
Is there a way with init to make the images define themself as the numbers? Or do I work with if-statements (if 1 then card1; if 2 then card2; etc)?


Sorry, if I'm making much work, I really try but I'm also fairly new to Phyton and just can't get my head into some codes, even though I work with the Ren'Py-wiki and Python v2.7.3 documentation to understand everything...
Image
Cards of Destiny (WIP) / Sky Eye (WIP)

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Special Battle System

#5 Post by nyaatrap » Mon Jun 18, 2012 4:07 am

How about renpy.random.randint(x,y)?
I'm using this statement along with int(renpy.random.random()*something)

User avatar
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Special Battle System

#6 Post by KimiYoriBaka » Mon Jun 18, 2012 9:06 am

whoops.

sorry about that, I screwed up.

the imagebuttons should be

Code: Select all

imagebutton:
    idle (str(a) + ".png")
    hover (str(a) + ".png")
    action Jump('attack')
    xpos (100 + a * 50) ypos 600
I was thinking of textbuttons, which take the visual content as a parameter instead of an action.

for the other error, it looks like I accidently put a period in place of one of the commas, but strangely, I don't see that in your post, even though the error is pointing to the same spot as if it was there. :/

try just retyping it and see if the error still comes up.

for the placing, that should be fine as long as you've already given a starting value to the necessary variables. it is hard to tell if it's correct, though, just from what you've said, but it sounds right.

for question 3, does it work if you add the bar like this?

Code: Select all

            hbox: 
                vbox: 
                    hbox:
                        text "HP" size 20
                        bar value currenthp range maxhp xmaximum 200
                    hbox:
                        text "SP" size 20
                        bar value currentmp range maxmp xmaximum 200
                vbox: 
                    hbox:
                        text "EnemyHP" size 20
                        bar value enemyhp range enemymaxhp xmaximum 200
                    hbox:
                        text "EnemySP" size 20
                        bar value enemymp range enemymaxmp xmaximum 200
                vbox:
                    text ("%d/%d" % (currenthp, maxhp)) xalign 0.5 size 20
                    text ("%d/%d" % (currentmp, maxmp)) xalign 0.5 size 20
lastly, about milkymalk's code, that's how you would use the other version of renpy.random that I didn't mention because it's a more explicit (or put another way, more complicated) way of doing exactly the same thing.

Code: Select all

int(renpy.random.random*max) + min
is what the function renpy.random.randint does. in addition

Code: Select all

list[renpy.random.randint(0, len(list))]
is what the function renpy.random.choice does. (disclaimer: I haven't actually looked inside to see if that's the explicit code, but that's at least equivalent)
the reason I suggested using renpy.random.choice with a list of numbers was because that function is easiest to explain and also easiest to convert to a list of filenames/image names since it does everything else for you.

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Special Battle System

#7 Post by Showsni » Mon Jun 18, 2012 9:41 am

I was thinking of making a card game type game in ren'py, so I actually had some nice code set up for shuffling decks, drawing cards, etc, but I lost it when I got a new computer... oh well. Anyway, just mentioning some things that might be useful:

First, the shuffle command. If you import the random module
import random
you can use random.shuffle(x) to shuffle a list x. You can then just use pop to draw a card (pop() will remove and return the last item in the list).

E.g. if you put:

Code: Select all

init:
    python:
        import random
        def shuffledeck(deck):
            random.shuffle(deck)
        def drawcard(hand, deck):
            hand.append(deck.pop())
at the top,

you can then use

$ shuffledeck(deck)

at any time to shuffle the list deck and

$ drawcard(hand, deck)

at any time to draw a card from the list hand and add it to the list deck.

It's basically the same outcome as KimiYoriBaka's code, though.

User avatar
Destiny
Veteran
Posts: 468
Joined: Thu Jun 14, 2012 2:00 pm
Projects: Cards of Destiny, Sky Eye
Location: Germany
Contact:

Re: Special Battle System

#8 Post by Destiny » Mon Jun 18, 2012 4:30 pm

@KimiYoriBaka

First thanks for making the HP bar work as I wanted :D
It's perfect now, thank you very much.

And yes, I was so stupid t not copy the error but write it down. I ereased the error about 1, 2, 3, etc.
There was a point where a comma was supposed to be.
I changed it and the error was gone.

But it's still not working.

Now there is this:

Code: Select all

label draw3:
    python:
        deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
        for i in range(3):
            newcard = renpy.random.choice(deck)
            deck.remove(newcard)
            hand.append(newcard)
line 31 to line 37, just for information

Code: Select all

While running game code:
  File "game/battle sample.rpy", line 32, in script
  File "game/battle sample.rpy", line 37, in python
NameError: name 'hand' is not defined
But hey, most of the errors are gone (or maybe they will only activate if this one vanishes? :'D)

I tried typing it myself in case there is a minor fault in the script but the error won't leave.
I guess, I need a init where def hand.append is used...?
I tried the code from showsni, since there is a simliar line but it didn't do anything visible, the error stayed and the game won't start :/
Image
Cards of Destiny (WIP) / Sky Eye (WIP)

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Special Battle System

#9 Post by Showsni » Mon Jun 18, 2012 7:43 pm

You just need to put

Code: Select all

$ hand = []
somewhere first. (I usually put all these variables under the start label). (You'd also need to define a deck for my code).

User avatar
Destiny
Veteran
Posts: 468
Joined: Thu Jun 14, 2012 2:00 pm
Projects: Cards of Destiny, Sky Eye
Location: Germany
Contact:

Re: Special Battle System

#10 Post by Destiny » Tue Jun 19, 2012 1:19 am

...Ok, this starts to get kind of frustrating, since I myself can't see the problem...

Suddenly Ren'py seems to go totally crazy.

When I want the HP bar in it, it either goes all blue with the battle text or it makes the error "could not find screen hpbars"
When I take the HP bar out, it either just makes the fight roll without showing any fight menü (not even mention something like my wanted card menü even though I have the command "show screen playerhand" command) or makes an error, that "22.png" in line 66 is missing.

Code: Select all

   "I attack the enemy!"
is the only thing in line 66. There is no "22.png" anywhere in the script...
If I insert a random image named "22.png", it suddenly wants a "32.png" in the every same line.

Theres no cache file that I could delete (since I hears, that could help sometimes).

Soooo... Help?
Image
Cards of Destiny (WIP) / Sky Eye (WIP)

User avatar
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Special Battle System

#11 Post by KimiYoriBaka » Tue Jun 19, 2012 8:02 am

makes an error, that "22.png" in line 66 is missing.
in general, error tend not to be detected on the line that they are actually on. it's usually either a line or two before it's detected, or in something that's being processed continually (such as a screen).

for example
even though I have the command "show screen playerhand" command
is this command right before line 66? if so that would mean any error that was in the screen itself wouldn't be noticed until an "interaction" occurs (which is usually in the form of either a pause command or dialog).

also, show screen doesn't cause an "interaction" so if your combat menu isn't showing it probably means you either need to use call screen instead or add in a pause command after show screen

as for the error itself, it just occurred to me that I didn't explain the line that actually says the filename in my code (which I definitely shouldn't have assumed would be obvious :oops: )

do you still have this part?

Code: Select all

    idle (str(a) + ".png")
    hover (str(a) + ".png")
cause if so, that means your imagebuttons are taking whatever is in the list and adding ".png" at the end to get the filename, so it expects images with the names "1.png", "2.png", etc... I just put that cause it works with the example. if that's not what your image files are called, you'll need to change it.

I'm not sure what's wrong with your hp bars. Did you name your screen containing them hpbars? also, I'm not sure what you mean by "goes all blue". do you mean the entire bar goes blue? or the entire screen?

User avatar
Destiny
Veteran
Posts: 468
Joined: Thu Jun 14, 2012 2:00 pm
Projects: Cards of Destiny, Sky Eye
Location: Germany
Contact:

Re: Special Battle System

#12 Post by Destiny » Tue Jun 19, 2012 9:11 am

The "call"-command did it with the hp bars :)
And it was simply the case, that the background wasn't seethrough (as it will look when not using a background) but the color of the menu (in my case blue).
Nothing else, just blue and the speech box.
But it's fixed now, the hint with call was good.

The error about "can't find 32.png" is also gone, seems to be wiped out.


And I also guess it's almost finished, the only problem is:
I don't see something ôo
The health bar is up there, but nothing else.
No speech box, no cards, nothing. I can also click on nothing, the screen seems to be totally empty.
I named my cards 1-22, of course as png. And I tried typing all the codes by hand in case I have an error there again.
I post my entire battle.rpy as code, maybe I just don't see the error or I did something wrong (like changing a command or stuff)

Code: Select all

init:
   $ hp = 100
   $ maxhp = 100
   $ enemyhp = 100
   $ enemymaxhp = 100
   $ hand = []


screen hpbars:
        frame:
            xalign 1.0
            yalign 0.0
            hbox:
                vbox:
                    hbox:
                        text "HP" size 20
                        bar value hp range maxhp xmaximum 200
                vbox:
                    hbox:
                        text "EnemyHP" size 20
                        bar value enemyhp range enemymaxhp xmaximum 200
                vbox:
                    text ("%d/%d" % (hp, maxhp)) xalign 0.5 size 20

                         
label draw3:
    python:
        deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
        for i in range(3):
            newcard = renpy.random.choice(deck)
            deck.remove(newcard)
            hand.append(newcard)
    jump battle

label battle:
    screen playerhand:
         for a in range(len(hand)):
             if a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:   #assuming 1-10 as attack cards     
                       imagebutton:
                             idle (str(a) + ".png")
                             hover (str(a) + ".png")
                             action Jump('attack')
                             xpos (100 + a * 50) ypos 600
             if a in [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]:
                       imagebutton:
                             idle (str(a) + ".png")
                             hover (str(a) + ".png")
                             action Jump('defend')
                             xpos (100 + a * 50) ypos 600
             if a in [21, 22]:
                       imagebutton:
                             idle (str(a) + ".png")
                             hover (str(a) + ".png")
                             action Jump('hurtplayer')
                             xpos (100 + a * 50) ypos 600
             if a in [10, 20]:
                       imagebutton:
                             idle (str(a) + ".png")
                             hover (str(a) + "18.png")
                             action Jump('healall')
                             xpos (100 + a * 50) ypos 600   
                             

    
label attack:
   "I attack the enemy!"
   $ enemyhp -= 10
   "I deal 10 damage."
   "Enemy's HP %(enemyhp)d."
   jump victory

label defend:
    "Nothing happend."
    jump battle
    
label healall:
    "Everyone is healed!"
    $ hp = maxhp
    $ enemyhp = enemymaxhp
    
label hurtplayer:
    "Argh!"
    $ hp -= 10
    "You lose 10 HP."
    "Robin HP %(hp)d."
    jump victory

label victory:
    if enemyhp < 1:
        "I won!" 
        jump after_battle
    else:
        jump lose

label lose:
    if hp < 1:
        "Game Over!"
        return
    else:
        jump damage
        
label damage:
    "The enemy attacked you!"
    $ hp -= 5
    "You lose 5 HP."
    "Robin HP %(hp)d."
    jump battle
Like I said, the images are called 1.png, 2.png, 3.png, etc till 22.png
So that wouldn't be a problem.
They are also 600x772 pixel, maybe they are too big?

I'm very sorry for all the work (and me being so stupid).
But what would be a card magician without magic cards? xD"

P.S.
Cool, spoiler doesn't work when posting a code =__=

P.P.S.

I just tried this, still won't work

Code: Select all

init:
   $ hp = 100
   $ maxhp = 100
   $ enemyhp = 100
   $ enemymaxhp = 100
   $ hand = []


screen hpbars:
        frame:
            xalign 1.0
            yalign 0.0
            hbox:
                vbox:
                    hbox:
                        text "HP" size 20
                        bar value hp range maxhp xmaximum 200
                vbox:
                    hbox:
                        text "EnemyHP" size 20
                        bar value enemyhp range enemymaxhp xmaximum 200
                vbox:
                    text ("%d/%d" % (hp, maxhp)) xalign 0.5 size 20
                    
                    
screen playerhand:
         for a in range(len(hand)):
             if a in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:   #assuming 1-10 as attack cards     
                       imagebutton:
                             idle (str(a) + ".png")
                             hover (str(a) + ".png")
                             action Jump('attack')
                             xpos (100 + a * 50) ypos 600
             if a in [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]:
                       imagebutton:
                             idle (str(a) + ".png")
                             hover (str(a) + ".png")
                             action Jump('defend')
                             xpos (100 + a * 50) ypos 600
             if a in [21, 22]:
                       imagebutton:
                             idle (str(a) + ".png")
                             hover (str(a) + ".png")
                             action Jump('hurtplayer')
                             xpos (100 + a * 50) ypos 600
             if a in [10, 20]:
                       imagebutton:
                             idle (str(a) + ".png")
                             hover (str(a) + "18.png")
                             action Jump('healall')
                             xpos (100 + a * 50) ypos 600

                         
label draw3:
    python:
        deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
        for i in range(3):
            newcard = renpy.random.choice(deck)
            deck.remove(newcard)
            hand.append(newcard)
    jump battle

label battle:
 call screen playerhand

    
label attack:
   "I attack the enemy!"
   $ enemyhp -= 10
   "I deal 10 damage."
   "Enemy's HP %(enemyhp)d."
   jump victory

label defend:
    "Nothing happend."
    jump battle
    
label healall:
    "Everyone is healed!"
    $ hp = maxhp
    $ enemyhp = enemymaxhp
    
label hurtplayer:
    "Argh!"
    $ hp -= 10
    "You lose 10 HP."
    "Robin HP %(hp)d."
    jump victory

label victory:
    if enemyhp < 1:
        "I won!" 
        jump after_battle
    else:
        jump lose

label lose:
    if hp < 1:
        "Game Over!"
        return
    else:
        jump damage
        
label damage:
    "The enemy attacked you!"
    $ hp -= 5
    "You lose 5 HP."
    "Robin HP %(hp)d."
    jump battle
Image
Cards of Destiny (WIP) / Sky Eye (WIP)

User avatar
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Special Battle System

#13 Post by KimiYoriBaka » Tue Jun 19, 2012 10:28 am

Code: Select all

xpos (100 + a * 50) ypos 600
... :oops:

by any chance, is your resolution set at anything normal? cause if so having a ypos at 600 would put your imagebuttons off the screen. just try fiddling around with the positions until they look good

I was probably thinking of the normal width instead of the height when I put that...

and yes, 600x772 is too big. even on widescreen resolutions that would be half the screen.

Code: Select all

if a in [10, 20]:
when you're adding in more effects, it'd be a good idea to make sure the numbers used aren't still in the lists for the other imagebuttons. you've still got 10 in attack and 20 in defense.

User avatar
Destiny
Veteran
Posts: 468
Joined: Thu Jun 14, 2012 2:00 pm
Projects: Cards of Destiny, Sky Eye
Location: Germany
Contact:

Re: Special Battle System

#14 Post by Destiny » Tue Jun 19, 2012 12:17 pm

KimiYoriBaka wrote:

Code: Select all

if a in [10, 20]:
when you're adding in more effects, it'd be a good idea to make sure the numbers used aren't still in the lists for the other imagebuttons. you've still got 10 in attack and 20 in defense.
:oops:
I ereased them in those lines, then thought it didn't work because of the extra command, put them back in and then inserted the extra command without ereasing those numbers again...
I seem to become forgetful...

And I noticed that the script seems to stop somewhere, because when I do this

Code: Select all

label battle:
    call screen playerhand
    menu:
            "Attack":
                   jump attack
            "Defend":
                   jump defend
I won't get the menu.
So it stops either in

Code: Select all

label draw3:
    python:
        deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
        for i in range(3):
            newcard = renpy.random.choice(deck)
            deck.remove(newcard)
            hand.append(newcard)
    jump battle
or in label battle :/
No errors, but also nothing to click or see (except for the hp bar).
So it reads the command "call hpbars" in script.rpy, it's also to use it (despite being in battle.rpy), but from battle.rpy it seems to read nothing or at least nothing I could notice...

No wonder I'm not able to see the cards (because I tried out almost every number between 0 and 1100 ôo)

I swear, I will breathe alot easier when this script finally works...
Image
Cards of Destiny (WIP) / Sky Eye (WIP)

User avatar
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: Special Battle System

#15 Post by KimiYoriBaka » Tue Jun 19, 2012 4:24 pm

tbh, I have no idea why this code isn't working. I'll try to fiddle around with similar code later to see if I can recreate your problems, but for now this is all I can think of.

Code: Select all

label battle:
    call screen playerhand
    menu:
            "Attack":
                   jump attack
            "Defend":
                   jump defend
this shouldn't get the menu, because it would wait for a choice to be made in call screen.

edit: I found what seems to be the problem. it was an oversight on my part. in the screen for the player's hand some of the references to a should be hand[a] so that it refers to the actual card in hand like this:

Code: Select all

if hand[a] in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:   #assuming 1-10 as attack cards     
             imagebutton (str(hand[a]) + ".png"):
                 action Jump('attack')
                 xpos (100 + a * 50) ypos 400
I didn't see any other problems besides what I mentioned earlier.

Post Reply

Who is online

Users browsing this forum: No registered users