Profile for Walker White
Field | Value |
---|---|
Displayed name | Walker White |
Member number | 4127 |
Title | Apprentice |
Postcount | 48 |
Homepage | |
Registered | Saturday, March 20 2004 08:00 |
Recent posts
Pages
Author | Recent posts |
---|---|
char_on_spot...? in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 16:24
Profile
quote:It is a good idea to check out the tech support page page, as I and others have been sending all these issues to Jeff. This is a bad documentation bug. There are two functions, each of which is poorly documented: char_on_spot() and char_on_loc(). The function char_on_spot() is NPC only. You are clearly checking for player characters here. Change it to char_on_loc(). Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
char_on_spot...? in Blades of Avernum | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 16:24
Profile
quote:It is a good idea to check out the tech support page page, as I and others have been sending all these issues to Jeff. This is a bad documentation bug. There are two functions, each of which is poorly documented: char_on_spot() and char_on_loc(). The function char_on_spot() is NPC only. You are clearly checking for player characters here. Change it to char_on_loc(). Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
what the heck? in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 16:14
Profile
quote:Depends on what you want to do. A lot of simple scripts can be written without much math. However, much more complicated scripts like ones I have been doing in the Monsters thread do have quite a bit of math, such as probability and modular arithmetic. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
what the heck? in Blades of Avernum | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 16:14
Profile
quote:Depends on what you want to do. A lot of simple scripts can be written without much math. However, much more complicated scripts like ones I have been doing in the Monsters thread do have quite a bit of math, such as probability and modular arithmetic. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Calls that we wish existed in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 16:07
Profile
quote:Well I'll be. Okay, that's one off the list. I swear, sometimes I cannot find these calls in the documentation (this is the second time this forum has shown me wrong). Does anyone else find the organization weird? [ Sunday, April 04, 2004 16:07: Message edited by: Walker White ] Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Calls that we wish existed in Blades of Avernum | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 16:07
Profile
quote:Well I'll be. Okay, that's one off the list. I swear, sometimes I cannot find these calls in the documentation (this is the second time this forum has shown me wrong). Does anyone else find the organization weird? [ Sunday, April 04, 2004 16:07: Message edited by: Walker White ] Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 12:43
Profile
quote:Then I will lay off that idea (but to be honest, I had not thought of it). My plans for the next few scripts after familiars are: A spawning pool that uses very complex messaging to control all its creatures as slaves (it does coordinated target acquisition and sends the creatures there). This will use a combination of tricks from my target acquisition and familiar examples.A bunch of interesting mirror terrains like a mirror of life trapping, and a mirror of opposition (if Jeff fixes give_char_item() so I can duplicate party items).You should be safe for a while. ;) Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 12:43
Profile
quote:Then I will lay off that idea (but to be honest, I had not thought of it). My plans for the next few scripts after familiars are: A spawning pool that uses very complex messaging to control all its creatures as slaves (it does coordinated target acquisition and sends the creatures there). This will use a combination of tricks from my target acquisition and familiar examples.A bunch of interesting mirror terrains like a mirror of life trapping, and a mirror of opposition (if Jeff fixes give_char_item() so I can duplicate party items).You should be safe for a while. ;) Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
AvernumScript Ideosyncracies in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 12:28
Profile
As I continue to play with AvernumScript, I find issues that I lump into three categories: (1) Bugs that need to be fixed, (2) Calls that I wish existed because I cannot fake, and (3) Things that don't work like I thought and need to be better documented. There are formal channels for (1), and Kelandon has created a thread for (2). This thread is for (3), the type of things that appear on the tech support page. That page is a stopgap for the really extreme problems. This thread is for people to post things they do not legitimately understand about the system and may need to appear in later documentation. Here is something to get us started. Boolean expressions in AvernumScript do not seem to short circuit. To see what I mean by this, consider the line of code if (who_hit_me() >= 0 && dist_to_char(who_hit_me() <= 2) { This checks if we were hits and that the offender is close (not an archer). In most programming languages, if who_hit_me() is negative, the script will not bother with the dist_to_char() call. One part is false, so the whole thing must be false. Not true in AvernumScript. If will make both calls. So if no one hit you, you will get an error here (because dist_to_char(-1) is bad). It also means that long complicated boolean expressions are inefficient. Is this a bug for Jeff to fix? Absolutely not. It was a reasonable design decision on his behalf. But this is something we need to be aware when writing scripts. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
AvernumScript Ideosyncracies in Blades of Avernum | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 12:28
Profile
As I continue to play with AvernumScript, I find issues that I lump into three categories: (1) Bugs that need to be fixed, (2) Calls that I wish existed because I cannot fake, and (3) Things that don't work like I thought and need to be better documented. There are formal channels for (1), and Kelandon has created a thread for (2). This thread is for (3), the type of things that appear on the tech support page. That page is a stopgap for the really extreme problems. This thread is for people to post things they do not legitimately understand about the system and may need to appear in later documentation. Here is something to get us started. Boolean expressions in AvernumScript do not seem to short circuit. To see what I mean by this, consider the line of code if (who_hit_me() >= 0 && dist_to_char(who_hit_me() <= 2) { This checks if we were hits and that the offender is close (not an archer). In most programming languages, if who_hit_me() is negative, the script will not bother with the dist_to_char() call. One part is false, so the whole thing must be false. Not true in AvernumScript. If will make both calls. So if no one hit you, you will get an error here (because dist_to_char(-1) is bad). It also means that long complicated boolean expressions are inefficient. Is this a bug for Jeff to fix? Absolutely not. It was a reasonable design decision on his behalf. But this is something we need to be aware when writing scripts. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Calls that we wish existed in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 12:06
Profile
Oh dear Lord. Where do I begin? Okay, here is a list, some of which I have already sent to Jeff. The Easy Ones (If Jeff did what I think he did) deduct_char_ap(short which_char, short amount) so items can manually deduct AP (and fix the 219 feature).equip_item_in_slot(short which_char, short which_item, short which_slot), so I can manually equip items in my creatures.set_char_memory_cell(short which_char, short which_cell). This would greatly improve message communication. We can already do this for terrain, why not characters?Missile animations for SFX. We can do booms and sparkles and effects. Why not missiles?A call to manually identify an item so that I am not forced to use shops.]The Hard Ones (I am dreaming)Get calls for every item ability (what's its damage, type, etc...)Get calls for determining a creature's special attacks.Path finding calls: Is there a path on the ground from A to B? Compute this without actually moving a character.A dialog box for numeric input. Dear lord what I could do with this (I cast clairvoyance on square x=13, y =2).There is also the issue of string handling (being able to glue strings together and then like for better print_str() output). I have made some suggestions to Jeff about this, and he is thinking about it. However, my suggestion on strings is a major overhaul and if we pressure him to do a lot of calls, it will not happen. [ Sunday, April 04, 2004 12:07: Message edited by: Walker White ] Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Calls that we wish existed in Blades of Avernum | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 12:06
Profile
Oh dear Lord. Where do I begin? Okay, here is a list, some of which I have already sent to Jeff. The Easy Ones (If Jeff did what I think he did) deduct_char_ap(short which_char, short amount) so items can manually deduct AP (and fix the 219 feature).equip_item_in_slot(short which_char, short which_item, short which_slot), so I can manually equip items in my creatures.set_char_memory_cell(short which_char, short which_cell). This would greatly improve message communication. We can already do this for terrain, why not characters?Missile animations for SFX. We can do booms and sparkles and effects. Why not missiles?A call to manually identify an item so that I am not forced to use shops.]The Hard Ones (I am dreaming)Get calls for every item ability (what's its damage, type, etc...)Get calls for determining a creature's special attacks.Path finding calls: Is there a path on the ground from A to B? Compute this without actually moving a character.A dialog box for numeric input. Dear lord what I could do with this (I cast clairvoyance on square x=13, y =2).There is also the issue of string handling (being able to glue strings together and then like for better print_str() output). I have made some suggestions to Jeff about this, and he is thinking about it. However, my suggestion on strings is a major overhaul and if we pressure him to do a lot of calls, it will not happen. [ Sunday, April 04, 2004 12:07: Message edited by: Walker White ] Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 11:35
Profile
quote:That is correct. I cannot imagine that is too difficult to add to the language, but he would have to call deduct_ap() something else. He does not want to erase the old call (for compatibility), and he needs a way for his interpreter to recognize the right calls as they will have a different number of arguments. However, this all depends on how difficult it is to add functions to AvernumScript in general. If he has a proper symbol look-up table, it shouldn't be too hard, but then I don't know how he chose to design this. There are other modifications I would like made to AvernumScript like unary minus and the not operator (!) that are much harder and I doubt those will be added. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum | |
Apprentice
Member # 4127
|
written Sunday, April 4 2004 11:35
Profile
quote:That is correct. I cannot imagine that is too difficult to add to the language, but he would have to call deduct_ap() something else. He does not want to erase the old call (for compatibility), and he needs a way for his interpreter to recognize the right calls as they will have a different number of arguments. However, this all depends on how difficult it is to add functions to AvernumScript in general. If he has a proper symbol look-up table, it shouldn't be too hard, but then I don't know how he chose to design this. There are other modifications I would like made to AvernumScript like unary minus and the not operator (!) that are much harder and I doubt those will be added. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 20:11
Profile
A Bonus Script: Mind Duel The last script this week doesn't really have all that much to do with targetting, but it is another really neat example, so I wanted to post it. This example is motivated by Avernum 2, specifically what it was lacking. Those of us who played Exile 2 where really let down by the final battle. Garzahd is a demon, oh my. Not a big deal when it is easy to give all 4 characters level 3 repel spirit. If you want a real battle with Garzahd, try Exile 2. You all know what I mean. I present the return of Mind Duel to Avernum. Making Mind Duel characters is really easy; we just use ideas from the magekiller scripts. That is what I have done in minddueler.txt. What is much more interesting, however, is giving that ability to the party. To do this, we have to use a custom item. Aesthetically, I would prefer a custom ability, but custom abilities cannot target foes. Fortunately, items can using special abilities 219 and 220. In my script for battle arena I present the code for a mind duel item. It works pretty well and utilizes a d20 style willpower versus willpower check. And I stole the idea for demonic corruption from the Conan d20 RPG. There are a couple of issues with this script however arising from limitations in AvernumScript. Some of these I feel are bugs (but then Jeff is probably starting to get tired of by bug reports). There is no get_energy() function. This is one of the greatest oversights in all of AvernumScript. This means I cannot prevent the character from draining creatures with no energy points! I hope Jeff adds this function. In the meantime, the script does at least keep the character from draining non-spell casters.Weapons of ability 219 cost no AP to use. So you can use them as many times as you want. I stop this (inelegantly) by putting in a flag that is reset each turn. This may be a feature and not a bug (to make items with multiple targets), but it seems strange to me.There is no unary negation in AvernumScript. Try y = -x in AvernumScript. It won't work. Instead, you have to fake negation by subtracting from 0 as in y = 0 - x.If Jeff ever adds get_energy(), we will be able to do a lot more with this. For example, we can make real Exile 2 style Garzahds (immune to everything, but die when all energy points are drained). If you want to play with the mindduel, I have yet another one room scenario set up for it. Pick up the orb and try it out. Well that's this week. Depending on work or so, I may be back in a week with my next topic. Next Week(ish): Familiars and Pets. I will also show you how to make leashes and dog whistles to have the pets do cool tricks. The stuff I plan to do will also indirectly answer Boot's question at the beginning of this thread. [ Saturday, April 03, 2004 20:12: Message edited by: Walker White ] Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 20:11
Profile
A Bonus Script: Mind Duel The last script this week doesn't really have all that much to do with targetting, but it is another really neat example, so I wanted to post it. This example is motivated by Avernum 2, specifically what it was lacking. Those of us who played Exile 2 where really let down by the final battle. Garzahd is a demon, oh my. Not a big deal when it is easy to give all 4 characters level 3 repel spirit. If you want a real battle with Garzahd, try Exile 2. You all know what I mean. I present the return of Mind Duel to Avernum. Making Mind Duel characters is really easy; we just use ideas from the magekiller scripts. That is what I have done in minddueler.txt. What is much more interesting, however, is giving that ability to the party. To do this, we have to use a custom item. Aesthetically, I would prefer a custom ability, but custom abilities cannot target foes. Fortunately, items can using special abilities 219 and 220. In my script for battle arena I present the code for a mind duel item. It works pretty well and utilizes a d20 style willpower versus willpower check. And I stole the idea for demonic corruption from the Conan d20 RPG. There are a couple of issues with this script however arising from limitations in AvernumScript. Some of these I feel are bugs (but then Jeff is probably starting to get tired of by bug reports). There is no get_energy() function. This is one of the greatest oversights in all of AvernumScript. This means I cannot prevent the character from draining creatures with no energy points! I hope Jeff adds this function. In the meantime, the script does at least keep the character from draining non-spell casters.Weapons of ability 219 cost no AP to use. So you can use them as many times as you want. I stop this (inelegantly) by putting in a flag that is reset each turn. This may be a feature and not a bug (to make items with multiple targets), but it seems strange to me.There is no unary negation in AvernumScript. Try y = -x in AvernumScript. It won't work. Instead, you have to fake negation by subtracting from 0 as in y = 0 - x.If Jeff ever adds get_energy(), we will be able to do a lot more with this. For example, we can make real Exile 2 style Garzahds (immune to everything, but die when all energy points are drained). If you want to play with the mindduel, I have yet another one room scenario set up for it. Pick up the orb and try it out. Well that's this week. Depending on work or so, I may be back in a week with my next topic. Next Week(ish): Familiars and Pets. I will also show you how to make leashes and dog whistles to have the pets do cool tricks. The stuff I plan to do will also indirectly answer Boot's question at the beginning of this thread. [ Saturday, April 03, 2004 20:12: Message edited by: Walker White ] Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 19:47
Profile
Back to Basics: Bodyguards These scripts got really complicated, and it was clear that if I continued along this track, I wasn't going to really add anything useful to the script community. So what I really needed was other ways for us to choose targets, beyond just assessment of strength. One obvious way that jumps out is to have characters choose targets for each other. Your characters act as a party, why can't the hostiles? All we need is a way for the monsters to talk to each. And we have that. It is called messaging. To illustrate a simple messaging example, I have two scripts. guardednpc.txt . This is an important NPC like an official that is surrounded by guards. When he is hit, he calls out to the guards to strike down the offender.bodyguard.txt . This is a guard for the guardednpc that chooses targets based on messages sent to it.Clearly, we can do much more complicated set ups than this. However, as the last example demonstrates, it is best to keep these scripts simple when we can. At first glance, the scripts seem to be very simple. When the guardednpc is hit, it sends the character number of the creature that hit it as a message. When the guards receive the message, they make that their target. But there are some things to worry about. The first issue is that messaging is quite primitive. All you can do it send and receive a number. The receiver cannot even ask who sent the message. In fact, as terrains or even items can send messages, it does not make sense to ask who sent a message. So, we have to make sure everyone is in the same group and we only send messages in the group. There is currently no way in the editor to set groups (this is a script function). So to make it easier on the non-programmer, we use memory cell 4 to store the group and initialize this value in the INITIAL_STATE. That way we don't send messages to people who are not guarding the guardednpc, and any message the bodyguards receive they will assume is a cry for help. This means, however, that you have to be careful when you start mixing creatures that use messages. They may start to read each others messages and get confused. To avoid this, always send messages to groups, and avoid using the broadcast functions (which send to everyone). Sometimes this cannot be helped, but it is generally good practice. Next, notice that we have to be prepared to receive messages in any state other than the initial and dead one. If we are in a state that does not receive messages, then the message that round is lost forever. This also means that we need to avoid the set_state_continue() that I am always using. set_state_continue() changes state without deleting the message, while set_state() deletes it (because it exits the script). So set_state_continue would cause us to restart the message response process and put us in an infinite loop. Using set_state() is okay; if the monster has AP, it will call the script back up again. It is just less efficient as it stops the script and then starts it back up. Finally, there is one more issue addressed in this script. If the guardednpc keeps getting hit (the bodyguards aren't doing a very good job) he may keep shouting out different targets to the bodyguards. This would cause the bodyguards to hop about doing damage to a lot of targets and not killing anyone. Maybe you want this behaviour. In case you do not, in cell 5 of the bodyguard, we set a tolerance value. This determines whether a bodyguard will respond to additional target requests beyond the first. Again, the documentation is in the comments. Finally, as a homework exercise, I assign the following. :) Add a message to the DEAD_STATE of guardednpc so that it can let the guards know it died. Then have the guards do something in response. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 19:47
Profile
Back to Basics: Bodyguards These scripts got really complicated, and it was clear that if I continued along this track, I wasn't going to really add anything useful to the script community. So what I really needed was other ways for us to choose targets, beyond just assessment of strength. One obvious way that jumps out is to have characters choose targets for each other. Your characters act as a party, why can't the hostiles? All we need is a way for the monsters to talk to each. And we have that. It is called messaging. To illustrate a simple messaging example, I have two scripts. guardednpc.txt . This is an important NPC like an official that is surrounded by guards. When he is hit, he calls out to the guards to strike down the offender.bodyguard.txt . This is a guard for the guardednpc that chooses targets based on messages sent to it.Clearly, we can do much more complicated set ups than this. However, as the last example demonstrates, it is best to keep these scripts simple when we can. At first glance, the scripts seem to be very simple. When the guardednpc is hit, it sends the character number of the creature that hit it as a message. When the guards receive the message, they make that their target. But there are some things to worry about. The first issue is that messaging is quite primitive. All you can do it send and receive a number. The receiver cannot even ask who sent the message. In fact, as terrains or even items can send messages, it does not make sense to ask who sent a message. So, we have to make sure everyone is in the same group and we only send messages in the group. There is currently no way in the editor to set groups (this is a script function). So to make it easier on the non-programmer, we use memory cell 4 to store the group and initialize this value in the INITIAL_STATE. That way we don't send messages to people who are not guarding the guardednpc, and any message the bodyguards receive they will assume is a cry for help. This means, however, that you have to be careful when you start mixing creatures that use messages. They may start to read each others messages and get confused. To avoid this, always send messages to groups, and avoid using the broadcast functions (which send to everyone). Sometimes this cannot be helped, but it is generally good practice. Next, notice that we have to be prepared to receive messages in any state other than the initial and dead one. If we are in a state that does not receive messages, then the message that round is lost forever. This also means that we need to avoid the set_state_continue() that I am always using. set_state_continue() changes state without deleting the message, while set_state() deletes it (because it exits the script). So set_state_continue would cause us to restart the message response process and put us in an infinite loop. Using set_state() is okay; if the monster has AP, it will call the script back up again. It is just less efficient as it stops the script and then starts it back up. Finally, there is one more issue addressed in this script. If the guardednpc keeps getting hit (the bodyguards aren't doing a very good job) he may keep shouting out different targets to the bodyguards. This would cause the bodyguards to hop about doing damage to a lot of targets and not killing anyone. Maybe you want this behaviour. In case you do not, in cell 5 of the bodyguard, we set a tolerance value. This determines whether a bodyguard will respond to additional target requests beyond the first. Again, the documentation is in the comments. Finally, as a homework exercise, I assign the following. :) Add a message to the DEAD_STATE of guardednpc so that it can let the guards know it died. Then have the guards do something in response. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 19:23
Profile
A Truly Complicated Example: AdvancedNPC Truly generic target assessment turns out to be much more complicated that I thought. A lot of things you take for granted in programming languages don't exist in AvernumScript. This is not really Jeff's fault. These things aren't easy and he had to make some design decisions. But in the end it limits what you can do. However, if you really know how to program, there is a lot of dark code magic that you can summon to make these programs do what you want to do. That is what I have done in advancednpc.txt. This is a fairly generic AI that allows the user to control everything through memory cells. In this AI I break everything into five categories. Closest targetsMelee targetsArcher targetsMage targetsPriest targetsTo use the script, just put the selection strategy in Cell 4, and fill out how you feel about each of the categories in Cells 5-9. The instructions are in the comments. You will notice that this script has a lot of states. That is because, as advanced programmers will see, I am really using the states as functions. However, they are not the same as function. Functions return to where you called them; they don't start the state over; and they have return values. I fake all this using variables. It's a lot like programming in assembly at times. I am not going to say much more about this script as it is really only for the very advanced programmer (and if you are really advanced, I feel ashamed at showing you my hacks). I consider it a failure as it is a lot of code to do very little. Try it and see. As the last example taught us, chosing a target is not always as important as reassessing the situtation, running away, or yelling for help. What this script did teach me was a lot of limitations in AvernumScript. It also inspired me to look for other innovative ways to do target selection. And that is what I talk about next. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 19:23
Profile
A Truly Complicated Example: AdvancedNPC Truly generic target assessment turns out to be much more complicated that I thought. A lot of things you take for granted in programming languages don't exist in AvernumScript. This is not really Jeff's fault. These things aren't easy and he had to make some design decisions. But in the end it limits what you can do. However, if you really know how to program, there is a lot of dark code magic that you can summon to make these programs do what you want to do. That is what I have done in advancednpc.txt. This is a fairly generic AI that allows the user to control everything through memory cells. In this AI I break everything into five categories. Closest targetsMelee targetsArcher targetsMage targetsPriest targetsTo use the script, just put the selection strategy in Cell 4, and fill out how you feel about each of the categories in Cells 5-9. The instructions are in the comments. You will notice that this script has a lot of states. That is because, as advanced programmers will see, I am really using the states as functions. However, they are not the same as function. Functions return to where you called them; they don't start the state over; and they have return values. I fake all this using variables. It's a lot like programming in assembly at times. I am not going to say much more about this script as it is really only for the very advanced programmer (and if you are really advanced, I feel ashamed at showing you my hacks). I consider it a failure as it is a lot of code to do very little. Try it and see. As the last example taught us, chosing a target is not always as important as reassessing the situtation, running away, or yelling for help. What this script did teach me was a lot of limitations in AvernumScript. It also inspired me to look for other innovative ways to do target selection. And that is what I talk about next. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 19:03
Profile
Next: Modified Magekiller *i was good enough to post a magekiller script in this thread. Short, sweet and to the point. However, it has two minor issues in it. It cannot be used by NPCs that are allied with the party.It cannot target allies that are not in the party. This includes wizard allies that might be following the party through a custom script.We are going to solve these problems, but in doing so our script is going to become much more complicated. This introduces us to the world of "engineering trade offs". If neither of the two points above apply to you, then use *i's script; it is much more efficient. But if you care about them, then you should play with mine and see if the slowdown is acceptable. In the end, the choice is up to you, the scenario designer. I am going to present two modified mage killers, each pointing out features of AvernumScript. The first mage killer has several important features to consider when manually choosing targets. I keep target acquistion as a separate state from the START_STATE. This is not necessary, but it makes the code easier to read. Note that I do it by checking if there are any targets at all in range, and then dropping into state 4 to manually chose a target. This is a trick that I will do a lot. If you use set_state_continue(), it will not be that expensive compared to the rest of your script.I find a target by looping through all characters 0 through 119. These are all the characters there are in a town, as outlined in the docs.I always check that a character can be seen and is hostile. If you do not do these things in manual target selection, your monsters may run out the room to attack their friends.I have a weird way of measuring mage strength. I don't consider just spell level; I consider a mixture of spell level and bonus. A character with one spell level lower than another, but twice the bonus, is going to do a lot more damage in his spells, and thus be more dangerous. Hence my metric is somewhat justified by a measurement of average damage the spells can deliver. The complete details are in the script, as well as instructions for changing it if you disagree.If we do not find any mage or priest, we always revert to the basicnpc strategy. In all manual target selection, you should always revert to the basicnpc behavior. Even if you think you have every case covered. This means less bugs.Notice how much more complicated this is than *i's. This is something we must always consider when we write these things. We can make them really complicated, but is it worth it? If you need an allied magekiller, then yes. Otherwise, it is less clear. One of the issues in this new script is that we created a new problem that did not occur in *i's script. To see what I mean, put a character with this script in a room and watch what happens when your party enters. More than likely your front line fighter got targetted. HUH? How did that happen after all that work? The problem is your fighter entered the room first, and the bad guy saw him, but did not see the mage. So, he targetted the fighter as an alternative, which is proper behaviour for the script (*i's script does not check line of sight, and so does not have this problem). Unfortunately, the script will not reselect a target until the fighter dies, and you certainly will not let that happen. Hence the mage is never targetted. To solve this problem, we need a script that forces the character to reacquire a target every few rounds. That is what we do in the second mage killer. Notice that if we have a mage, we never stay on it until it is dead. However, if we do not have a mage, we look for one every few rounds. When you play this script, you will discover that this addition makes a big difference. So the moral is that initial assessment is not always as important as continual reassessment. This is something to keep in mind when writing your own targetting AI. [ Saturday, April 03, 2004 19:09: Message edited by: Walker White ] Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 19:03
Profile
Next: Modified Magekiller *i was good enough to post a magekiller script in this thread. Short, sweet and to the point. However, it has two minor issues in it. It cannot be used by NPCs that are allied with the party.It cannot target allies that are not in the party. This includes wizard allies that might be following the party through a custom script.We are going to solve these problems, but in doing so our script is going to become much more complicated. This introduces us to the world of "engineering trade offs". If neither of the two points above apply to you, then use *i's script; it is much more efficient. But if you care about them, then you should play with mine and see if the slowdown is acceptable. In the end, the choice is up to you, the scenario designer. I am going to present two modified mage killers, each pointing out features of AvernumScript. The first mage killer has several important features to consider when manually choosing targets. I keep target acquistion as a separate state from the START_STATE. This is not necessary, but it makes the code easier to read. Note that I do it by checking if there are any targets at all in range, and then dropping into state 4 to manually chose a target. This is a trick that I will do a lot. If you use set_state_continue(), it will not be that expensive compared to the rest of your script.I find a target by looping through all characters 0 through 119. These are all the characters there are in a town, as outlined in the docs.I always check that a character can be seen and is hostile. If you do not do these things in manual target selection, your monsters may run out the room to attack their friends.I have a weird way of measuring mage strength. I don't consider just spell level; I consider a mixture of spell level and bonus. A character with one spell level lower than another, but twice the bonus, is going to do a lot more damage in his spells, and thus be more dangerous. Hence my metric is somewhat justified by a measurement of average damage the spells can deliver. The complete details are in the script, as well as instructions for changing it if you disagree.If we do not find any mage or priest, we always revert to the basicnpc strategy. In all manual target selection, you should always revert to the basicnpc behavior. Even if you think you have every case covered. This means less bugs.Notice how much more complicated this is than *i's. This is something we must always consider when we write these things. We can make them really complicated, but is it worth it? If you need an allied magekiller, then yes. Otherwise, it is less clear. One of the issues in this new script is that we created a new problem that did not occur in *i's script. To see what I mean, put a character with this script in a room and watch what happens when your party enters. More than likely your front line fighter got targetted. HUH? How did that happen after all that work? The problem is your fighter entered the room first, and the bad guy saw him, but did not see the mage. So, he targetted the fighter as an alternative, which is proper behaviour for the script (*i's script does not check line of sight, and so does not have this problem). Unfortunately, the script will not reselect a target until the fighter dies, and you certainly will not let that happen. Hence the mage is never targetted. To solve this problem, we need a script that forces the character to reacquire a target every few rounds. That is what we do in the second mage killer. Notice that if we have a mage, we never stay on it until it is dead. However, if we do not have a mage, we look for one every few rounds. When you play this script, you will discover that this addition makes a big difference. So the moral is that initial assessment is not always as important as continual reassessment. This is something to keep in mind when writing your own targetting AI. [ Saturday, April 03, 2004 19:09: Message edited by: Walker White ] Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum Editor | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 18:17
Profile
Ok. I am Back I said I would have the next installment in a week. It has been over a week, but real work got in the way. Plus, some of the stuff that I wanted to do turned out to be a lot harder than I thought, or virtually impossible. I have certainly started to discover the boundaries of AvernumScript now. Its nice, but it is missing some very desirable (and simple to implement functions). But more on that later. I have a lot of goodies this week, so I will keep each one to an individual post. As I said last time, this week I planned to play around with target acquisition and combat AI. All of these scripts are for enemies, not for party NPCs. Next week I will implement familiars and pets, and that will address some of Boot's comments at the beginning of this thread. Throughout all of these script postings I will be working with a slightly modified form of basicnpc. The modified script that I am using is available here. What's the difference you ask? I changed the AI for responding to who_hit_me(). If your think about it, there is very little reason to put who_hit_me() after target selection. The only way this will be called if no one is in range, but someone hit you. While possible, this is rare. So, it makes more sense to react to being hit before standard target selection, at least if the target is in within melee range. However, if you do this, you must check that the who_hit_me() character is alive. It is possible that you were hit, but your buddy dispatched him before the script was called. If you do not check for this fact, target acquisition will put you in an infinite loop. I still retain the old code for who_hit_me() after standard target selection. This is for hunting down people who hit you but are now out of range. Anway, the code is not much more complicated than the standard basicnpc, and it will provide the basis for my next several posts. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Post yer monster scripts here in Blades of Avernum | |
Apprentice
Member # 4127
|
written Saturday, April 3 2004 18:17
Profile
Ok. I am Back I said I would have the next installment in a week. It has been over a week, but real work got in the way. Plus, some of the stuff that I wanted to do turned out to be a lot harder than I thought, or virtually impossible. I have certainly started to discover the boundaries of AvernumScript now. Its nice, but it is missing some very desirable (and simple to implement functions). But more on that later. I have a lot of goodies this week, so I will keep each one to an individual post. As I said last time, this week I planned to play around with target acquisition and combat AI. All of these scripts are for enemies, not for party NPCs. Next week I will implement familiars and pets, and that will address some of Boot's comments at the beginning of this thread. Throughout all of these script postings I will be working with a slightly modified form of basicnpc. The modified script that I am using is available here. What's the difference you ask? I changed the AI for responding to who_hit_me(). If your think about it, there is very little reason to put who_hit_me() after target selection. The only way this will be called if no one is in range, but someone hit you. While possible, this is rare. So, it makes more sense to react to being hit before standard target selection, at least if the target is in within melee range. However, if you do this, you must check that the who_hit_me() character is alive. It is possible that you were hit, but your buddy dispatched him before the script was called. If you do not check for this fact, target acquisition will put you in an infinite loop. I still retain the old code for who_hit_me() after standard target selection. This is for hunting down people who hit you but are now out of range. Anway, the code is not much more complicated than the standard basicnpc, and it will provide the basis for my next several posts. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Formulae for Abilites? in Blades of Avernum | |
Apprentice
Member # 4127
|
written Friday, March 26 2004 19:35
Profile
Has anyone figured out all the formulae to the abilities, or is this hush-hush secret stuff in danger of being censored by Jeff? I want some of these for a monster AI script. Here is what I know. Every two levels of strength adds a damage category (including missiles?).Dex ups chance to hit by +5% and reduces to be hit by -5%.Each weapon skill (including the weapon level) ups to hit by +5% and damage by one category.Defense reduces to hit by a random amount up to -5% per level (which to anyone that knows probability, since a randomizer is uniform, this results in an average reduction of -2.5% per level).Hardiness seems to reduce damage a random amount of up to 1 per level (so an average reduction of -0.5 points per level).I haven't figured out how assassination works.Parry seems to work just like defense (so an average of -2.5%), except that you must have a melee weapon for it to take effect.Blademaster is a non-random +5% to hit per level, and some unknown (to me) effect to damage.I haven't figured out how anatomy works.Gymnastics seems to work like parry, except that you may get extra AP.Lethal Blow is very random and seems to be skill dependent. That's all I know.I could just make monsters and have them duke it out to guess these unknown abilities, but this is getting annoying. Does anyone have a clue. And while you are at it, how to Magery and Resistance effect spells? Why do I need this? Basically I want a mathematical way to compare damage between a fighter and mage in target selection, and I need to know a little bit about the probabilities so that I can properly weight the skills. For example, it is clear from above, that offensively, one melee skill (with that weapon in hand) is equal to one DEX and two STR. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |