Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - erwin

Pages: 1 2 [3] 4 5 ... 21
31
Suggestions & Ideas / Re: Questjournal v1
« on: November 30, 2015, 03:21:25 am »
I was actually thinking of an automated way to tabulate the zoneflags collected, which would start on the day the triggers were created so it'll start from zero - similar to how the helper's vouchers were done. But that will probably be in the future!

I think there's some debate about the joje flags - I've heard that there were flags like joje_completed, joje1, joje2, etc..

32
Suggestions & Ideas / Re: Questjournal v1
« on: November 23, 2015, 10:14:35 pm »
In short: If there was an old variable used, which is not on the current triggers, then there is no way that the old variable can be used to show you have completed a quest.

To make this clearer, suppose builder A wrote the following script:

Code: [Select]
if !%actor.varexists(completed)%
  set completed %actor.id%
  remote %actor.id%
endif

to show that the player has completed a quest. Much later, upon realizing this variable is poorly named, the builder changes it.

Code: [Select]
if !%actor.varexists(this_zone_completed)%
  set this_zone_completed %actor.id%
  remote %actor.id%
endif

Surprisingly, the builder never does
Code: [Select]
* There used to be a variable called completed here. It's been replaced by this_zone_completed
if !%actor.varexists(this_zone_completed)%
  set this_zone_completed %actor.id%
  remote %actor.id%
endif

When anyone looks at the current script, and does a quest_journal type thing to show the quest has been completed, it will always be similar to this form
Code: [Select]
if !%actor.varexists(this_zone_completed)%
  %echo% %actor% has not completed this quest!
else
  %echo% %actor% has completed this quest!
endif

If, unfortunately, you had the variable completed, then the script will say you have not completed the quest. Furthermore, there is no human way of finding out what the "extra" variables you have correspond to. The solution would be to redo the quest.

On the bright side, because the variables have been changed, you can probably do the quest again for the full reward.

What's the point of the Quest Journal then?

1. Change of variables / future knowledge.

Suppose a quest had 5 variables. var1 var2 var3 var4 var5
Halfway through the quest, someone decides to change them to newvar1 newvar2 newvar3 newvar4 newvar5
You get stuck, because future scripts are looking for newvari instead of vari, which you have.

Or, suppose you did something stupid / had future knowledge.

Imagine a quest arc where you talk to Molly, who tells you to talk to Kvetch, who then tells you to talk to Rynald. Rynald asks you to give a bone to Bart's dog.

Suppose to check whether the quest has been complete, the builder write a trigger to check if you have talked to all 3 people, and given the bone.

However, instead of talking to Molly, you decided to give a bone to the dog because you like dogs. Unfortunately, there's a script which prevents you from talking to Molly, Kvetch, and Rynald once you've given the bone.

So to summarize - you've only given the bone, but not talked to the three imms. But since there's a script preventing you from talking to them after having given the bone, and you needed to talk to all three of them to complete the quest, the quest is bugged.

The questjournal allows anyone to reset the questflags. Suppose an imm made a mistake in the flags? Well, he can ask everyone to RESET their flags, and so start again. The quest journal (on the backend at least), allows that flexibility and rebuilding of quest flags in an array to account for this. Suppose you did something out of sequence? Well, you can RESET the flags and start again.

2. Prevent spam

Suppose a quest had 10 variables altogether, and maybe they are called: bone1 bone2 ... bone10

If you vstat a player, you get this:
Code: [Select]

                                        bone1:                     1
                                        bone2:                     1
                                        bone3:                     1
                                        bone4:                     1
                                        bone5:                     1
                                        bone6:                     1
                                        bone7:                     1
                                        bone8:                     1
                                        bone9:                     1
                                      bone10:                     1

Wouldn't it be nicer if you just had:

Code: [Select]
dino_bone: bone1yes bone2yes bone3yes bone4yes bone5yes bone6yes bone7yes bone8yes bone9yes bone10yesor better still
Code: [Select]
dino_bone_list: yes yes yes no no yes yes yes no yesFurthermore, instead of
Code: [Select]
if %actor.varexists(bone5)%
  %send% %actor% You have bone number 5
