I'm trying to do an effect for all monsters and players in any given level, where their movement speed is proportional to the amount of damage they took beneath their standard amount. I need this to be a constant system so it is done evenly and without interruption or other cockamamie flaws.
So I need to make ACS that:
1. Keeps track of the original health and speed values, so even if a player/monster has more than 100% of their normal health, the code won't run, or if it's less, the code will. Remember, players may have 100 or 200 health, but some monsters can have 400 to 4000 health, so percentages and proportion math will be necessary.
2. Runs a constant loop for each character actor (both player and monster) to make sure the values are what they're supposed to be instead of doing it in specific states.
3. Takes into account that I have weapons that set speed values, that these should not reset the movement speed (it happened to me during testing).
4. When health gets unbearably low, the speed limiting effect should cut off so you aren't completely immobile when you're down to like 15% of health points or less.
I originally wanted to write this as an OPEN script to run across the level for every player and monster that does spawn while the level is active (thus use a loop). Then I found out that it's impossible to keep an array of every specific player and monster on the map.
That's when I decided to instead make it a required ACS call for each player or monster that spawns in the Spawn: state, and move its original Spawn: to Idle:. Doing this makes a little more sense, because now it is specific to whatever actors have it rather than relying on the level to decide that.
I made sure my library, file, and even script names are all the same exact name, and 8 characters or less. I used LOADACS to ensure that the .o gets loaded in. But the game kept throwing an "unrecognized" script, even with [ Spawn: TNT1 A 1 ACS_NamedExecuteAlways("dmgslwmv") ].
If it helps any, here's my ACS...
Code: Select all
/*
Damage Slow Move
When a character actor (player or enemy) suffers enough damage,
they will start to move slower than normal.
This must be called on every relevant actor's Spawn state.
*/
// Initial
#library "dmgslwmv"
#include "zcommon.acs"
// Main Script
script "dmgslwmv" ENTER {
int health = GetActorProperty(0, APROP_Health);
int speed = GetActorProperty(0, APROP_Speed);
while (GetActorProperty(0, APROP_Health > 0)) {
int newspeed = (GetActorProperty(0, APROP_Health)*speed)/health;
SetActorProperty(0, APROP_Speed, newspeed);
// Still need to do the "very low health" limiter so you aren't completely trapped.
delay(1);
}
}