ZDaemon Forum Index ZDaemon
Client/Server DOOM
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SetActivator function

 
Post new topic   Reply to topic    ZDaemon Forum Index -> Implemented Requests
View previous topic :: View next topic  
Author Message
Xsnake
Unstoppable!


Joined: 29 Dec 2004
Location: France, Bordeaux

PostPosted: Sat Feb 18, 2012 6:40 pm    Post subject: SetActivator function Reply with quote

Hey,

I'm not sure this has been discussed before. In co-op/survival, if a player activates a script that contains delays and leaves before the script has ended, the script will stop causing the map to be potentially bugged.

SetActivator(-1) would help fix this issue, but it's not working. If this function is called at the beginning of a script, it will just stop right from the beginning.

I'm posting this in the "requests" forum but this might be a bug.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sr69Mm-jC
Spamming!


Joined: 21 Jul 2011

PostPosted: Sat Feb 18, 2012 7:25 pm    Post subject: Reply with quote

Oh wow.. Been calling such scripts literally for ages; if it's true, then I'm glad I was lucky enough to not experience this yet :S Cause this one really sounds like it could break a ton of wads.

Anyway, I went ahead and made a test map.. There's a switch which waits 10 seconds and then spawns a BFG. It also prints the activator's nickname while waiting, maybe that helps too. So one should press it and disconnect and the other player reports whether the BFG was spawned or not.
http://www.mediafire.com/download.php?d2lubvgn4i20nq8
Back to top
View user's profile Send private message
Sr69Mm-jC
Spamming!


Joined: 21 Jul 2011

PostPosted: Sat Feb 18, 2012 8:21 pm    Post subject: Reply with quote

Ok, we tested the map with Krawa. It works just fine. Once activator has disconnected, it prints an empty line instead of his nickname. The script, however, will continue working and will spawn BFG at the end.
We tested functions "80 - Script Execute" and "226 - Script Execute Always"; both work fine.
So yeah.. Might be something related to the specific map. If it still gets broken for you, please post a test map Smile
Back to top
View user's profile Send private message
Xsnake
Unstoppable!


Joined: 29 Dec 2004
Location: France, Bordeaux

PostPosted: Sat Feb 18, 2012 8:50 pm    Post subject: Reply with quote

Well, thanks for your help guys. I was wrong apparently Smile

However, I think this function (currently not known by ZDaemon it seems) would be useful to make all the clients run functions that only apply to the activator. Example : FadeTo(). According to the ZDoom wiki, this function will only affect the script activator's view.

Typical example :
Code:

script 1 (void) // Activated by a player
{
  for(int i=0; i<16; i++)  // Big flash for everyone
    if(PlayerInGame(i)){
      SetActivator(PLAYER_TID+i);
      FadeTo(.....);   
    }
}


Last edited by Xsnake on Sun Feb 19, 2012 12:13 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
EarthQuake
Spamming!


Joined: 02 Apr 2004
Location: Athens, Ohio. Dieblieber gonna getcha!

PostPosted: Sun Feb 19, 2012 6:21 am    Post subject: Reply with quote

SR already pointed it out: the script will continue to work, but the activator does not exist any more. Trying to print the name of the nonexistant player will print "DoomPlayer" instead (or used to), and trying to get information about that activator will either give default values or random garbage. Setting information may result in all sorts of strangeness, depending on which special you are using.

To prevent all this, you can check if a player exists by using one of two methods:

1) Give the player a unique TID, and use ThingCount() to see if that TID is in use. It will return 0 if that player is not in the game.

2) Check if the activator is in the game using PlayerInGame(). You must pass PlayerNumber() to it. If PlayerNumber() returns -1, it's not a player, but a monster instead.

Regarding the function you inquired about, passing it a value of -1 is not probably something you would want to do (assuming it actually worked in ZDaemon)... -1 would be interpreted as NULL, since the TID in question does not exist (they shouldn't be negative). You'd get the same behavior by passing a TID unused by the map.

Seems it doesn't matter though, since we don't have this function. Unknown action specials or "extended" functions will cause the ACS interpreter to terminate the script when encountered. Unknown "built-in" ACS functions will usually cause a crash instead.

Aaaand... FadeTo()... yeah, would be nice, but there is currently no net message sent from the server to the clients, so you only get this effect offline. If you want all players to have their screens fade simultaneously, you can loop through sectors in the map and gradually darken/lighten/whatever them using Sector_SetColor, Sector_SetFade, or Light_ChangeToValue. I've tried this before, and it works pretty good online provided you use small steppings (e.g. don't loop through each possible "light" value). It will also speed up things on the client end by prebuilding all the color tables you plan to loop through.
Back to top
View user's profile Send private message Send e-mail
rhinoduck
Potatoes


Joined: 22 Oct 2012

PostPosted: Fri Dec 07, 2012 9:23 pm    Post subject: Reply with quote

What we sometimes do in TNS after we go through a wad with standard settings is that we take the monsters and replace them with random new ones for a wholly new experience. This all is done using PATCHINF and ACS at the start of each map without the need for modifying the original wad or restarting the server. The problem is that the least amount of monsters I can remove at one time is currently a whole class which very easily becomes too much for the network. In addition, I also need to kill the monsters first because the only way to get their coordinates now seems to be through a special executed upon their deaths.

Hopefully, this function would allow me to avoid packet loss problems resulting in ghost monsters by making it possible to iterate over things with the same tid and choose which to modify first and which to leave for later. In general, this would free the practically limitless in game thing control and altering possibilities which are now bound by the workaround being too heavy to be reasonably usable.

At the moment SetActivator() seems to always return false in ZDaemon. The proper behavior is described in the SetActivator() ZDoom wiki entry. As far as I am concerned I do not need the optional 'pointer_selector' parameter.

Here is a simple example of how easy it would become to assign a unique tid to each monster/thing in a map:
Code:
int groupTid = 8000; // tid assigned to a thing type in the PATCHINF lump
int newTid = 9000;

while (ThingCount(0, groupTid)) {
   SetActivator(groupTid);
   Thing_ChangeTID(0, newTid++);
}


I made a test wad with one map (map01). After three seconds the OPEN script starts killing monsters one by one (one each second) logging their coordinates and then prints a specific message to each player that is in game - see the source code for more details. It works in Zandronum - if you are going to test it there, note that in Zandronum the Log() function only prints to the server console.

If SetActivator() made it to the next server release, it would be awesome. If that is already the plan, is there a rough estimate on when the next release will be out?


Last edited by rhinoduck on Wed Feb 13, 2013 12:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
Evolution
Spamming!


Joined: 06 Sep 2005

PostPosted: Sun Dec 09, 2012 9:31 pm    Post subject: Reply with quote

Aye, this would be great!
Back to top
View user's profile Send private message Send e-mail
phenex2
Spamming!


Joined: 10 Jan 2008

PostPosted: Tue Feb 12, 2013 11:21 pm    Post subject: Reply with quote

Upcoming version supports TIDs in SetActivator.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ZDaemon Forum Index -> Implemented Requests All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group