else
  %send% %actor% You don't have this bone!
  %send% %actor% But I'll give you the variable
  set bone5 1
  remote bone5 %actor.id%
endif
you get
Code: [Select]
set dino_bone_list %actor.dino_bone_list%
if %dino_bone.wordat(5)% == yes
  %send% %actor% You have bone number 5
else
  %send% %actor% You don't have this bone!
  %send% %actor% But I'll give you the variable
  replace_word yes 5 dino_bone_list
  remote dino_bone_list %actor.id%
endif

It's only one line longer (because of set dino_bone %actor.dino_bone%). But think of the spam reduction...

33
Suggestions & Ideas / Re: Questjournal v1
« on: November 23, 2015, 09:32:59 pm »
So - just a heads up.

The questjournal does not wipe out quests, although flags are changed. The main script works as follows to convert flags:

Code: [Select]
If variable newquestvariable does not exist
  create newquestvariable
  for oldquestflags
    replace them in newquestvariable
    delete oldquestflags
   endif
endif

So... Why are there quests missing?

Well, here's an idea. Ask an imm to check your newbie task flags with the helper's whistle. You will find that although when you started MUDding ages ago, and definitely picked up the vouchers / did the tasks, they're reflected as incomplete. That means you never entered the newbie school.

Hold on, you say. I did these quests before the new scripts were put in, old variables deleted, and new variables added. Obviously it's not saved on my pfile because my pfile has the old variables and not the new variables. The whistle can't tell me whether I've completed these quests because no one knows what the old variables are, unless my pfile is manually looked at, and people can guess that some weird variable name "completed" actually means: "I completed the newbie school". Duh.

With this in mind, here's why there are missing quests.

1. The variable has changed. Suppose in the past, you did a quest where the flag to show you have completed the quest was "complete".

Now, that's a pretty crappy flag, because most builders might use the same variable. A better variable could have been "alibabazone_complete" or similar. So Molly would come in, and say: "use a different flag instead of complete, because another zone has the same flag."

So the builder changes the flag in a script - let's call it alibabazone_complete, so when subsequent players have completed the quest, that would be the flag set on them, instead of complete.

Unfortunately, for players who have already completed that quest - their "completed" flag is still called "complete", and not alibabazone_complete. So, since the quest journal looks for the flag alibabazone_complete, it will not detect that flag on your player profile, and thus - will show you have not completed the quest.

Solution: Redo the quest. I don't know what the old variable is called because it's not on the quest script.

2. Give mob an item quest. If the mob always gives the same reward (trading quests), or small item rewards, then usually builders won't set an extra variable on it to show the player has completed it once.

So the variables they set would be of the form: item1 item2 item3

If item1 item2 item3 are collected, then the quest resets. There is no "fourth" variable stored to show that you have completed the quest or not.

In other words, there is no variable that states you have completed that quest on the MUD. So the quest journal similarly won't reflect that you have completed the quest, even though you have.

To extend this, there's also a zoneflag questcard to collect all zoneflags. There are no triggers on any of the zoneflags to add variables to show they have been picked up except the newbie ones. Thus, should a zoneflag script be done, everyone will have 0 zoneflags collected (even if they have collected more than one).


That being said, here are some legit concerns:

Will my equipment poof?

Answer: No, simply because equipment triggers would have that quest variable there. If there was a change of variables, then the equipment trigger would have looked like

Code: [Select]
if %actor.varexists(complete)%% || %actor.varexists(alibabazone_complete)%
  %send% %actor% You wear the equipment

and it's easy to add in complete and alibabazone_complete to the script, because they are there.

34
Suggestions & Ideas / Questjournal v1
« on: November 23, 2015, 12:35:00 pm »
The first batch of questcards for the quest journal has been released. They're also all quests in the Prehistoric era. Now's the time to test and see if you can find any errors / try to break them and abuse loopholes if any :)

To get the quest journal, go to Bart (in recall, not in SF), and say javert and chauvelin. He will give you the quest journal.

The current questcards that are available are:

Questcard 33
Questcard 35
Questcard 39
Questcard 81
Questcard 118
Questcard 121 

Have fun, and happy questing!

If there are any bugs / typos / suggestions / etc feel free to post them here, unless it involves a quest - in that case send pix a note.


