Jump to content
  • Announcements

    • How to eat sound

      Logging in   05/10/2017

      If you had an account and can't log in as of 5/9/17, this may be because of a change in logins with new forum software. You can log in using your publicly displayed name (not your username) or your email address and the password you used before.   If you have problems with this, please ask any of the mods or admins. 
Sign in to follow this  
Thralni

Groups

Recommended Posts

Thralni   

Hey all,

 

Another question. I recently rediscovered the idea of groups. I'd never used them before, because I'd never really need them, I guess, but now I find myself looking for shortcuts, and certain function that may only be reliable if using groups. My question is whether groups can only be created from a script, or whether I can assign creatures to a  group also within the editor? It doesn't seem to be the case, but I thought I'd ask.

 

Thanks!

Share this post


Link to post
Share on other sites
Kelandon   

It's only within a script. For certain group functions, you may also need to do something in the editor, e.g., using the groupnpc script, but you assign the groups in a script.

Share this post


Link to post
Share on other sites
Thralni   

A related question to an older topic. I have been fiddling around with groups, hoping to devise a way to quickly check for certain creatures having died so as to display a message upon the death of a group of enemies. And so I used the number of creatures in a  group, and when this reaches 0, the message is triggered. And then it struck me that, when  creature dies, I'm not even sure that this "deletes" a creature from a group at all... Anybody have any idea? Is it required that i specifically delete them upon death? And can I do this from within the DEAD state in the creature script (is it even possible to use erase_char(ME)?)?

 

Many questions. I hope somebody can help me figure this out. Thanks in advance!

Share this post


Link to post
Share on other sites
Kelandon   

I've always dealt with this using flags: increment a flag in each character's DEAD_STATE, and if you know that there are, say, 6 characters that need to die before something happens, then make the thing happen once the flag reaches 6.

 

I think you can also do this the way you're intending, but you have to be a little bit careful. Crucially, a creature is still alive when its DEAD_STATE runs; it doesn't die until the script finishes. Thus, if you want to do something in the last creature's DEAD_STATE, you should do it when the number of creatures in the group reaches one, not zero.

 

I just tried this out in my testing scenario — a scenario that consists of basically nothing except whatever it is that I'm trying to test (here, a town with four hostile Giant Rats with a script that prints the number of creatures in the group in each character's DEAD_STATE) — and it appears that dead creatures don't count as being a part of the group. So this does work without having to remove monsters manually.

Share this post


Link to post
Share on other sites
Thralni   

That's good news, and thank you for the suggestion you mentioned. It definitely sounds more simple than what i'm trying to do, but since it's already there I'll just leave it unless I find it doesn't work as well as I hoped. With regards to creatures only being 'dead' after the scripts stops running, the code that checks the group size is in the town's start state, so I'm assuming that when combat ends, or at a new turn, the code will be executed. Right...?

 

By your words, I presume you can, in fact, use erase_char(ME) inside a script (also outside the DEAD_STATE). But perhaps you have to follow it with end(); in order to stop running the script?

Share this post


Link to post
Share on other sites
Kelandon   
1 hour ago, Thralni said:

With regards to creatures only being 'dead' after the scripts stops running, the code that checks the group size is in the town's start state, so I'm assuming that when combat ends, or at a new turn, the code will be executed. Right...?

Yes, that should be fine.

1 hour ago, Thralni said:

By your words, I presume you can, in fact, use erase_char(ME) inside a script (also outside the DEAD_STATE). But perhaps you have to follow it with end(); in order to stop running the script?

Yes, you can erase a character from within its own script. You don't have to follow it with an end().

 

This is maybe just me being overly cautious, but I never use ME; I always use my_number(). ME works in some calls and not others, but my_number() always works. So I don't know if erase_char(ME) actually works.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×