HELP - trying to reverse engineer old code

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.
Post Reply
Message
Author
User avatar
Bryy
Veteran
Posts: 407
Joined: Thu Dec 20, 2012 10:12 pm
Completed: 30+ games so far
Projects: Furry Shakespeare
Organization: Stegalosaurus Game Development
Location: Portage, MI
Contact:

HELP - trying to reverse engineer old code

#1 Post by Bryy »

So, Army of Tentacles had a fairly modifiable quest log system that I'm trying to reverse engineer into the code for the sequel. But it doesn't seem to be working.

Here's Army 1's quest code:

Code: Select all

init -6 python:
    import math
    class Quest():
        def __init__(self):
            self.name = "Quest"
            self.reward_text = "Reward: "
            self.reward_stat = 0
            self.reward_army = None
            self.reward_party = None
            self.task = ""
            self.layer=1

    class q_Fixing_Things(Quest):
        def __init__(self):
            Quest.__init__(self)
            self.name = 'Fixing Things'
            self.reward_text = ""
            self.task = "Go to Harbor, get netting. Go to Fishery, get oil. Go to General Store, get wrench."

screen quest_menu:
    add "media_assets/ui/quest_window.png"
    vbox:
        frame:
            background None
            yminimum 0.625
            ymaximum 0.625
            xminimum 0.70
            xmaximum 0.70
            left_padding 30
            bottom_padding 5
            top_padding 30
            vbox:                
                text "Open Quests" color "#1B3" size 40 font font_default outlines [(3,"#000"), (3,"#000a",2,2)] xalign 0.5
                side "c r":
                    viewport:
                        draggable True
                        mousewheel True
                        yadjustment QUEST_SCROLL_ADJUSTMENT
                        vbox:
                            for q in perry.quests:
                                vbox:
                                    text [q.name] color "#BB0" size 28 font font_default outlines [(3,"#000"), (3,"#000a",2,2)] xalign 0.5
                                    text q.task size 30 font font_default outlines [(3,"#000"), (3,"#000a",2,2)]
                                    text 'Reward: [q.reward_text]' size 30 font font_default outlines [(3,"#000"), (3,"#000a",2,2)]
                                    image "media_assets/ui/bar_clear.png"
                    vbar:
                        style "l_vscrollbar"
                        adjustment QUEST_SCROLL_ADJUSTMENT
In my main flags:

Code: Select all

q_Fixing_Things = q_Fixing_Things()
and in the script:

Code: Select all

    $perry.quests.append(q_cady)
    perry "This is the quest code that puts it into the screen!"
    $perry.remove_quest(q_cady)
    perry "Oh no, we did it go?"
Now, here's where I'm trying to put it in the screens file:

Code: Select all

init -6 python:
    import math
    class Quest():
        def __init__(self):
            self.name = "Quest"
            self.reward_text = "Reward: "
            self.reward_stat = 0
            self.reward_army = None
            self.reward_party = None
            self.task = ""
            self.layer=1
            
    class q_Humonz(Quest):
        def __init__(self):
            Quest.__init__(self)
            self.name = 'Fixing Things'
            self.reward_text = ""
            self.task = "Go to Harbor, get netting. Go to Fishery, get oil. Go to General Store, get wrench."
            
screen quest_log:
    tag menu
    add "gui/prefs_bg.png"
    frame:
        for q in perry.quests:
            vbox:
                text [q.name] color "#BB0" size 28 font font_default outlines [(3,"#000"), (3,"#000a",2,2)] xalign 0.5
                text q.task size 30 font font_default outlines [(3,"#000"), (3,"#000a",2,2)]
                text 'Reward: [q.reward_text]' size 30 font font_default outlines [(3,"#000"), (3,"#000a",2,2)]
Complete with q_Humonz in my flags.

But this is the error that I get:

Code: Select all

While running game code:
  File "game/script.rpy", line 5047, in script
    call screen quest_log
  File "renpy/common/000statements.rpy", line 471, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "game/screens.rpy", line 2853, in execute
    screen quest_log:
  File "game/screens.rpy", line 2853, in execute
    screen quest_log:
  File "game/screens.rpy", line 2856, in execute
    frame:
  File "game/screens.rpy", line 2857, in execute
    for q in perry.quests:
AttributeError: 'ADVCharacter' object has no attribute 'quests'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 5047, in script
    call screen quest_log
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\ast.py", line 1706, in execute
    self.call("execute")
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\ast.py", line 1724, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\statements.py", line 145, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 471, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\exports.py", line 2521, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\display\core.py", line 2504, in interact
    scene_lists.replace_transient()
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\display\core.py", line 809, in replace_transient
    self.remove(layer, tag)
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\display\core.py", line 1094, in remove
    self.hide_or_replace(layer, remove_index, "hide")
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\display\core.py", line 1018, in hide_or_replace
    d = oldsle.displayable._hide(now - st, now - at, prefix)
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\display\screen.py", line 443, in _hide
    self.update()
  File "E:\BRYY 11.25.2015\STEG 4.20.2016\renpy-6.99.12.1-sdk\renpy\display\screen.py", line 578, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 2853, in execute
    screen quest_log:
  File "game/screens.rpy", line 2853, in execute
    screen quest_log:
  File "game/screens.rpy", line 2856, in execute
    frame:
  File "game/screens.rpy", line 2857, in execute
    for q in perry.quests:
  File "<screen language>", line 2857, in <module>
