Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : Development : Scripting a challenge (For those of us who are challenged)
New Topic New Poll Post Reply
Poster Message
noma
Level: Smitemaster
Avatar
Rank Points: 1594
Registered: 11-22-2006
IP: Logged
icon Scripting a challenge (+1)  
Two parter question: how to script a challenge in the first place; and two, how to script the following: if an entity activates something (or moves to a specific location as either will set the correct things in motion) by a specific turn and the room is eventually cleared the challenge is completed. Or are those one and the same things? I've found some items in the Customize Character script menu that point me in the right direction but I can't seem to get at my destination.

This is the best I could come up with but I know it's wrong:
If ...
Wait for turn #
Wait for entity type X at (x,y) (x,y)
End If
Wait for clean room
Challenge completed "name of challenge"
But this of course shows Challenge Completed just for clearing the room. Moving the End If to the end does nothing. There needs to be an If in there somewhere right? hahaha. ... please help.
06-29-2015 at 07:09 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
noma
Level: Smitemaster
Avatar
Rank Points: 1594
Registered: 11-22-2006
IP: Logged
icon Re: Scripting a challenge (0)  
Now I've got something that seems to be working. At least it doesn't trigger "Challenge Completed" just for clearing the room.
Wait for turn #
If ...
Wait for entity type X at (x,y) (x,y)
Wait for clean room
Challenge completed "name of challenge"
End If

More testing ensues.
06-29-2015 at 07:30 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
noma
Level: Smitemaster
Avatar
Rank Points: 1594
Registered: 11-22-2006
IP: Logged
icon Re: Scripting a challenge (0)  
Now I want to set a second challenge whereby the player must clear the room without using a certain entity (by allowing it to get killed.) From looking at the scripting for 3 in 1, I see that I can set a variable where (Entity)Dead=1 but how do I define what that means?
06-29-2015 at 08:10 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 1306
Registered: 07-11-2014
IP: Logged
icon Re: Scripting a challenge (+3)  
Try this:

  Set var "Challenge_Success" = 0
  Set var "Challenge_Timer" = 0
  If ... 
        Wait for clean room 
     Go to Skip to End
  If End 
Label Loop
  If ... 
        Wait until var "Challenge_Timer" <= 20
     If ... 
           Wait for entity type Roach,7,9,7,9
        Set var "Challenge_Success" = 1
        Go to Break out of loop
     If End 
     Set var "Challenge_Timer" + 1
     Wait 0
     Go to Loop
  If End 
Label Break out of loop
  Wait for clean room 
  If ... 
        Wait until var "Challenge_Success" = 1
     Challenge completed Beethro Kicks Butt
  If End 
Label Skip to End


This will award the challenge the turn after you clear the room as long as a roach enters square (7,9) by turn 20 at the latest. Change the numbers as you see fit.

To copy the above, highlight it, copy it to your clipboard, then press Ctrl+Shift+B inside the character script editor in-game.

There is a way to get the challenge be awarded directly on the turn the room is cleared, but it has some pitfalls that cause it to not work when certain entities are in the room, so I'll post it separately.

____________________________
(07:23 PM) Pearls: Kieran is correct.
06-29-2015 at 08:14 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 1306
Registered: 07-11-2014
IP: Logged
icon Re: Scripting a challenge (+3)  
Here's the version that awards the challenge instantly on the turn the room ends. It fails in the following circumstances (and probably some other's I've forgotten about that I've not listed here):
*There is a conquer token in the room
*There are gentryii or puffs in the room
*The player is a monster player role.

  Set var "Challenge_Success" = 0
  Set var "Challenge_Timer" = 0
  If ... 
        Wait for clean room 
     Go to Skip to End
  If End 
Label Loop
  If ... 
        Wait until var "Challenge_Timer" <= 20
     If ... 
           Wait for entity type Roach,7,9,7,9
        Set var "Challenge_Success" = 1
        Go to Break out of loop
     If End 
     Set var "Challenge_Timer" + 1
     Wait 0
     Go to Loop
  If End 
