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


Caravel Forum : DROD Boards : Architecture : Counting monster
New Topic New Poll Post Reply
Poster Message
robin
Level: Smitemaster
Avatar
Rank Points: 842
Registered: 09-01-2004
IP: Logged
icon Counting monster (0)  
Is it possible, with scripting, to locate a specific type of monster and how many of them?

For example a roach queen.

I'm trying to script a challenge, where you first need to kill all brains before killing any roach queen,
of course there will be roaches to kill, so I can't use something like "wait for monster stabbed.
Also the roach queens can move around...

EDIT:
I'm trying something like this: 2NPC's
1)
Click here to view the secret text


2)
Click here to view the secret text


So I'm hoping that every turn, the script counts the queens.
Of course I just saw, that every turn the var resets to 0 and so the second script will fail.

But does that counter thing work? because i have no idea how the _myscripts work.
I tried searching in the help files, but I didn't find enough to help me.


____________________________
Click here to view the secret text


[Last edited by robin at 09-25-2015 12:18 AM]
09-24-2015 at 11:13 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores Quote Reply
Jacob
Level: Smitemaster
Rank Points: 3746
Registered: 10-01-2004
IP: Logged
icon Re: Counting monster (0)  
PPs under the queens that close doors to the brains?

____________________________
New to DROD? You may want to read this.
My Holds and Levels:
Click here to view the secret text

09-25-2015 at 12:55 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
Xindaris
Level: Smitemaster
Avatar
Rank Points: 1531
Registered: 06-13-2015
IP: Logged
icon Re: Counting monster (0)  
This happens to be a problem similar to one I needed to solve at one point, but with stalwarts rather than queens, and for an end-of-room challenge. What I did was run a couple of loops that increment myscriptX and myscriptY from 0 to their max-within-a-room in order to "look at" each tile individually and add 1 to a variable (called F1N1EStalwartsLeft in my case, because that helped me identify what and where the variable was for) whenever they see a stalwart on said tile. I dunno if it'll cause lag to do this every turn, though.

My code, if you want to examine/re-adapt:
Click here to view the secret text


____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 09-25-2015 01:12 AM]
09-25-2015 at 01:09 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 1531
Registered: 06-13-2015
IP: Logged
icon Re: Counting monster (0)  
On closer inspection of your code, I see some things I can tell you about it that might be helpful:

The _X and _Y variables point to the Player's location; what the _MyscriptX/Y do is override the x/y location for commands that want a location (such as wait for item/entity/entity type at, generate entity, etc.) with values you can dynamically change via scripting. Your script 1) is looking for a roach queen at the player's location, which is always going to return false.

And yes, a "Wait while brain in room" followed by a code like the one I made would be more efficient than checking how many queens there are every turn. You'll just need something to "store" whether or not there were the right number of queens at the moment the last brain died so the challenge is only awarded when the room's clear (which is presumably what you want).

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 09-25-2015 03:54 AM]
09-25-2015 at 03:50 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
robin
Level: Smitemaster
Avatar
Rank Points: 842
Registered: 09-01-2004
IP: Logged
icon Re: Counting monster (0)  
Thanks everybody!

After reading all this, I understand the myscripts a lot better now.
This is what I've done:
Roach queen locater:
Label start
  Set var "LocaterX" = 0
  Set var "LocaterY" = 0
  Set var "Roach Queen Counter" = 0
Label Loop
  Set var "_MyScriptX" = LocaterX
  Set var "_MyScriptY" = LocaterY
  If ... 
        Wait for entity type Roach queen,0,0,0,0
     Set var "Roach Queen Counter" + 1
  If End 
  If ... 
        Wait until var "LocaterY" = 32
     Wait 0
     Go to start
  Else 
     If ... 
           Wait until var "LocaterX" = 38
        Set var "LocaterX" = 0
        Set var "LocaterY" + 1
     Else 
        Set var "LocaterX" + 1
     If End 
  If End 
  Go to Loop


And the Challenge:
  If ... 
        Wait for clean room 
     Go to NOK
  If End 
  Wait for event All brains removed
  Wait 0
  If ... 
        Wait until var "Roach Queen Counter" = 4
     Go to OK
  Else 
     Go to NOK
  If End 
  Wait 1
Label OK
  Wait for clean room 
  Challenge completed 
  End 
Label NOK



____________________________
Click here to view the secret text

09-25-2015 at 08:57 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 1531
Registered: 06-13-2015
IP: Logged
icon Re: Counting monster (0)  
You might run into some trouble with that "Wait 0" in the first script. I'm not sure which one, but either _MyscriptX or Y overrides the number of turns to wait, so it's usually necessary to reset both to -9999 (which tells the script "don't override") before telling it to wait. It might be waiting 30-something turns between queen countings as-is.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 09-25-2015 03:00 PM]
09-25-2015 at 02:58 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
robin
Level: Smitemaster
Avatar
Rank Points: 842
Registered: 09-01-2004
IP: Logged
icon Re: Counting monster (0)  
Xindaris wrote:
You might run into some trouble with that "Wait 0" in the first script. I'm not sure which one, but either _MyscriptX or Y overrides the number of turns to wait, so it's usually necessary to reset both to -9999 (which tells the script "don't override") before telling it to wait. It might be waiting 30-something turns between queen countings as-is.

I forgot about that, but it seems I'm lucky.
_MyscriptX will always be reset to 0, when it hits the "wait 0" command.
I should probably add a -9999 somewhere.

Thanks for the reminder.

____________________________
Click here to view the secret text

09-25-2015 at 04:19 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Architecture : Counting monster
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.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.