God, this code is confusing

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.
Post Reply
Xionlord
Posts: 8
Joined: February 18th, 2007, 1:46 am
Location: a cold place

God, this code is confusing

Post by Xionlord »

I am trying to make free for all death match between myself and 3 comps or people.
i cannot get the code to work even with the guide and your tips.
its a four corners style map, i am making one like a friends, he has it so everyone starts with one of the races, and when you kill a type of unit you can now make that unit. he also setup some sort of summoning system, you place your sacrafice on one village, and then a random monsterish thing appears (zombie, bat, etc). he also downloaded some sweet new monster boss's and code for them (dragon, cerberus, titan, golem, and greater demon) does anyone know were i can get these? to be truthful hes a dick, he refuses to tell me where he downloaded this stuff and where he got the code. i was hoping for some help from you guys.

No email addresses in post please, if you want to know whether there has been a reply, select the "Notify me when a reply is posted" option.
--SkeletonCrew
Last edited by Xionlord on February 18th, 2007, 11:30 am, edited 1 time in total.
love this game
Xionlord
Posts: 8
Joined: February 18th, 2007, 1:46 am
Location: a cold place

Post by Xionlord »

uh thanks, but can anyone help me out?
i was hoping to get the basic, kill all enemys code for my level.
love this game
User avatar
Viliam
Translator
Posts: 1341
Joined: January 30th, 2004, 11:07 am
Location: Bratislava, Slovakia
Contact:

Post by Viliam »

I do not know WML enough to help you write code. I just would like to say that perhaps it would be useful to say clearly what exactly you want. This is how I understood it, please correct me if it is wrong.

1) When player kills enemy unit, that unit type is added to his recruitment list.

2) When player puts his unit on a specified place, it is killed and replaced by unit of some other type.

3) How to make a new cool "boss" unit?



Let's start from 3, because seems like the easiest one. To have a new unit, you need unit code and pictures (and maybe sounds). You probably should click the "Get Add-ons" buttons and download a few custom campaigns from campaign server. You can also find some rare units in mainline campaigns, such as Skeletal Dragon in EI, Fire Dragon in TROW. Each unit has its own CFG file, which is a text file describing unit properties. To create an uber-boss, just make a copy of existing CFG file under different name, change the "id" and "name" of the unit, and give it more hitpoints and damage.

The part 2 should be relatively easy (for someone with experience in writing WML code), if you just want to have a few places, each of them turning unit into a specified unit type. The question is what should happen if the modified unit steps there again. Will is be replaced again? That could be abused for healing. There could be a constraint that place does never destroy the same type of units as it produces; for example it can kill anything and replace it with Zombie, but it will not kill a Zombie.

The part 1 seems most difficult. Just a question: If my opponent recruits a level 1 unit, and it will advance to level 2 unit, and then I kill it... does it mean that I should be able to recruit the level 2 unit?
Xionlord
Posts: 8
Joined: February 18th, 2007, 1:46 am
Location: a cold place

Post by Xionlord »

I do not know WML enough to help you write code. I just would like to say that perhaps it would be useful to say clearly what exactly you want. This is how I understood it, please correct me if it is wrong.

1) When player kills enemy unit, that unit type is added to his recruitment list.

2) When player puts his unit on a specified place, it is killed and replaced by unit of some other type.

3) How to make a new cool "boss" unit?



Let's start from 3, because seems like the easiest one. To have a new unit, you need unit code and pictures (and maybe sounds). You probably should click the "Get Add-ons" buttons and download a few custom campaigns from campaign server. You can also find some rare units in mainline campaigns, such as Skeletal Dragon in EI, Fire Dragon in TROW. Each unit has its own CFG file, which is a text file describing unit properties. To create an uber-boss, just make a copy of existing CFG file under different name, change the "id" and "name" of the unit, and give it more hitpoints and damage.


KK, thanks


The part 2 should be relatively easy (for someone with experience in writing WML code), if you just want to have a few places, each of them turning unit into a specified unit type. The question is what should happen if the modified unit steps there again. Will is be replaced again? That could be abused for healing. There could be a constraint that place does never destroy the same type of units as it produces; for example it can kill anything and replace it with Zombie, but it will not kill a Zombie.


