Jump to content

Scripting Troubles


Recommended Posts

I want to make someone offer to join your party after being defeated, but putting the relevant code in the DEAD_STATE doesn't seem to work. The trouble, I'm guessing, is that add_char_to_party() doesn't work because the character is dead. So, if I'm right, I need to revive it in the DEAD_STATE. Any idea how that could be done? Or any other suggestions?

Link to comment
Share on other sites

Without knowing much about Avernumscript, it seems like it would be easier to have a second character who is hidden and then joins (or appears and offers to join, or whatever) on a cue triggered by the first (hostile) character's death state. That also allows you to make their stats different if appropriate.

Link to comment
Share on other sites

Are you sure that the problem isn't that you're calling add_char_to_party from a creature script? I can't find the reference now, but I've been working on similar things today, and had issues with a call that could only be used from a town or dialogue script.

 

I'm not sure whether there's a good way to deal with the creature being (sort of) dead already in the DEAD_STATE. In general spawn_creature() can be used to resurrect preset town creatures, but it may not be applicable in your situation. There is a low level sneaky way to bring things back to life, which is what I've found I need for what I'm doing, but I assume you want to avoid that if possible. (In addition to the fact that I still need to research the right magic numbers to use on Windows.)

 

One way that you might work around this entire problem is that if you have exactly one case where you need to do this, you could just have a duplicate of the creature hidden 'off stage', and join that one to the party when the original dies. (You could do this for multiple cases as well, but it would get tedious for obvious reasons.) If you felt like being a little elaborate you could use place_monster to generate the double on the fly, but this way has multiple possible failure modes, and is probably easier to avoid if you don't need it.

Link to comment
Share on other sites

Actually, I was calling add_char_to_party from a dialog script invoked upon death. I tried spawn_creature, but that didn't seem to work either.

 

Duplicating the creature would work if I hadn't reached the quota of creatures in a town. On the other hand, I can probably find a creature to delete to make way for it, so I guess I'll go with that one.

 

Thanks.

Link to comment
Share on other sites

Quote:
Duplicating the creature would work if I hadn't reached the quota of creatures in a town. On the other hand, I can probably find a creature to delete to make way for it, so I guess I'll go with that one.

This might make you actually want to use place_monster(), then, since it lets you used a summon slot rather than a preset monster slot. You have to be careful, however, that it really does get summoned, as large fights can quickly summon enough creatures to fill all 34 slots. Of course you can always check to see if there are any summon slots free, and if not, erase one of the summoned creatures, since they probably aren't very important.
Link to comment
Share on other sites

Okay, so I'm trying to spawn a creature and put a box on a space after four other creatures have died. Each of them is set to call state 23 upon death, which contains the following code:

 

Code:
beginstate 23;	demons = demons + 1;	if(demons >= 4) {		message_dialog("","");		place_monster(42,41,113,0);		set_terrain(42,41,200);	}break;

 

However, when the fourth one is killed, nothing happens.

Link to comment
Share on other sites

I discovered a strange glitch; it's not really related to scripting, but it's something I kind of need to solve.

 

I have a town, which contains a boat. You are supposed to leave the town to the west. However, attempts to do so result in coming up against an invisible wall, even though the town boundaries leave one space at the edge rather than going all the way to the edge. If you try leaving to the north or south (which has three spaces beyond the boundary rect), you can go off the town boundaries (possibly even beyond the actual physical boundaries of the town); only after fiddling around a bit do you end up in the outdoors, and then you end up on land (but that's probably because the north and south entrances are supposed to be land entrances).

Link to comment
Share on other sites

My impression was that only one space outside the boundary was needed to allow the party to exit effectively. I guess I'll have to try shrinking it, though that might be a bit difficult since almost all the space is used up.

 

EDIT: Apparently I was wrong. One space is insufficient; three is sufficient. Hopefully two will work.

 

EDIT EDIT: Fortunately it does. For future reference, at least two spaces must be left on any side you want to be able to exit from.

Link to comment
Share on other sites

I'm so rusty at writing cutscenes that I had some troubles with something similar sounding. You may want to get advice from someone more knowledgable (or examine a script written by such a person), but the fix I used was to mostly move the party around using march_party(). It takes some extra effort, since you have to march them to the place where you want the final member to end up and then sequentially through the spaces for the other members up to the first member, but it gets the job done.

Link to comment
Share on other sites

I actually did use march_party; however, at the beginning of the cutscene I had used relocate_character to make sure that they were not in a position where they'd get in the way of the cutscene. I guess I can try getting them there with march_party instead and see if that works.

 

By the way, I'm pretty sure I remembered to include a one-second pause after each frame, yet some of the frames seem to be skipped when I actually see the cutscene (for example, it jumps from text bubble #1 to text bubble #3). Any idea what might cause that?

Link to comment
Share on other sites

First of all, is the first party character returning to the space where the cut scene is activated? If so, you need to include the call block_entry somewhere in the code for your relocations to stick. I believe that applies to march_party as well.

As for the text bubbles, empty strings do work to clear them. Make absolutely sure that you include the call force_instant_terrain_redraw() every time you want a change to be displayed to the player, and then include a pause, even between changes in text bubbles.

Link to comment
Share on other sites

Perhaps this is a silly question, but is there any way to a) determine if a PC has a cursed item equipped and B) remove said curse using a script? I'm looking at simulating an Exile-type healing interface, where you have a list of ailments that afflict some member of the party and choose from the list to heal that ailment. One of said ailments is cursed items, at least in Exile.

 

