Post by Zaphod Beeblbrox on Mar 9, 2007 15:59:25 GMT
1) Open the Function Editor, from the list of Your Book SEL files highlight the adventure you want to use FF combat in and click 'Load'
2) Scroll the page down and from the very bottom right box (in the column 'excluded' and row 'hosted') hold down ctrl and highlight 'GeneralLib' 'FFLib' and 'FFCombat'. Now click the button 'Save'
3) In your adventure text use the following code to put a combat in your page:
<SCRIPT script="&combat_1on1(1,1,1,'Orc',6,8,'Goblin',5,7);"></SCRIPT>
Replace the first number '1' with the page number you are writing on
The second '1' is to uniquely identify the combat on the page in case you have more than one combat on a page. If you do, make sure al combats on this page have a different value here (doesn't matter what provided it isn't 0)
The third '1' is a flag to indicate whether escaping is allowed or not. If you do NOT want to allow escape change this to a 0
This will give you a combat against an Orc with Skill 6 and Stamina 8, and a Goblin with Skill 5 Stamina 7. The combat will be fought one at a time. If you want to use standard (or at least what I have deduced as standard) multiple fighting rules use the following for the same situation:
<SCRIPT script="&combat_multi(1,1,1,'Orc',6,8,'Goblin',5,7);"></SCRIPT>
This will give exactly the same combat BUT fighting both enemies at the same time, allowing the hero to choose who to attack, and the enemy not selected for attack gets a 'free' swing at the hero (i.e. if the other enemy loses against the hero they are not damaged and the hero is simply considered to have 'avoided' the attack).
To use these two functions you MUST have the permanent variables $skill, $stamina and $luck declared and defined previously. You must also NOT have a permanent variable $combat.
I hope it's easy enough to see how to add more enemies or change the stats and names to your requirements.
If you want to find out how the combat is going or has ended, you can examine the value of the variable $combat[7]. This is most pertinent to disabling subsequent Turn To links until the combat has been won, i.e.
<IF condition="$combat[7] eq 'won';" reval="yes">If you win the combat you carry on down the passage <TT ref="123">Turn to 123</TT></IF>
<IF condition="$combat[7] eq 'escaped';" reval="yes">If you escape the combat you run out of the dungeon and wonder where to go next<TT ref="321">Turn to 321</TT></IF>
It is very important that the 'reval' parameter is used in the IF tags here, as the first time the page is processed the combat will obviously not have been won/escaped yet - without reval="yes" the conditions will not be checked again each time the page is processed.
There are many more ways of using combat from FFCombat, allowing you to change things like the damage caused by an enemy, the number of rounds a combat will be limited to and much more. This all requires using the &combat_full routine. However &combat_full is not yet finalised and as such cannot be relied upon not to change. The two examples (&combat_1on1 and &combat_multi) I have given are 'interface' functions that actually use &combat_full, however the method of using them will NOT change so it's safe to use them in your adventure.
If you want to use the advanced functionality of &combat_full at this stage it is recommended you do NOT include the FFCombat library, and simply copy/paste the entire library code into the library for your adventure. That way any changes made to the hosted library will not affect how it is used in your particular adventure. (Note you will still have to include FFLib and GeneralLib for it to work though). I am of course happy to help anyone trying to use it at it's current stage of development.
2) Scroll the page down and from the very bottom right box (in the column 'excluded' and row 'hosted') hold down ctrl and highlight 'GeneralLib' 'FFLib' and 'FFCombat'. Now click the button 'Save'
3) In your adventure text use the following code to put a combat in your page:
<SCRIPT script="&combat_1on1(1,1,1,'Orc',6,8,'Goblin',5,7);"></SCRIPT>
Replace the first number '1' with the page number you are writing on
The second '1' is to uniquely identify the combat on the page in case you have more than one combat on a page. If you do, make sure al combats on this page have a different value here (doesn't matter what provided it isn't 0)
The third '1' is a flag to indicate whether escaping is allowed or not. If you do NOT want to allow escape change this to a 0
This will give you a combat against an Orc with Skill 6 and Stamina 8, and a Goblin with Skill 5 Stamina 7. The combat will be fought one at a time. If you want to use standard (or at least what I have deduced as standard) multiple fighting rules use the following for the same situation:
<SCRIPT script="&combat_multi(1,1,1,'Orc',6,8,'Goblin',5,7);"></SCRIPT>
This will give exactly the same combat BUT fighting both enemies at the same time, allowing the hero to choose who to attack, and the enemy not selected for attack gets a 'free' swing at the hero (i.e. if the other enemy loses against the hero they are not damaged and the hero is simply considered to have 'avoided' the attack).
To use these two functions you MUST have the permanent variables $skill, $stamina and $luck declared and defined previously. You must also NOT have a permanent variable $combat.
I hope it's easy enough to see how to add more enemies or change the stats and names to your requirements.
If you want to find out how the combat is going or has ended, you can examine the value of the variable $combat[7]. This is most pertinent to disabling subsequent Turn To links until the combat has been won, i.e.
<IF condition="$combat[7] eq 'won';" reval="yes">If you win the combat you carry on down the passage <TT ref="123">Turn to 123</TT></IF>
<IF condition="$combat[7] eq 'escaped';" reval="yes">If you escape the combat you run out of the dungeon and wonder where to go next<TT ref="321">Turn to 321</TT></IF>
It is very important that the 'reval' parameter is used in the IF tags here, as the first time the page is processed the combat will obviously not have been won/escaped yet - without reval="yes" the conditions will not be checked again each time the page is processed.
There are many more ways of using combat from FFCombat, allowing you to change things like the damage caused by an enemy, the number of rounds a combat will be limited to and much more. This all requires using the &combat_full routine. However &combat_full is not yet finalised and as such cannot be relied upon not to change. The two examples (&combat_1on1 and &combat_multi) I have given are 'interface' functions that actually use &combat_full, however the method of using them will NOT change so it's safe to use them in your adventure.
If you want to use the advanced functionality of &combat_full at this stage it is recommended you do NOT include the FFCombat library, and simply copy/paste the entire library code into the library for your adventure. That way any changes made to the hosted library will not affect how it is used in your particular adventure. (Note you will still have to include FFLib and GeneralLib for it to work though). I am of course happy to help anyone trying to use it at it's current stage of development.