Cpt. Wrathbow's WML questions

The place to post your WML questions and answers.

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.
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Cpt. Wrathbow's WML questions

Post by Captain_Wrathbow »

In my RPG, where it's entirely possible (and likely) for a unit to levelup 10 or more times, I want to increase the unit's level every time it levels up, even though it's really just getting a custom AMLA, so that the level value reflects how many times the unit has leveled up. This is easy enough to do with an event that triggers upon advancement and manually increases the unit's level, but there's a problem with this: I don't want enemy units to be gaining tons of XP just for fighting the unit. Is there a way I can make the level value high, while keeping the fight-but-not-kill reward XP at 2?
Last edited by Captain_Wrathbow on August 12th, 2010, 10:44 pm, edited 2 times in total.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Making "level" behave differently

Post by zookeeper »

Not without decreasing the level in an attack event and restoring it in an attack end event...and even then you could occasionally get wrong results displayed in the attack dialog in case the enemy would levelup and fullheal if it got the full XP but wouldn't with the lowered XP.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Making "level" behave differently

Post by Dixie »

Or you could go and mess with the game configs, so that XP for fighting/killing is lower. But it would also affect the players, which might be a bother...
http://wiki.wesnoth.org/GameConfigWML
http://wiki.wesnoth.org/LuaWML:Misc#wesnoth.game_config
You can take a peek at Paintball Era for the Lua version of this (second link)

Other ways: manually remove some experience from enemies in a attack end event, or make the XP requirement for enemies higher.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Re: Making "level" behave differently

Post by Captain_Wrathbow »

Hmm... so there's really no neat way of doing it. Perhaps I'll just settle for not changing the level value. :hmm:
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2176
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Re: Making "level" behave differently

Post by Ken_Oh »

Yeah, for Wesband I went with sub-leveling and then changing the real unit level for every 5 sub-levels.
User avatar
Vendanna
Posts: 624
Joined: September 16th, 2006, 10:07 pm
Location: Spain

Re: Making "level" behave differently

Post by Vendanna »

Give the players a "dummy trait" that just increases on level up and amla. It won't affect anything, it will just say your character level.

Dunno if that's possible to do, but I think it would be a better solution than fiddling with the lvl. As it won't affect the enemies experience gained throught combat or killing.
"Mysteries are revealed in the light of reason."
Anonymissimus
Inactive Developer
Posts: 2460
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: Making "level" behave differently

Post by Anonymissimus »

zookeeper wrote:Not without decreasing the level in an attack event and restoring it in an attack end event...and even then you could occasionally get wrong results displayed in the attack dialog in case the enemy would levelup and fullheal if it got the full XP but wouldn't with the lowered XP.
setting attacker.experience = attacker.experience - defender.level in an attack event (filter so that only chosen sides are affected) ? not sure about negative experience causing problems

game config (lua or whatever) can only set experience for killing a unit
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Re: Making "level" behave differently

Post by Captain_Wrathbow »

Vendanna wrote:Give the players a "dummy trait" that just increases on level up and amla. It won't affect anything, it will just say your character level.