35
Scripting Board / Re: What are arrays, and why should we use them?
« on: October 27, 2015, 11:44:43 am »
Yeah, it would be nice to have our own wiki.

I like the reference as a basis reference, but there are some 4D unique functions (dg_letter, mod, etc) which aren't there, nor 4D specific fields (helper, hero, etc).

36
Scripting Board / Re: What are arrays, and why should we use them?
« on: October 25, 2015, 10:41:59 pm »
on second thought, is there a nice page / link / helpfile / command to show all such DG functions / fields?

37
Scripting Board / Re: What are arrays, and why should we use them?
« on: October 25, 2015, 10:39:28 pm »
rynald you are the best :)

38
Scripting Board / What are arrays, and why should we use them?
« on: October 24, 2015, 02:40:34 am »
Molly asked!

The easiest way to think of arrays (in a non coding context) is to think of sentences. For example, most variables are set to "one word / one number / one character" values.

PS. I'm not sure if they exist, but are there dg "replace" code which replaces items / characters in an array/string, as well as dg_code to find the length of the array? If yes, could any coders give the syntax, much appreciated! If not, would it be possible to code it in? Thanks!

PPS. Hashsets in DG?

Code: [Select]
* Disclaimer: These are not real quest variables, but how things could be
robinhooddagger: done
killedgreenie: 1
highscore: 12345
gotvoucher1: yes
gotvoucher2: yes
gotvoucher3: yes
gotvoucher4: yes
gotvoucher5: yes

But variables with "one word / one number / one character" entries give too much clutter - eg type vstat player virisin. One solution would be to store arrays as variables, and make the array as intuitive sounding as possible.

For example, here are some variables as arrays. Which one do you think is more intuitive?

Code: [Select]
helpervoucher: to be or not to be
helpervoucher: 1 0 0 1 1
helpervoucher: yes yes no no yes
helpervoucher: found found notfound found notfound


So here are two ways how to use arrays, for simple quests.

One way is to store items found on one variable. Eg, you might have a quest that wanted you to find five items.
Code: [Select]
*Do something to trigger the quest
set myfirstquest notfound notfound notfound notfound notfound incomplete
remote myfirstquest %actor.id%

* This gives a variable that looks like this
myfirstquest: notfound notfound notfound notfound notfound incomplete

Now, we simply change the appropriate "word" in the variable. If the player finds the third item, then we just change the third notfound to found. If the player has completed this quest at least once, then we change the incomplete to complete.


A second way that arrays can be used is to store things on a trigger. For example, you might have a quest that wants you to give the mob some grapes. But there are lots of grapes. One possible trigger could be:
Code: [Select]
if (%object.vnum == 10) || (%object.vnum == 11) || (%object.vnum% == 12)
  do something
endif

However, this becomes clunky if there are lots of possible objects. Furthermore, there's a max number of characters per line. Here's a cleaner way
Code: [Select]
set correctobjects 10 11 12

* Technically, don't need numobjects unless you want to be fancy
* Could always set numobjects = 3 manually below
set numobjects 3


set j 0
while %j% < %numobjects%
  eval j %j% + 1
  * This extracts the jth number of correctobjects.
  * If j is 1, it will get the number 10. If j = 2, it will get the number 11. If j = 3, it will get 12
  extract objecttocheck %j% %correctobjects%
  if %objecttocheck% == %object.vnum%
    %echo% Correct object, hooray
    set gotcorrect 1
  endif
done

if !%gotcorrect%
  %echo% We didn't get a correct object.
endif

You might say: "Hey, this actually results in a more lines." Yes, you're right, it does. But there are three advantages to this.

First advantage - You only need to edit the variables numobjects and correctobjects. For example, if you added a new vnum 12345 you just need
Code: [Select]
set correctobjects 10 11 12 12345
set numobjects 4
compared to
Code: [Select]
if (%object.vnum == 10) || (%object.vnum == 11) || (%object.vnum% == 12) || (%object.vnum% == 12345)
There's fewer chances of mistakes, even though it's just changing one line. Furthermore, some clients have terrible wrapping, and you might get
Code: [Select]
if (%object.vnum == 10) || (%object.vnum == 11) || (%object.vnum%
 == 12) || (%object.vnum% == 12345)