Good point, but since it is located in an odd spot and only replaces with weak stuff like the farmers or zombies it levels things out

The part 1 seems most difficult. Just a question: If my opponent recruits a level 1 unit, and it will advance to level 2 unit, and then I kill it... does it mean that I should be able to recruit the level 2 unit?

oh right, i meant their base version, the lvl 1's. this would allow you to slowly but surely get a diverse and poweful army.

see i am making a map like this style (see attachment), there will be 10 villages plus 5 unit spawn points per base. one summons spot per base.
the choke poist will have small walled spots for defense and villages.
this will be a deathmatch or team deathmatch map ( a smaller version of "fastest possible map" in starcraft)
the second version will have a middle base with an extremly tough comp boss unit, all players will be needed to beat it. (if anyone know were to get the titan unit for the undead let me know)
see i can make the map easily but i do not understand the code, they say simple, i put up my hand and say " for a normal gamer, i am a casual gamer" So any willing to help me make this code will be metioned in the map description.



BTW: this game is fun and a lot like fire emblem, i am finding it hard to win but i am having fun so its ok. i am thinking on making a campaign based on my book.
Attachments
map.JPG
map.JPG (17.9 KiB) Viewed 3925 times
love this game
Xionlord
Posts: 8
Joined: February 18th, 2007, 1:46 am
Location: a cold place

Post by Xionlord »

Come on, can anyone help?
I want to finish this soon
love this game
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Post by Ken_Oh »

If you don't know how something is done, you should try to find the closest thing in a campaign and then see how they did it. For example, adding to the recruit list mid-scenario is done in The South Guard scenario 5.

OK, I'll give it a shot:

Code: Select all

[event]
	name=die
	first_time_only=no
	
	#this is what is being killed, a Footpad or a Footpad level 2
	[filter]
		type=Footpad,Outlaw
	[/filter]
	
	#this checks for which side did the killing, $x2,$y2 are the secondary coordinates (who did the killing)
	[store_unit]
		variable=killer
		[filter]
		x,y=$x2,$y2
		[/filter]
		kill=no
	[/store_unit]
	
	#this checks the unit's side and makes a condition
	[if]
		[variable]
			name=killer.side
			equals=1
		[/variable]
		[then]
			[allow_recruit]
				side=1
				type=Footpad
			[/allow_recruit]
		[/then]

	
	#repeat the next bit for every side you want in on the deal
			[else]
				[if]
					[variable]
						name=killer.side
						equals=2
					[/variable]
					[then]
						[allow_recruit]
							side=2
							type=Footpad
						[/allow_recruit]
					[/then]
				[/if]
			[/else]
			
	#but don't forget to close the if tag
	[/if]

	{CLEAR_VARIABLE killer}

[/event]
You then have to figure out if there'll be a conflict if a monster kills one of -your- newly recruitable units and then goes to recruit them when it isn't supposed to.

The price of getting code from me is that I can't guarantee it'll work. But, you're a lot more likely to get someone to say "oh nonono, that's wrong, this is what you want" and fixing what's wrong (or giving you new code), than if you don't post anything at all.
Aisling Morrighan
Posts: 27
Joined: January 5th, 2007, 11:24 pm

Post by Aisling Morrighan »

I know almost nothing about WML, so this is for my own education as much as yours :wink:

Try this, it's more generic than Ken Oh's version (and decidedly more elegant!):-

Code: Select all

[event]
name=die
first_time_only=no
{STORE_UNIT_VAR x,y=$x2,$y2 side killer_side}
{STORE_UNIT_VAR x,y=$x1,$y1 type killed_type}
#{STORE_UNIT_VAR x,y=$x1,$y1 advanceto advancements}	
[allow_recruit]
side=$killer_side
type=$killed_type
[/allow_recruit]
#[allow_recruit]
#side=$killer_side
#type=$advancements
#[/allow_recruit]
{CLEAR_VARIABLE killer_side}
{CLEAR_VARIABLE killed_type}
[/event]
Edit: Fixed the missing } (Thanks, Ken Oh!). If you remove all the #'s, in theory you should also gain the ability to recruit any unit that the killed unit can advance into (I think?)

