How does one make a reduceable *object* which sticks ...

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
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

How does one make a reduce-able(able to *lose*) *object* which sticks to a unit, and was there since the unit was created?

You see, I am making a unit with 3 wishes, and I want it so that the unit has only 3 wishes, that most of the wishes apply to the leader only (like recruits, buffs, weapons etc.), and when the unit has used up the 3 wishes, it dies, unless one of those wishes were used to make the *wisher* a different unit, say Mystic Jinn.

So, what I want is on appearance of unit, that unit has 3 *objects* which, if by chance a second of that unit was made, that one would have 3 *objects* which wouldn't combine to make 6, and which are *stuck* to the unit even when it switches sides, but can be *lost* on *buying* something from the *wishing store*
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
User avatar
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

Re: How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

Oh, and I am on Wesnoth v. 1.4 Ubuntu
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Re: How does one make a reduceable *object* which sticks ...

Post by Ken_Oh »

Col Lightbeam wrote:Oh, and I am on Wesnoth v. 1.4 Ubuntu
Haha, what?
monochromatic
Posts: 1549
Joined: June 18th, 2009, 1:45 am

Re: How does one make a reduceable *object* which sticks ...

Post by monochromatic »

Ken_Oh wrote:
Col Lightbeam wrote:Oh, and I am on Wesnoth v. 1.4 Ubuntu
Haha, what?
Get 1.8. It's MUCH better than 1.4.

And don't double post please. It's a bad habit; just edit your post next time.
User avatar
Hulavuta
Posts: 1668
Joined: October 11th, 2008, 8:17 pm
Location: United States

Re: How does one make a reduceable *object* which sticks ...

Post by Hulavuta »

Ken_Oh wrote:
Col Lightbeam wrote:Oh, and I am on Wesnoth v. 1.4 Ubuntu
Haha, what?
Image

Is that pushing it a bit?
F:tGJ, Saurian Campaign
The Southern Chains, a fanfic
“The difference between winners and champions is that champions are more consistent."
~Sierra
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: How does one make a reduceable *object* which sticks ...

Post by Sapient »

To answer your question, you should store a unit variable and set an overlay in the unit's "recruit" event.

Code: Select all

[event]
  first_time_only=no
  name=recruit
  [filter]
    type=Mystic Jinn
  [/filter]
  [unit_overlay]
    x,y=$x1,$y1
    image="three_wishes_left.png"
  [/unit_overlay]
  {VARIABLE unit.variables.wishes 3}
  [unstore_unit]
    variable=unit
  [/unstore_unit]
[/event]
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
Hulavuta
Posts: 1668
Joined: October 11th, 2008, 8:17 pm
Location: United States

Re: How does one make a reduceable *object* which sticks ...

Post by Hulavuta »

....I guess we were so carried away that he was still using 1.4 that we forgot that he had a question...
F:tGJ, Saurian Campaign
The Southern Chains, a fanfic
“The difference between winners and champions is that champions are more consistent."
~Sierra
User avatar
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

Re: How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

There are a few problems of using Wesnoth 1.8, which are apparent even when I DON'T have it yet...

