Post by Kyzrati on Jan 10, 2013 11:09:41 GMT -5
In making my own mod I learned quite a bit as I had to figure out how to use the existing system to implement the features I wanted. In most cases there was a satisfactory way to work around any problems or limitations, but in others I was forced to add a new feature to the engine, some of which I'll cover here because they are quite useful.
I don't yet see a perfect way to organize all the ideas I'm going to discuss, so let's just start with some of the more interesting ones and go from there.
INTERACTIVE ENVIRONMENTS
Triggering events in the environment through special abilities (which by now most of you should have noticed I prefer to abbreviate "SA"), has gotten a whole lot easier as of 8.3.
In Rookie's Tale you encounter fun design elements like secret doors/stairs, collapsing floors/walls, falling stone traps, cave-ins, enemies teleporting in, etc. Part of what makes these much more viable is that props can now be made invisible, meaning they won't appear on the map or HUD, and can even be placed *inside* walls (as long as invisible) to keep them out of the way of the normal play space (good because remember that only *one* prop can occupy each cell, even if that prop is invisible). Because props can carry SA, you can use them to detect and activate location/situation-based effects. Even better, because these triggers are controlled by props you can even place them randomly within a certain area to make the area even more dynamic and unpredictable since your traps and secrets won't always be found in the exact same place (though for design purposes you'll often *want* them in the exact same place)
Probably the most useful kind of prop-based trigger requires an "explosion", so you can cause something to happen somewhere other than at the prop itself. These "explosions" don't do any real damage, but instead specify the damage type "SA", meaning the explosion will propagate and hit objects normally, but only apply any SA it has and not any real damage or other effects. Such an explosion should use the Invisible_Blast particle to propagate its effect outward at the fastest possible speed without showing anything on the map, and the new "NoSide" designation to disable the sideview during the explosion.
Another important mechanic to be familiar with regarding this technique is X-COM explosion damage falloff (see UFOpaedia). Unlike normal explosions SP damage is set to *never* falloff in the same plane, so it will always extend out to the explosion's full radius, while the damage value is reduced by 10 per z-level in the vertical direction (so 15 would go up and down 1 z-level from the origin plane). This is the only way in which an SP explosion's damage value is important--to determine how many levels up/down it can travel, if at all.
So obviously this explosion we're talking about here should carry some kind of special ability which is going to be applied to whatever object we're aiming to trigger. In cases where you want to affect a section of a normal wall (as with opening a secret door, since it normally looks like any other wall), you would also need to create another prop "receiver" to be hit by the explosive effect, and this receiver knows to convert the wall at its location to an open secret door when the triggering explosion hits it. The first and simplest secret doors I created simply used the E_MOV_BYTHIS_P2 trigger on a prop inside the wall to detect adjacent moves, while the method I describe above is for triggering something further away. For example you could use this technique to have a computer console prop that when manipulated causes an invisible triggering explosion that sends a signal (SA) across to another side of the room and opens a locked door (this can be taken even further by requiring that the entity manipulating the console be carrying a keycard, etc etc...).
Because even SP explosions can still be blocked by explosion-blocking props/cells, when you want to trigger things on the other side of walls set "Pasthru" (passthrough) to 1, which will ignore all obstacles. You could theorietically even send a huge explosion across the entire map to do some map-wide check/modification of some object, like turning on/off the lights across an entire base. Would be interesting to make some kind of night/dark aliens-type mod where all units have fewer TUs and thus move more slowly, and also produce very little light, so they need to find light-producing items and/or armor to see enemies before they close in and overwhelm them. They would also rely on sound-based messages that enemies produce when within a certain range of XCOM. Just another one of the many random ideas...
TRAITS
While simple, when combined with SA traits are probably one of the most powerful tools available for creating unique content. Traits can be used as markers, to tell whether an object fits a certain description/category, and as counters, to represent the degree to which an object expresses that trait. Traits are most useful for setting conditions on SA triggers/effects, thus limiting the types of objects that may be affected by that SA; you'll see lots of examples in the Rookie's Tale scripts. One thing to keep in mind is the player has no idea what traits they or other objects possess, so it needs to be either obvious (e.g., skeletons are undead) or reinforced through messages (e.g., so-and-so is poisoned) unless the trait is only used for some form of internal checking, which may also be the case. Traits can be added/subtracted dynamically from objects using GIVE_SA_/REMOVE_SA_ effects (subtracting to 0 or less removes that trait entirely; adding to 1 or more gives the object that trait). Objects inherit/stack traits in some cases, like an entity's traits come from itself, its race, and its current armor (if any). Another neat use for traits is creating a scanning effect that looks for a certain trait on nearby objects, like the "Detect Evil" ability in Rookie's Tale.
CONTINGENCY
Multi-effect SA are extremely useful recent additions, and combined with the new CONTINGENCY data setting they're now a lot more dynamic. You'll see a huge number of CONTINGENCY-based effects in Rookie's Tale, stringing together multiple effects, but only if certain other effects did or did not occur, so that it's easy to group them. Another strategy when using CONTINGENCY is to first use a few FLUFF effects to simple check conditions on an object and handle special cases/exceptions, then do the real effects afterwards only once those fail (since they were the exceptions). CONTINGENCY settings can be PASSED (any previous effect already passed all its conditions), PASSED_ALL (all previous effects passed), PASSED_LAST (last previously listed effect passed), plus FAILED versions of the above (reverse meaning).
DURATION EFFECTS
I didn't think it was possible at first since I never planned on it, but I eventually came up with a way to use the existing SA system to implement duration effects that work for poisoning, slowing, paralysis, temporary strength/buffs etc. The key is to create an effect that destroys itself after a certain period has passed. This generally requires creating two separate SA on the affected entity, one applies the actual effect, and the other is a pure "timer" which, after the duration is up, destroys both itself and the effect SA. Spider_Poison and Spider_Web are two of many examples you can see in Rookie's Tale sa.xt
ENTITY ABILITIES
It's really useful to have AI-controlled entities that cast "spells" and have other special attacks, but right now the AI is incredibly simple and only knows how to use standard direct fire item weapons rather than any manual-use SA you give them, so you have to fake pretty much everything on that front. As I think most of you have already figured out from my examples, this requires usage of so-called "natural weapons" which must still be items, the ability/effect must be carried by the projectile, and require a special type of inventory slot. This last point is necessitates probably one of the most annoying workarounds so far, in that races that want to do this need different anatomies thus Rookie's Tale has "goblinkind", "human caster" etc variations on races for implementing this. Another unfortunate side-effect of this is that any armor worn by such entities will be incompatible with otherwise similar/same races.
Another way to give entities abilities is by having them be passive or automatically triggered. They can at least *seem* active due to text provided when triggered, like at the beginning of a new turn or when they're attacked. There are a number of examples in Rookie's Tale--all the "Auto_"-prefixed SA: things like automatic healing of nearby allies and automatic summoning of allies when enemies approach.
SPEECH
Speech is mostly for flavor, but can also give gameplay hints. This has been a staple since Cataclysm, but I thought I'd list it here because it adds to the immersion, and there are some points you may not have noticed about implementation. When it's triggered speech should obviously be limited to when it should be heard by XCOM (or the speaker seen, if appropriate), which can be done through the E_FACTION_RANGE/E_FACTION_RANGE_Z conditions (the latter limits the check to the same z-plane), as well as E_FACTION_SPOT and E_ENEMY_RANGE. Useful triggers for speech include SPOT_ENT (said when one entity sees another), E_MOV_BYTHIS_E1 (said when an ent moves up to speaker), and of course ENT_NEW_TURN. Using COUNT==0 on the trigger data to make sure it's said only say once is good, too. As long as the speech is properly limited through conditions, you can set Message Knwldge to GLOBAL instead of DEFAULT so the speaker/source doesn't have to be inside XCOM FOV to have it show on the HUD. Putting a WEIGHT on multi-effect speech triggers can enable different content, too.
MAP GENERATION
As seen on the changelog, I added the possibility of forced placement of areas, which was is how I ensured one start and one boss area per map--see the new manual for that.
I ended up not using area groups to great effect. If enough time I'd have made larger towns with a central 2x2 area, the "core", and bunch of optional attached areas like a blacksmith, mages guild, farms, etc. that would arrange themselves around the town randomly, if and when they were picked for generation.
3x3 areas are very large and not really recommended unless you're really familiar with drawing ASCII maps, since they're a pain to design. But I felt that I had to do it to make some of the more epic parts viable (e.g., trap-filled ruins with multiple paths to the end).
BALANCE
Early on it's important to come up with a general idea of the number scale(s) you want to use for your mod (or build off the X-COM values), since relative damage/health/integrity/strength values obviously have a huge impact on gameplay and are hard to go back and rebalance once they're all over the place. To get the best results, you should hopefully already be familiar with how X-COM damage mechanics work in terms of randomness and ranges. Weapons actually do anywhere from 0~200% damage to targeted units (same as X@COM), while most projectile damage types do 25~75% damage to terrain and melee damage types do 25~125% to terrain.
PATICLE EFFECTS
I added a ton of particles for 8.3, and you can pretty easily use these for your own objects. I wouldn't recommend making your own particles since I've never explained how the system works, but recoloring existing particles could be fairly trivial if you stare at the file long enough
Particles come in three types:
* PRO: Projectiles, used for items
* BLA: Blasts, used for explosions
* GEN: Generic, either spawned by PRO or BLA for more complicated effects, or used directly by SA for visual effects
But you don't really need to open up the particle definition file and care about this stuff, just copy particle names that you want to use from items.xt, explosions.xt, or sa.xt to your own corresponding file. It's much preferred to have *some* visual effect associated with your SA, using the PARTICLE= effect data. To make enemies that have special ranged attacks that shouldn't show a particle at all, like non direct-fire magic, you can use Invisible_Particle on an item. I also faked the Ethereal's psi-amp mind control ability this way in Rookie's Tale! He can actually take control of X-COM units inside his FOV.
SPECIFIC EXAMPLES
Here I'm just listing some other cool things you can find in Rookie's Tale that use a technique mentioned above, or that you might want to look into for reference:
* Druid Ritual: This one was pretty neat, requiring that you have two items in your possession, the dagger and seed, and when you manipulate the altar it cuts the seed (destroying it), sends out an explosive signal that searches for the Great Druid, who then responds with his own explosive signal to say he's there, which allows the ritual to be completed and summons the Forest Spirit, which also triggers all the druids to turn on you by switching their faction through another explosion (which passes through all walls etc to make sure it gets to all the druids). And if before that the Great Druid spots anyone carrying the dagger or lifeseed, stolen from their room, he will also immediately send out an explosion that turns all druids on you.
* "Props as Units": Props can be turned into units under special conditions, so they don't normally behave like units. Sleeping wolves/bears that might wake up when you walk nearby, and will wake up others pretty quickly if they're woken up. Unconscious/injured/captured adventurers you can rescue.
* Dynamic Props: Pure "dynamic map design" props can be created that randomly convert themselves into some other random prop (usually based on a weighted ratio) before the first turn of a mission. Different kinds of treasure chests, special trees/bushes, and locked/unlocked doors can be created this way, so they're different each time the map is generated. You could also achieve this effect through spawning.xt, but that is a *lot* more time-consuming and not as dynamic. Props like this can also be used to do pre-start effects, like exploding certain areas of the map for example.
* Spawn Points: Most of you are familiar with spawn point usage, and the addition of invisible props allows for yet another option with these. Generally you want your spawn points visible when it makes sense, like the spider holes and orcish mines in Rookie's Tale--so you can collapse them and stop the spawning. Consider using conditional checks to make sure there are or are not X-COM units nearby when spawning (P_FACTION_RANGE/P_FACTION_RANGE_Z), whatever's most appropriate.
* Interesting Combinations: There are quite a few triggers and effects now, so you can try to come up with unexpected combinations that force new tactical considerations, like the Shamblers in Rookie's Tale that may explode into a cloud of noxious gas when struck (stuns), or the gas spiders which explode for damage, sometimes even when they attack you. Gas spiders are cool in other ways, too, like they may explode when they fall and hit the ground
and you can even throw their dead bodies like grenades (if they didn't explode on death).
* Exclusive Items: Items that only certain units can use, like Kyzrati's Staff and Quentaficus' Staff, can be created through resitrictive conditions, and may be fun or useful. Another example is only Victor can use the Alien Device and win the mission.
There's lots of other stuff you can find in Rookie's Tale. Feel free to bring up questions about anything mentioned above, or other content you find. I'll be posting to the blog (within the next week or so) a more in-depth guide to playing the mod which may spark your imagination, or perhaps point out more features you didn't know about that you'd like me to explain.
I don't yet see a perfect way to organize all the ideas I'm going to discuss, so let's just start with some of the more interesting ones and go from there.
INTERACTIVE ENVIRONMENTS
Triggering events in the environment through special abilities (which by now most of you should have noticed I prefer to abbreviate "SA"), has gotten a whole lot easier as of 8.3.
In Rookie's Tale you encounter fun design elements like secret doors/stairs, collapsing floors/walls, falling stone traps, cave-ins, enemies teleporting in, etc. Part of what makes these much more viable is that props can now be made invisible, meaning they won't appear on the map or HUD, and can even be placed *inside* walls (as long as invisible) to keep them out of the way of the normal play space (good because remember that only *one* prop can occupy each cell, even if that prop is invisible). Because props can carry SA, you can use them to detect and activate location/situation-based effects. Even better, because these triggers are controlled by props you can even place them randomly within a certain area to make the area even more dynamic and unpredictable since your traps and secrets won't always be found in the exact same place (though for design purposes you'll often *want* them in the exact same place)
Probably the most useful kind of prop-based trigger requires an "explosion", so you can cause something to happen somewhere other than at the prop itself. These "explosions" don't do any real damage, but instead specify the damage type "SA", meaning the explosion will propagate and hit objects normally, but only apply any SA it has and not any real damage or other effects. Such an explosion should use the Invisible_Blast particle to propagate its effect outward at the fastest possible speed without showing anything on the map, and the new "NoSide" designation to disable the sideview during the explosion.
Another important mechanic to be familiar with regarding this technique is X-COM explosion damage falloff (see UFOpaedia). Unlike normal explosions SP damage is set to *never* falloff in the same plane, so it will always extend out to the explosion's full radius, while the damage value is reduced by 10 per z-level in the vertical direction (so 15 would go up and down 1 z-level from the origin plane). This is the only way in which an SP explosion's damage value is important--to determine how many levels up/down it can travel, if at all.
So obviously this explosion we're talking about here should carry some kind of special ability which is going to be applied to whatever object we're aiming to trigger. In cases where you want to affect a section of a normal wall (as with opening a secret door, since it normally looks like any other wall), you would also need to create another prop "receiver" to be hit by the explosive effect, and this receiver knows to convert the wall at its location to an open secret door when the triggering explosion hits it. The first and simplest secret doors I created simply used the E_MOV_BYTHIS_P2 trigger on a prop inside the wall to detect adjacent moves, while the method I describe above is for triggering something further away. For example you could use this technique to have a computer console prop that when manipulated causes an invisible triggering explosion that sends a signal (SA) across to another side of the room and opens a locked door (this can be taken even further by requiring that the entity manipulating the console be carrying a keycard, etc etc...).
Because even SP explosions can still be blocked by explosion-blocking props/cells, when you want to trigger things on the other side of walls set "Pasthru" (passthrough) to 1, which will ignore all obstacles. You could theorietically even send a huge explosion across the entire map to do some map-wide check/modification of some object, like turning on/off the lights across an entire base. Would be interesting to make some kind of night/dark aliens-type mod where all units have fewer TUs and thus move more slowly, and also produce very little light, so they need to find light-producing items and/or armor to see enemies before they close in and overwhelm them. They would also rely on sound-based messages that enemies produce when within a certain range of XCOM. Just another one of the many random ideas...
TRAITS
While simple, when combined with SA traits are probably one of the most powerful tools available for creating unique content. Traits can be used as markers, to tell whether an object fits a certain description/category, and as counters, to represent the degree to which an object expresses that trait. Traits are most useful for setting conditions on SA triggers/effects, thus limiting the types of objects that may be affected by that SA; you'll see lots of examples in the Rookie's Tale scripts. One thing to keep in mind is the player has no idea what traits they or other objects possess, so it needs to be either obvious (e.g., skeletons are undead) or reinforced through messages (e.g., so-and-so is poisoned) unless the trait is only used for some form of internal checking, which may also be the case. Traits can be added/subtracted dynamically from objects using GIVE_SA_/REMOVE_SA_ effects (subtracting to 0 or less removes that trait entirely; adding to 1 or more gives the object that trait). Objects inherit/stack traits in some cases, like an entity's traits come from itself, its race, and its current armor (if any). Another neat use for traits is creating a scanning effect that looks for a certain trait on nearby objects, like the "Detect Evil" ability in Rookie's Tale.
CONTINGENCY
Multi-effect SA are extremely useful recent additions, and combined with the new CONTINGENCY data setting they're now a lot more dynamic. You'll see a huge number of CONTINGENCY-based effects in Rookie's Tale, stringing together multiple effects, but only if certain other effects did or did not occur, so that it's easy to group them. Another strategy when using CONTINGENCY is to first use a few FLUFF effects to simple check conditions on an object and handle special cases/exceptions, then do the real effects afterwards only once those fail (since they were the exceptions). CONTINGENCY settings can be PASSED (any previous effect already passed all its conditions), PASSED_ALL (all previous effects passed), PASSED_LAST (last previously listed effect passed), plus FAILED versions of the above (reverse meaning).
DURATION EFFECTS
I didn't think it was possible at first since I never planned on it, but I eventually came up with a way to use the existing SA system to implement duration effects that work for poisoning, slowing, paralysis, temporary strength/buffs etc. The key is to create an effect that destroys itself after a certain period has passed. This generally requires creating two separate SA on the affected entity, one applies the actual effect, and the other is a pure "timer" which, after the duration is up, destroys both itself and the effect SA. Spider_Poison and Spider_Web are two of many examples you can see in Rookie's Tale sa.xt
ENTITY ABILITIES
It's really useful to have AI-controlled entities that cast "spells" and have other special attacks, but right now the AI is incredibly simple and only knows how to use standard direct fire item weapons rather than any manual-use SA you give them, so you have to fake pretty much everything on that front. As I think most of you have already figured out from my examples, this requires usage of so-called "natural weapons" which must still be items, the ability/effect must be carried by the projectile, and require a special type of inventory slot. This last point is necessitates probably one of the most annoying workarounds so far, in that races that want to do this need different anatomies thus Rookie's Tale has "goblinkind", "human caster" etc variations on races for implementing this. Another unfortunate side-effect of this is that any armor worn by such entities will be incompatible with otherwise similar/same races.
Another way to give entities abilities is by having them be passive or automatically triggered. They can at least *seem* active due to text provided when triggered, like at the beginning of a new turn or when they're attacked. There are a number of examples in Rookie's Tale--all the "Auto_"-prefixed SA: things like automatic healing of nearby allies and automatic summoning of allies when enemies approach.
SPEECH
Speech is mostly for flavor, but can also give gameplay hints. This has been a staple since Cataclysm, but I thought I'd list it here because it adds to the immersion, and there are some points you may not have noticed about implementation. When it's triggered speech should obviously be limited to when it should be heard by XCOM (or the speaker seen, if appropriate), which can be done through the E_FACTION_RANGE/E_FACTION_RANGE_Z conditions (the latter limits the check to the same z-plane), as well as E_FACTION_SPOT and E_ENEMY_RANGE. Useful triggers for speech include SPOT_ENT (said when one entity sees another), E_MOV_BYTHIS_E1 (said when an ent moves up to speaker), and of course ENT_NEW_TURN. Using COUNT==0 on the trigger data to make sure it's said only say once is good, too. As long as the speech is properly limited through conditions, you can set Message Knwldge to GLOBAL instead of DEFAULT so the speaker/source doesn't have to be inside XCOM FOV to have it show on the HUD. Putting a WEIGHT on multi-effect speech triggers can enable different content, too.
MAP GENERATION
As seen on the changelog, I added the possibility of forced placement of areas, which was is how I ensured one start and one boss area per map--see the new manual for that.
I ended up not using area groups to great effect. If enough time I'd have made larger towns with a central 2x2 area, the "core", and bunch of optional attached areas like a blacksmith, mages guild, farms, etc. that would arrange themselves around the town randomly, if and when they were picked for generation.
3x3 areas are very large and not really recommended unless you're really familiar with drawing ASCII maps, since they're a pain to design. But I felt that I had to do it to make some of the more epic parts viable (e.g., trap-filled ruins with multiple paths to the end).
BALANCE
Early on it's important to come up with a general idea of the number scale(s) you want to use for your mod (or build off the X-COM values), since relative damage/health/integrity/strength values obviously have a huge impact on gameplay and are hard to go back and rebalance once they're all over the place. To get the best results, you should hopefully already be familiar with how X-COM damage mechanics work in terms of randomness and ranges. Weapons actually do anywhere from 0~200% damage to targeted units (same as X@COM), while most projectile damage types do 25~75% damage to terrain and melee damage types do 25~125% to terrain.
PATICLE EFFECTS
I added a ton of particles for 8.3, and you can pretty easily use these for your own objects. I wouldn't recommend making your own particles since I've never explained how the system works, but recoloring existing particles could be fairly trivial if you stare at the file long enough

