need help with teleport from uncertain position + triggering

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
User avatar
StDrake
Posts: 996
Joined: July 21st, 2009, 6:50 am

need help with teleport from uncertain position + triggering

Post by StDrake »

maybe im searching the wrong way, but san't find a solution
- i want to move a unit of certain sides back behind a certain border if it crosses it too early. Thought id just do a moveto triggered event and teleport it, and everything okay except..the unit is still where it went, no teleporting took place it seems. Maybe you could find out what i did wrong?

Code: Select all

[teleport]
[filter]
side=2,4
x=8-13
[/filter]
x=16
[/teleport] 
i've thought maybe i should add y coordinate to it too, so did x,y=16,unit.y instead of the x=16 but nothing changed

and the second issue - i cant seem to find any way of triggering an event if a unit passes over, but doesn't stop on a certain tile. Is it possible somehow and i just can't find the way?
Yes sorry if its noobish i started my adventure with WML esterday :P
Like cats? I've made a whole faction of them to kick ass with!
Don't like cats? I've made a whole faction of them to kick their asses! So everyone's happy :)
Felinian faction is part of the Beyond Southern Hells era
kitties need sprites! art topic here
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: need help with teleport from uncertain position + triggering

Post by zookeeper »

StDrake wrote:maybe im searching the wrong way, but san't find a solution
- i want to move a unit of certain sides back behind a certain border if it crosses it too early. Thought id just do a moveto triggered event and teleport it, and everything okay except..the unit is still where it went, no teleporting took place it seems. Maybe you could find out what i did wrong?

Code: Select all

[teleport]
[filter]
side=2,4
x=8-13
[/filter]
x=16
[/teleport] 
i've thought maybe i should add y coordinate to it too, so did x,y=16,unit.y instead of the x=16 but nothing changed
unit.y is the name of a variable. $unit.y is the value of that variable. So just use x,y=16,$unit.y. And that's assuming you want to refer to the y coordinate of the primary unit of that event in which you use that. If it's really a moveto event then the primary unit is the unit that moved.

And of course you could still have other mistakes in the rest of the event code.
StDrake wrote:and the second issue - i cant seem to find any way of triggering an event if a unit passes over, but doesn't stop on a certain tile. Is it possible somehow and i just can't find the way?
No, it's not really possible.
User avatar
melinath
Posts: 1298
Joined: May 20th, 2009, 7:42 am

Re: need help with teleport from uncertain position + triggering

Post by melinath »

zookeeper wrote:
StDrake wrote:and the second issue - i cant seem to find any way of triggering an event if a unit passes over, but doesn't stop on a certain tile. Is it possible somehow and i just can't find the way?
No, it's not really possible.
It's completely impossible, in fact. There's another thread discussing this at some length somewhere...
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Re: need help with teleport from uncertain position + triggering

Post by silene »

melinath wrote:It's completely impossible, in fact.
Impossible is a bit too strong. It may not be practicable to do, but it is definitely feasible. For instance, you could start by storing the positions of all the units. Then you would register a moveto event. You would code a pathfinding algorithm; it would give you afterward what path the unit followed between the stored starting position and the current ending position. Finally you would fire a "moveby" event for all the intermediate steps. The drawback of this approach is that the unit is already at its ending position by the time the event is fired. So it wouldn't look good if the unit was supposed to die on a given hex; but other than that, it would work.
User avatar
StDrake
Posts: 996
Joined: July 21st, 2009, 6:50 am

Re: need help with teleport from uncertain position + triggering

Post by StDrake »

hmm too bad, guess ill have to do with landing on the dangerous terrain only
Anyway the $ worked perfectly, its a bit of a mystery to me why a message cant be executed after, only before the teleport, but that made no difference fortunately :)
thanks
Like cats? I've made a whole faction of them to kick ass with!
Don't like cats? I've made a whole faction of them to kick their asses! So everyone's happy :)
Felinian faction is part of the Beyond Southern Hells era
kitties need sprites! art topic here
Post Reply