Announcement: Why not try our official idea generator for inspiration when making puzzles?


Caravel Forum : DROD Boards : Architecture : Questions about Scripting
New Topic New Poll Post Reply
Poster Message
Timo006
Level: Smitemaster
Avatar
Rank Points: 527
Registered: 07-19-2006
IP: Logged
icon Questions about Scripting (0)  
Soooo, I tried to take a look at the scripting system and I have a pretty basic question.

Is there any simple way to script an NPC in such a way that it will act if an entity appears at a position relative to that same NPC? (so, for example, if a monster moves to the tile directly south of the NPC, it stabs that monster)

I know it's possible to script a seperate gigantic script that scans every tile of the room and stores its content into a bunch of variables and use that as a reference, but that kinda beats the "simple" limit. :p



____________________________
Drod Number: 3034; 8th person to see the Second Sky
06-26-2014 at 01:02 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 4972
Registered: 02-20-2007
IP: Logged
icon Re: Questions about Scripting (+3)  
Like this:
Label loop
  Set var "_MyScriptX" = _MyX
  Set var "_MyScriptY" = _MyY + 2
  If ... 
        Wait for entity Monster 0,0,0,0
     Set var "_MyScriptX" = -9999
     Set var "_MyScriptY" = -9999
     Move 0,1,1,0
     Move 0,-1,1,0
  If End 
  Set var "_MyScriptX" = -9999
  Set var "_MyScriptY" = -9999
  Wait 0
  Go to loop

This particular script will check the tile two squares south of the character. If a monster crosses that tile, it steps south, then north. (I made it two squares to allow room for the character's sword.) To check other directions, change "MyX" to "MyX - 2" for west, "MyX + 2" for east, and change "MyY + 2" to "MyY - 2" for north. The movement commands will require a similar adjustment.

____________________________
50th Skywatcher

[Last edited by Nuntar at 06-26-2014 02:51 AM]
06-26-2014 at 01:41 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Timo006
Level: Smitemaster
Avatar
Rank Points: 527
Registered: 07-19-2006
IP: Logged
icon Re: Questions about Scripting (0)  
oooooooh, so does that mean that the _MyScriptX/Y variables have an effect how the script interprets coordinates?

Thanks a lot for answering this. :D

____________________________
Drod Number: 3034; 8th person to see the Second Sky
06-26-2014 at 02:31 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Someone Else
Level: Smitemaster
Avatar
Rank Points: 2358
Registered: 06-14-2005
IP: Logged
icon Re: Questions about Scripting (+1)  
Yes. Also, the _MyScript W and H refer to width and height, respectively (for script commands such as Wait for Entity... that could conceivably take those arguments).

The coordinates are measured from the top left corner of the map, and increase as you move down and right.
06-26-2014 at 02:38 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Architecture : Questions about Scripting
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.9
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.