Spawning a unit in 2 scenarios later based on a choice
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Spawning a unit in 2 scenarios later based on a choice
Didn't really know what to put in the subject line.
So, in one of my scenarios you can choose 4 units out of a total of eight units to accompany you in the following scenarios.
Two scenarios later, I spawn in the units that you didn't pick to help defend.
But it's not working; they are not spawning, and I don't know why.
Here is an example of what I have for one of the units:
Scenario 3 (Where you pick the units) I did not include the entire event as it is large.
So that event makes it where the variable is set to 2 if you choose him. Otherwise, it is set to one. I also set the variable to one at the start of the scenario, so it's rather redundant, but it's there for the sake of testing.
Two scenarios later, I do a check and attempt to spawn in the unit.
But he doesn't spawn, despite the variable's value being 1. Nothing happens.
So to recap: I want the units that aren't picked to spawn in two scenarios later. I do this by assigning variable's value to 1 if they're not picked, and 2 if they're picked. Two scenarios later, I check if the value is 1. If it's one, I attempt to create the unit, but it doesn't work.
Thanks!
So, in one of my scenarios you can choose 4 units out of a total of eight units to accompany you in the following scenarios.
Two scenarios later, I spawn in the units that you didn't pick to help defend.
But it's not working; they are not spawning, and I don't know why.
Here is an example of what I have for one of the units:
Scenario 3 (Where you pick the units) I did not include the entire event as it is large.
Spoiler:
Two scenarios later, I do a check and attempt to spawn in the unit.
Code: Select all
[event]
name=harlarvar
[if]
[variable]
name=harlarvar
equals=1
[/variable]
[then]
{NAMED_UNIT 4 "Dwarvish Steelclad" 13 9 Harlar "Harlar the Quiet" hitpoints=38}
[/then]
[/if]
[/event]
So to recap: I want the units that aren't picked to spawn in two scenarios later. I do this by assigning variable's value to 1 if they're not picked, and 2 if they're picked. Two scenarios later, I check if the value is 1. If it's one, I attempt to create the unit, but it doesn't work.
Thanks!
Last edited by tribes55 on July 28th, 2018, 9:21 pm, edited 1 time in total.
Re: Spawning a unit in 2 scenarios later based on a choice
Oh yes, I did. I have made the adjustment to the second part, I think that's all that's necessary to make since the first part isn't conditional around the variable.
But it still doesn't work.
But it still doesn't work.
Re: Spawning a unit in 2 scenarios later based on a choice
Are you sure the event in the later scenario is triggering? It has
BTW, you don't need conditional code, you can just store an array of units in a variable with
name=harlarvar
, but I'd expect name=start
or name=turn 1
.BTW, you don't need conditional code, you can just store an array of units in a variable with
[store_unit]
and unstore them in a later scenario, which means you only need to put their stats in the first scenario.Re: Spawning a unit in 2 scenarios later based on a choice
Yeah, I figured a work-around would be to switch their sides via [modify_unit], then store them. Then I suppose I could recall and then modify their side again, but that seems pretty duct-tapey. I don't want them to be owned by player one.
Edit:
I tried including it all in the start event (excluding the event tags of the original code, and their respective names) and it still did not work.
Edit:
I tried including it all in the start event (excluding the event tags of the original code, and their respective names) and it still did not work.
Re: Spawning a unit in 2 scenarios later based on a choice
Split the problem in to smaller ones - put a
They don't need to be owned by side 1 to be stored in a variable (although you would still have to switch the side number if it was a different side in the second scenario).
[message]
in the event, and check that the event triggers. Then put some debugging in to the message, or use an [inspect]
tag, to check the values of the variables just before it fails.They don't need to be owned by side 1 to be stored in a variable (although you would still have to switch the side number if it was a different side in the second scenario).