I don't want to give too much away regarding this, but I'm completely stumped as to how to code a certain type of item for my first area.
Basically what I'm looking for is a program that I can put on an item that will respond to a command word being typed, the result of which being that the item (Provided it is being held) has a chance to break, depending on a success roll made against a skill (Or at least self-destruct, and no longer be in the inventory), preferably with an echo to that effect.
Is this doable, or am I asking the impossible?
Breaking items
Breaking items
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
-Miriel
- Argentia
- Sword Grand Master
- Posts: 357
- Joined: Fri Jul 23, 2004 4:31 am
- Location: The City of Splendors
- Contact:
Yep, sure is possible. =) Try something like this...(Experienced coders please correct me if needed! )
Where "break" is the command you want to entered, "QQ001" is the vnum for your item, and rand(50) is the percentage you want it to happen.(In this case, 50%)
Hope that helped. Please give corrections as needed. =)
Code: Select all
>intercept_prog break~
if actorhasobjnum(QQ001)
if rand(50)
mpecho A flimsy wooden practice sword splinters into pieces!
mpjunk iQQ001
endif
endif
~
|
Hope that helped. Please give corrections as needed. =)
Do not meddle in the affairs of dragons, for you are crunchy and go well with ketchup.
That's brilliant! Thanks muchly! If I can get this work, there shall be much rejoicing.
Would it be possible to add a skill check into that to make it less likely that the sword would break when the command was used, but still random?
Would it be possible to add a skill check into that to make it less likely that the sword would break when the command was used, but still random?
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
-Miriel
-
- Sword Grand Master
- Posts: 4708
- Joined: Tue Jul 15, 2003 9:26 pm
- Location: House of Wonder, Waterdeep
To trigger a program when someone types something, you would use an intercept_prog, as Argentia wrote.
To check whether an objects is worn, you would use if wear_loc($o) != -1 (-1 means: not worn).
To break an object on a character, you would use mpjunk $o $n.
To make a skill check, you would use if skill check(skill,$n).
For example, if you want a program that triggers when someone types "hello", which only works if the object is worn, that realizes a check in "second attack", echoes "Success!" if the test works and breaks the object otherwise, you could use, on the object, the following program:
To make things random, you can use if rand(N), where N is a number between 1 (happens with a 1% probability) and 100 (always happens with a 100% probability).
To check whether an objects is worn, you would use if wear_loc($o) != -1 (-1 means: not worn).
To break an object on a character, you would use mpjunk $o $n.
To make a skill check, you would use if skill check(skill,$n).
For example, if you want a program that triggers when someone types "hello", which only works if the object is worn, that realizes a check in "second attack", echoes "Success!" if the test works and breaks the object otherwise, you could use, on the object, the following program:
Code: Select all
>intercept_prog hello~
if wear_loc($o) == -1
mpechoat $n {90}You should wear/hold the object first!
else
if skillcheck(second attack,$n)
mpechoat $n {B0}SUCCESS!
mpechoaround $n {B0}$N succeeded!
else
mpechoat $n {B0}Too bad... your object broke!
mpechoaround $n {B0}Too bad... $N's object broke!
mpjunk $o $n
endif
endif
~
Thankyou!
With this, I've managed to come up with something that I think might work.
As a finishing touch, what is the wait command, so as to wait say five seconds before doing the next action in a bit of code?
ie:
mpecho {90}Scary Movie III starts
wait 60
mpecho {90}The audience leaves in disgust
With this, I've managed to come up with something that I think might work.
As a finishing touch, what is the wait command, so as to wait say five seconds before doing the next action in a bit of code?
ie:
mpecho {90}Scary Movie III starts
wait 60
mpecho {90}The audience leaves in disgust
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
-Miriel
-
- Sword Grand Master
- Posts: 4708
- Joined: Tue Jul 15, 2003 9:26 pm
- Location: House of Wonder, Waterdeep
We don't have any wait command.
The only way to simulate waiting is by using rand programs. The syntax is: ">rand_prog N", where N is a number between 1 and 100. Each "tick", there is a N% chance that the program will run (those programs are to be rare, since they use a lot of resource). The delay is simulated by the fact that the program generally does not trigger immediately, but only after some time; and there is no way to control exactly how much time passes before it triggers.
Now, when we use this trick, it's generally on a mob, on which we can set a quest bit value. The program looks something like:
The quest bit thing is used to make sure that the program effectively does something only when we want. For example, if we want a mob to say Hello, then wait for a short time, then say Goodbye,
- we make the mob say "Hello" in a greet_prog (for example) and set a bit on himself
- we check for that bit in the rand prog, so that it says Goodbye ONLY when the bit is set. (Without that, the mob would randomly say Goodbye now and then).
Now, it would be technically possible to set a special flag on the object, so that the second part of your program (after the pause) only happens when/if this flag is set. Objects have 6 values and the last one is not used. Since the first value is numbered 0, the last one (which is not used by the code) is value5. You can set it with "mposet $o value5 value" (if the object is on the ground; if it is carried by $n, we need to use mposet on $n $o value5 value) and check its value by "if objval5($o) == value".
So... if you want to use this method to code a "pause", you would use something like:
with
(Note that, in a rand_prog, $c is the person who is carrying the object)
If what must be done in the second part may vary, you can also use different values:
The only way to simulate waiting is by using rand programs. The syntax is: ">rand_prog N", where N is a number between 1 and 100. Each "tick", there is a N% chance that the program will run (those programs are to be rare, since they use a lot of resource). The delay is simulated by the fact that the program generally does not trigger immediately, but only after some time; and there is no way to control exactly how much time passes before it triggers.
Now, when we use this trick, it's generally on a mob, on which we can set a quest bit value. The program looks something like:
Code: Select all
>rand_prog 30~
if questbit ok
... do something
... change quest bit
endif
~
- we make the mob say "Hello" in a greet_prog (for example) and set a bit on himself
- we check for that bit in the rand prog, so that it says Goodbye ONLY when the bit is set. (Without that, the mob would randomly say Goodbye now and then).
Now, it would be technically possible to set a special flag on the object, so that the second part of your program (after the pause) only happens when/if this flag is set. Objects have 6 values and the last one is not used. Since the first value is numbered 0, the last one (which is not used by the code) is value5. You can set it with "mposet $o value5 value" (if the object is on the ground; if it is carried by $n, we need to use mposet on $n $o value5 value) and check its value by "if objval5($o) == value".
So... if you want to use this method to code a "pause", you would use something like:
Code: Select all
... do things before the pause
... mposet on $n $o value5 1
Code: Select all
>rand_prog 60~
if objval5($o) == 1
... do things after the pause
mposet on $c $o value5 0
endif
~
If what must be done in the second part may vary, you can also use different values:
Code: Select all
>rand_prog 60~
if objval5($o) == 1
... do things after the pause
mposet on $c $o value5 0
endif
if objval5($o) == 2
... do other things after the pause
mposet on $c $o value5 0
endif
...
~