Second edit: After reading the thread again, I realised that the new 'advancements' function is the exact opposite of what you wanted (or, at least, of what Ken Oh did)...
I'm leaving it there anyway, just in case you do decide you want it.
Last edited by Aisling Morrighan on February 22nd, 2007, 5:13 am, edited 3 times in total.
Codail faoi shíocháin, a chroí.
Eitil go Tir na n'Og.
Cronaim tusa, Fiach Dubh.
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Post by Ken_Oh »

Yeah, I'm not a coder so what Aisling did above is most definitely more elegant (but you forgot a "}"). Though, if the unit you're talking about is going to level up, you're going to want to use my version of the "killed_type" part.
Xionlord
Posts: 8
Joined: February 18th, 2007, 1:46 am
Location: a cold place

Post by Xionlord »

well they work but not, i now need to write the code for my campaign. peice by peice it will be done.
also is it possible to make ranged attacks actually ranged, say an extra hex away, i wish to know because i am making a catapult (then a ballista, then cannon) and musketeer (rifleman, gunslinger)
these would become availiblt to the loyalists and northerners (different names of course)
love this game
commanderkeen
Posts: 183
Joined: November 16th, 2006, 6:41 am
Location: In your browser cache!
Contact:

Post by commanderkeen »

It was once possible to do multi-hex attacks, but now it isn't. It was phased out because it made things for both the player and AI too complicated.
Xionlord
Posts: 8
Joined: February 18th, 2007, 1:46 am
Location: a cold place

Post by Xionlord »

commanderkeen wrote:It was once possible to do multi-hex attacks, but now it isn't. It was phased out because it made things for both the player and AI too complicated.
see now that sucks, but i shall still work on these units.
the catapult set will have a davastating ranged but no melee, and the musketeer set will have a good ranged but can hit alot.
is there a critical hit system in this game, i was thinking of tweaking the musketeers crit hit rating to account for the fact he has a gun.
love this game
Aisling Morrighan
Posts: 27
Joined: January 5th, 2007, 11:24 pm

Post by Aisling Morrighan »

In theory you could make a unit appear to attack at a range greater than one hex, with the following (rather major) problems:

* Technically it wouldn't be a real attack, but an event (most probably a moveto event, where you select a target hex from a dialog menu), with a percentage chance of modifying the target's HP (presumably in a downward direction!). For single-player use ONLY, you could do it via select events instead.

* No counterattack would be possible, even if the target unit has the same ability.

* Because it's not an attack, it won't trigger on_attack or on_hit events.

* The AI won't use it. Ever. It just doesn't know how - not only can it not select anything from a menu, but it won't even be aware that any unit has the ability (so it will build them, use them horrendously badly, and happily sit within range of yours). There is NO way to solve this, unless you want to re-write the entire Wesnoth AI code (in C++, not WML). It just isn't designed to respond to [event]s.

* It's almost certainly very, very complex to code.

Regarding your other question, no, there currently is no critical hit mechanism, but it wouldn't be too hard to do it in WML.
Codail faoi shíocháin, a chroí.
Eitil go Tir na n'Og.
Cronaim tusa, Fiach Dubh.
Xionlord
Posts: 8
Joined: February 18th, 2007, 1:46 am
Location: a cold place

Post by Xionlord »

the sad part is that i have no understanding of WML
what i would need is a walkthrough likething that teaches you each step

ex.
for the beggining of a hit/ miss ratio
{hit/miss}60%
(yes i know this is inaccurate, its an exampl)

the guide you guys have allow me to see what the code looks like and a bit of the meaning, but it does not have enough clarity for me to understand each peice of it.

also when i make a map, do i need to make a wml for it or could i just use it in multiplayer in a deathmatch against an Ai or person. i am stumped in the code writing department, all i want is a simple kill everything match
love this game
Post Reply