This isn't really necessary for my scenario, since it doesn't really have cursed items, but I want to have it for completeness so that I can post it on Blades Forge or something.

Link to comment
Share on other sites

Quote:
a) determine if a PC has a cursed item equipped

In Jeff's infinite wisdom: No!

Quote:
B) remove said curse using a script

Yes, according to the docs restore_pc() does this.

Edit: Just realized that it should be possible to implement a sneaky work-around to accomplish (a). I think that I have all of the necessary information, so I'll just have to code it up and test it.
Link to comment
Share on other sites

Will the sneaky way work in the condition of a dialog node, though? And can B) be done without restore_pc()?

 

Next question... how to remove dread curse? alter_stat doesn't seem to work, possibly because dread curse reduces all stats by 1 including itself. I can detect it with get_stat_levels_bought (which is actually kind of strange, but whatever), but I can't seem to remove it.

 

Again, it's not strictly needed for my scenario, but for completeness...

Link to comment
Share on other sites

Quote:
Will the sneaky way work in the condition of a dialog node, though?

It's not going to be a one-liner, so no. You could fake it fairly well by evaluating it from a special rectangle that the party has to (or at least is likely to) walk through before starting the conversation and storing the result, though. (After all, the party isn't going to be taking off a cursed item between walking through the rectangle and talking to the NPC.)

Quote:
And can B) be done without restore_pc()?

I think yes, using more sneakiness, but why? Is there something wrong with using restore_pc()? If you're concerned about preserving the character's hitpoints and energy, you can just store them before and then revise them to match again afterwards.

Quote:
Next question... how to remove dread curse? alter_stat doesn't seem to work, possibly because dread curse reduces all stats by 1 including itself. I can detect it with get_stat_levels_bought (which is actually kind of strange, but whatever), but I can't seem to remove it.

Huh, I hadn't thought there was a problem with this. Nephilim Mystery gives the party 12 levels (!) of Dread Curse and then removes them again, successfully as far as I recall. Maybe someone else has some experience with this.
Link to comment
Share on other sites

Originally Posted By: Niemand
I think yes, using more sneakiness, but why? Is there something wrong with using restore_pc()? If you're concerned about preserving the character's hitpoints and energy, you can just store them before and then revise them to match again afterwards.
Good point. That would probably be easier.

Originally Posted By: Niemand
Huh, I hadn't thought there was a problem with this. Nephilim Mystery gives the party 12 levels (!) of Dread Curse and then removes them again, successfully as far as I recall. Maybe someone else has some experience with this.
Well, I tried the following two lines (not at the same time):
Code:
alter_stat(i,31,0 - get_stat_levels_bought(i,31));alter_stat(i,31,-500);
The first didn't work. I don't think the second did either.


On an unrelated note, does anyone know if there is a maximum on the number of animations (explosions, etc) running simultaneously? I think I might have run into such a limit.
Link to comment
Share on other sites

You could iterate "short char_has_item_of_class_equip(short char_num,short which_class,short take_item)" for all the cursed items in the game if you give all such items the same special class. It depends if you only to check for one specific type of cursed item or if you want to check for any type at all.

Link to comment
Share on other sites

Quote:
On an unrelated note, does anyone know if there is a maximum on the number of animations (explosions, etc) running simultaneously? I think I might have run into such a limit.

There is such a limit; as I recall Ephesos hit it with some of his animations in early versions of SoG, but I don't know what exactly it was. if you determine it please make note so we don't forget again.

Quote:
You could iterate "short char_has_item_of_class_equip(short char_num,short which_class,short take_item)" for all the cursed items in the game if you give all such items the same special class. It depends if you only to check for one specific type of cursed item or if you want to check for any type at all.

