devolution

Author Topic: General Discussion  (Read 3821782 times)

0 Members and 28 Guests are viewing this topic.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6045 on: October 12, 2015, 03:58:59 AM »
When I try to run function
Quote
    def storyi_randomfight():
        enemy_team = Team(name="Enemy Team", max_size=3)
        your_team = Team(name="Your Team", max_size=3)
        rand_mobs = ["Infantryman", "Archer", "Soldier"]
        for i in range(randint(1, 3)):
            mob = build_mob(id=choice(rand_mobs), level=randint(1, 2))
            mob.controller = BE_AI(mob)
            enemy_team.add(mob)
        your_team.add(k)
        for member in your_team:
            member.controller = BE_AI(member)
        # your_team.add(hero)
        battle = BE_Core(Image("content/gfx/bg/be/dungeon.jpg"), music="content/sfx/music/be/battle (14).ogg", start_sfx=get_random_image_dissolve(1.5), end_sfx=dissolve)
        battle.teams.append(your_team)
        battle.teams.append(enemy_team)
        battle.start_battle()
        your_team.reset_controller()
        if battle.winner != your_team:
            renpy.jump("game_over")
I get
Quote
  File "game/library/events/StoryI/prison_break.rpy", line 57, in script
    $ storyi_randomfight()
  File "game/library/events/StoryI/prison_break.rpy", line 57, in <module>
    $ storyi_randomfight()
  File "game/library/events/StoryI/prison_break.rpy", line 22, in storyi_randomfight
    battle.start_battle()
  File "game/library/be/core.rpy", line 122, in start_battle
    self.main_loop()
  File "game/library/be/core.rpy", line 71, in main_loop
    ev.controller()
  File "game/library/be/core.rpy", line 777, in __call__
    skills = self.get_skills()
  File "game/library/be/core.rpy", line 807, in get_skills
    t = skill.get_targets(source=self.source)
  File "game/library/be/core.rpy", line 417, in get_targets
    l = battle.get_fighters()
NameError: global name 'battle' is not defined
I know it works via calling a label, but I'd prefer to do it via function.
« Last Edit: October 12, 2015, 04:11:11 AM by DarkTl »

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6046 on: October 12, 2015, 06:04:46 AM »
Besides, how should I use that "char.show("0000-bs.png", resize=(300, 300))" from fix #77? When I try something like chars["Sakura"].show(...), I have an error.

Offline Alex250

  • Newbie
  • *
  • Posts: 11
Re: General Discussion
« Reply #6047 on: October 12, 2015, 10:29:15 AM »
It eems the error happens in the start_battle() function of battle and you try to use battle.get_fighters(). Shouldn't you use self.get_fighters() since you are in a member function?
French -> please tell me when I make writing mistakes.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6048 on: October 12, 2015, 11:12:03 AM »
No idea... I tried everything I could think of, and end up with calling all battle parts outside of the function via call, since it keeps giving various errors about battle (yeah, they are various, depending on how I try it to avoid it, amazing  :D ).

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6049 on: October 12, 2015, 01:21:48 PM »
When I try to run functionI getI know it works via calling a label, but I'd prefer to do it via function.

BE code has never been reviewed or refactored or cleaned up (not once). Battle is presently expected to be a global variable, so:

Code: [Select]
    def storyi_randomfight():
        enemy_team = Team(name="Enemy Team", max_size=3)
        your_team = Team(name="Your Team", max_size=3)
        rand_mobs = ["Infantryman", "Archer", "Soldier"]
        for i in range(randint(1, 3)):
            mob = build_mob(id=choice(rand_mobs), level=randint(1, 2))
            mob.controller = BE_AI(mob)
            enemy_team.add(mob)
        your_team.add(k)
        for member in your_team:
            member.controller = BE_AI(member)
        # your_team.add(hero)

        # Use this instead:
        store.battle = BE_Core(Image("content/gfx/bg/be/dungeon.jpg"), music="content/sfx/music/be/battle (14).ogg", start_sfx=get_random_image_dissolve(1.5), end_sfx=dissolve)
        battle = store.battle

        battle.teams.append(your_team)
        battle.teams.append(enemy_team)
        battle.start_battle()
        your_team.reset_controller()
        if battle.winner != your_team:
            renpy.jump("game_over")

and it should work. You can also use:

Code: [Select]
global battle
if you like, it should result in exactly the same thing.
Like what we're doing?

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6050 on: October 12, 2015, 01:34:23 PM »
I'll be in chat for a couple of hours if anything needs to be discussed*
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6051 on: October 12, 2015, 01:47:08 PM »
I slept poorly last night, so I cannot afford to use chat today, it always ends up with staying up late  :D
I just need to clarify for tomorrow how to call a specific image from issue #77. You mentioned it like char.show(image name, size), but stuff like chars["character id"].show(...) doesn't work no matter what.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6052 on: October 12, 2015, 01:49:06 PM »
I slept poorly last night, so I cannot afford to use chat today, it always ends up with staying up late  :D
I just need to clarify for tomorrow how to call a specific image from issue #77. You mentioned it like char.show(image name, size), but stuff like chars["character id"].show(...) doesn't work no matter what.

