Burktross Posted July 26, 2016 So I'm trying to use ACS to dynamically resize decorations. I have this script here which is supposed to get the difference of the floor and ceiling and yield the SectorHeight. Then I divide the sector height by the height of the actor (104 units) to get a multiplier which I apply to the decoration to make it adjust size to the ceiling.#include "zcommon.acs" script "DecorationScaler" (Void) { int DecorationId = UniqueTID(); int SectorHeight = GetActorCeilingZ(DecorationId) - GetActorFloorZ(DecorationId); int SizeScalar = SectorHeight / 104; SetActorProperty(DecorationId, APROP_ScaleY, SizeScalar); } and I initiate the script here, in decorate [yes, it is compiled]: actor Xeno2 16015 { //$Category HM Decor //$Color 4 Height 104 Radius 12 +SOLID States { Spawn: XEN2 A 1 ACS_NamedExecute("DecorationScaler") XEN2 A -1 Stop } } But nothing seems to happen on map load. I've tested this in Zdoom 2.8.1 and Zandronum 3 beta and still no dice. Any ideas? 0 Share this post Link to post
Graf Zahl Posted July 26, 2016 The very first state's function is not called normally. You can work around that by adding a 'nodelay' flag to the state's definition. I have no idea if this is available in Zandronum, though, if that does not work you have to add an empty 0-length state right after the 'Spawn' label, this should have the empty TNT1 sprite, though, to avoid some glitched display with the scale. 0 Share this post Link to post
Ijon Tichy Posted July 26, 2016 you shouldn't even need to give the decoration a tid, GetFloor/CeilingZ and SetActorProperty all accept 0 as "activator" for tid put "nodelay" before the ACS call, the first state run on an actor doesn't have its action function run by default edit: yes, nodelay is available in zandronum 3, although I don't know if an actor's modified scalex/y is sent to new clients I'd test that, and if it isn't, I'd just have the script set the scale every second or two, the performance and bandwidth hit is negligible if you aren't using a billion of these (after submitting a bug report to the zandronum tracker anyway) 0 Share this post Link to post
Burktross Posted July 26, 2016 Glorious! Much appreciated! This will make mapping infinitely more flexible. Final version of the code, for future reference:#include "zcommon.acs" script "DecorationScaler" (Void) { //int DecorationId = UniqueTID(); int SectorHeight = GetActorCeilingZ(0) - GetActorFloorZ(0); int SizeScalar = SectorHeight / 104; SetActorProperty(0, APROP_ScaleY, SizeScalar); }actor Xeno2 16015 { //$Category HM Decor //$Color 4 Height 104 Radius 12 +SOLID States { Spawn: TNT1 A 0 XEN2 A 1 NoDelay ACS_NamedExecute("DecorationScaler") XEN2 A -1 Stop } }Unfortunately I've run into another roadblock. Only some of the decorations actually load the script, apparently. It seems like the script can't run in parallel? In that if multiple ones try to call the script at once it doesn't work. I can "solve" this by adding a random number to the tics of the script state This makes everything take a long time to actually initialize the script, and en masse, like I intend to use them, I assume it'd be a terrible speed killer. Alright, fixed THIS too. http://imgur.com/r7JpLby Just changed the script to ExecuteAlways: "XEN2 A 1 NoDelay ACS_NamedExecuteAlways("DecorationScaler")" 0 Share this post Link to post
Graf Zahl Posted July 26, 2016 Ijon Tichy said:I'd test that, and if it isn't, I'd just have the script set the scale every second or two, the performance and bandwidth hit is negligible if you aren't using a billion of these We are talking about executing scripts here. 'Just' looping such states can put a major drag on performance, especally if it's just to make absolutely sure that things get done. 0 Share this post Link to post
scifista42 Posted July 26, 2016 Burktross said:It seems like the script can't run in parallel? ACS_NamedExecute indeed can't run multiple instances of the same script in parallel. ACS_NamedExecuteAlways can. EDIT: Sorry, I've missed the last part of your post where you've already figured it out. 0 Share this post Link to post
Ijon Tichy Posted July 27, 2016 Graf Zahl said:We are talking about executing scripts here. 'Just' looping such states can put a major drag on performance, especally if it's just to make absolutely sure that things get done. it took me 10000 rocket boxes looping a pretty complicated script every tic for things to drop below 30fps here, I think 100 decorations calling a short script every second or two will be fine 0 Share this post Link to post