AttributeError: 'ADVCharacter' object has no attribute 'quests'

User avatar
valeatory
Regular
Posts: 36
Joined: Mon Apr 23, 2007 3:01 pm
Projects: Nightglove Institute, Monstrata Fracture
Organization: Astralore Games
Tumblr: valeatory
itch: astralore
Location: America
Contact:

Re: HELP - trying to reverse engineer old code

#2 Post by valeatory »

I don't see where you've defined perry, perry.quests, or perry.remove_quest. I do see that you're using perry as your sayer, which is what is causing the error to refer to 'perry' as an 'ADVCharacter' object. Showing where you've assigned the things in that list might help people to figure out how the system is meant to work.
Nightglove Institute - Kidnapped students, forced to train to be secret agents and assassins!
Monstrata Fracture - Date cute monsters! But will you risk destabilizing the human plane of existence?

User avatar
Bryy
Veteran
Posts: 407
Joined: Thu Dec 20, 2012 10:12 pm
Completed: 30+ games so far
Projects: Furry Shakespeare
Organization: Stegalosaurus Game Development
Location: Portage, MI
Contact:

Re: HELP - trying to reverse engineer old code

#3 Post by Bryy »

*facepalm*

I forgot to include that, didn't I?

Here is the info from the Perry file, there's a lot of stuff here but a lot of it is not been incorporated into the sequel's code (such as the leveling system, etc.). I'm just trying to take out the basic parts to mimic it enough so what it will do is:

1) Quest name shows up on Quest Screen when the quest is received in the code
2) Quests are removed through other means of code

Code: Select all

       

    class Hero():
        def __init__(self, shout, image, image_path, max_hp):
            self.name = shout.name
            self.shout = shout
            self.image = image
            self.image_path = image_path
            self.image_scale = 1
            self.level_dict = { 1 : "Novice" }
            self.level = 0
            self.days_to_train=28
            self.max_hp = max_hp
            self.hp = self.max_hp
            self.intelligence = 1
            self.cur_max_hp = max_hp
            self.cur_intelligence = 1
            self.weapon = None
            self.army = []
            self.quests = []
            self.armor = None
            self.weapon2 = None
            self.armor2 = None
            self.quest_items = { None : None } #Dummy Entry
            self.equipment = { None : None } #Dummy Entry 

def has_quest_item(self, item):
            for k, v in self.quest_items.iteritems():
                if k == item.name:
                    return True
            return False
            
        def get_quest_item(self, item):
            for k, v in self.inventory.iteritems():
                if v == item:
                    return v
            return None
            
        def get_quest_item_list(self):
            temp = []
            for k, v in self.quest_items.iteritems():
                if not( k is None):
                    temp.append(v)
            return temp
            
        def add_quest_item(self, item_obj):
            if not(self.quest_items.has_key(item_obj.name)):
                self.quest_items[item_obj.name] = item_obj
                return True
            return False
                
        def remove_quest_item(self, item_obj):
            if self.quest_items.has_key(item_obj.name):
                del self.quest_items[item_obj.name]
                return True
            return False
            
        def remove_quest(self, item_obj):
            for k in self.quests:
                if k.name == item_obj.name:
                    self.quests.remove(k)
                    return True
            return False
    
    class Perry_Character(Hero):
        def __init__(self, is_male=True):
            Hero.__init__(self, p, 'chara_angus', chara_path_angus, 30)
            self.is_male = is_male
            self.image = 'chara_male_perry'
            self.image_path = chara_path_male_perry
            if is_male:
                self.image = 'chara_male_perry'
                self.image_path = chara_path_male_perry
            else:
                self.image = 'chara_fem_perry'
                self.image_path = chara_path_fem_perry
            self.image_scale = 1
            self.level_dict = { -1: "Untrained", 0 : "Untrained", 1 : "Soldier", 2 : "Captain" , 3 : "Commander" , 4 : "General", 5: "General"  }

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: HELP - trying to reverse engineer old code

#4 Post by xela »

Check if Hero inherits from ADVCharacter in the original code. You can obviously also just instantiate Hero and sayer separately.
Like what we're doing? Support us at:
Image

User avatar
Bryy
Veteran
Posts: 407
Joined: Thu Dec 20, 2012 10:12 pm
Completed: 30+ games so far
Projects: Furry Shakespeare
Organization: Stegalosaurus Game Development
Location: Portage, MI
Contact:

Re: HELP - trying to reverse engineer old code

#5 Post by Bryy »

Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users