Need advice on AOE skill [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.
Post Reply
Message
Author
Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Need advice on AOE skill [SOLVED]

#1 Post by Nero »

Hey there so I made game that can currently fit up to 6 enemy players.
My question is how can I make AOE spell that damages all players inside

Code: Select all

$ enemy_members_list = []
without needing to repeat same code over and over like I did here (AOE ATTACK) and below.Second question: is there also a easier way to randomize damage done all across enemies? For example enemy1 got damaged for 78dmg enemy2 took 59dmg etc?

Code: Select all

    $ enemy_members_list = []    
    
    python:
        for i in range ( 1 ):
            enemy_members_list.append(enemy1)
            enemy_members_list.append(enemy2)
            enemy_members_list.append(enemy3)
            enemy_members_list.append(enemy4)
            enemy_members_list.append(enemy5)   
            enemy_members_list.append(enemy6)     
    

    
    menu:    
        "AOE ATTACK":
             $ player_damage = renpy.random.randint(bob.PLAYER_MAX_DAMAGE, bob.PLAYER_MIN_DAMAGE)
             $ enemy1 -= player_damage
             $ enemy2 -= player_damage
             $ enemy3 -= player_damage
             $ enemy4 -= player_damage
             $ enemy5 -= player_damage
             $ enemy6 -= player_damage
             jump PLAYER_TURN_RESET
Last edited by Nero on Fri Jul 14, 2017 4:52 pm, edited 1 time in total.

User avatar
Zetsubou
Miko-Class Veteran
Posts: 522
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Need advice on AOE skill

#2 Post by Zetsubou »

Untested, but maybe something like:

Code: Select all

    $ enemy_members_list = [enemy1, enemy2, enemy3, enemy4, enemy5, enemy6]

    menu:   
        "AOE ATTACK":
             for enemy in enemy_members_list:
                 $ player_damage = renpy.random.randint(bob.PLAYER_MAX_DAMAGE, bob.PLAYER_MIN_DAMAGE)
                 $ enemy -= player_damage
             jump PLAYER_TURN_RESET
Whether the above works as-is or not, the point is that looping through your enemies list, and redefining player_damage within that loop, solves both of your problems.
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire, My Heart Grows Fonder, Man And Elf, A Dragon's Treasure, An Adventurer's Gallantry
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Sable's Grimoire 2

https://zetsubou.games

Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Re: Need advice on AOE skill

#3 Post by Nero »

Yeah thats what I meant but I got error: expected statement for enemy in enemy_members_list .. Dont know what is wrong in there

User avatar
Zetsubou
Miko-Class Veteran
Posts: 522
Joined: Wed Mar 05, 2014 1:00 am
Completed: See my signature
Github: koroshiya
itch: zetsuboushita
Contact:

Re: Need advice on AOE skill

#4 Post by Zetsubou »

Try sticking it in a python block?

Code: Select all

    $ enemy_members_list = [enemy1, enemy2, enemy3, enemy4, enemy5, enemy6]

    menu:   
        "AOE ATTACK":
             python:
                 for enemy in enemy_members_list:
                     player_damage = renpy.random.randint(bob.PLAYER_MAX_DAMAGE, bob.PLAYER_MIN_DAMAGE)
                     enemy -= player_damage
             jump PLAYER_TURN_RESET
Finished games
-My games: Sickness, Wander No More, Max Massacre, Humanity Must Perish, Tomboys Need Love Too, Sable's Grimoire, My Heart Grows Fonder, Man And Elf, A Dragon's Treasure, An Adventurer's Gallantry
-Commissions: No One But You, Written In The Sky, Diamond Rose, To Libertad, Catch Canvas, Love Ribbon, Happy Campers, Wolf Tails

Working on:
Sable's Grimoire 2

https://zetsubou.games

Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Re: Need advice on AOE skill

#5 Post by Nero »

Ok I got it working. Thanks a lot!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]