Jump to content

Groups


Thralni

Recommended Posts

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!

Link to comment
Share on other sites

  • 4 weeks later...

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...