which screws up the code.

Second advantage: There's only a maximum number of characters per line. It's harder to go over the limit using arrays.

Third advantage: If the quest wasn't just to give grapes, but to give grapes, nuts, clothes, gems, etc, then you'd be repeating a lot of code. Take a look at http://4dimensions.org/forum/index.php/topic,682.msg6927.html#msg6927

It's just easier to edit the first part - everything else follows automatically from the code. For example:
Code: [Select]
Note Number:   9
       From:  Tor
    Subject:  Quest doesn't work
     Posted:  Tue Oct 21 03:23:42 2015
         To:  imm
=================================================

The questmob wanted a list of items.
1. An emerald
2. A ruby
3. A garnet
4. An onyx

However, I gave the mob some items, such as
emerald from Thandar, Arabian Desert, Flying Fortress
ruby from Dragon Island ...
garnet from ....
onyx from ...

If you've received this note, and the builder didn't use arrays you could edit the trigger, which would take extremely long - because you want to search through the script to find where the if statements occur, find the syntax the builder used, and add them in.

Or, if the builder just used an array like the trigger of the day, all you need to do is to just
Code: [Select]
set questitem1 123 153 167 14678 21563
set questitem2 642 7434 2359 4928 9872
set questitem3 6982 7939 1765 53

and it's fixed!

39
Scripting Board / Re: Trigger of the .... something
« on: October 24, 2015, 01:52:46 am »
What happens if we want to script a quest which went like this:

1. Give me grapes from Ancient Greece
2. Give me a laser gun
3. Give me a game

Well, most quests are specific, eg: "Give me grapes from Imbros, give me a 4D laser gun, give me a Battleship game." But what if we wanted to make sure ALL possible items are valid? Well, we could add in if statements. However, this gets tricky when more and more zones are built, and thus more items are valid?

We show how we can do this with one quest array, and how builders can copy and paste the entire script below and adapt it to any such quest.

Let the questarray be an array with 4 variables. First 3 are yes/no variables, and the last denoting whether the quest has been completed before or not.

Here are examples of some arrays

Code: [Select]
* Example of quest not done
myquestvar: no no no incomplete
* Example of quest where first item and third item has been found, but player hasn't completed it
myquestvar: yes no yes incomplete
* Example of quest where player has completed it at least once before, and is trying again and he only gave the second item
myquestvar: no yes no complete

Now, here is the grand script.

Code: [Select]
**** CANDIDATE LIST
**** This quest accepts multiple possible items, so update this list
**** accordingly. For example, if someone typos that another item
**** might fit, then add in the new vnum to the array. This is the only
**** change you need! YEAH!

**** Number of different items needed
set numquests 3   

**** Item 1
set questitem1 12345 4205 14673
set msg1 Thanks for giving me questitem1

**** Item 2
set questitem2 1222 5070 5323 64325
set msg2 Thanks for giving me item 2!
   
**** Item 3
set questitem3 503 703
set msg3 Thanks buddy

*** This is it! Edit the above part when more items get added - the below will do everything for you
*** Msg is optional, could add more stuff, but you get the gist.

** We're going to loop through this

** Note: This is not the most efficient way of doing so, but
** we have relatively few quest items. If you want to re-use this code
** for substantially more vnums, one way is to order the arrays in
** increasing order, and do a binary search for appropriate vnums

