ID:149961
 
How would i go about making an icon(character) leave a trial behind it and as the character moves the trail will move with it untill it stops, i have NO idea i to do this, Thank you for any help ^_^
Chibbi wrote:
How would i go about making an icon(character) leave a trial behind it and as the character moves the trail will move with it untill it stops, i have NO idea i to do this, Thank you for any help ^_^


I have no idea....but.....I doubt this would help but what happened if you made a verb to drop then they had INF amount of whatever the trail is and then slept it or something.....I'm sorry. I'm no help. :(

This is what I was thinking....

verb/Drop()
set src in usr.contents
src.Move(usr.loc)
sleep(20)

That won't work and I don't know how to make verbs delay......but something like that. Sorry.
Chibbi wrote:
How would i go about making an icon(character) leave a trial behind it and as the character moves the trail will move with it untill it stops, i have NO idea i to do this, Thank you for any help ^_^

Are you speaking of how to make a trail or are you speaking of how to make things follow a character?

(Does the trail really "move" with the character or is more of the trail simply made?)
In response to ACWraith
i was thinking so when the player moves in a direction there would be a trail say 3-4 spaces behind it and when it stops the trail will move away, obviously the trail will need to be icons, but i just dont know the code of how to make them appear/disapear

i guess it would be following the character untill it has stopped, so im not sure whether it would fall under being a trail or something following a character, any code suggestions would be appreciated and i could test them...thank you
In response to Chibbi
What do you mean by trial though? Footprints? A copy of the player? Give us a clue :)
In response to Dreq
its actually for a flying icon i was like a coloured trail behind it
In response to Chibbi
To make a trail marker, you could make an icon state that is a trail marker for each turf that can be walked over. This could be a lot of grunt work if you have a lot of turf icons.

Alternatively, you could make a trail marker obj with it's own trail marker icon. I'd use this method.

To leave the trail, you could use the mob's Move() proc. (Exited() makes more sense to me, but it didn't like being called when I tried.)

If the current location does not have a trail marker and the new location is different from the current location: If you don't have any trail marker objs to spare, either delete the eldest object or simply move it to the current location. If you have trail markers left, then move (create?) a marker to (in) the current location.