You can do this, but I'm not impressed with this as a solution in general, since it both requires a bunch of redundant work tagging all of the relevant items in the scenario's data definitions, each item can carry only one tag (potentially causing problems if you wanted to be able to query more than one property this way), and it can't work on items that the party carries into the scenario. That being said, in some situations this will be good enough, and is supported, which may make it the pragmatic choice.

Finally, regarding the sneaky dark magic I mentioned above: It seems I don't have quite the right incantations handy; the ones I have do something different than what I thought. A bit more research will be required, although the fundamental idea should still be sound.
Link to comment
Share on other sites

Originally Posted By: Celtic Minstrel
Next question... how to remove dread curse? alter_stat doesn't seem to work, possibly because dread curse reduces all stats by 1 including itself. I can detect it with get_stat_levels_bought (which is actually kind of strange, but whatever), but I can't seem to remove it.

Again, it's not strictly needed for my scenario, but for completeness...

If you don't give the party Dread Curse to the party in your scenario, then you don't need to worry about it. Dread Curse is removed once the party leaves the scenario where the curse was acquired.
Link to comment
Share on other sites

Originally Posted By: B.J.Earles
If you don't give the party Dread Curse to the party in your scenario, then you don't need to worry about it. Dread Curse is removed once the party leaves the scenario where the curse was acquired.
I realize this, but I'm trying to make it generic so that it could be used in other scenarios.

EDIT: Effects limit is 60. For effects and sparkles, the num_effects and num_sparkles are the number that counts towards the effect. Explosions count for one. I'm not quite sure how zaps count.
Link to comment
Share on other sites

For my research on the node limit, see this post. Short answer: it's 32000.

 

Quote:
Is there any other way to get a numeric response other than having a check_text_response_match call for every possible value?

There is no other supported way. I assume you recall the discussion which resulted in this suggestion, which is what I would recommend using in general. This is another thing that can be done very nicely via tricks, but given that a not totally horrible legal way exists, it might be best to stick to that. At some point I'll publish a finished version of the tricky version, though. (So many irons in the fire. SO MANY.)

Link to comment
Share on other sites

Originally Posted By: Niemand
Huh, I hadn't thought there was a problem with this. Nephilim Mystery gives the party 12 levels (!) of Dread Curse and then removes them again, successfully as far as I recall. Maybe someone else has some experience with this.
It seems there are problems with giving insane levels of Dread Curse; my test case involved giving 100 levels (something which will almost certainly not occur in practice), and it didn't work, but reducing the test case to 10 levels allowed it to work just fine. Perhaps someone should research the maximum safe level of Dread Curse.

(Might be worth noting that the test case did in fact remove the Dread Curse as far as get_stat_levels_bought was concerned, yet still showed it in the skill list.)
Link to comment
Share on other sites

You know, now that you mention it, I remember having similar problems with manipulating stats for the identification scrolls in BoR. If I boosted the character's Intelligence or Arcane Lore too high, it wouldn't go back down again. I eventually settled on always boosting to 60, rather than the +100 or some such that I had originally used. Unfortunately, I don't think I have any notes from my session of debugging it with Nikki, since we were using KoL chat to communicate.

Link to comment
Share on other sites

Okay, there's a character who I want to automatically become hostile whenever you steal anything in a particular town. I have a setup theoretically working by basically checking if the crime level has changed in the START_STATE, but there's a problem. It's possible for the character to join your party, and if you steal his stuff after he has joined you he should leave your party and attack.

 

However, since he's in your party, there's no-one to see you to increase the crime level, so it won't work in that case. Any suggestions?

Link to comment
Share on other sites

You could make an invisible character to follow the party around and watch them while the other character is a party member. It might be tricky to make sure that this didn't interfere in any other detectable way, though. (The invisible character would need to never get in the way of the party or visible NPCs.)

Link to comment
Share on other sites

There is a call that checks if there is an item of a certain class on a space. You would need to give each of the items their own special classes and then check to make sure those items are still where they belong every turn. It would be a bit clunky, but wouldn't get in the way of PCs and NPCs. I've never actually done this before, but it should work in theory.

Link to comment
Share on other sites

Well, this is odd. I have an NPC in the party with a custom script, and its DEAD_STATE appears to not be running when it dies... and yet, it definitely worked yesterday. I have the following code:

 

Code:
beginstate DEAD_STATE;	if(this_char_is_in_party()) {		set_flag(5,5,3);		drop_item(459);		if(is_town()) {			if(current_town() == 5) {				spawn_creature(66);				set_attitude(66,3);				spawn_creature(67);				set_attitude(67,3);				spawn_creature(69);				set_attitude(69,3);			}		}	}break;

 

The only thing I added today was the is_town conditional; however, I'm not getting a script error, so I'm doubtful that that's the problem.

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...