Getting a portal ability to work

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
User avatar
Nyanyanyan
Posts: 41
Joined: May 11th, 2018, 10:40 pm

Getting a portal ability to work

Post by Nyanyanyan »

Hi, I'm trying to make an ability that allows friendly units to teleport from a portal master to another portal master, but the [teleport] tag doesn't work since it only allows the ability carrier to use the tunnel. I tried just setting a prestart event with a dummy ability, but that doesn't work either since it seems to not update the source and target locations after the event runs once (at least that's what I'm assuming).

Any and all help would be appreciated.

Here's my code for the prestart event:

Code: Select all

#define ABILITY_PORTALMASTER
[dummy]
id=portalmaster
name=master of portals
description="This unit can teleport allied units to other portal masters."
[/dummy]
[event]
name=prestart
	[tunnel]
		pass_allied_units=yes
		[filter]
		[/filter]
		[source]
			[filter_adjacent_location]
			[filter]
			ability=portalmaster
			side=$side_number
			[/filter]
			[/filter_adjacent_location]
		[/source]
		[target]
			[filter_adjacent_location]
			[filter]
			ability=portalmaster
			side=$side_number
			[/filter]
			[/filter_adjacent_location]
		[/target]
	[/tunnel]
[/event]
#enddef
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.

User avatar
lhybrideur
Posts: 129
Joined: July 9th, 2019, 1:46 pm

Re: Getting a portal ability to work

Post by lhybrideur »

What if you do a turn event that remove the old portal and recreate a new one with the new coordinates.
It might only work with one unit with this ability though.

I don't know tunnel syntax so it might be a problem with the syntax though

User avatar
Ravana
Forum Moderator
Posts: 2440
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Getting a portal ability to work

Post by Ravana »

Code: Select all

	[teleport]
		id=portalmaster
		name=master of portals
		description="This unit can teleport allied units to other portal masters."
		[affect_adjacent]
			[filter]
			[/filter]
		[/affect_adjacent]
		[tunnel]
			pass_allied_units=yes
			[filter]
			[/filter]
			[source]
				[filter]
				[/filter]
			[/source]
			[target]
				[filter_adjacent_location]
				[filter]
				ability=portalmaster
				[/filter]
				[/filter_adjacent_location]
			[/target]
		[/tunnel]
	[/teleport]
It works to some extent at least, so you should be able to add extra filters now where needed.

Btw, it seems ridiculously overpowered - send one portal master ahead through another portal master, and then can move rest of army 20+ tiles per turn. First turn - https://i.vgy.me/HkNUKG.jpg, second turn - https://i.vgy.me/m0DFf2.jpg.

User avatar
Nyanyanyan
Posts: 41
Joined: May 11th, 2018, 10:40 pm

Re: Getting a portal ability to work

Post by Nyanyanyan »

Thanks a lot, I completely forgot about [affect_adjacent].
That solution works for MP, but I think bots would have a problem with using the teleport.
I'll playtest a bit and then try to think up an AI friendly solution.

I didn't really consider balance yet, but it seems like a neat idea for a specialized unit for a mage leader.
Preventing the units from using their own portals and putting some extra walking distance in (effectively 3 MP) should make it more or less balanced as a mage advancement or expensive base unit, I think.

Code: Select all

#define ABILITY_PORTALMASTER
[teleport]
		id=portalmaster
		name=master of portals
		description="This unit can teleport allied units to other portal masters."
		affect_self=no
		[affect_adjacent]
			[filter]
				is_enemy=no
			[/filter]
		[/affect_adjacent]
		[tunnel]
			pass_allied_units=yes
			[filter]
			[/filter]
			[source]
				[filter]
					ability=portalmaster
				[/filter]
			[/source]
			[target]
				[filter]
					ability=portalmaster
				[/filter]
			[/target]
		[/tunnel]
	[/teleport]
#enddef
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.

User avatar
Nyanyanyan
Posts: 41
Joined: May 11th, 2018, 10:40 pm

Re: Getting a portal ability to work

Post by Nyanyanyan »

If you either don't care about the unit using its own portal or just disable portal usage for portal masters (which I settled for, even just for balance's sake), it's pretty easy to make it work in a way that the AI can understand it.

I just made the event moveto and changed a few things.

Code: Select all

#define ABILITY_PORTALMASTER
	[dummy]
		id=portalmaster
		name=master of portals
		description="This unit can teleport allied units to other portal masters."
	[/dummy]
	[/abilities]
	[event]
	id=movetoportal
	first_time_only=no
	name=moveto
	[filter]
	ability=portalmaster
	[/filter]
			[tunnel]
			id=portaltunnel
			pass_allied_units=yes
			[filter]
				[not]
					ability=portalmaster
				[/not]
			[/filter]
			[source]
				[filter]
					ability=portalmaster
				[/filter]
			[/source]
			[target]
				[filter]
					ability=portalmaster
				[/filter]
			[/target]
			[/tunnel]
	[/event]
	[+abilities]
#enddef
Author of Age of Lords and the Revolution and Civil War and Expendable Leaders 2 multiplayer mods.

Post Reply