* PRO: Projectiles, used for items
* BLA: Blasts, used for explosions
* GEN: Generic, either spawned by PRO or BLA for more complicated effects, or used directly by SA for visual effects
But you don't really need to open up the particle definition file and care about this stuff, just copy particle names that you want to use from items.xt, explosions.xt, or sa.xt to your own corresponding file. It's much preferred to have *some* visual effect associated with your SA, using the PARTICLE= effect data. To make enemies that have special ranged attacks that shouldn't show a particle at all, like non direct-fire magic, you can use Invisible_Particle on an item. I also faked the Ethereal's psi-amp mind control ability this way in Rookie's Tale! He can actually take control of X-COM units inside his FOV.
SPECIFIC EXAMPLES
Here I'm just listing some other cool things you can find in Rookie's Tale that use a technique mentioned above, or that you might want to look into for reference:
* Druid Ritual: This one was pretty neat, requiring that you have two items in your possession, the dagger and seed, and when you manipulate the altar it cuts the seed (destroying it), sends out an explosive signal that searches for the Great Druid, who then responds with his own explosive signal to say he's there, which allows the ritual to be completed and summons the Forest Spirit, which also triggers all the druids to turn on you by switching their faction through another explosion (which passes through all walls etc to make sure it gets to all the druids). And if before that the Great Druid spots anyone carrying the dagger or lifeseed, stolen from their room, he will also immediately send out an explosion that turns all druids on you.
* "Props as Units": Props can be turned into units under special conditions, so they don't normally behave like units. Sleeping wolves/bears that might wake up when you walk nearby, and will wake up others pretty quickly if they're woken up. Unconscious/injured/captured adventurers you can rescue.
* Dynamic Props: Pure "dynamic map design" props can be created that randomly convert themselves into some other random prop (usually based on a weighted ratio) before the first turn of a mission. Different kinds of treasure chests, special trees/bushes, and locked/unlocked doors can be created this way, so they're different each time the map is generated. You could also achieve this effect through spawning.xt, but that is a *lot* more time-consuming and not as dynamic. Props like this can also be used to do pre-start effects, like exploding certain areas of the map for example.
* Spawn Points: Most of you are familiar with spawn point usage, and the addition of invisible props allows for yet another option with these. Generally you want your spawn points visible when it makes sense, like the spider holes and orcish mines in Rookie's Tale--so you can collapse them and stop the spawning. Consider using conditional checks to make sure there are or are not X-COM units nearby when spawning (P_FACTION_RANGE/P_FACTION_RANGE_Z), whatever's most appropriate.
* Interesting Combinations: There are quite a few triggers and effects now, so you can try to come up with unexpected combinations that force new tactical considerations, like the Shamblers in Rookie's Tale that may explode into a cloud of noxious gas when struck (stuns), or the gas spiders which explode for damage, sometimes even when they attack you. Gas spiders are cool in other ways, too, like they may explode when they fall and hit the ground

* Exclusive Items: Items that only certain units can use, like Kyzrati's Staff and Quentaficus' Staff, can be created through resitrictive conditions, and may be fun or useful. Another example is only Victor can use the Alien Device and win the mission.
There's lots of other stuff you can find in Rookie's Tale. Feel free to bring up questions about anything mentioned above, or other content you find. I'll be posting to the blog (within the next week or so) a more in-depth guide to playing the mod which may spark your imagination, or perhaps point out more features you didn't know about that you'd like me to explain.