ID:2316059
 
Havent been on byond in ages until lately and now Im pretty rusty when it comes to coding.... Anyways Im working on a project currently where I want to be able to basically turn a player into a enemy NPC at the start of a event... They wont be able to control themselves or stop themselves, once the effect is active, their character will just go on a rampage and attack anyone in sight until they die and respawn which will reset it... I can do most of the program myself, Im just at a loss on how to disable player input and make the computer take over their character. If anyone can atleast get me started in the proper direction I would be very thankful.

mob
player
var/tmp/controlled=0

proc
Controlled() // do whatever you want once he is controlled
while(src.controlled)
walk_rand(src)
sleep(rand(10,20))

mob
verb/keydown(k as text)
set hidden = 1
set instant = 1
if(controlled)return // WE NEED TO SET MACROS AND PREVENT THEM TO USE WHILE CONTROLLED
if(k == "North") step(usr,NORTH)
if(k == "West") step(usr,WEST)
if(k == "South") step(usr,SOUTH)
if(k == "East") step(usr,EAST)


Didn`t have time to test this but just an idea of how i would do it. Hope it helps
Damn... setting a if statement and return infront of movement.... cant believe I didnt think of that....thats what I get for overthinking things,thanks though, Ill be able to rig something up based off of this, got most of it set up, just trying to get it all smoothed out.
And for future possible use to others that look at this, I have a enemy NPC that attacks people, when a certain event triggers theres a chance for you to turn into one of those NPCs. So I set up a attack on sight script and based it off the icon, so NPCs with that icon attack other mobs on sight, and if you get turned into one, you also have that icon so the attack on sight proc triggers for you as well, now just to cut off player input so they cant control themselves and Im set.

**SIDE NOTE** Good script for making a zombie game or something similar as well!
In response to ThunderBane1
ThunderBane1 wrote:
Damn... setting a if statement and return infront of movement.... cant believe I didnt think of that....thats what I get for overthinking things,thanks though, Ill be able to rig something up based off of this, got most of it set up, just trying to get it all smoothed out.


If you use if() statement and retun infront of movement proc they wont be able to use walk_rand or other proc for walking. You need to prevent them from using macros. Sorry for my bad English but I hope you get the point.
Like I said Im a bit rusty at programming, and to be honest never was REALLY good at it. I have yet to test it yet, but it appears to me as this would work, cause it will only return if controlled=1, if not, it would carry on as normal. Again havent tested it yet, and Im not good enough to know if this will work of the top of my head....If it doesnt my next plan was to research what it would take to detect keypresses... so you have normal movement, but if your in a NPC state, it would register your trying to press a movement key but wouldnt let you actually move, and adding that to the proc that turns you into a NPC so that it doesnt effect other movement procs...

Not trying to argue anything, just an attempt to get a better understanding