One: Wesnoth drops some add-ons every time it updates. Some of those add-ons were good but still discontinued, like for instance, Defence of the Castle, which incidentally is Wesnoth 1.2 :( .

Two: Every time I have used a "new and improved" Wesnoth version, it has more graphics, more animations, and hogs up more resources, like RAM and storage, if you get my drift.

Three: For 1.4 and 1.6 I know where to go to find the programming code for most anything and much of the programming syntax of said versions. So why would I change versions just so that I have to find out where the coding is and how to *write* it?

Four: I am not even sure that the edition of Ubuntu Linux on this computer will even allow me to update to even version 1.6 and I don't want to jeopardize a shared computer.

Do I need to continue?

Oh and thank you for the advice on how to make those wishes. I will try it soon as my *wishing store* isn't complete yet...
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
User avatar
Pentarctagon
Project Manager
Posts: 5732
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: How does one make a reduceable *object* which sticks ...

Post by Pentarctagon »

Two: Every time I have used a "new and improved" Wesnoth version, it has more graphics, more animations, and hogs up more resources, like RAM and storage, if you get my drift.
you could just delete the stuff you don't want/need. ex: you could save ~142MB by deleting the music.
Three: For 1.4 and 1.6 I know where to go to find the programming code for most anything and much of the programming syntax of said versions. So why would I change versions just so that I have to find out where the coding is and how to *write* it?
1.8.2 has many bugfixes/added tags (and lua) since 1.4.4, so you can do more and it actually works like it is supposed to. there's the wiki, which has pretty decent documentation overall. and you could download another add-on/look at the core files to see they it works.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

Re: How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

Nice...

Maybe you and I should go on a debate on opposite teams.

Now that aside, I am trying to make a HEALS ability which acts like a Survival Extreme shop heal, minus the removing of slows, and maybe, for bonus points, be able to remove stone.

I DID try fusing HEALS and SX shop and that hasn't worked yet...
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: How does one make a reduceable *object* which sticks ...

Post by Anonymissimus »

Col Lightbeam wrote:One: Wesnoth drops some add-ons every time it updates. Some of those add-ons were good but still discontinued, like for instance, Defence of the Castle, which incidentally is Wesnoth 1.2 :( .
Some experienced Linux user can kindly explain to you how to install several versions of the same program on Linux (I'd like to know that too, been installing with the package manager only until now...)
Two: Every time I have used a "new and improved" Wesnoth version, it has more graphics, more animations, and hogs up more resources, like RAM and storage, if you get my drift.
As for CPU and RAM, I hardly noticed any difference between 1.4 and 1.8. Actually, it got faster at some points - the reloading when pressing F5 (I think). As for disk space usage, yes, that's a problem. But look at those space-consuming, *FANTASTIC* portraits made by Kitty, wouldn't it be a shame to not use them ?
Three: For 1.4 and 1.6 I know where to go to find the programming code for most anything and much of the programming syntax of said versions. So why would I change versions just so that I have to find out where the coding is and how to *write* it?
There are few wml differences (things that got changed or removed) between 1.4 and 1.8 - I started coding with 1.4, and updated some stuff from 1.2; the big difference was the new terrain system between 1.2 and 1.4. Also, you get documentation only for the newest release - you should have severe problems when reading 1.8 wiki documantation and wondering why things don't work as they should...
As for the "places" where the code is - that didn't change since 1.2.
Four: I am not even sure that the edition of Ubuntu Linux on this computer will even allow me to update to even version 1.6 and I don't want to jeopardize a shared computer.
see above (probably...)

I can confirm that wesnoth actually got a lot better between 1.4 and 1.8 (partly due to me reporting bugs 8) ). Some things made it a lot easier for campaign authors, e.g. you don't get :inspect dialog in 1.4, get meaningless preprocessor errors, need to wait longer until your add-on reloads...
These things can also help you indirectly with you current problem...
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
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

Re: How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

There are few wml differences (things that got changed or removed) between 1.4 and 1.8 - I started coding with 1.4, and updated some stuff from 1.2; the big difference was the new terrain system between 1.2 and 1.4. Also, you get documentation only for the newest release - you should have severe problems when reading 1.8 wiki documantation and wondering why things don't work as they should...
As for the "places" where the code is - that didn't change since 1.2.
Then what happened to cause me to have much difficulty finding wesnoth/data/ etc. for a labtop of my brother's which was probably Vista?
I am still not sure the files I found were for wesnoth 1.8...

Would someone please explain how to make a randomizer which is supposed to have a 75% chance of doing nothing and a 5% chance each of doing one of five things: +1 HP, +1 XP, +1 GP, +2 moves(not max) or +1 wood (I am currently basing an era off of GEB)

This is what I have thought of...

Code: Select all

###Prayer01###
[event]
	name=turn 1
	first_time_only=yes
	[set_menu_item]
		id=pray01
		description="pray"
		[show_if]
			[have_unit]
				side=$side_number
				x,y=$x1,$y1
				[filter]
					race="celestial"
				[/filter]
			[/have_unit]
		[/show_if]
		[command]
			[store_gold]
				side=$side_number
				variable=goldamount
			[/store_gold]
			[store_unit]
				[filter]
					x=$x1
					y=$y1
				[/filter]
				kill=yes
				mode=replace
				variable=worker
			[/store_unit]
				[if]
					[variable]
						name=worker.moves
						greater_than=0
					[/variable]
					[then]
						[set_variable]
							name=worker.moves
							add=-1
						[/set_variable]
						[set_variable]
							name=praychance01
							rand=0,0,0,1..5
						[/set_variable]
						[if]
							[variable]
								name=praychance01
								is_equal_to=0
							[/variable]
							[then]
								[unstore_unit]
									variable=worker
								[/unstore_unit]
							[/then]
							[else]
								[if]
									[variable]
										name=praychance01
										is_equal_to=1
									[/variable]
									[then]
										[unstore_unit]
											variable=worker
										[/unstore_unit]
										[gold]
											side=$side_number
											amount=$praychance01
										[/gold]
									[/then]
									[else]
										[if]
											[variable]
												name=praychance01
												is_equal_to=2
											[/variable]
											[then]
												[unstore_unit]
													variable=worker
												[/unstore_unit]
												[set_variable]
													name=wood_$side_number
													add=1
												[/set_variable]
											[/then]
											[else]
												[if]
													[variable]
														name=praychance01
														is_equal_to=3
													[/variable]
													[then]
														[unstore_unit]
															variable=worker
														[/unstore_unit]
														[set_variable]
															name=worker.hitpoints
															add=1
														[/set_variable]
													[/then]
													[else]
														[if]
															[variable]
																name=praychance01
																is_equal_to=4
															[/variable]
															[then]
																[unstore_unit]
																	variable=worker
																[/unstore_unit]
																[set_variable]
																	name=worker.experience
																	add=1
																[/set_variable]
															[/then]
															[else]
																[then]
																	[unstore_unit]
																		variable=worker
																	[/unstore_unit]
																	[set_variable]
																		name=worker.moves
																		add=2
																	[/set_variable]
																[/then]
															[/else]
														[/if]
													[/else]
												[/if]
											[/else]
										[/if]
									[/else]
								[/if]
							[/else]
						[/if]
					[/then]
					[else]
						[unstore_unit]
							variable=worker
						[/unstore_unit]
					[/else]
				[/if]
			[/command]
		[/option]
	[/set_menu_item]
[/event]
EDIT: Use the

Code: Select all

 tags! -zookeeper[/color]
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: How does one make a reduceable *object* which sticks ...

Post by Sapient »

Would someone please explain how to make a randomizer which is supposed to have a 75% chance of doing nothing and a 5% chance each of doing one of five things: +1 HP, +1 XP, +1 GP, +2 moves(not max) or +1 wood
Easy enough... you could just set all the 5 possible actions into an array of commands then choose which command to insert by selecting a random array index between 0 and 19.

Code: Select all

[set_variables]
  name=possible_commands
  [literal]
   # code for +1 HP
  [/literal]
  [literal]
   # code for +1 XP
  [/literal]
  [literal]
   # code for +1 GP
  [/literal]
  [literal]
   # code for +2 moves
  [/literal]
  [literal]
   # code for +1 wood
  [/literal]
[/set_variables]
{RANDOM 0..19}
[insert_tag]
  name=command
  variable=possible_commands[$random]
[/insert_tag]
Note: a [command] tag when encountered by itself in an event will simply cause the contents within the block to be executed
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: How does one make a reduceable *object* which sticks ...

Post by Anonymissimus »

Col Lightbeam wrote:Then what happened to cause me to have much difficulty finding wesnoth/data/ etc. for a labtop of my brother's which was probably Vista?
I am still not sure the files I found were for wesnoth 1.8...
Probably the "virtual folders" stuff. I don't know a windows newer than XP, but I never had problems finding the files on xp or any Linux distribution. And it certainly doesn't have anything do to with the wesnoth version.
(Although sometimes the userdata files are stored in the system's userdata dir on win if you tell it so during installation, but you're referring to the core files anyway.)
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
Col Lightbeam
Posts: 46
Joined: November 18th, 2008, 1:01 am

Re: How does one make a reduceable *object* which sticks ...

Post by Col Lightbeam »

Um, I have never been in a WML class. Yes, I know what arrays are supposed to do, but haven't worked with them in WML. Would you please tell how to make

Code: Select all

[set_variables]
  name=possible_commands
  [literal]
   # code for +1 HP
  [/literal]
  [literal]
   # code for +1 XP
  [/literal]
  [literal]
   # code for +1 GP
  [/literal]
  [literal]
   # code for +2 moves
  [/literal]
  [literal]
   # code for +1 wood
  [/literal]
[/set_variables]
{RANDOM 0..19}
[insert_tag]
  name=command
  variable=possible_commands[$random]
[/insert_tag]
allow using ranges of commands? I am almost certain I am NOT going to find out how to do this in original Wesnoth or any of the add-ons I currently have...
Mix Era Of Magic, Era of Myths, and Extended Era and you get all my favorite teams on one group! and ULTIMATE POWER!!!!!!!!!!!!

Also in the programming industry... later.
Post Reply