Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

problem getting hero X,Y and npc X,Y to match

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
iamben




Joined: 29 May 2007
Posts: 10
Location: university of virginia

PostPosted: Sun Aug 05, 2007 4:52 pm    Post subject: problem getting hero X,Y and npc X,Y to match Reply with quote

I have a guard on a horizontal walkway. He is walking from the right side to the left. The script I'm trying to write checks to see if I am on the correct hallway (y-coordinate) and then it checks to see if my X-coordinate is equal to the guard's X-coordinate (in other words, it checks to see if he is on top of me). The walkway the guard is walking on and the floor that I am walking on are separated by 3 tiles (3 tiles=one column to support the walkway).

Here is my flawed script:

Code:

script, fights with guards, begin

#FIRST GUARD

variable (guard one)
set variable (guard one, NPC reference (2,1))

if (hero y(me) == 21, and, hero x(me) == NPC x(guard one)) then, begin

suspend player
suspend NPCs

set NPC speed (guard one, 4)
set NPC direction (guard one, north)
wait (2)
set NPC direction (guard one, south)
wait (2)
set NPC direction (guard one, north)
wait (2)
set NPC direction (guard one, south)
wait (2)
show text box (11)
wait for text box
fight formation (1)
set NPC speed (guard one, 1)
destroy NPC (guard one)

resume NPCs
resume player

end


#SECOND GUARD

end


The script is called when the map loads. Thanks for any help!
Back to top
View user's profile Send private message
msw188




Joined: 02 Jul 2003
Posts: 1041

PostPosted: Sun Aug 05, 2007 5:12 pm    Post subject: Reply with quote

On a quick read, the script looks okay, the problem is that it is only called once (when the map loads) and then it never checks again. You need this running in a while loop, most likely. Something like:
[code]
script, fight with guards, begin
while (current map == map:map with guards),do
begin

#everthing you currently have

end

end
_________________
My first completed OHR game, Tales of the New World:
http://castleparadox.com/gamelist-display.php?game=161

This website link is for my funk/rock band, Euphonic Brew:
www.euphonicbrew.com
Back to top
View user's profile Send private message Visit poster's website
iamben




Joined: 29 May 2007
Posts: 10
Location: university of virginia

PostPosted: Sun Aug 05, 2007 5:56 pm    Post subject: Reply with quote

But won't that loop never end? There are other things I want to do on the level (the guard script is called by the main "prison" script, which is called by the map). Perhaps I could work it out if I put everything inside the loop and used tags to make sure that things I don't want to happen many times only happen once...

I'll give it a shot after my friend is finished drawing some graphics.

And thanks for the help. =)
Back to top
View user's profile Send private message
Ysoft_Entertainment
VB Programmer




Joined: 23 Sep 2003
Posts: 810
Location: Wherever There is a good game.

PostPosted: Mon Aug 06, 2007 5:46 am    Post subject: Reply with quote

The script will end looping when you leave the map.
_________________
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
View user's profile Send private message Send e-mail Visit poster's website
iamben




Joined: 29 May 2007
Posts: 10
Location: university of virginia

PostPosted: Mon Aug 06, 2007 8:45 am    Post subject: Reply with quote

Yes, but it will keep looping while I'm on the map.
Back to top
View user's profile Send private message
iamben




Joined: 29 May 2007
Posts: 10
Location: university of virginia

PostPosted: Mon Aug 06, 2007 9:11 am    Post subject: Reply with quote

Let me show you what I'm trying to do:

Code:

script, prison, begin        #map autorun script

while (current map == 1) do, begin

if (check tag(4) == true) then ( destroy NPC (NPC reference(2,0)) ) else, begin

suspend player
suspend NPCs
show text box (2)
wait for text box

set hero speed (me, 10)             #hero busts out of his cell
walk hero (me, south, 1)
wait for hero (me)
set hero speed (me, 4)

variable (guard)
set variable (guard, NPC reference (2,0))
set NPC direction (guard, north)       #guard throws hands up
wait (2)
set NPC direction (guard, south)       #hands down
wait (2)
set NPC direction (guard, north)
wait (2)
set NPC direction (guard, south)
wait (2)
set NPC direction (guard, north)
wait (2)
set NPC direction (guard, south)
wait (2)
set NPC direction (guard, north)
wait (2)
set NPC direction (guard, south)
wait (2)
set NPC speed (guard, 5)                                   #guard runs towards hero
walk NPC (guard, west, 7)
wait for NPC (guard)
walk NPC (guard, south, 1)
wait for NPC (guard)
set NPC direction (guard, north)   #hands up
wait (2)
set NPC direction (guard, south)  #hands down
wait (2)
set NPC direction (guard, north)
wait (2)
set NPC direction (guard, south)
wait (2)
show text box (3)
wait for text box
fight formation (0)
set NPC speed (guard, 1)
destroy NPC (guard)
set tag (4, on)                            # "killed guard"

resume NPCs
resume player

end

fights with guards

end
end


#-------------------------------------------------------------------

