ADRIFT Forum


The place to discuss the ADRIFT Interactive Fiction toolkit

Combat System that uses loops problem

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Combat System that uses loops problem

Postby DazaKiwi » Sat Jun 06, 2020 4:31 am

I have made a demo that for the most part works, but not as intended as far as outputting dice results. I am wondering if someone has an idea as to why its not working as intended, read on for details.

I have two loops that each cycle rolls a 1d3 dice and then 3 tasks to match the dice roll (so 1 match out of 3) and then output the result. There are 20 Defenders and 22 Attackers. So a dice roll is for each number, should be outputting the dice result for each one- which is in text form of A pirate was killed or a pirate was wounded etc.

Roll a Dice rand(1,3) for each side using a loop

1 = wounded
2 = killed
3 = survivors

Total Survivors to determine winner and for Defenders if morale >= 50 then wounded or killed number is reduced and survivor increase by 3, sort of like a saving throw. At the moment Morale is set to 40.

Problems

1) only 3 of each side gets outputted results instead of matching the total number of each side where there should be at least 20 lines in a row with either dice result eg. a pirate was wounded, a defender killed etc, yet debugger shows there should be much more, as the tasks that pass and even in debugger where it says executing actions the text output result. So in theory this should work, but doesn't.

2) there is a delay at the end before the cursor comes back to life- although the numbers calculate seem to be completed within a second, if you try to type something Runner is still busy for a few seconds, which by time player reads is no problem, unless the game has some events in play which could make the delay worse? is there a solution to this? Originally i had it to display The Pirates are attacking before running the tasks- but runner would hang for 8 seconds before outputting the combat results. So i created an extra task to run the loops and seem to fix that issue- but there is still a delay at the end.
Attachments
BasicBoardingCombat_v1.taf
Demo
(17.3 KiB) Downloaded 10 times
User avatar
DazaKiwi
 
Posts: 743
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 61

Re: Combat System that uses loops problem

Postby Denk » Sat Jun 06, 2020 10:52 am

Problem 1:
ADRIFT 5 tries to be smart by not displaying "redundant" information, i.e. it only prints "A pirate was wounded" once, no matter how many times you want it to be displayed. I am aware of a work-around to force ADRIFT to display each line. For instance change the message field in the task "Attackers Wounded (P2.2)" from:
adrift Code: Select all
A %EnemyType% was wounded
 

to:
adrift Code: Select all
A %EnemyType% was wounded <# "<" & rand(0,1000000) & ">" #>
 

With this technique, ADRIFT notice that each line is different even though the printed text will be the same, and thus it will print all the "missing" lines, e.g. 10 lines of "A Pirate was wounded". It might be safer to have a count-variable than a randomized number, even if it is one out of a million.

Problem 2:
As far as I can see, the demo almost replies instantly. Note that the Runner runs much slower when the debugger is open. Perhaps the delay you see is caused by having the debugger open?
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
User avatar
Denk
 
Posts: 465
Joined: Mon Feb 22, 2016 6:21 pm
Location: Hjørring, Denmark
Points: 251

Re: Combat System that uses loops problem

Postby DazaKiwi » Sat Jun 06, 2020 11:09 am

Thanks for your reply Denk, I never suspected that, and i did not know Runner runs slower with the Debugger open, but now i think about it, it makes sense.
User avatar
DazaKiwi
 
Posts: 743
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 61

Re: Combat System that uses loops problem

Postby DazaKiwi » Sat Jun 06, 2020 10:47 pm

I have updated the demo with your suggestion and at first i saw no new change, so i tried turning off 'aggregate output' for each task and it sorted that out nicely.

I tried to create my demo as a module and when importing it into my game Adrift hangs and crashes, yet if import it into a blank Adrift project no problem, a bit weird.
User avatar
DazaKiwi
 
Posts: 743
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 61

Re: Combat System that uses loops problem

Postby Denk » Sun Jun 07, 2020 12:02 am

DazaKiwi wrote:I have updated the demo with your suggestion and at first i saw no new change, so i tried turning off 'aggregate output' for each task and it sorted that out nicely.
You are right, I forgot to mention that it was necessary to turn off "aggregate output".

DazaKiwi wrote:I tried to create my demo as a module and when importing it into my game Adrift hangs and crashes, yet if import it into a blank Adrift project no problem, a bit weird.
I have no idea about this one - perhaps some items have the same key? (wild guess)
----------------------------------------------------------------------
The Bash Saga:
1. The Dragon Diamond 2. The Way Home 3. Stone of Wisdom
----------------------------------------------------------------------
User avatar
Denk
 
Posts: 465
Joined: Mon Feb 22, 2016 6:21 pm
Location: Hjørring, Denmark
Points: 251

Re: Combat System that uses loops problem

Postby DazaKiwi » Sun Jun 07, 2020 1:15 am

Yeah i don't know what the issue was, but since it was a small combat system i just manually recreated it in my project and runs fine.

Anyway thanks for your help getting this combat system working :)
Attachments
BasicBoardingCombat_v4.taf
Updated demo that works as intended
(17.37 KiB) Downloaded 11 times
User avatar
DazaKiwi
 
Posts: 743
Joined: Thu Oct 21, 2010 9:05 am
Location: New Zealand
Points: 61


Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 14 guests