![]() |
NPC Movement / Actions
To make it easier for level makers to add some NPC life into their levels I created this.
It allows the user to make an npc follow a simple movement path, and use some animation while staying the on clientside to avoid using the server's resources also looks a lot smoother. Class: movement PHP Code:
PHP Code:
Edit: If you do need the actions sync'd on the serverside just remove the //#CLIENTSIDE from the scripts, however there is nothing that puts the script at "rest." Feel free to PM me if you need help setting it up. Enjoy. |
Why not just use move() serverside for syncing to other players?
Looks good, though you should use GS2 for showing the character, not GS1. |
Quote:
I don't see GS1 support getting completely dropped anytime soon so I just kept as is from the level editor's template. |
That's actually pretty cool, servers could greatly benefit from interactive NPCs that don't just sit around all day and actually move about and do things like normal people. Reminds me of the Graal2001 police-NPCs that walked around town and screamed at you for getting in their way, though this system would allow for greater customization. Nice work. :)
|
Quote:
Quote:
|
Well from my experience with this script multiple moves on the serverside can appear choppy/rushed, laggy players would see this more than the others.
But I guess we should be promoting GS2 so I changed that part in the script. |
Some updates I made to it when I used it on iClassic:
this.can_stop - boolean - set to true if you want to 'stop' the npc mid-movement. npc_stop(); - stops the npc. npc_continue(); - starts the npc back up again. "emote:image:time" - new action to make the npc do an emote for a specified time (3 if not specified) "levelvar:var:value" - sets a level variable to value PHP Code:
PHP Code:
|
great work!
Does it still support serverside if clientside tag is removed? Or is it not recommended? *must spread reputation before giving fowplay rep etc |
When you reconnect, or just connect to the server, it completely stops functioning. I added this to the top, and it messed up the direction of the NPC:
PHP Code:
|
I've been wondering lately if it would be possible to make a class NPC that could be written to move toward special marker classes that could be placed in some levels to give them a multi-step function that would be more dynamic than having to figure out the exact number of tiles they need to move in each direction.
However, my concern is that it might be slightly inaccurate, or less feasible to do it that way. What do you think? |
My example uses deltas but you can use specific coordinates, via moveto:x:y.
If you need that functionality just create a new action to interact with your way-point system. |
Added support for more verbose move commands.
e.g. movewest, moveup, movedownright, movenorth, etc. move[up|down|left|right|north|east|west|south|][up|down|left|right|north|east|west|south|] You can also specify an amount of tiles to move, otherwise it just moves by 1 tile. {"moveeast", 3} PHP Code:
|
Quote:
|
;)Yeah this script is great. I made a slight addition to the script on N-Pulse so I could join to a class with this script in it. And in my script that the class joins from I can add new commands, and use them without having to edit the class.
PHP Code:
|
Quote:
might want to add a whitelist to data[1] |
All times are GMT +2. The time now is 12:02 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.