How you keep track of trail markers is up to you. (Arguably, that's the trick of the whole thing, but I'm trying to just get you started since that's what you asked for.)

Personally, I like the idea of just dropping trail markers and setting a timer for them to delete themselves after. It might not be the best use of processing...but..er...uh... it might look cool.

I believe people have asked about trails before. You might want to look around the forums.
In response to ACWraith
hmm ok ive got a faint idea, what im looking for is say a player is on Square 1 (call it S1) and he moves to Square 2(S2) i want the Character to be on S2 and the trail icon to appear on S1, then when the character moves to S3, S1 and S2 will have the trail icon...this will all happen when the Character is in his moving state once he has stopped then Delete all Trail Icons which the character has left....Any Code suggestions to get me started would be an awsome help...thank you
In response to Chibbi
Chibbi wrote:
hmm ok ive got a faint idea, what im looking for is say a player is on Square 1 (call it S1) and he moves to Square 2(S2) i want the Character to be on S2 and the trail icon to appear on S1, then when the character moves to S3, S1 and S2 will have the trail icon...this will all happen when the Character is in his moving state once he has stopped then Delete all Trail Icons which the character has left....Any Code suggestions to get me started would be an awsome help...thank you

Not to be a jerk about it, but my "current location" is your "S1", my "new location" is your "S2", and I stored each trail icon in a trail marker object. I can admit that I didn't bother with the stop case, but I gave a proc (mob.Move()) to overwrite and some conditional statements to use.

There is no actual stop proc to overwrite that I know of, but you could just make sure the trail marker objs have a timer. When the time is right, remove them.

Mind you, I don't claim that my partial algorithm was perfect. However, I'm trying to save you from those who will jump down your throat for asking for code. (Some are not always friendly.) It doesn't help matters that I'm pretty sure trails have been discussed already. (Although, I admit the forums are not the easiest thing to search through.)

[Edit]
(I just did a search for trail in Code Problems and Newbie Central. I didn't find anything. If it's there, it could be under some random topic like "hEeeelp plEEsE" or "pRobLeeem w/ Cdoe". It could even be in a random forum. I wouldn't hold not being able to find trail information against anyone just because I remember "something" I read "somewhere".)
In response to ACWraith
thanks man, but i still got nothing from what u just said, i just need a little bit to get me started as i said at the beginning ive got NO idea how to do this but i really want to get it, in regards to angry replys to my post asking for code, it doesnt bother me in the slightest its just text on my computer screen takes alot more then that to get me me intimidated...so if anyone has a bit of code to get me started off id appreciate it heaps thank you again...
In response to Chibbi
Are you making a dbz game?
In response to Nadrew
DBZ = dragonball z??..well no anyway its actually going to be based on X-Men, there is a character in it who can run really fast and he leaves a yellow trail behind him i wana get that effect
In response to Chibbi
Doing that will cause extreme lag.
In response to Nadrew
then ill only use it in single player mode..can you be any help to me?
In response to Chibbi
Even in single player mode it will be very laggy, you'd be making and deleting icons way too much.
In response to Nadrew
Its for an NPC, its going to be on a small island so the most trail icons that will be drawn would be 3-4, if you can help please help im not worried about lag or any other factors. Cheers :)
In response to Nadrew
Nadrew wrote:
Even in single player mode it will be very laggy, you'd be making and deleting icons way too much.

You don't have to make and delete many times. Once you get the maximum or whatever you can just move them. I have it running right now, but I'm using Deadron's eventloop library to time the stop.
In response to Chibbi
I edited this to try to avoid annoying wrapping while keeping the page thin enough. I don't usually write in this style. I did not test it in this form and I did not optimize. Excuses, excuses... Anyway...

#include <deadron\eventloop\eventloop.dme>

obj/trailMarker
icon = // Fill this in

obj/trail
var/const/timeUntilStop_ = 10 as num
var/timeOfLastMove_ = 0 as num
var/const/MAXMARKERS = 4 as num
var/list/trailMarkers_[MAXMARKERS]
var/eldestMarker_ = MAXMARKERS as num

obj/trail/base_EventCycle(world_time)
// Remove markers if the trail was still too long
if (world_time > (timeOfLastMove_ + timeUntilStop_))
var/obj/trailMarker/marker
for(marker in trailMarkers_)
marker.loc = null
..()

obj/trail/New()
// Creating markers here (change if taking too much memory)
var/markerIndex as num
for(markerIndex = 1, markerIndex <= trailMarkers_.len, markerIndex++)
trailMarkers_[markerIndex] = new/obj/trailMarker

// Using Deadron's EventLoop to time the stop
if (!GameController)
GameController = new()

GameController.AddEventCycleReceiver(src)

..()

obj/trail/proc/LayTrail(location)
// Maybe not the best place to set this
timeOfLastMove_ = world.time

if ((location == null) || !isloc(location))
return

// Don't bother if there is already a marker in the location
var/obj/trailMarker/marker
for(marker in trailMarkers_)
if (marker.loc == location)
return

// Find the eldest marker and move it to the location

eldestMarker_++
if (eldestMarker_ > MAXMARKERS)
eldestMarker_ = 1

marker = trailMarkers_[eldestMarker_]
marker.loc = location // Avoiding triggers

mob/var/obj/trail/trail = new

mob/Move(NewLoc,Dir=0)
trail.LayTrail(loc)
// whatever move junk
In response to ACWraith
What if i wanted something to follow an NPC around everywhere, i was just watching someone play pokemon on their gameboy and pikachu follows Ash around...How would i get this trail icon to follow my NPC around exept when the NPC stops or dies then the icon will delete...so the trail will just be 1 or 2 squares at a time...Any Suggestions?

---The code from AC--
it looks very complicated, i wanted it to be on an NPC (badguy) so how would i incorperate this code for that character? maybe a drop() and del() proc would be more simple i have no idea, that just looks awful complicated, i apreciate the help. I had an error

saving.dm:57:error:= :expected a constant expression

marker = trailMarkers_[eldestMarker_]
marker.loc = location // Avoiding triggers

mob/var/obj/trail/trail = new <---Error points to this line

mob/Move(NewLoc,Dir=0)
trail.LayTrail(loc)
// whatever move junk

anymore help would be awsome thanks man
In response to Chibbi
If you want something to follow something else, study the step and walk family of procs.

(If you want to not drive those trying to help you nuts, please learn some common terms. :) Mobs, objs, turfs and whatever may have icons, but they are not icons themselves. You probably want to deal with mobs for following.)

My trail code may look complicated to you. However, you need a method of keeping track of what was "dropped" and what will be removed. You may leave a trail marker somewhere, but you need to be able to find which one it is you are getting rid of. (To be honest, I don't like some of the design and rewrote it anyway.)

To give a mob a trail, you simply declare a trail variable for the mob and then call the trail's LayTrail proc in the mob's Move proc.

mob/var/obj/trail/trail = new <---Error points to this line

That's the mob's trail declaration and a reasonable complaint. I use a beta of BYOND which allows that. You may want to remove the "= new" part and place "trail = new" in your mob's New proc.

Alternatively, I made a library variant of the code I posted if you still want it. It is more related to the blur of the fast person you mentioned. It is not for making mobs follow other mobs. I made it in 307b25, but I don't think I used anything too new. You might want to upgrade to something more recent, but it's up to you. You can at least study some of the code if you need more hints.

http://www.byond.com/hub/hub.cgi?hub=ACWraith/Trail

PS:
mob/Move(NewLoc,Dir=0)
trail.LayTrail(loc)
// whatever move junk

*ahem* At least call ..() in Move(). I gave you a snippet to work with, not a beginner's tutorial. :) If you still have the line "icon = // Fill this in", I'm going to cry.
Page: 1 2