ID:680526
 
(See the best response by Albro1.)
Problem description: I am trying to add swimming to my game but the only ways I can come up with would cause EXTREME lag to my host's servers which I want to avoid at all costs, bottom line I was hoping someone could tell me the proper way to go about coding this.

thx for reading,

Orange55

NOTE:A demo would be appreciated, since I could not find one myself.
Could you be a bit more specific? How did you try implementing swimming, and how did it bog down your server?
thx for quick reply LordAndrew I tried using it on the Move() to check for a water turf but in the end that would cause more lag than its worth so I took it out ASAP.

keep in mind this is used for ALL mobs and there are animal npc's in the game...

this method I discovered...resulted in an overall unstable server...
Can't you make Move for mob/player or w.e u have players mob set as.
As just explained when combined with all the animals and other NPC's I will have on the actual game map this makes it lag before we ever have a player base.

this is why I was looking for a proper method.
If you make it mob/player it will only allow it for the players of the game and not NPCs
How exactly are you wanting swimming to be implemented? Just an icon change while in water? That isn't difficult at all.

mob
Move()
. = ..()
var/turf/t = src.loc
if(istype(t, /turf/water))
src.icon_state = "swimming"
else
src.icon_state = "walk"


That small little check shouldn't cause any lag.

Now, since you apparently are getting lag from your implementation, what exactly are you trying to accomplish? What should happen to a mob when it enters water? How should it react when going from a water to a water turf, or a water to a land turf?

Details, and we may be able to help.
In response to Albro1
Albro1 wrote:
world
mob=/mob/player

> mob/player // Just add whatever u set player mob as in world right here .-.
> Move()
> . = ..()
> var/turf/t = src.loc
> if(istype(t, /turf/water))
> src.icon_state = "swimming"
> else
> src.icon_state = "walk"
>


I would actually like it to be attached to the water Albro so when players are on land no processing power is wasted.

is there a way to make a check for the water and then allow the check to rest when no mobs are near it?

(something like this that uses minimal server power is what I am looking for)

Best response
Use the Enter() proc.

Enter() is called when an atom attempts to enter a turf. It is the same proc that will cause Bump() to be called.
Entered() is called after they enter.

Either one could work for you.

turf/water
Enter(atom/a) // a is the atom that is trying to enter
. = ..()
if(ismob(a))
a.icon_state = "swimming"



ImmeasurableHate:

He wants all of the mobs to change, for a more realistic feel.
Ahh I thought he was saying he only wanted players to swim my bad I was reading it wrong then xD
Remember to vote up my response so those with similar problems to you can find a solution faster.