I find that hard to accept... there should be no difference between the two. I'll try it myself tonight, maybe I've messed something up like writing char instead of self in the method.

===
Code: [Select]
char.show("0000-bs.png", resize=(120, 120))
chars["Hinata"].show("0000-bs.png", resize=(120, 120))

Console returns exactly the same thing in both cases (I tried calling Hinata from chars when char was set to a random girl as well). You'll have to be a bit more specific about the error you get.
« Last Edit: October 12, 2015, 01:58:13 PM by Xela »
Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6053 on: October 12, 2015, 02:00:36 PM »
I don't get an error, I don't see a picture on the screen.

$ s = chars["Sakura"]
$ s.show("002D-sx-ea-ee-c8-l4-ld-ma-m4-m8-bd-b2-b7.jpg", resize=(800, 600))

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6054 on: October 12, 2015, 02:18:01 PM »
I slept poorly last night,

No kidding...

This is your code from when you were awake:

Like what we're doing?

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6055 on: October 12, 2015, 02:29:29 PM »
Ah, expression. My bad. Until tomorrow then  :)

Offline Alex250

  • Newbie
  • *
  • Posts: 11
Re: General Discussion
« Reply #6056 on: October 12, 2015, 07:35:22 PM »
I will not push the .gitignore change we talked about in the other thread. I made that because I was frustrated, it took me a good hour before I could run the game. Once you know how it works the current system is easy and safe to work with while with .gitignore in the folders you risk accidentally deleting it and adding all of your images to the repo if you are not careful.

I am working on restoring Xenoa. I moved her interraction under a label ("find_xenoa") and removed the global flag it was using. It works and I could push it now, but I want to know if it is alright with you to have a new label, I don't know if it can cause issues in other parts of the code.

Also, how do you add a girl to your team? I want to make a girl train with Xenoa. In the alpha there used to be a bug/exploit there, I want to see if I can fix it if it hasn't already.
French -> please tell me when I make writing mistakes.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: General Discussion
« Reply #6057 on: October 13, 2015, 12:21:18 AM »
I am working on restoring Xenoa. I moved her interraction under a label ("find_xenoa") and removed the global flag it was using.

1) Her name should be Xeona.

2) I am not sure what you mean by "moved interaction". She is supposed to greet the player once upon entry to the Arena Outside and then she can be found using the Find Xeona button.

It works and I could push it now, but I want to know if it is alright with you to have a new label, I don't know if it can cause issues in other parts of the code.

I don't think that it can cause issues in this code, renaming labels can most definitely cause issues in other places but usually those are game gui screens or Interactions labels and not NPC labels.

Also, how do you add a girl to your team? I want to make a girl train with Xenoa. In the alpha there used to be a bug/exploit there, I want to see if I can fix it if it hasn't already.

Use console or a button in girls profile (it's an icon on the left side of the top stripe).
Like what we're doing?

Offline Alex250

  • Newbie
  • *
  • Posts: 11
Re: General Discussion
« Reply #6058 on: October 13, 2015, 02:22:47 AM »
1) Her name should be Xeona.

2) I am not sure what you mean by "moved interaction".

1) Thanks

2) I moved the code of her interaction out of the arena_outside label to a new label in the same file. She still acts the same, offers training and arena permit.


I found the button and did my test, the exploit is still there. Making a girl train with Xeona gives her XP based on MC's level and gives stats to MC. Training cost is correctly based on girl's level. I'll try to fix it tomorrow but it might be too complex for me, if it is I will make a Git Issue.

edit: I corrected my label and it broke my save. When I use a saved game which has spoken to Xeona while her interaction was Under the faulty label then speaking to her again makes an error: cannot find label "find_xenoa". Why is this saved? Is it a Renpy feature? Is that what you were warning me about when you said renaming labels caused problems?
I'm just curious, everything still works and the transition from old to new causes no problem.
« Last Edit: October 13, 2015, 09:53:52 AM by Alex250 »
French -> please tell me when I make writing mistakes.

Offline DarkTl

  • Hero Member
  • *****
  • Posts: 4737
Re: General Discussion
« Reply #6059 on: October 13, 2015, 10:05:59 AM »
In my experience, saves are not a perfectly reliable way to test changes in the code, they don't take into account many things. Usually it's better to start a new game and, if needed, run the label you want to test from the console.

Also, when you change the code a lot, sometimes you have to force recompile the game, there is an option for that in renpy launcher.