if %actor.varexists(myquestvar)%
  set questvars %actor.myquestvar%
  eval statusnum %numquests% + 1
  extract status %statusnum% %questvars%
  set curritem %object.vnum%
 
  *First loop through all arrays. numquests quest items, so numquests arrays
  set arrnum 0
  while %arrnum% < %numquests%
    eval arrnum %arrnum% + 1
    extract itemarray %arrnum% %questvars%
    set item%arrnum% %itemarray%
    * read this array
   
    * Note: We have to eval this, and not set, otherwise it'll be a string
    eval currarray %%questitem%arrnum%%%
   
    * So for example, if arrnum was 1, then
    * currarray would be set to 12345 4205 14673 (value of questitem1)
    * %echo% %currarray%   
    * uncomment above to check!
   
    * Now, find the length of this array
    set stopping_criteria 1
    set start 1
    while %stopping_criteria% != stop
      extract num %start% %currarray%
      if !%num%
        eval num %start% - 1
        set stopping_criteria stop
      endif
      eval start %start% + 1
    done
   
    * We've got the length of the array stored as %num%
    * Now, loop through each item in the array
   
    set j 0
   
    while %j% < %num%
      eval j %j% + 1
      extract itemtocheck %j% %currarray%
     
      * Finally, we check if it's the same item as what we want
      if %curritem% == %itemtocheck%
        wait 1s
        mjunk %object%
        * Perfect, let's set the variable to yes
        set item%arrnum% yes
       
        * Again, eval and not set
        eval currmsg %%msg%arrnum%%%
        say %currmsg%
       
        * Set a variable gotcorrectitem because we want the mob to respond
        * if none of the items were right
        set gotcorrectitem yes   
      endif
     
    done           
  done
 
  * At the end of the loop, we need to do two things
  * If no right item was given, then
 
  if !%gotcorrectitem%
    wait 1
    say No, no, that's all wrong.
    say Try to get it right next time.
    mjunk %object%
    wait 2
    emo waves his hands and what you handed him disappears!
    halt
  endif
 
  * Now, we have to check if all 3 were achieved, and concurrently update
  * the new variable. Create loop to rebuild array, and count how many
  * correct items
 
  * Create new variable resetquest in case player gets all 3
 
  set j 0
  set counter 0
 
  while %j% < %numquests%
    eval j %j% + 1
    eval curritem %%item%j%%%
   
    if %curritem% == yes
      eval counter %counter% + 1
    endif
   
    if %j% == 1
      set myquestvar %curritem%
      set resetquest no
    else
      set myquestvar %myquestvar% %curritem%
      set resetquest %resetquest% no
    endif     
  done
 
 
  if %counter% < %numquests%
    * Can't set status to incomplete, but need to use previous
    * one, because player might have done quest before
    set myquestvar %myquestvar% %status%
  else
    * Note, got to reset quest, but must flag complete
    set myquestvar %resetquest% complete
    * Set complete quest sequence here

    %send% %actor% I reward thee!
  endif
  * Finally, don't forget to remote this
  remote myquestvar %actor.id%
else
  * If no questflag, giving should not do anything
  halt
endif


40
Scripting Board / Re: Card Game Functions
« on: October 24, 2015, 12:47:34 am »
Hmm..is there still the 8-10 page limit for triggers? I'd wager scripting complicated card games would take a lot more pages without using functions :(

41
Scripting Board / Re: Card Game Functions
« on: October 18, 2015, 04:26:39 pm »
Function 14: Checking if player has these cards

Takes in an input of the player, and checks if he/she has that card in his / her hand, given either the inputs:

Code: [Select]
ArrangedBySuitSuits
ArrangedBySuitNums

or

Code: [Select]
ArrangedByNumSuits
ArrangedByNumNums

and the input

Code: [Select]
maxnum
Using "place" as the command word, possible inputs would be:

place 4D 4H 4H
place 4D 4H
place 4D 8H JS AS
place 4D 7H AA BB

Function will check if the player has these cards (note duplicates, invalid cards, and card placement more than maxnum must not be allowed), and returns an output (string) either yes/no.

Function 15: An extension of Function 14, to REMOVE the valid cards in a player's hand, and returns a smaller Array of cards.


42
Scripting Board / Card Game Functions
« on: October 18, 2015, 04:00:34 pm »
There's been talk about scripting card games (here, a standard deck of 52 cards), and I think it would be nice to consolidate all functions we would need for all possible card games. This means reusable functions for games (not just limited to Poker).

Since there are two main types of games (suit taking games - easier to script), and hand winning games (pairs, two pairs, straights, etc - harder to script), here's what I propose for functions in order to build such games. Feel free to add / suggest better functions, with the idea that "using these functions will allow anyone to script any kind of card game - not just limited to poker / hearts"

1. A shuffle function

with two inputs. These inputs are two (variables) arrays, corresponding to

