+traeumer Posted November 30, 2014 Share Posted November 30, 2014 I'm using the urwigo builder to create my first module based on my Nebit the Gnome fantasy game. I have created a basic game, but I don't know how to reduce a character's health after an unsuccessful battle. I also want player character's to be able to be healed by gone to a healing zone. Any advice would be great. Thanks for your help ahead of time! Quote Link to comment
+traeumer Posted November 30, 2014 Author Share Posted November 30, 2014 I figured out to use the increment/decrement command, but how do I loop it to force the player to keep battling until they have either won the battle or are forced to go to a healing zone? Quote Link to comment
Ranger Fox Posted November 30, 2014 Share Posted November 30, 2014 After the enemy attacks and you do the damage calculation, use an if/else statement. If the character's health is above zero, change the fight command input's text to reflect the character's remaining HP and then show a message box with a message like "The enemy performed the attack 'Firefall' for 294 HP damage. You have 410 HP left." with a callback to the input that asks for the character's attack, else deactivate the fight zone, activate the healing zone, set the character's HP to zero (to avoid showing negative health), and show a message stating the character needs to heal. Likewise, when you do the character's attack's damage calculation, if the enemy's HP is above zero, show a message like "You performed the attack 'Bleeding Point' for a critical hit of 425 HP. The enemy has 529 HP remaining." with a callback to a function that decides the enemy's action, else hide the enemy character if shown, perform whatever EXP assignment is necessary, and show the message "You defeated the enemy!" Note: The attack names are from a large story/game world I created around fifteen years ago, called "The Phoenix Cycle", separated into three books: "Phoenix's Rising", "Phoenix's Flourish", and "Phoenix's Fall". Quote Link to comment
+traeumer Posted November 30, 2014 Author Share Posted November 30, 2014 Thanks for your help. I'm using the if/else commands, but something isn't working properly because a character gets the new story arc zone activated - even if the battle is lost - when in fact they should continue fighting until they either win or lose enough hit points to go to the healing zone. I've attached several screenshots of my program. Screenshots 2 & 3 are functions. Perhaps you can see the error? Quote Link to comment
+jonny65 Posted November 30, 2014 Share Posted November 30, 2014 Wondering why the admins are not able to solve the problem with the attached pics. What to do now, decreasing health if the player lose the combat until an assigned value is reached (i.g 5) then close the combat zone and activate the healing zone ? If the player won what to do then ? Quote Link to comment
Ranger Fox Posted November 30, 2014 Share Posted November 30, 2014 You might want to try attaching your cartridge, traeumer, if the forum is going to eat your thumbnails. Or you can try attaching the thumbnails again. By the way, I don't have any privileged information about the photo attachment problem. Quote Link to comment
+traeumer Posted November 30, 2014 Author Share Posted November 30, 2014 I can't attach the cartridge for some reason, so I am providing a link: https://drive.google.com/file/d/0BzlSfNv22FuRVmlyVlNFbncybVU/view?usp=sharing Thanks! Quote Link to comment
Ranger Fox Posted November 30, 2014 Share Posted November 30, 2014 And after I wrote my previous post, the thumbnails showed up. I wonder what's going on. Anyway... If the character starts at six health, losing health once will cause the story arc to proceed. And if the character starts at five health, the arc will proceed without combat. If the character starts at four health, the character will fight once and then nothing will happen if the character is injured. Deciding what to do based on "health equals x" isn't a good idea. You could say, "If health is greater than one, combat; else do the healing zone." In your screen shots, I do not see what click first triggers the function, nor do I see what keeps it going. At most, it seems the combat function will be called twice, depending upon the character's health. Here's what I'm thinking. While most of this is valid code, I'm not sure about making the callback in the way I defined it. You can replace it with a message box callback function, anyway. I was trying to make the functions dealing with combat generic enough that you could use them for multiple combat scenarios. local playerHealth = 5 local zoneToActivateWhenCombatWon = nil local zoneCurrentCombatZone = nil function zoneCombat:OnProximity() --Because I activate the combat zone again if battle was unsuccessful. if playerHealth > 1 then zoneCombat.Active = false --So OnProximity is not called due to coordinate jitter zoneCurrentCombatZone = zoneCombat zoneToActivateWhenCombatWon = zoneNextTown CombatTurn() end end function CombatTurn() local rand = math.random(1,100) if rand > 80 then CombatWon() else AssignDamage() if playerHealth > 1 then Wherigo.MessageBox{Text=[[You took damage, but you can try again!]], Callback=CombatTurn} else Wherigo.MessageBox{Text=[[You fled battle because you almost died. Go and heal, then try again.]],} zoneHealingSpring.Active = true zoneCurrentCombatZone.Active = true end end end function AssignDamage() playerHealth = playerHealth - 1 end function CombatWon() Wherigo.MessageBox{Text=[[You defeated the enemy!]],} zoneToActivateWhenCombatWon.Active = true end Quote Link to comment
Tyreless Posted November 30, 2014 Share Posted November 30, 2014 In Urwigo you could try something like this: Geoff aka Tyreless Quote Link to comment
+traeumer Posted December 2, 2014 Author Share Posted December 2, 2014 Thanks everyone for all of the help! I'll let you know if I have any other issues. Quote Link to comment
+traeumer Posted December 19, 2014 Author Share Posted December 19, 2014 Thanks again for all of the help. The cache was published as GC5HAGW. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.