View previous topic :: View next topic |
Author |
Message |
Retrogamer Trailblazer

Joined: 17 Mar 2003 Posts: 30 Location: Canada
|
Posted: Tue May 25, 2004 3:51 pm Post subject: Wha? |
|
|
I've experimented with my example and it worked fine.
I used a keypress script with two commands... a button that orders the NPC to walk a certain distance (Ex: NPC (0) walks right 8 tiles) and one that'll freeze him in place. He stops dead in his tracks every time.
I don't have any idea why it's not working for you... more specifics, please? =p
~Retro |
|
Back to top |
|
 |
MultiColoredWizard Come back, baby! The Breastmaster

Joined: 01 Feb 2003 Posts: 1232
|
Posted: Tue May 25, 2004 4:06 pm Post subject: |
|
|
What shadow has told me is this.
Apparantly, npc 2 walks to a designated spot(which is say, 8 tiles right).
So, walknpc(2,2, .
but if you press X the NPC will stop walking.
edit: what if..
while(npciswalking(true)[forget how that goes])
do(
if(keyispressed(key:x))
then(setnpcspeed(2,0)
)
wait
)
That should work. |
|
Back to top |
|
 |
Retrogamer Trailblazer

Joined: 17 Mar 2003 Posts: 30 Location: Canada
|
Posted: Tue May 25, 2004 4:33 pm Post subject: Hmmm... |
|
|
That should work with the given setup... but it would also depend on the status of the NPC. A still NPC that is given a walk command will move with no problem... but if the NPC has "wander", "pace" or so on activated, they'll try moving on their own after you "stop" them. Therefore, the suspend NPCs command is necessary before hand (or alter NPC).
If NPC (2) is just walking to the right, you'd be able to use the following code:
If key is pressed ("x scancode whatever") then, begin
walk NPC (2, right, 0)
end
if the direction is unknown, use this:
If key is pressed ("x scancode whatever") then, begin
walk NPC (2, NPC direction (2), 0)
end
~Retro |
|
Back to top |
|
 |
MultiColoredWizard Come back, baby! The Breastmaster

Joined: 01 Feb 2003 Posts: 1232
|
Posted: Tue May 25, 2004 4:45 pm Post subject: |
|
|
i'm pretty sure the npc only moves during a walknpc command.
oh, and i don't think you should deal with alternpc for setting the speed, because i'm pretty sure that setnpcspeed is just a softcoded version of it with a bunch of arguments used.
You know, the tutors should make their scripts like softcoded commands. It'd make teh scripts look much cleaner.
So you could say like:
keyispressed(enter)
sword(herousingsword,npcassword)
instead of using:
keyispressed(enter)
putnpc(etc
etc..
I'm gonna go bug them about that RIGHT NOW. |
|
Back to top |
|
 |
Ysoft_Entertainment VB Programmer

Joined: 23 Sep 2003 Posts: 810 Location: Wherever There is a good game.
|
Posted: Tue May 25, 2004 4:59 pm Post subject: |
|
|
yo shadowiii here is something for stoping the npc
put it in a loop
say you want the npc to walk 6 tiles wherever, and you want it to stop in the middle and do something
while(walk <=6 and stop), do( 'stop must be true and walk must be less than or equal to 6
wait(1) 'Always necesarry or else the script will freeze
walknpc(who,direction, 1)
increment(walk,1) ' increments the variable
if (walk == 3), then( ' 3 can be the any number you want it to stop
stop:=false 'this will trigger the end of the loop
)
)
do whatever with the npc
now in this sample script the npc should walk 6 tiles in the direction you want, and if it reaches 3, it will stop or you could put whatever argument you want in the if statement inside the while loop, and it should work.
also, the 6 can be any number you want the npc to go to.
hope it is what you are looking for. _________________ Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals. |
|
Back to top |
|
 |
junahu Custom Title: 45 character limit

Joined: 13 Jan 2004 Posts: 369 Location: Hull, England
|
Posted: Wed May 26, 2004 2:45 am Post subject: |
|
|
I think alter npc(npc,npcstat:speed,0) really would work
it would cancel out the walk npc command like so;
ie.
1 move npc 0 to the right 15 tiles
2 set npc walking to true
3 npc 0 has a speed of 0
4 therfor it is no longer walking
5 npc walking is therefor false
6 the engine thinks that the npc has walked one tile right because it is not walking when previously it was
7 this repeats every tick until the engine thinks it has moved all the tiles npc 0 was commanded to move
8 the engine does not seem to be able to tell the difference between an npc actually moving 15 physical tiles and being told it cannot move 15 times.
you wait for a number of ticks that matches the number of tiles it would have moved, then you set the speed back to what it was.
ps: I only read half this thread before posting. sorry about not contributing anything new to this thread. _________________
 |
|
Back to top |
|
 |
MultiColoredWizard Come back, baby! The Breastmaster

Joined: 01 Feb 2003 Posts: 1232
|
Posted: Wed May 26, 2004 5:27 am Post subject: |
|
|
why don't you bastards read my posts. >: (
junahu, you should have read the entire thread, and ysoft you should have read my post. you didn't understand the idea at all, heh.
anyways, if my way still doesn't work, then shadow, i think you've ruined the script yourself.
ysoft, teh fixored version of that script in shadow's want is:
Code: | while(walk <=8 and stop)
do(
wait(1)
walknpc(2,npcdirection(2), 1)
increment(walk,1)
if (key is pressed(key:x))
then(
stop:=false
)
) | but yeah. either way, this script should work, but ysoft's method is better.
Last edited by MultiColoredWizard on Wed May 26, 2004 2:10 pm; edited 1 time in total |
|
Back to top |
|
 |
Ysoft_Entertainment VB Programmer

Joined: 23 Sep 2003 Posts: 810 Location: Wherever There is a good game.
|
Posted: Wed May 26, 2004 7:43 am Post subject: |
|
|
mcw, why in the world do you need that second if statement
the script will stop after you press x or the walk is 8 or more
and the second if statement is useless. and junahu, alter npc would only work after the npc stops moving(I think), so mcw and mine method so far look more easy to understand. _________________ Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals. |
|
Back to top |
|
 |
MultiColoredWizard Come back, baby! The Breastmaster

Joined: 01 Feb 2003 Posts: 1232
|
Posted: Wed May 26, 2004 2:11 pm Post subject: |
|
|
What second if statement?  |
|
Back to top |
|
 |
Ysoft_Entertainment VB Programmer

Joined: 23 Sep 2003 Posts: 810 Location: Wherever There is a good game.
|
Posted: Wed May 26, 2004 7:21 pm Post subject: |
|
|
by the time I posted this message, there was the second if statement. _________________ Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals. |
|
Back to top |
|
 |
|