Some weird error
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.
Some weird error
When the scenario starts, both leaders disappear. (visibly)
When I end the turn then, I lose.
The problematic code:
And another question, is it even possible to abuse the role for a unit specific flag?
(I think it is, but I better ask)
When I end the turn then, I lose.
The problematic code:
Code: Select all
[event]
name=new turn
first_time_only=no
[store_unit]
variable=mudcrawlers
[filter]
type=Mudcrawler
[/filter]
kill=no
[/store_unit]
{FOREACH mudcrawlers i}
#If the mudcrawler i is not marked as a fusion part, check for an adjacent mudcrawler
[if]
[variable]
name=mudcrawlers[$i].role
not_equals="fusion"
[/variable]
[then]
{VARIABLE_OP tmp_x format $mudcrawlers[$i].x}
{VARIABLE_OP tmp_y format $mudcrawlers[$i].y}
[store_locations]
variable=surround
x,y=$tmp_x,$tmp_y
radius=1
[/store_locations]
{FOREACH surround k}
#debu note seem to work till here
{VARIABLE_OP tmp_x2 format $mudcrawlers[$i].x}
{VARIABLE_OP tmp_y2 format $mudcrawlers[$i].y}
[if]
[have_unit]
[filter]
type=Mudcrawler
x,y=$tmp_x2,$tmp_y2
[/filter]
[/have_unit]
[then]
#mark adjacent as fusion part
[store_unit]
variable=adjacent
[filter]
x,y=$tmp_x2,$tmp_y2
[/filter]
kill=no
[/store_unit]
[if]
[and]
[variable]
name=adjacent.role
not_equals=fusion
[/variable]
[variable]
name=adjacent.role
not_equals=found
[/variable]
[/and]
[then] #found an adjacent non-fusion
[set_variable]
name=adjacent[$k].role
value=fusion
[/set_variable]
[set_variable]
name=mudcrawlers[$i].role
value=found
[/set_variable]
[/then]
[/if]
[/then]
[/if]
{NEXT k}
[/then]
[/if]
{NEXT i}
#kill those who fusionate with others (role=fusion)
[kill]
fire_event=no
[filter]
role=fusion
[/filter]
[/kill]
#make found-s to Giant Mudcrawler
{MODIFY_UNIT (role=found) type (Giant Mudcrawler)}
[/event]
(I think it is, but I better ask)
Last edited by toms on June 27th, 2007, 2:54 pm, edited 1 time in total.
First read, then think. Read again, think again. And then post!
Re: Some weird error
Maybe you could show where the problem is more exactly, instead of the whole scenario?
EDIT: Nevermind, this one caught my eye and is probably the cause of it:
EDIT: Nevermind, this one caught my eye and is probably the cause of it:
Code: Select all
[kill]
fire_event=no
[filter]
role=fusion
[/filter]
[/kill]
Sure.toms wrote:And another question, is it even possible to abuse the role for a unit specific flag?
(I think it is, but I better ask)
That can't be...Noyga wrote:I see some #ifdef without a #endif
these are the only #ifdef-s in the scenario (checked via search)
Code: Select all
#ifdef EASY
{VARIABLE spawn 5}#endif
#ifdef NORMAL
{VARIABLE spawn 7}#endif
#ifdef HARD
{VARIABLE spawn 9}#endif
First read, then think. Read again, think again. And then post!
Re: Some weird error
You're checking the original coordinates twice (always storing the original mudcrawler), then marking some none-existing array element for "fusion".
Look at this part:
I think you want to set temp_x2 / temp_y2 like thus:
I also think you just want to adjust adjacent.role instead of adjacent[$k].role.
What do you think
Look at this part:
Code: Select all
...
{FOREACH mudcrawlers i}
#If the mudcrawler i is not marked as a fusion part, check for an adjacent mudcrawler
[if]
[variable]
name=mudcrawlers[$i].role
not_equals="fusion"
[/variable]
[then]
{VARIABLE_OP tmp_x format $mudcrawlers[$i].x}
{VARIABLE_OP tmp_y format $mudcrawlers[$i].y}
[store_locations]
variable=surround
x,y=$tmp_x,$tmp_y
radius=1
[/store_locations]
{FOREACH surround k}
### DUPLICATE COORDINATES FOLLOW!! ###
{VARIABLE_OP tmp_x2 format $mudcrawlers[$i].x}
{VARIABLE_OP tmp_y2 format $mudcrawlers[$i].y}
### DUPLICATE COORDINATES ABOVE!! ###
[if]
[have_unit]
[filter]
type=Mudcrawler
x,y=$tmp_x2,$tmp_y2
### FILTERING ON _ORIGINAL_ UNIT'S COORDINATES ###
[/filter]
[/have_unit]
[then]
### STORING ORIGINAL UNIT AGAIN ###
[store_unit]
variable=adjacent
[filter]
x,y=$tmp_x2,$tmp_y2
[/filter]
kill=no
[/store_unit]
[if]
[and]
[variable]
name=adjacent.role
not_equals=fusion
[/variable]
[variable]
name=adjacent.role
not_equals=found
[/variable]
[/and]
[then]
[set_variable]
### WHAT'S THE MEANING OF ADJACENT[$K] ??? ###
name=adjacent[$k].role
value=fusion
[/set_variable]
[set_variable]
name=mudcrawlers[$i].role
value=found
[/set_variable]
[/then]
[/if]
...
Code: Select all
{VARIABLE_OP tmp_x2 format $surround[$k].x}
{VARIABLE_OP tmp_y2 format $surround[$k].y}
What do you think
Try some Multiplayer Scenarios / Campaigns
I found that already, and the same is true for [have_unit]...TL wrote:[kill] is a standard unit filter, the [filter] tag inside it is meaningless. Keys to filter on have to be directly inside [kill]. Since there are no keys to restrict the kill tag, it kills everything.
First read, then think. Read again, think again. And then post!
I need help again. This just does nothing...
It seems like the [if] with the [have_unit] does not work right, but I'm not sure...
Code: Select all
[event]
name=new turn
first_time_only=no
### Fusion Mudcrawlers standing next to each other ###
[store_unit]
variable=mudcrawlers
[filter]
type=Mudcrawler
[/filter]
kill=no
[/store_unit]
{FOREACH mudcrawlers i}
#If the mudcrawler i is not marked as a fusion part, check for an adjacent mudcrawler
[if]
[and]
[variable]
name=mudcrawlers[$i].role
not_equals="fusion"
[/variable]
[/and]
[and]
[variable]
name=mudcrawlers[$i].role
not_equals="found"
[/variable]
[/and]
[then]
{VARIABLE_OP tmp_x format $mudcrawlers[$i].x}
{VARIABLE_OP tmp_y format $mudcrawlers[$i].y}
[store_locations]
variable=surround
x,y=$tmp_x,$tmp_y
radius=1
[/store_locations]
#check surrounding hexes for other crawlers
{FOREACH surround k}
{VARIABLE_OP tmp_x2 format $surround[$k].x}
{VARIABLE_OP tmp_y2 format $surround[$k].y}
[if]
[have_unit]
type=Mudcrawler
x,y=$tmp_x2,$tmp_y2
[/have_unit]
[then]
{DEBUG_MSG (_"Found")}
#mark adjacent as fusion part
[store_unit]
variable=adjacent
[filter]
type=Mudcrawler
x,y=$tmp_x2,$tmp_y2
[/filter]
kill=no
[/store_unit]
[if]
[and]
[variable]
name=adjacent.role
not_equals=fusion
[/variable]
[and]
[/and]
[variable]
name=adjacent.role
not_equals=found
[/variable]
[/and]
[then]
[set_variable]
name=adjacent.role
value=fusion
[/set_variable]
[unstore_unit]
variable=adjacent
[/unstore_unit]
[set_variable]
name=mudcrawlers[$i].role
value=found
[/set_variable]
[/then]
[/if]
[/then]
[/if]
{NEXT k}
{CLEAR_VARIABLE surround}
[/then]
[/if]
{NEXT i}
[unstore_unit]
variable=mudcrawlers
[/unstore_unit]
{CLEAR_VARIABLE mudcrawlers}
#kill those who fusionate with others (role=fusion)
[kill]
role=fusion
fire_event=no
[/kill]
#convert found-s to Giant Mudcrawler
{MODIFY_UNIT (role=found) type (Giant Mudcrawler)}
## code to spawn new mudcrawlers is left out because it works ##
[/event]
First read, then think. Read again, think again. And then post!
I'm sorry for being that dumb, but I do not get what you mean...zookeeper wrote:[have_unit] itself contains the SUF, not a [filter] which contains the SUF like you've done it here.toms wrote:It seems like the [if] with the [have_unit] does not work right, but I'm not sure...
(I know that SUF=Standard Unit Filter)
First read, then think. Read again, think again. And then post!