Code: [Select]
SuitArray:  2 3 4 5 6 7 8 9 10 J K Q A 2 3 4 5 ....
NumArray: C C C ... C D  .. D S .. S  H .. H

The function SHUFFLES these cards, and gives the shuffled output as two arrays:

Code: [Select]
ShuffledSuitArray:  ....
ShuffledNumArray: ....

The purpose of this function is to shuffle cards randomly. Scripts can be used to "divide" the shuffled cards up according to player.

2. An "arrangement" function.

Takes two inputs SuitArray and NumArray (both must be of the same length, but not necessarily 52. These would correspond to cards in a 2 player game (26 each)  4 player game (13 each), poker (5 each), etc).

Gives four outputs, namely:

Code: [Select]
ArrangedBySuitSuits:  C C C D D
ArrangedBySuitNums: 4 5 6 2 8
ArrangedByNumSuits: 2 4 5 6 8
ArrangedByNumNums: D C C C D


The purpose of this function is to cater for different type of games, where arranging by numbers / arranging by suits would be more convenient.

3. A "presentation" function for the above arrangement. Basically, the function takes in any of the above four inputs, and presents the cards to the players in a readable way. This will probably differ based on the type of game


Functions 4-12

With the above three functions, we can now customize our functions. For hand winning games, I suggest scripting the nine functions which correspond to the nine poker hands - Straight Flush, etc ... with the following four inputs - note that this function is NOT restricted to 5 elements in an array. Obviously with checks, eg, can't get a Flush if you had only 3 cards to compare, etc:

Code: [Select]
FirstPlayerSuit   H H H S S
FirstPlayerNum  2 5 6  3 6
SecondPlayerSuit:  D D D D D
SecondPlayerNum: 4 5 6 7 8

These functions would compare the hands of two players, and output a string with the player which has a higher hand. If neither player has a hand of that type, output null (or NA). Furthermore, make these 9 functions in running order - hopefully for some vnum xxx01 to xxx09 (for games which rely on placing a same poker hand, or one with higher value) - so if a person placed a hand of type 05, we can loop through for 06-09.


With the above 12 functions, we can script most games. For example, if we wanted to script a Poker Game, then we write a comparison function, eg below.

13. A comparison function. Given the arrays of X number of players, and an array PlayerName, eg:

Code: [Select]
XerxesSuit   H H H S S
XerxesNum  2 5 6  3 6
TorSuit:  D D D D D
TorNum: 4 5 6 7 8
ErwinSuit: C D H S C
ErwinNum: A 2 3 4 5

PlayerName: Xerxes Tor Erwin


run this function together with the previous 9 functions in order to see which player wins.

The logic would be: Run these functions from highest poker hand to lowest poker hand, until one poker hand is found. Compare with all other players to see who has the highest hand. Output the player name.


Any other functions do you think we need?










43
Scripting Board / Some very advanced scripts
« on: October 15, 2015, 09:54:21 am »
Some very advanced scripts.

I'm trying to create a document which details {more} advanced scripts, and with proper syntax as well - hopefully to give people ideas on what scripts can do. Any suggestions / ideas for scripts welcome. Particularly if you also provide the script :)

44
Scripting Board / Re: Scripted Quest Rewards you would like to see
« on: October 09, 2015, 02:51:24 pm »
thanks!

45
Scripting Board / Re: Scripted Quest Rewards you would like to see
« on: October 08, 2015, 06:20:22 pm »
Great, thanks :)

One more question: What would be needed if I wanted a pointer to a mob, in order to get the mob to do stuff?

Say for example, I created a mob (not necessarily a unique name), with unique ID 12345, and then:

Code: [Select]
set mobPointer %self.id%
remote mobPointer %actor.id%

The variable 12345 is stored on the player. However, if I wanted to do the following:

a) Force the mob to do something
b) Find the room the mob is in

what would the appropriate syntax be? At the moment, I've tried

Code: [Select]
%force% %mobPointer% jump
%echo% %%mobPointer%.room%

which admittedly doesn't work, since the number stored in mobPointer could represent a string / object / room / anything else instead - so I'm not even sure if I'm storing the right variable.

So yeah, what would I need to do to get this to work? Thanks again!




Pages: 1 2 [3] 4 5 ... 21