Label Break out of loop
  Wait while entity Monster 0,0,37,31
  If ... 
        Wait until var "Challenge_Success" = 1
     Challenge completed Beethro Kicks Butt
  If End 
Label Skip to End


____________________________
(07:23 PM) Pearls: Kieran is correct.
06-29-2015 at 08:19 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
noma
Level: Smitemaster
Avatar
Rank Points: 1594
Registered: 11-22-2006
IP: Logged
icon Re: Scripting a challenge (0)  
Thanks for this. Much more complete than what I had cobbled. Works perfectly.
06-29-2015 at 10:42 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
averagemoe
Level: Delver
Avatar
Rank Points: 65
Registered: 03-22-2012
IP: Logged
icon Re: Scripting a challenge (0)  
Oh you people and your tendancy to overcomplicate scripts. Here's how I would do that first one

wait for turn #
if
wait for entity type X at (x,y) (x,y)
wait for clean room
challenge completed "name of challenge"
if end
wait for clean room
end

____________________________
The only right way to make DROD into a movie is to have it be animated in the style that Erik draws the characters in.
08-13-2015 at 12:53 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Dischorran
Level: Smitemaster
Avatar
Rank Points: 1908
Registered: 09-10-2005
IP: Logged
icon Re: Scripting a challenge (+2)  
And you would simplify too much by checking the character presence at x,y on turn t exactly, instead of on any turn up to t.

____________________________
Click here to view the secret text

08-13-2015 at 02:32 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
kieranmillar
Level: Smitemaster
Rank Points: 1306
Registered: 07-11-2014
IP: Logged
icon Re: Scripting a challenge (0)  
Also, should the room contain tarstuff or a seeding beacon there is a risk that you can have the script permanently end and then reset the room to beat the challenge and not be awarded it. As a general rule, putting the End command in your challenge scripts is a bad idea, you should instead check if the room is clear on entry of the room and immediately jump to the bottom of the script if it is.

____________________________
(07:23 PM) Pearls: Kieran is correct.
08-13-2015 at 06:17 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Someone Else
Level: Smitemaster
Avatar
Rank Points: 1077
Registered: 06-14-2005
IP: Logged
icon Re: Scripting a challenge (0)  
How would it not be okay to have the script End when the challenge is beaten?
08-13-2015 at 02:22 PM
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: 2965
Registered: 02-20-2007
IP: Logged
icon Re: Scripting a challenge (0)  
Then you could get the challenge, unclear the room and come back, and the script wouldn't recognise it. That isn't terrible as you'd still have it marked as cleared on the Restore screen, but (1) you wouldn't get the player-satisfaction of "Challenge completed" appearing; (2) subsequent demos would not be listed as "The player completed a challenge"; (3) you would not have a convenient record of which of your demos completed the challenge and which didn't -- that doesn't affect anything external, but players may want a private record of their fewest moves to complete the challenge; (4) deleting the first challenge demo would unclear it on the Restore screen.

All that said, I prefer to use End rather than Goto a label at the end of the script, just because I don't know whether having scripts running is using up processing power. But I would make an exception for rooms that can be uncleared (tarstuff or seeding beacons) for the above reasons.

____________________________
50th Skywatcher
08-13-2015 at 05:44 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 1306
Registered: 07-11-2014
IP: Logged
icon Re: Scripting a challenge (0)  
You could have a hold like 3 in 1 where the same character holds the code for 3 different challenges.

Regardless, I personally think it's just a good idea to get into the habit of building your challenge scripts with these safeguards, that way you're less likely to introduce unexpected bugs, and if you're just copying these bits from your previous script it's not like its going to take you much time.

____________________________
(07:23 PM) Pearls: Kieran is correct.
08-13-2015 at 05:45 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : Development : Scripting a challenge (For those of us who are challenged)
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.