script, fights with guards, begin

#FIRST GUARD

variable (guard one)
set variable (guard one, NPC reference (2,1))

if (hero y(me) == 21, and, hero x(me) == NPC x(guard one)) then, begin

suspend player
suspend NPCs

set NPC speed (guard one, 4)
set NPC direction (guard one, north)
wait (2)
set NPC direction (guard one, south)
wait (2)
set NPC direction (guard one, north)
wait (2)
set NPC direction (guard one, south)
wait (2)
show text box (11)
wait for text box
fight formation (1)
set NPC speed (guard one, 1)
destroy NPC (guard one)

resume NPCs
resume player

end

if (hero y(me) == 22, and, hero x(me) == NPC x(guard one)) then, begin

suspend player
suspend NPCs

set NPC speed (guard one, 4)
set NPC direction (guard one, north)
wait (2)
set NPC direction (guard one, south)
wait (2)
set NPC direction (guard one, north)
wait (2)
set NPC direction (guard one, south)
wait (2)
show text box (11)
wait for text box
fight formation (1)
set NPC speed (guard one, 1)
destroy NPC (guard one)

resume NPCs
resume player

end



#SECOND GUARD

end


Now the problem that I encounter, even when I don't call "fights with guards" from the "prison" script, is that after I fight and defeat the first guard that busts me for breaking out of my cell, the screen goes black and I have to exit game.exe by using the task manager.

Let me know if you need me to post my .rpg file.

Thanks!
Back to top
View user's profile Send private message
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Mon Aug 06, 2007 10:17 pm    Post subject: Reply with quote

The screen goes black because you have an infinite non-waiting loop running after the battle, so the game never gets to a wait which would cause it to fade in.

Now, you want that busting out of the cell sequence to only run once when you enter the map, so there's no reason to put it inside the while loop. Instead, put it before the while loop. And
Code:
if (check tag(4) == true) then ( destroy NPC (NPC reference(2,0)) )

isn't needed because you destroy that guard after the scripted battle. Infact, running destroy NPC(NPC reference(2,0)) repeatedly will destroy all the guards on the map, because when you destroy the 1st guard (number 0), the 2nd guard (number 1) becomes the new first guard. So you probably want the walkways bit to check for guard NPC reference(2,0) instead. To make things less confusing, you could set up guard npc ref variables before deleting any guards.

You should have a wait inside the while loop, because the script runs continously forever until it reaches a wait, but you only want it to loop once every game tick.

You check for 2 Y values, but do identical things for both. Instead, check for either of the Y values in the same if statement, using or.

So your script would be something like this:
Code:
script, prison, begin        #map autorun script

suspend player
suspend NPCs
show text box (2)
wait for text box

set hero speed (me, 10)             #hero busts out of his cell
walk hero (me, south, 1)
wait for hero (me)
set hero speed (me, 4)

variable (guard)
set variable (guard, NPC reference (2,0))
set NPC direction (guard, north)       #guard throws hands up
wait (2)
set NPC direction (guard, south)       #hands down
wait (2)
set NPC direction (guard, north)
wait (2)
set NPC direction (guard, south)
wait (2)
set NPC direction (guard, north)
wait (2)
set NPC direction (guard, south)
wait (2)
set NPC direction (guard, north)
wait (2)
set NPC direction (guard, south)
wait (2)
set NPC speed (guard, 5)                                   #guard runs towards hero
walk NPC (guard, west, 7)
wait for NPC (guard)
walk NPC (guard, south, 1)
wait for NPC (guard)
set NPC direction (guard, north)   #hands up
wait (2)
set NPC direction (guard, south)  #hands down
wait (2)
set NPC direction (guard, north)
wait (2)
set NPC direction (guard, south)
wait (2)
show text box (3)
wait for text box
fight formation (0)
set NPC speed (guard, 1)
destroy NPC (guard)

resume NPCs
resume player

while (current map == 1) do, begin
  fights with guards
  wait
end

end


#-------------------------------------------------------------------

script, fights with guards, begin

#FIRST GUARD

variable (guard one)
set variable (guard one, NPC reference (2,0))  #guard 0 is the old guard 1

if ((hero y(me) == 21, or, hero y(me) == 22), and, hero x(me) == NPC x(guard one)) then, begin

  suspend player
  suspend NPCs

  set NPC speed (guard one, 4)
  set NPC direction (guard one, north)
  wait (2)
  set NPC direction (guard one, south)
  wait (2)
  set NPC direction (guard one, north)
  wait (2)
  set NPC direction (guard one, south)
  wait (2)
  show text box (11)
  wait for text box
  fight formation (1)
  set NPC speed (guard one, 1)
  destroy NPC (guard one)

  resume NPCs
  resume player

end


#SECOND GUARD

end

_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
iamben




Joined: 29 May 2007
Posts: 10
Location: university of virginia

PostPosted: Tue Aug 07, 2007 7:43 pm    Post subject: Reply with quote

Thank you again, Mad Cacti.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group