So I found several problems when doing my game project.
Also, I wanted to make the monster attack after few seconds, but when I apply the script and run the game, what I get is instead me getting attacked repetitively even though the monster is dead :v
Helph please...
My productivity has fallen so much, day by day, as more questions keep on popping
(Though I'm still grateful for being able to take out the code last time and not restarting my game making from the start. Thanks everyone :D)
game.WhateverYouCalledTheHealthStatusAttribute = Player.Health+"/"+Player.MaxHealth
Monster Delay vs Repeated Attacking - Without knowing more about your script itself I really can't help. It's possible you're running the "Wait X seconds and then do something" block, and then after-but-outside you have something else. So, in psuedocode:
wait 5 seconds and then{
// do thingA
}
do thingB
, the above which results in the code saying, "Alright, I'll wait 5 seconds to do thingA. Now let me just do thingB IMMEDIATELY. Alright 5 seconds passed, time for thingA now!"
if (SomeKeyObject.parent=Player){
ShowMenu("Open the door?", Split("Yes-No", "-"), false){
if (result="Yes"){
//Do the stuff for opening the door.
}
else{
// Do the stuff for not yet opening the door.
}
}
}
else{
msg("You don't have the key")
}
Like always, I have to type out what it is in code-view, but it becomes more understandable once you copy-paste and convert to regular view. Hope this helps!
Lastly, don't worry about productivity. My latest game, I had to completely scrap 3 times because I kept finding I didn't know enough about Quest to make the game I'd envisioned. It was only on attempt 4 I could put things together right.
http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375
I'm using the 'RandomChance (XXX)' Function/Script, so this requires that your parameter's argument/input/value/attribute's_value/variable's_value be in the range/bounds of 0 to 100)
https://docs.textadventures.co.uk/quest/functions/corelibrary/randomchance.html
for example: player.luck = GetRandomInt (0,100)
example usage (likely in your combat/attack coding):
// create ("katana")
// katana.damage = 50
// player.weapon = katana
// player.luck = GetRandomInt (0,100)
player.damage = player.weapon.damage * critical_hit_function (player.luck)
// player.damage = [50] * [either: 2 or 1]
// player.damage = [either: 100 or 50]
// orc.current_life = orc.current_life - player.damage
<function name="critical_hit_function" parameters="integer_attribute_parameter" type="int">
if (RandomChance (integer_attribute_parameter)) {
critical_hit_modifier_integer_variable = 2
} else {
critical_hit_modifier_integer_variable = 1
}
return (critical_hit_modifier_integer_variable)
</function>
PS, here's some help/guides on learning quest and its coding:
http://textadventures.co.uk/forum/general/topic/ljjm32av4e2t9ot49k478g/help#710be61e-eae1-4af1-8363-520cc718ba1c
ask if you need any help or explanation with anything
Thanks a lot for the quick reply >_<
@Io Owh I think it's because I used string. Am I supposed to use integer/double? :v
Alright. Will keep your advice in mind.
(I'll get through the details tom. It's getting late here)
Yep, integer/double. In code view, it's the difference between "5" and 5.
Quest can no more divide "5" by 10 than it can divide "Fox" by 10.
Btw hegemonkhan, as for the link you posted for my third problem, I did exactly that with the IF script, by using the percentage random chance.
But then there's an error saying sth like "LazyLoadScript" or sth
there's lot of issues with using doubles (floats / floating points / decimals / fractions) and integers (non-decimals / non-fractionals) together: rounding (truncation vs upper/lower, precision, etc) and etc issues... (programming calculators... is a lot of "fun"... lol)
it's really better if possible to only use integers... though this can be challenging as well... meh... math is messy and hard, lol
Amount (able to do arithmetic:addition/subtraction/multiplication/division/modulus, upon them) Data Types:
Integers: ..., -999, 0, 999, ...
Doubles: ..., -999.999, 0.0, 123.1, ...
NON-Amount (NOT able to do arithmetic upon them) Data Types:
Strings (able to do concatenation upon them): "a", "abc", "1", "123", "true", "orc", "abc_123", "hi, how are you? my name is hk, what is your name?"
Booleans: true/false
and other Data Types
@Io
Oof
Thank you so much :v
So I'll just have to do ! % on the status rite
For the percentage health, you might want 100 * health / maxhealth
.
Putting health / maxhealth * 100
, I would expect it to divide health by maxhealth, round it to an int (getting 1 if you're on full health and 0 otherwise) and then multiply by 100 to get either 100 or 0.
It's working now. Thanks.
I'm still confused about the WAIT script and CRITICAL ATTACK though...
Well again, short of seeing your code there's not much we can help with wait. As for critical though, try something like:
if (RandomChance(25)) {
Player.Damage=Player.Damage*2
//We had a 25% chance to crit, and we did, doubling our damage
}
else{
//We failed and nothing happens
}
Here's my script:
if (Snake_1.Active = true) {
firsttime {
msg ("You make the first move and charge towards the snake")
}
Snake_1.Health = Snake_1.Health - You.Attack
msg ("You inflict {You.Attack} damage to Snake (Lv.5)!\"")
if (Snake_1.Active = true) {
You.Health = You.Health - Snake_1.Attack
msg ("You receive {Snake_1.Attack} damage!")
}
}
else if (Snake_1.Active = False) {
msg ("It's dead already, smh.")
}
So what you'd want is to have a script to change You.Attack based on whether you crit or not, and insert that before
Snake_1.Health = Snake_1.Health - You.Attack
but after your firsttime script.
I recommend looking at ThePix's Zombie Apocalypse game. Otherwise, I would need to see the whole code of your game.