Announcement: Be excellent to each other.


Caravel Forum : DROD RPG Boards : RPG Architecture : The BIG thread about scripting
1
Page 2 of 2
New Topic New Poll Post Reply
Poster Message
reyll3
Level: Delver
Avatar
Rank Points: 33
Registered: 01-01-2007
IP: Logged
icon Re: The BIG thread about scripting (0)  
How can you make a custom monster add 10 to your hp after it is defeated?

____________________________
A cat
11-05-2008 at 06:04 PM
View Profile Send Private Message to User Show all user's posts High Scores Quote Reply
mxvladi
Level: Smitemaster
Rank Points: 2505
Registered: 02-11-2008
IP: Logged
icon Re: The BIG thread about scripting (+2)  
Smth like that:

Creating custom NPC with name, say, idiotic roach. Make the following script in the roach:

Set var _MyHP=[add number here]
Set var _My ATK=[add number here]
Set var _My DEF=[add number here]
Set var _My Gold=[add number here]
Set var _My REP=[add number here]
Behaviour Face target


Then, there're two ways to do what you want to do:

1st way: simple way. Place another NPC in the room and set his script:

wait while entity at [add coordinates of your custom monster here]
Set var _HP+10


Remember: var name must be _HP, not _MyHP! Or HP won;t be added to player. :(

2nd way(harder). Add the following to your custom monster script(in addition to what you've already added):

Imperative Unkillable
Wait for defeat
Set var _HP+10
Imperative Die



Hope this will help. :)
11-05-2008 at 06:19 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
reyll3
Level: Delver
Avatar
Rank Points: 33
Registered: 01-01-2007
IP: Logged
icon Re: The BIG thread about scripting (0)  
yes,it finally worked, i just forgot to insert imperative unkillable...i thought a own monster would survive as a sorta --ghost--
anyway, i cant use your easy way, it would be the hard way,it will count for every monster in my hold.

____________________________
A cat
11-05-2008 at 06:48 PM
View Profile Send Private Message to User Show all user's posts High Scores Quote Reply
Kwakstur
Level: Smiter
Avatar
Rank Points: 385
Registered: 05-05-2006
IP: Logged
icon Re: The BIG thread about scripting (+1)  
I'm trying to make an enemy that, like those in normal DROD games:
1. Pursues the player and attacks if, at the beginning of its own turn, the player is nearby.
2. Resets upon room entry until smited.
I've already gotten one enemy to do this... this was no problem. Here's the main code:

(NPC must start as invisible)
  Imperative Restart script on entrance
  Imperative Deadly
  Appear at [NPC's coordinates]
  Behavior Face target
  Set var "_MyHP" = [Desired HP]
  [Set any other stats]
Label On Turn
  Move to Player  Forbid turning Single step
  Go to On Turn
This works exactly as desired... for one enemy.

Rather than copy and paste the character and set the Appear at coords for each instance, I want to save space and just put this code in the default script for the custom character. But I'm having trouble resetting the position. Obviously, the Appear at command I'm using right now is not going to work, because I need to specify coordinates, which are different for each instance. Any suggestions? Or will I have to just copy and paste?

____________________________
Also known as ExpHP everywhere else.
11-27-2008 at 01:34 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
Kwakstur
Level: Smiter
Avatar
Rank Points: 385
Registered: 05-05-2006
IP: Logged
icon Re: The BIG thread about scripting (0)  
Nuntar wrote:
Why must the NPC start as invisible? Omit the Appear at... line and have it start visible at the desired location.
Because, more than anything, I need the position to be reset. In contrast to normal DROD, pretty much everything about room state is retained upon leaving in DRPG, and I currently need the game to forget an enemy's position.

The only way I can think of that will allow an NPC's position to reset upon room entrance is to set a Restart Script at Entrance imperative and use an Appear at command very first thing. I'm asking here if there's an alternative... any ideas?

____________________________
Also known as ExpHP everywhere else.

[Last edited by Kwakstur at 11-27-2008 03:42 AM]
11-27-2008 at 03:38 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
Remlin
Level: Master Delver
Rank Points: 181
Registered: 04-28-2005
IP: Logged
icon Re: The BIG thread about scripting (+3)  
It's somewhat of a hack, but you can use a predefined private variable to record the x/y coordinates of the monster the very first time it ever appears. From then on, every time you detect turn 0 you reset _MyX and _MyY to those stored coordinates:

I used _MyRep to store the coordinates in this code. If you care about reputation in your hold, that obviously won't work.

  Imperative No restart on entrance
  Imperative Deadly
  Behavior Face target
  Set var "_MyHP" = [Desired HP]
  [Set any other stats]
  Appear 
  Set var "_MyREP" = _MyX
  Set var "_MyREP" * 100
  Set var "_MyREP" + _MyY
Label Move
  Move to Player 1,1
  If ... 
        Wait for turn 1
     Go to Move
  If End 
  Disappear 
  Set var "TempVar" = _MyRep
  Set var "TempVar" / 100
  Set var "_MyX" = TempVar
  Set var "TempVar" = _MyRep
  Set var "TempVar" % 100
  Set var "_MyY" = TempVar
  Appear 
  Go to Move

11-27-2008 at 10:08 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Kwakstur
Level: Smiter
Avatar
Rank Points: 385
Registered: 05-05-2006
IP: Logged
icon Re: The BIG thread about scripting (+2)  
You, my friend, are a genius. I forgot about the _My variables!

Also, I really like how you managed to use a temporary variable in default code; I guess since no two characters ever have their script run concurrently, a temporary var can be used in calculations as long as it's only for the duration of the NPC's turn.
I love a good learning experience.

Muchos gracias, seņor.

[Edit: By the way, I looked into script vars, and it looks like as long as I never use any Wait for/while entity at commands, I can use _MyScriptW and _MyScriptH as X and Y respectively rather than making a 4-digit rep. Haven' tested it, yet, but I'm pretty confident it will work.]
[Edit Edit: Scratch that! Guess what: Script vars are automatically reset to -9999 upon room entry, so they cannot be used to retain data like this.
In other words, Remlin's code is the way to go.]

____________________________
Also known as ExpHP everywhere else.

[Last edited by Kwakstur at 11-27-2008 08:08 PM]
11-27-2008 at 06:23 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
Kwakstur
Level: Smiter
Avatar
Rank Points: 385
Registered: 05-05-2006
IP: Logged

File: Tunnler Colony.PNG (356 bytes)
Downloaded 62 times.
License: Public Domain
icon Re: The BIG thread about scripting (+2)  
Figured I would share my most recent creation here:

Tunnler Colony:
One-time use accessory that creates a Tunnel under the Player, in the direction he is facing. Player must not be facing diagonal, and must be on one of the 6 normal ground types.

This code can be pasted in DROD with Ctrl+Shift+B.
Click here to view the secret text

And you can equip it with a Equipment Swap Accessory Tunnler Colony.

____________________________
Also known as ExpHP everywhere else.

[Last edited by Kwakstur at 11-28-2008 02:59 AM]
11-28-2008 at 02:38 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
techant
Level: Smitemaster
Avatar
Rank Points: 854
Registered: 06-08-2004
IP: Logged
icon Re: The BIG thread about scripting (0)  
Please Help..I am trying, without success, to have a sword appear when an arrow token is activated. I want the sword to be a wooden one and to look and act just like it. I am trying to have the sword appear in the room after the token is activated.

I read the Help and this thread. I tried a few things but I can't get the NPC to look like the sword. The Origami Shield was close but I didn't know what to change in that script for what I needed. The "create pits" gave me some ideas but it was not what I was looking for.

What I am trying to do in a nutshell. The room is empty of sword but when a toggle is activated a simple wooden sword appears in the room a distance from the player. When picked up it act just like a wooden sword. Toggling the token after that while it move arrows has no affect on the sword.

I am using this in the contest so I am looking for a solution now rather than later if anyone can help. Thanks ahead of time.

____________________________
DROD RPG Released!! You must try it out it is Great!!
Click here to view the secret text

12-21-2008 at 10:00 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
techant
Level: Smitemaster
Avatar
Rank Points: 854
Registered: 06-08-2004
IP: Logged
icon Re: The BIG thread about scripting (0)  
O!K! I will try that, thanks

Edit: That worked THANKS!! I just wish there was a way to say which token was activated rather than using a specific location. I have 2 types of tokens in the room and only want 1 type to activate the sword appearing, but your solution works so I am happy.

____________________________
DROD RPG Released!! You must try it out it is Great!!
Click here to view the secret text


[Last edited by techant at 12-23-2008 04:26 AM]
12-23-2008 at 04:01 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
RoboBob3000
Level: Smitemaster
Avatar
Rank Points: 1978
Registered: 10-23-2003
IP: Logged
icon Re: The BIG thread about scripting (0)  
Remlin wrote:
It's somewhat of a hack, but you can use a predefined private variable to record the x/y coordinates of the monster the very first time it ever appears. From then on, every time you detect turn 0 you reset _MyX and _MyY to those stored coordinates:

I used _MyRep to store the coordinates in this code. If you care about reputation in your hold, that obviously won't work.
That's a great technique, Remlin! I'm going to make sure to steal it until it's rendered obsolete! :)

Am I correct in assuming that there is no way to create a private variable for a default script and that Remlin's hack is the only way to go?

It would be quite nice if any user-created variable with the prefix _My was treated as private variable.

____________________________
http://beepsandbloops.wordpress.com/
08-12-2009 at 01:08 AM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Fang
Level: Master Delver
Avatar
Rank Points: 175
Registered: 07-25-2008
IP: Logged
icon Re: The BIG thread about scripting (+3)  
I need help with a script I'm working on. This should give you a menu when pressing CMD, with which you may choose to either use a Sleeping Bag, a Tent or a Nice Tent, and you may check how much of each you currently hold. Anyone can tell me what's wrong with it, because no matter what I press, it's always as if I took the first option, and sometimes Undo causes errors with the distinctive cling sound.

Click here to view the secret text


____________________________
"Imagination is more important than knowledge." -Albert Einstein

[Last edited by Fang at 08-20-2009 09:01 PM]
08-20-2009 at 09:00 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Monkey
Level: Master Delver
Avatar
Rank Points: 190
Registered: 03-21-2006
IP: Logged
icon Re: The BIG thread about scripting (0)  
Here's your problem.

____________________________
lurking
08-21-2009 at 04:41 AM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Fang
Level: Master Delver
Avatar
Rank Points: 175
Registered: 07-25-2008
IP: Logged
icon Re: The BIG thread about scripting (0)  
Yeah, I noticed TFMurphy went ahead and posted the bug when he helped me earlier.

____________________________
"Imagination is more important than knowledge." -Albert Einstein
08-21-2009 at 04:54 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Monkey
Level: Master Delver
Avatar
Rank Points: 190
Registered: 03-21-2006
IP: Logged
icon Re: The BIG thread about scripting (+3)  
Also, by the way, I made a non-buggy backpack. Granted, you'll still have to undo to before the question if you want to undo an item use, but that's un-workaroundable.
Click here to view the secret text
(Highlight the secret text above.)


____________________________
lurking
08-21-2009 at 05:17 AM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Monkey
Level: Master Delver
Avatar
Rank Points: 190
Registered: 03-21-2006
IP: Logged
icon Re: The BIG thread about scripting (+1)  
Here's a script that simulates trapdoor dropping when unarmed (or at all). Will most likely become obsolete soon.
Click here to view the secret text
(Highlight the secret text above.)


____________________________
lurking

[Last edited by Monkey at 08-23-2009 12:35 AM]
08-23-2009 at 12:35 AM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Thelas
Level: Delver
Rank Points: 32
Registered: 08-15-2009
IP: Logged
icon Re: The BIG thread about scripting (0)  
Everyone other than me probably knows this, but how do I make a custom sword?
Specifically, I want to replicate the Foil from the Holds Anonymous thingy. (+10 ATK, metal).
EDIT:
Completely different question, but I have a character (visible wraithwing) scripted as follows:
Set var _MyHP = 35
Set var _MyATK = 38
Set var _MyDEF = 3
Imperative Unkillable
Wait for defeat
Set var _HP + 50
Imperative Die

It works exactly as I want it to, with one exception. After it heals the player, I have to wait one move before it kills itself. How can I fix this?
(If this script looks like it makes no sense, that's because it was hand-copied; how do you copy a script again?)

Thelas

[Last edited by Thelas at 08-31-2009 10:36 PM]
08-31-2009 at 10:31 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 4590
Registered: 02-20-2007
IP: Logged
icon Re: The BIG thread about scripting (+4)  
This post in the DAA Architectural Handbook contains more detail on scripting custom equipment, but here's a brief summary:

* Create a new character. To do this, place an NPC, click "Characters" in the upper-right of the scripting window to open the characters window, then enter the name and click "Add character".

* Click "Custom Tiles" and upload the image you want to use. (The image for the Foil has been made publicly available for anyone to use; it's in the "Post your custom monsters or items!" thread.)

* Click "Edit Default Script" and enter the following. (You can select and copy it, and use ctrl-shift-B to paste it in the script editor.)

  Set var "_MyATK" = 10
  Behavior 10
  Wait for player to touch me 
  Disappear 
  Set var "_X" = _MyX
  Set var "_Y" = _MyY
  Equipment 0,1,20000


Here's an explanation of what this means:

Set var "_MyATK" = 10 sets the ATK to 10
Behavior 10 is "Metal"
Wait for player to touch me does precisely what it says
Disappear makes the sword disappear when stepped on
Set var "_X" = _MyX and Set var "_Y" = _MyY change the player's coordinates to match the NPC's coordinates (since you can't move onto an NPC, the move is simulated by making the NPC disappear and moving the player manually)
Equipment 0,1,20000 completes the simulation of what happens when you step on any other sword by making it your current equipment. The "0" is "Swap", so anything you're currently carrying is placed on the ground; "1" is "Weapon"; "20000" is the character's ID. When you create the character, it will appear in the list of characters, and clicking on any character in this list will show what its ID is. The first character you create will always have the ID 20000; subsequent characters increment the ID by 1. For the script to work, this line must contain, instead of 20000, the actual ID of the Foil character once you've created it.

* Finally, delete the NPC you temporarily created to gain access to the Characters window, and, when you want to place your sword on the level, place a new NPC and select "Foil" from the list of characters on the right. Don't forget to make it visible!

Completely different question, but I have a character (visible wraithwing) scripted as follows:
Set var _MyHP = 35
Set var _MyATK = 38
Set var _MyDEF = 3
Imperative Unkillable
Wait for defeat
Set var _HP + 50
Imperative Die

It works exactly as I want it to, with one exception. After it heals the player, I have to wait one move before it kills itself. How can I fix this?
(If this script looks like it makes no sense, that's because it was hand-copied; how do you copy a script again?)
Instead of Imperative Die, use Disappear.

Copy scripts from the editor with ctrl-B; paste them into the editor with ctrl-shift-B.

____________________________
50th Skywatcher

[Last edited by Nuntar at 08-31-2009 10:47 PM]
08-31-2009 at 10:46 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Thelas
Level: Delver
Rank Points: 32
Registered: 08-15-2009
IP: Logged
icon Re: The BIG thread about scripting (0)  
The wraithwing worked, thanks.
On the other hand, the foil...

Well, it gives no attack and actually CARRIES a sword. It sits there, if you grab it the sword it's carrying disappears and it gives you 0 ATK, if you run into the sword you take 5 damage (but the character had 5 DEF, so... 10 damage actually.)
08-31-2009 at 11:05 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 4590
Registered: 02-20-2007
IP: Logged
icon Re: The BIG thread about scripting (0)  
Okay, not sure what's going on there. (Attach hold, please?) Are you sure that (1) you made a new character and put the script I gave you in its default script; (2) you changed 20000 to the Foil's character ID; and (3) you placed a visible Foil character in the room?

____________________________
50th Skywatcher
08-31-2009 at 11:51 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Thelas
Level: Delver
Rank Points: 32
Registered: 08-15-2009
IP: Logged

File: Practice with hold-building.drh (5.1 KB)
Downloaded 43 times.
License: Public Domain
icon Re: The BIG thread about scripting (+1)  
I just realized I put the script in the actual Foil NPC's script, not the Foil Character's script... let's try to fix that.

Fixed, retested, didn't help.
Hold attached.
The Foil character is in the Entrance, so that shouldn't take too long to test.
(Those stat subtractions are from an invisible NPC, I just want you starting 500/0/5.)
EDIT: Did help, actually, but only halfway. It still has a sword, but the actual item sword works now and gives the stat bonuses.

[Last edited by Thelas at 08-31-2009 11:59 PM]
08-31-2009 at 11:58 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Nuntar
Level: Smitemaster
Avatar
Rank Points: 4590
Registered: 02-20-2007
IP: Logged
icon Re: The BIG thread about scripting (+1)  
I see.

Thing is, each character is based on a template -- these are selected in the Graphics menu. This determines what graphic is used for the character if there's no custom tile, but even if there is a custom tile, it also affects the character's behaviour. (For instance, custom monsters based on a Wraithwing can move across pits.)

For custom equipment, use Citizen 1. You've based the Foil on Beethro, who has a sword by default, which is why you see a sword holding another sword.

____________________________
50th Skywatcher

[Last edited by Nuntar at 09-01-2009 12:14 AM]
09-01-2009 at 12:12 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Fang
Level: Master Delver
Avatar
Rank Points: 175
Registered: 07-25-2008
IP: Logged
icon Re: The BIG thread about scripting (0)  
I personally use None on every custom item.

____________________________
"Imagination is more important than knowledge." -Albert Einstein
09-01-2009 at 12:52 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
12th Archivist
Level: Smitemaster
Avatar
Rank Points: 789
Registered: 12-07-2008
IP: Logged
icon Re: The BIG thread about scripting (+1)  
Since this is the forum's thread for RPG scripting (I think), I have a script to share.

Click here to view the secret text


Basically, this script allows a character to move to a location, disappear, wait a few turns, and reappear at a location. However, what makes this script special is that every time they move, you can bump into them and make them face you and say something before continuing to move.

I spent many, many hours making this work. Most of the bugs are ironed out. Put it in a script, change a few of the _MyX and _MyY variables, and check it out.

I will give anyone that wants to use this complete freedom of script. No permission needed.

EDIT: This script will only work for a character who you want to move in one direction. Here is the script for a character who will turn after reaching a certain location:

Click here to view the secret text


____________________________
It was going well until it exploded.
~Scott Manley

Check out the DROD Wikia project here!

[Last edited by 12th Archivist at 06-18-2011 11:27 AM]
09-26-2010 at 06:34 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Fang
Level: Master Delver
Avatar
Rank Points: 175
Registered: 07-25-2008
IP: Logged
icon Re: The BIG thread about scripting (0)  
Character swap global command
This one takes the inventory command spot, so if you want to add an inventory AND a character swap, you'd have to make it not global and restricted to the inventory room, along with a command swap every time the player leaves the inventory so that instead of swapping characters you can still access the inventory.

You need to create a var for each HP, ATT, DEF, GR, REP, Sword, Shield, Accessory for P1 and P2, along with a character named Good and another named Evil for the script to properly implement. Theoretically you can even add up to an infinite number of characters by making more "P3, P4, etc" vars, but it will take a lot of space, and swapping through them will take a lot of time for the player.

Click here to view the secret text


____________________________
"Imagination is more important than knowledge." -Albert Einstein
10-21-2010 at 04:00 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
12th Archivist
Level: Smitemaster
Avatar
Rank Points: 789
Registered: 12-07-2008
IP: Logged
icon Re: The BIG thread about scripting (+3)  
Weapon storage and switcher! The following code can be copied and pasted into a character using Ctrl-B and Ctrl-Shift-B, respectively.

(Secreted due to length)
Click here to view the secret text


What this script does is it allows you to store and retrieve up to eight custom weapons at a time. To use, create a character with this script:

Click here to view the secret text


Create more characters with similar scripts (change 20000 to successive sword values and change the "First" to more appropriate names) to simulate having more and more swords the player can store and swap out using the weapon chest. Note that the first question allows you to do the same with custom shields and custom accessories, but those would have very similar scripts and so were not elaborated upon.

One problem with the script is that "First" can be nameless in the weapon swap. I will see if I can get a fix for this tomorrow. Way too late for me, after already bashing dozens of bugs with the script over the past five hours. EDIT: After over a week, I finally found the bug and fixed it. The error was that in the "Label Put current weapon in chest", two of the name swaps were in the wrong order, thus giving a sword variable the wrong name. This has been fixed. Anyone looking to use the script should delete their version of the script and recopy the script in this post.

Credit me if you wish to use the script, though TFMurphy also had a hand in it, so you can decide if you want to credit him as well.

EDIT 2: I just wanted to note that with some logic and probably additional variables (or additional If... commands), you can create dynamically changing inventories, all in a single character script (i.e. without using the Build command to create additional inventory slots so that the player can step on them). I will see what I can do about getting an example script of this posted.

____________________________
It was going well until it exploded.
~Scott Manley

Check out the DROD Wikia project here!

[Last edited by 12th Archivist at 02-21-2011 11:48 PM]
01-24-2011 at 08:10 AM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
1
Page 2 of 2
New Topic New Poll Post Reply
Caravel Forum : DROD RPG Boards : RPG Architecture : The BIG thread 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.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.