Don't know if this is still active or what, but while looking for someway to make the battles more random in my game, I stumbled across this topic, which was more or less what I was looking for. Now, the reason I'm typing this is because while playing around with it trying to get it to fit my needs alittle better, I ran upon an error (that only appears when I try to get the game to run using my own version of the script, so there's nothing wrong with the original) that when, during combat, instantly kills the 'hero' no matter what I do >_<;
How, here's the code, and if anyone can help me figure out what's wrong, I'd be happy.
Code: Select all
init:
python hide:
def CombatIn():
if CombatStatus== 'starting':
ui.fixed()
ui.at(Move((-0.3, 0.1), (0.14, 0.1), 0.5))
ui.image(HeroPortrait)
ui.at(Move((1.0, 0.1), (0.60, 0.1), 0.5))
ui.image(FoePortrait)
ui.at(FactorZoom(0.0, 1.0, 0.5, xpos=0.43, ypos=0.3, opaque=False))
ui.image(CombatVS)
ui.close()
elif CombatStatus== 'starting2':
ui.fixed()
ui.at(Move((-0.3, 0.1), (0.14, 0.1), 0.5))
ui.image(HeroPortrait2)
ui.at(Move((1.0, 0.1), (0.60, 0.1), 0.5))
ui.image(FoePortrait)
ui.at(FactorZoom(0.0, 1.0, 0.5, xpos=0.43, ypos=0.3, opaque=False))
ui.image(CombatVS)
ui.close()
config.overlay_functions.append(CombatIn)
def CombatOn():
if CombatStatus== 'on':
ui.fixed()
ui.at(Position(xpos=0.14, ypos=0.1, xanchor=0.0, yanchor=0.0))
ui.image(HeroPortrait)
ui.at(Position(xpos=0.60, ypos=0.1, xanchor=0.0, yanchor=0.0))
ui.image(FoePortrait)
ui.at(Position(xpos=0.43, ypos=0.3, xanchor=0.0, yanchor=0.0))
ui.image(CombatVS)
ui.close()
elif CombatStatus== 'on2':
ui.fixed()
ui.at(Position(xpos=0.14, ypos=0.1, xanchor=0.0, yanchor=0.0))
ui.image(HeroPortrait2)
ui.at(Position(xpos=0.60, ypos=0.1, xanchor=0.0, yanchor=0.0))
ui.image(FoePortrait)
ui.at(Position(xpos=0.43, ypos=0.3, xanchor=0.0, yanchor=0.0))
ui.image(CombatVS)
ui.close()
config.overlay_functions.append(CombatOn)
def CombatOut():
if CombatStatus== 'ending':
ui.fixed()
ui.at(Move((0.14, 0.1), (-0.3, 0.1), 0.5))
ui.image(HeroPortrait)
ui.at(Move((0.60, 0.1), (1.0, 0.1), 0.5))
ui.image(FoePortrait)
ui.at(FactorZoom(1.0, 0.0, 0.5, xpos=0.43, ypos=0.3, opaque=False))
ui.image(CombatVS)
ui.close()
elif CombatStatus== 'ending2':
ui.fixed()
ui.at(Move((0.14, 0.1), (-0.3, 0.1), 0.5))
ui.image(HeroPortrait)
ui.at(Move((0.60, 0.1), (1.0, 0.1), 0.5))
ui.image(FoePortrait)
ui.at(FactorZoom(1.0, 0.0, 0.5, xpos=0.43, ypos=0.3, opaque=False))
ui.image(CombatVS)
ui.close()
config.overlay_functions.append(CombatOut)
label BasicFight:
python:
display_charsheet = True
CombatStatus = 'starting'
FoePortrait= FoeData.pop(0)
renpy.restart_interaction()
renpy.pause(1.4)
CombatStatus = 'on'
renpy.restart_interaction()
FoeName = FoeData.pop(0)
FoeSkill = FoeData.pop(0)
FoeCurrentHP = FoeData.pop(0)
special_rules = FoeData
HeroCombatSkill = HeroSkill
CombatResolved = False
while CombatResolved == False:
CombatRatio = HeroCombatSkill - FoeSkill
if CombatRatio > 0:
CombatRatioDisplay= '+'+str(CombatRatio)
else:
CombatRatioDisplay= str(CombatRatio)
ui.fixed()
ui.vbox(xpos=0.27, ypos=0.65, xanchor=0.5, yanchor=0.0)
ui.text(HeroName)
ui.hbox()
ui.text("Power: ", size=14)
ui.text(str(HeroCombatSkill), size=14)
ui.close() ### HeroCombatSkill Line
ui.hbox()
ui.text("Stamina: ", size=14)
ui.text(str(HeroCurrentHP), size=14)
ui.close() ###HeroStamina Line
ui.close() ###Hero Column
ui.text("Advantage", size=27, xpos=0.5, ypos=0.63, xanchor=0.5, yanchor=0.0)
ui.text(CombatRatioDisplay, size=27, xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
ui.vbox(xpos=0.73, ypos=0.65, xanchor=0.5, yanchor=0.0)
ui.text(FoeName)
ui.hbox()
ui.text("Power: ", size=14)
ui.text(str(FoeSkill), size=14)
ui.close() ###FoeSkill Line
ui.hbox()
ui.text("Stamina: ", size=14)
ui.text(str(FoeCurrentHP), size=14)
ui.close() ###FoeStam Line
ui.close() ###Foe Column
ui.close() ###Stats area
ui.vbox(xpos=0.5, ypos=0.75, xanchor=0.5, yanchor=0.0)
ui.textbutton("Attack", clicked=ui.returns('attack'))
ui.textbutton("Defend", clicked=ui.returns('defend')) #added
if 'escapable' in special_rules:
ui.textbutton("Escape!", clicked=ui.returns('escape'))
if 'Strength Potion' in inven:
ui.textbutton("Drink a Strength Potion", clicked=ui.returns('SPotion'))
ui.close()
ChosenAction=ui.interact()
if ChosenAction == 'attack':
DiceInGroups= [3] #altered from 2
AttackRoll=reduce(add, rolld6(DiceInGroups, ' ', 'combat', 0.425, 0.5)) + CombatRatio
HeroHits = False
FoeHits = False
if AttackRoll <= 7: #altered from 7
FoeHits = True
if AttackRoll >= 7: #altered from 7
HeroHits= True
if HeroHits== True:
ui.text("%(HeroName)s hits %(FoeName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
else:
ui.text("%(HeroName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if FoeHits == True:
ui.text("%(FoeName)s hits %(HeroName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
else:
ui.text("%(FoeName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if HeroHits== True:
FoeCurrentHP -= 5
if FoeHits== True:
HeroCurrentHP -= 5
elif ChosenAction == 'defend':
FoeHits = True
ui.text("%(HeroName)s defends." % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
ui.text("%(FoeName)s hits %(HeroName)s for 1 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if FoeHits== True:
HeroCurrentHP -=1
elif ChosenAction == 'escape':
CombatResult= 'escaped'
CombatResolved= True
HeroCurrentHP -= 4
ui.text("%(HeroName)s escapes the fight!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
ui.text("But %(FoeName)s hits with a parting shot for 4 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
elif ChosenAction == 'SPotion':
inven.remove('Strength Potion')
HeroCombatSkill += 2
ui.text("%(HeroName)s ducks back out of combat and quickly gulps a Strength Potion!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
ui.text("%(HeroName)s's Skill is temporarily increased by 2!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if HeroCurrentHP <= 0:
CombatResolved= True
CombatResult = 'lose'
ui.text("%(HeroName)s is defeated!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.5)
elif FoeCurrentHP <= 0:
CombatResolved= True
CombatResult= 'win'
ui.text("%(FoeName)s is defeated!" %globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
CombatStatus = 'ending'
renpy.restart_interaction()
renpy.pause(0.8)
CombatStatus = 'off'
display_charsheet = False
renpy.restart_interaction()
return
label BasicFight2:
python:
display_charsheet = True
CombatStatus = 'starting2'
FoePortrait= FoeData.pop(0)
renpy.restart_interaction()
renpy.pause(1.4)
CombatStatus = 'on2'
renpy.restart_interaction()
FoeName = FoeData.pop(0)
FoeSkill = FoeData.pop(0)
FoeCurrentHP = FoeData.pop(0)
special_rules = FoeData
HeroCombatSkill = HeroSkill # allows the Strength Potion to work as designed.
CombatResolved = False
while CombatResolved == False:
CombatRatio = HeroCombatSkill - FoeSkill
if CombatRatio > 0:
CombatRatioDisplay= '+'+str(CombatRatio)
else:
CombatRatioDisplay= str(CombatRatio)
ui.fixed()
ui.vbox(xpos=0.27, ypos=0.65, xanchor=0.5, yanchor=0.0)
ui.text(HeroName)
ui.hbox()
ui.text("Power: ", size=14)
ui.text(str(HeroCombatSkill), size=14)
ui.close() ### HeroCombatSkill Line
ui.hbox()
ui.text("Stamina: ", size=14)
ui.text(str(HeroCurrentHP), size=14)
ui.close() ###HeroStamina Line
ui.close() ###Hero Column
ui.text("Advantage", size=27, xpos=0.5, ypos=0.63, xanchor=0.5, yanchor=0.0)
ui.text(CombatRatioDisplay, size=27, xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
ui.vbox(xpos=0.73, ypos=0.65, xanchor=0.5, yanchor=0.0)
ui.text(FoeName)
ui.hbox()
ui.text("Power: ", size=14)
ui.text(str(FoeSkill), size=14)
ui.close() ###FoeSkill Line
ui.hbox()
ui.text("Stamina: ", size=14)
ui.text(str(FoeCurrentHP), size=14)
ui.close() ###FoeStam Line
ui.close() ###Foe Column
ui.close() ###Stats area
ui.vbox(xpos=0.5, ypos=0.75, xanchor=0.5, yanchor=0.0)
ui.textbutton("Attack", clicked=ui.returns('attack'))
ui.textbutton("Defend", clicked=ui.returns('defend')) #added
ui.textbutton("Combo", clicked=ui.returns('combo')) #added
if 'escapable' in special_rules:
ui.textbutton("Escape!", clicked=ui.returns('escape'))
if 'Strength Potion' in inven:
ui.textbutton("Drink a Strength Potion", clicked=ui.returns('SPotion'))
ui.close()
ChosenAction=ui.interact()
if ChosenAction == 'attack':
DiceInGroups= [3] #altered from 2
AttackRoll=reduce(add, rolld6(DiceInGroups, ' ', 'combat', 0.425, 0.5)) + CombatRatio
HeroHits = False
FoeHits = False
if AttackRoll <= 7: #altered from 7
FoeHits = True
if AttackRoll >= 7: #altered from 7
HeroHits= True
if HeroHits== True:
ui.text("%(HeroName)s hits %(FoeName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
else:
ui.text("%(HeroName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if FoeHits == True:
ui.text("%(FoeName)s hits %(HeroName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
else:
ui.text("%(FoeName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if HeroHits== True:
FoeCurrentHP -= 5
if FoeHits== True:
HeroCurrentHP -= 5
elif ChosenAction == 'defend':
FoeHits = True
ui.text("%(HeroName)s defends." % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
ui.text("%(FoeName)s hits %(HeroName)s for 1 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if FoeHits== True:
HeroCurrentHP -=1
elif ChosenAction == 'combo':
DiceInGroups= [3] #altered from 2
AttackRoll=reduce(add, rolld6(DiceInGroups, ' ', 'combat', 0.425, 0.5)) + CombatRatio
HeroHits = False
FoeHits = False
if AttackRoll <= 11: #altered from 7
FoeHits = True
if AttackRoll >= 11: #altered from 7
HeroHits= True
if HeroHits== True:
ui.text("%(HeroName)s hits %(FoeName)s twice, for a total of 10 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
else:
ui.text("%(HeroName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if FoeHits == True:
ui.text("%(FoeName)s hits %(HeroName)s for 5 damage!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
else:
ui.text("%(FoeName)s misses!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
if HeroHits== True:
FoeCurrentHP -= 10
if FoeHits== True:
HeroCurrentHP -= 5
if HeroCurrentHP <= 0:
CombatResolved= True
CombatResult = 'lose'
ui.text("%(HeroName)s is defeated!" % globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.5)
elif FoeCurrentHP <= 0:
CombatResolved= True
CombatResult= 'win'
ui.text("%(FoeName)s is defeated!" %globals(), xpos=0.5, ypos=0.68, xanchor=0.5, yanchor=0.0)
renpy.pause(0.8)
CombatStatus = 'ending2'
renpy.restart_interaction()
renpy.pause(0.8)
CombatStatus = 'off'
display_charsheet = False
renpy.restart_interaction()
return
Me, I can make no sense of it. I created this code simply by looking at the original and copying and then testing, and this error that kills the player, I can't figure out how to solve >_<; Help me, please.