Icon of Sin / Baphomet
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > Need some ACS assistance
 
Author
All times are GMT. The time now is 16:59. Post New Thread    Post A Reply
jdagenet
Junior Member


Posts: 168
Registered: 07-11


I'm trying to make a script that will constantly loop and check if an actors health goes below 701 and when it does, it'll spawn other monsters. Here is the script I currently have put together:

code:
script 1 (void) { if (checkactorproperty (60, aprop_health, 700)) { spawnspot ("SpawnFire", 67, 0, 0); delay (10); thing_spawnnofog (67, t_baron, 64, 68); } else { acs_execute (16, 0, 0, 0, 0); } delay (1); }


I'm not sure if I did the else loop correct but, could someone please help me with this?

Last edited by jdagenet on 12-27-11 at 23:27

Old Post 12-27-11 23:17 #
jdagenet is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
EarthQuake
9.5 on the Richter!


Posts: 2745
Registered: 05-03


You should format your code a little better to help improve readability.

code:
script 1 (void) { If (CheckActorProperty(60, APROP_HEALTH, 700)) { SpawnSpot("SpawnFire", 67, 0, 0); Delay(10); Thing_SpawnNoFog(67, T_BARON, 64, 68); } Else { ACS_Execute(16, 0, 0, 0, 0); } Delay(1); }


The way you have the code written basically works like this:

code:
Is the actor's health 700? Yes, then spawn fire, delay, and spawn some barons. No, then execute script 16. Now wait 1 tic and exit the script.


As you can see, it doesn't make too much sense.

Here's what you probably want:

code:
Script 1 (void) { // Get health of the target monster. int Health = GetActorProperty(60, APROP_HEALTH); // See if we're below 700 health. If (Health < 700) { // If it is, spawn fire, wait, then spawn barons... SpawnSpot("SpawnFire", 67, 0, 0); Delay(10); Thing_SpawnNoFog(67, T_BARON, 64, 68); // The script will stop looping now... } Else { // Otherwise, wait a bit and restart the script // so the target monster's health can be checked again... Delay(1); Restart; } }


I have no idea what Script 16 does, so I didn't include it in my correction. Note the use of GetActorProperty instead of CheckActorProperty. There are other ways of doing this as well, but this one might be the simplest to understand. Hope this helps.

Last edited by EarthQuake on 12-28-11 at 00:48

Old Post 12-28-11 00:42 #
EarthQuake is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
jdagenet
Junior Member


Posts: 168
Registered: 07-11


Thanks a lot, I'll be sure to try this. I'm not really familiar with the loops so that why mine looks so jacked up.

Old Post 12-28-11 01:03 #
jdagenet is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
EarthQuake
9.5 on the Richter!


Posts: 2745
Registered: 05-03


Usually you would use a loop structure, like "While" or "For" loops, where each work a bit differently. Your situation calls for a "While" loop, but your script is so simple, you can just restart the script and execute the code again. Your original piece of code did not seem to contain a loop, unless script 1 was called by script 16 somehow.

Here's a similar and shorter way of doing the above script:

code:
Script 1 Open { While (GetActorProperty(60, APROP_HEALTH) > 700) Delay(1); SpawnSpot("SpawnFire", 67, 0, 0); Delay(10); Thing_SpawnNoFog(67, T_BARON, 64, 68); }


This one practically does the same thing, except it starts checking the monster when the map loads, and not when you tell it to start. It'll delay action until the monster falls to 700 or less HP.

Old Post 12-28-11 01:10 #
EarthQuake is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 7036
Registered: 07-07


Alternatively:
code:
script 1 (void) { while (GetActorProperty(60, APROP_HEALTH) > 700) { ACS_Execute(16, 0, 0, 0, 0); Delay(1); } SpawnSpot("SpawnFire", 67, 0, 0); Delay(10); Thing_SpawnNoFog(67, T_BARON, 64, 68); }


This code will run the mysterious script 16 every tic until health gets lower than or equal to 700. Then it'll spawn fire, wait 10 tics, spawn a baron, and exit.

Old Post 12-28-11 01:15 #
Gez is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
EarthQuake
9.5 on the Richter!


Posts: 2745
Registered: 05-03


I'm utterly curious now, jdagenet. What does script 16 do? :p

Old Post 12-28-11 01:18 #
EarthQuake is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
jdagenet
Junior Member


Posts: 168
Registered: 07-11


Well, script 16 is actually the script you guys are helping me with, I just made it script 1.

Old Post 12-28-11 01:27 #
jdagenet is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 7036
Registered: 07-07



jdagenet said:
Well, script 16 is actually the script you guys are helping me with, I just made it script 1.

Oh. Well, it wasn't going to work because you just made the script executes itself forever all in the same tic.

You could have gotten something working with a delay(1); ACS_Execute(16); setup, but the loop is more elegant anyway.

Old Post 12-28-11 12:43 #
Gez is offline Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 16:59. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > Need some ACS assistance

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Forums Directory