Dunno if that's possible to do, but I think it would be a better solution than fiddling with the lvl. As it won't affect the enemies experience gained throught combat or killing.
Would be possible, but then there would be two things in the info box showing the unit level... :hmm:
Anonymissimus wrote:setting attacker.experience = attacker.experience - defender.level in an attack event (filter so that only chosen sides are affected) ? not sure about negative experience causing problems
I thought about that, but decided against it for the same reason you mentioned at the end. :(
Ken_Oh wrote:Yeah, for Wesband I went with sub-leveling and then changing the real unit level for every 5 sub-levels.
But you can't view what sublevel you're on. At least not without some ugly, inconvenient right-click menu item.


:lol2: I guess there's no easy way to make it work. I'll just scrap the changing level thing, I guess. Oh well.
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Re: Making "level" behave differently

Post by Captain_Wrathbow »

Okay, new question, but I figure I might as well use the same thread.

In the scenario, it's possible for units to buy items at a shop, then use them, drop them, etc. But I've got an entire inventory system crafted and written and working, but now I'm having trouble with the drop function. It's theoretically possible that an unlimited number of items could be dropped, so how do I keep track of the coordinates of all the dropped items? (so that the player could move back to that spot and re-pick them up) It seems that I would need to store the coordinates in a different variable every time, but there's no way to predict how many variables would be needed, and I can't reuse the same variable, cause that would overwrite it.
I'm not sure how much sense I'm making, but does anyone have an idea of how to do this? It seems to have been done in Wesband, but I can't make any sense of the super-complex mazes of code in there or find where it's done, so that doesn't help me.
I don't need the code written for me, just an explanation or suggestion of some reasonable way of accomplishing this. I'm at my wits' end.
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: New question: storing coordinates of dropped items

Post by Dixie »

Now I'm reading this and I'm thinking "This would be so simple with Lua" :lol2: Now I understand how Anonymissimus and Silene must have felt helping me in my WML thread.

Seriously, though, I think it could still be possible in WML. You have to consider your variable as an array. As you might already know, location_variable is already an array of sort: one that has only one entry. As such, you could as well call it with location_variable[0]. So what we want to do is add an entry at the end of the array (so we do not overwrite anything). we could envision something like that:

Code: Select all

{VARIABLE my_array_new_entry_position $my_location_array.length}
{VARIABLE my_location_array[$my_array_new_entry_position] "my new value"}
(Notice how we didn't do the new_entry thing + 1, since arrays in wml start at position 0, but length starts at 1)

Ok, so I checked something in the wiki, and actually, it could be much simpler:

Code: Select all

[set_variables]
  name=my_location_array
  mode=append
# I'm not 100% wether mode=merge would be more suitable
  [value]
    x=1
    y=1
    item="banana peel"
    hey_lookit_im_a_key="I'm a value"
  [/value]
[/set_variables]
I am not 100% sure how it would behave if you cleared an entry in the middle of the array, though: would all the entries move back one spot or not? Would length be reduced?
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Re: New question: storing coordinates of dropped items

Post by Captain_Wrathbow »

Hmm.... I'm intrigued. 8) I've never dealt with arrays much before. I'll play with it a bit, and be back with another question shortly, I'm sure. :P
Thanks! :D

EDIT:
...One more question. (I'm still working on getting the dropped items to function properly, but I think I'm making progress. :D )
Unfortunately, I'm awful at the different filters' syntax. I really should be more experienced with them, since I use them so much, but I'm not.
Anyway, I need to store all units that are on side 1 and adjacent to the unit with id=Darth Vader. (just for the example :P )
I don't have the slightest clue how to do this, although I suspect it involves [filter_adjacent] and/or a little bit of [filter_location]...? Looking at the wiki pages about filters just confuse me more... :roll:
Any help is greatly appreciated.

EDIT2:
I figured it out on my own. :mrgreen:
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Cpt. Wrathbow's WML questions

Post by Sapient »

You do realize there is a sticky thread at the top of this forum explaining an easy way to manage sets of locations in WML?


Also, yes, clearing an explicit index of an array will remove that element from an array.

Dixie, I appreciate the fact that you're trying to be helpful, but saying misleading things about WML (like claiming filter_location doesn't work right) is not really helpful and it's actually annoying because you could very easily test these things in the test scenario rather than making these public speculations about how it might or might not behave.

I am glad that you are excited about Lua but that doesn't mean that we want WML to be seen as unusable or outdated. On the contrary, you need to understand how WML works before learning Lua since they often need to interract.

It is my goal that people will be able to use pure WML to comfortably program any Wesnoth scenario that doesn't require advanced programming techniques (when I say "advanced" I mean writing a custom AI or something equivalently complex).
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Dixie
Posts: 1757
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Cpt. Wrathbow's WML questions

Post by Dixie »

Mea culpa, I guess I got a bit carried away :oops: I'll try to be more careful in the future.

The thing about filter/store locations is that I often encountered surprises when using them, but it probably stems from my assuming they work like their unit counterparts, which I think they don't exactly. You are right I should probably have tested it throughly and said "filter location works like this" instead of "filter location works funny". Sorry.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth
User avatar
Captain_Wrathbow
Posts: 1664
Joined: June 30th, 2009, 2:03 pm
Location: Guardia

Re: Cpt. Wrathbow's WML questions

Post by Captain_Wrathbow »

New question. (I didn't really think it was worth it to make a new thread, so I'm just using this one)

RPG again. I want the friendly NPCs in a village to just sort of wander around in random directions. But I don't want them entering houses, or leaving the village. How would I do this? I've imagined it would involve storing a location, then setting it as the unit's goto location, or something like that. Is that right at all? :hmm:
User avatar
Pentarctagon
Project Manager
Posts: 4516
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Cpt. Wrathbow's WML questions

Post by Pentarctagon »

what you could do is set their mp to 0, randomly generate 2 numbers for the x,y coordinates, then use the MOVE_UNIT macro to move the units to that location (you could check the location before moving them and add 1 to the x or y coordinate if it would be a village).
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Post Reply