Help coding 'ricochet' weapon special.
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.
Help coding 'ricochet' weapon special.
I'm trying to code a special attack for personal use, but I've run into an unknown problem in my code while trying to test it.
The error details reads "Missing closing tag for tag unstore_unit" but as far I can tell that isn't the problem at all.
The attack has a weapon special called ricochet that is supposed to cause the attack to have a chance to damage more units if it hits initially. The problem is most likely in this area of code:
The error details reads "Missing closing tag for tag unstore_unit" but as far I can tell that isn't the problem at all.
The attack has a weapon special called ricochet that is supposed to cause the attack to have a chance to damage more units if it hits initially. The problem is most likely in this area of code:
Spoiler:
Expanding Wesnoth
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
Re: Help coding 'ricochet' weapon special.
At a glance, I can't notice any errors with [unstore_unit] tags. Would you mind posting the stderr.txt?
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
Re: Help coding 'ricochet' weapon special.
a macro isn't a function call. the way (looks unnecessarily complicated anyway) you use CAP_SHIELD_RICOCHET_A and CAP_SHIELD_RICOCHET_B results in an infinite recursion...
Re: Help coding 'ricochet' weapon special.
@Max: Do you think the loop is causing the error? I'm not sure how else to make it work.
@A Guy: How do I find the stderr.txt? I'm using a Mac btw.
@A Guy: How do I find the stderr.txt? I'm using a Mac btw.
Expanding Wesnoth
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
Re: Help coding 'ricochet' weapon special.
stderr.txt should be in the main folder for Wesnoth.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
Re: Help coding 'ricochet' weapon special.
someone wrote:How do I find the stderr.txt? I'm using a Mac btw.
boru wrote:To see stderr messages on a Mac:
- Open Wesnoth by control clicking and choose "show package contents"
- Open the "Macintosh" folder. Inside are two terminal scripts, drag the one named Wesnoth to your dock and click it to launch the game every time
- Terminal will open and then launch Wesnoth
- stderr messages will be in Terminal.
Alarantalara wrote:Another way to view the stderr messages on a Mac is to use the Console application in /Applications/Utilities
All stderr messages that aren't displayed in Terminal using boru's method are logged in the Console Messages log (you may need to show the log list to find it). This will let you see messages even if you forget to start it boru's way.
Re: Help coding 'ricochet' weapon special.
yes.someone wrote:@Max: Do you think the loop is causing the error? I'm not sure how else to make it work
here's whats happening:
the preprocessor reads your event, comes to the place where you use CAP_SHIELD_RICOCHET_A. it get's replaced with the contents of that macro. inside that macro you use CAP_SHIELD_RICOCHET_B. this again is replaced with the contents, now there's CAP_SHIELD_RICOCHET_A inside CAP_SHIELD_RICOCHET_B and so on.
usually you run out of memory or there's a stack overflow. not sure why it's not crashing. maybe there's a hardcoded limit somewhere.
looking at your code (correct me if i'm wrong) i guess that's what your trying to do:
if a unit is hit there's a 50% chance that an adjacent unit of the same side might get hit.
- use a while loop (as long as there are units to process and your special didn't miss)
(to know we've processed a unit we can set a unit variable. see http://wiki.wesnoth.org/SingleUnitWML)
- store adjacent unit (range=1, x,y of last unit, side!=attacker, [filter_wml] for our unit variable, see above).
(remember that [store_unit] can store more than one unit, we'll use the first one only)
- set a unit variable so we know we've processed that unit
Re: Help coding 'ricochet' weapon special.
Can an [while] tag include an else tag?
Expanding Wesnoth
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
Re: Help coding 'ricochet' weapon special.
ConditionalActionsWML#while
No.
Assuming the wiki is right, you'll have to use an independent [if] construct.
Crend
No.
Assuming the wiki is right, you'll have to use an independent [if] construct.
Crend
UMC Story Images — Story images for your campaign!
Re: Help coding 'ricochet' weapon special.
So, I tried reworking it using the [while] tag, and here's what I came up with:
But, when the attack tries to hit a third target, the game stops responding.
Spoiler:
Expanding Wesnoth
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
You are an Arch Mage - You're definitely intelligent, but some people would say you spend too much time inside. The power you have learned, however, is simply unmatched.
Re: Help coding 'ricochet' weapon special.
that's because you've create an infinite loop somehow (that's an improvement compared to infinite recursion^^)
use debug messages to see why this is happening.
use debug messages to see why this is happening.