4Dimensions Forum

Building & Scripting => Scripting Board => Topic started by: Kvetch on June 06, 2011, 06:58:26 am

Title: Trigger of the .... something
Post by: Kvetch on June 06, 2011, 06:58:26 am
I'd like to be bold and say trigger of the day, but the sites I know of that have done that haven't posted anything for about 2 years.  Trigger of the month is much too slow.  I guess it's trigger of the - whenever I feel like posting one.  Right now I've got a bunch that I've snuck off TBA along with a few of my own so we may be busy for a while.  To start with, let's use one that's actually in 4D right now, though the idea of it could have come from posts on the TBA board

Name: 'Pirate Parrot Repeat Script',  VNum: [23020], RNum: [ 5138]
Trigger Intended Assignment: Mobiles
Trigger Type: Speech, Numeric Arg: 100, Arg list: *
Commands:
Code: [Select]
if %actor.vnum% < 0
  if %c%<20
    eval c 20
    global c
  end
  if !(%speech%/=!)
    eval c (%c%)+1
    global c
    set %c% %speech%
    global %c%
    eval 1 Walk the plank, ye scurvy bilgerat.
    eval 2 Weigh anchor or I'll give ye a taste of the cap'n's daughter.
    eval 3 Ahoy.  Ye scurvy dogs.
    eval 4 Avast.
    eval 5 Aye aye.
    eval 6 Arrr.
    eval 7 C'mere, me boxom beauty.
    eval 8 Well, me hearties, let's see what crawled out of the bung hole.
    eval 9 Drink up, me hearties.
    eval 10 Keelhaul that land rubber.
    eval 11 Awk. Polly wants a cracker.
    eval 12 Avast, me proud beauty. Wanna know why my Roger is so Jolly?
    eval 13 Aye, that's a hornpipe in my pocket and I am happy to see ye.
    eval 14 Prepare to be boarded.
    eval 15 That's the finest pirate booty I've ever laid eyes on. Aye.
    eval 16 That's some treasure chest you've got there.
    eval 17 That's quite a cutlass ye got thar, what ye need is a good scabbard.
    eval 18 Shiver me timbers.  That's a mighty big cannon.
    eval 19 Blow yer man down.
    eval 20 Swab the deck.
    eval count %%random.%c%%%
    set ans %%%count%%%
    eval ans %ans%
    wait %random.5%
    say %ans%
  endif
endif
What  this script does is make it so the parrot can change what it says based on what's being said around it.  Works for fun, laughs and the irritation of anyone around it for any length of time.
Title: Re: Trigger of the .... something
Post by: Kvetch on June 08, 2011, 10:15:35 am
This could be fun if someone wanted to run with it - or do we have something like it and I don't know about it - that's easy to do.  Could be one of those games kind of like the arena.

Code: [Select]

<On blue paintball gun>

Name: 'Obj Command 81 - Paintball Shoot Blue',  VNum: [   96], RNum: [   96]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 2, Arg list: shoot
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
if %arg.room% != %actor.room% || %arg.id% == %actor.id%
  %send% %actor% Shoot: Invalid Target!
  halt
end
set inroom %actor.room%
if %arg.inventory(80)%
  %echoaround% %actor% %actor.name% blasts %arg.name% with %actor.hisher% paintball gun.
  %send% %actor% You blast %arg.name%.
  %send% %arg% You lose!
  %purge% %arg.inventory(80)%
  %zoneecho% %inroom.vnum% %actor.name% shoots %arg.name%. A score for the Blue Team.
elseif %arg.inventory(81)%
  %send% %actor% They are on your team!
elseif
  %send% %actor% %arg.name% is not playing.
End

<On Red paintball gun>

Name: 'Obj Command 80 - Paintball Shoot Red',  VNum: [   97], RNum: [   97]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 2, Arg list: shoot
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
if %arg.room% != %actor.room% || %arg.id% == %actor.id%
  %send% %actor% Shoot: Invalid Target!
  halt
end
set inroom %actor.room%
if %arg.inventory(81)%
  %echoaround% %actor% %actor.name% blasts %arg.name% with %actor.hisher% paintball gun.
  %send% %actor% You blast %arg.name%.
  %send% %arg% You lose!
  %purge% %arg.inventory(81)%
  %zoneecho% %inroom.vnum% %actor.name% shoots %arg.name%. A score for the Red Team.
elseif %arg.inventory(80)%
  %send% %actor% They are on your team!
elseif
  %send% %actor% %arg.name% is not playing.
End

Title: Re: Trigger of the .... something
Post by: Kvetch on June 09, 2011, 09:40:15 pm
Making it so players have to figure out some sort of combination.  Of course, there would have to be hints, clues or whatnot in the area, but here's the jest of it:

Code: [Select]

Name: 'Room Command Combination Lock',  VNum: [   92], RNum: [   92]
Trigger Intended Assignment: Rooms
Trigger Type: Command , Numeric Arg: 100, Arg list: push
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
*
* To allow multiple scripts based on this script we set a context:
  context %self.id%
* clear old var, if set.
  unset reset_buttons
* check argument
  if %arg% == red
    %send% %actor% You push the red button.
    set pushed_red 1
    global pushed_red
  elseif %arg% == yellow
    %send% %actor% You push the yellow button.
    if %pushed_red%
      set pushed_yellow 1
      global pushed_yellow
else
      set reset_buttons 1
    end
  elseif %arg% == green
    %send% %actor% You push the green button.
    if %pushed_red% && %pushed_yellow%
      set pushed_green 1
      global pushed_green
    else
      set reset_buttons 1
    end
  elseif %arg% == blue
    %send% %actor% You push the blue button.
    if %pushed_red% && %pushed_yellow% && %pushed_green%
      set pushed_blue 1
      global pushed_blue
    else
      set reset_buttons 1
    end
  elseif %arg% == purple
%send% %actor% You push the purple button.
    if %pushed_red% && %pushed_yellow% && %pushed_green% && %pushed_blue%
      %send% %actor% You hear a loud click as you push the final button.
      set reset_buttons 1
    else
      set reset_buttons 1
      end
  elseif %arg% == white
    %send% %actor% You push the white reset button.
    set reset_buttons 1
  else
    %send% %actor% Push what ?!
    halt
  end
* reset the buttons if necessary
  if %reset_buttons%
    unset reset_buttons
    unset pushed_red
    unset pushed_yellow
    unset pushed_green
unset pushed_blue
    %send% %actor% The buttons all suddenly pop back out.
  end
* send the state of the buttons
  %send% %actor% red:%pushed_red% yellow:%pushed_yellow% green:%pushed_green% blue:%pushed_blue% purple:%pushed_purple%
Title: Re: Trigger of the .... something
Post by: Kvetch on June 10, 2011, 06:10:13 pm
Do you want it so someone REALLY can't get rid of an item?  Got you covered.  ACtually, I'm not sure that you wouldn't be able to put the item in a container and get rid of it that way, but otherwise, it's worse than being CURSED!  Plus it's a short, easy script.
Code: [Select]

Name: '!DROP Assigner - 1332',  VNum: [ 1366], RNum: [  438]
Trigger Intended Assignment: Objects
Trigger Type: Drop Give Consume , Numeric Arg: 100, Arg list: None
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
if %actor.level% < 32
  %send% %actor% You can't get rid of %self.shortdesc%.
  return 0
end
Title: Re: Trigger of the .... something
Post by: Molly on June 11, 2011, 01:25:15 am
ACtually, I'm not sure that you wouldn't be able to put the item in a container and get rid of it that way,

We have a trigger type for containers; put-in.
Have you trid if that works?
Title: Re: Trigger of the .... something
Post by: Kvetch on June 11, 2011, 08:54:47 pm
I was just pointing out that there may be a way around the script.
Title: Re: Trigger of the .... something
Post by: Kvetch on June 16, 2011, 09:56:19 pm
Code: [Select]
Name: 'Crystal Ball to Locate a Mob.',  VNum: [  205], RNum: [  205]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 7, Arg list: locate
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
set find %arg%
if !%find.is_pc%
  eval rname %find.room%
  %send% %actor% As you gaze into the ball, it starts to glow. You see an image of %find.name% in %rname.name%.
else
  %send% %actor% All that you see is a blurry haze.
end
%echoaround% %actor% %actor.name% peers into %actor.hisher% gently glowing crystal ball.
Title: Re: Trigger of the .... something
Post by: Kvetch on June 21, 2011, 09:37:51 am
Code: [Select]
Name: 'Open a Chest once per zone reset',  VNum: [  209], RNum: [  209]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 100, Arg list: open
Commands:
* By Mordecai
if chest /= %arg%
  * Verify that the player typed 'open chest'
  * Has the player already opened this chest?
  context %actor.id%
  if %already_opened_chest%
    %send% %actor% The chest has already been opened, and emptied.
  else
    * The first time!  OK, open the chest.
    %send% %actor% You get a jar of naphthalene from an iron bound chest.
    %load% obj 306 %actor% inv
    set already_opened_chest 1
    global already_opened_chest
    return 0
  end
else
* Not 'open chest' - pass control back to the command parser
  return 0
end
Title: Re: Trigger of the .... something
Post by: Kvetch on June 22, 2011, 06:06:28 pm
A voodoo doll that could actually hurt a PC?  Sounds dangerous.

Code: [Select]
Name: 'Voodoo Doll',  VNum: [ 1381], RNum: [  453]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 2, Arg list: pin
Commands:
* By Heiach
if !%arg%
  %send% %actor% Stab a pin into a voodoo doll of who?
else
  eval dmg %arg.hitp% * 100 / %arg.maxhitp%
  if (%dmg% > 25)
    eval pain %random.15%
    switch %pain%
      case 1
        set hurt back
      break
      case 2
        set hurt head
      break
      case 3
        set hurt stomach
break
      case 4
        set hurt left eye
      break
      case 5
        set hurt chest
      break
      case 6
        set hurt right eye
      break
      case 7
        set hurt left arm
      break
      case 8
        set hurt right arm
      break
      case 9
        set hurt left leg
      break
      case 10
set hurt right leg
      break
      case 11
        set hurt groin
      break
      case 12
        set hurt left foot
      break
      case 13
        set hurt right foot
      break
      case 14
        set hurt throat
      break
      case 15
        set hurt heart
      break
      default
      break
    done
%send% %actor% You slowly push a pin into the voodoo doll of %arg.name%'s %hurt%.
    %echoaround% %actor% %actor.name% slowly pushes a pin into a voodoo doll.
    %send% %arg% You suddenly feel a sharp stabbing pain in your %hurt%!
    %echoaround% %arg% %arg.name% suddenly screams with pain, clenching %arg.hisher% %hurt%!
    %damage% %arg% 10
    wait 20 s
  elseif %dmg% < 26
    set msg %random.5%
    switch %msg%
      case 1
        %send% %actor% %arg.name% has suffered enough!
      break
      case 2
        %send% %actor% %arg.name% can't take it anymore!
      break
      case 3
        %send% %actor% %arg.name% is too weak!
      break
case 4
        %send% %actor% %arg.name% is still writhing in pain!
      break
      case 5
        %send% %actor% %arg.name% won't survive another pin!
      break
      default
      break
    done
  end
end

Title: Re: Trigger of the .... something
Post by: Molly on June 23, 2011, 01:35:35 am
Heh, I like that.
Can I have one.
There is someone I'd like to hurt a bit. :P
Title: Re: Trigger of the .... something
Post by: Kvetch on June 24, 2011, 07:54:26 pm
Molly witha voodoo doll.. that sent a shiver down my spine.
Here's a script that will let your mobs load with different eq when they load.  That way each "knight" can look slightly different - even if they are the same vnum.

Code: [Select]
Name: '(2700) different eq on load',  VNum: [ 2772], RNum: [  731]
Trigger Intended Assignment: Mobiles
Trigger Type: Load , Numeric Arg: 100, Arg list: None
Commands:
switch %random.3%
  case 1
    %load% obj 2750
    wear tunic
  break
  case 2
    %load% obj 2752
    wear shirt
  break
  case 3
    %load% obj 2753
    wear vest
  break
  default
    %load% obj 2752
    wear shirt
break
done
switch %random.3%
  case 1
    %load% obj 2754
    wear pants
  break
  case 2
    %load% obj 2755
    wear trousers
  break
  case 3
    %load% obj 2756
    wear breeches
  break
  default
    %load% obj 2755
    wear trousers
  break
done
switch %random.3%
  case 1
    %load% obj 2757
    wear sandals
  break
  case 2
    %load% obj 2758
    wear shoes
  break
  case 3
    %load% obj 2760
    wear boots
  break
  default
    %load% obj 2758
    wear shoes
  break
done
switch %random.2%
  case 1
%load% obj 2751
    wear cord
  break
  case 2
    %load% obj 2759
    wear belt
  break
  default
    %load% obj 2751
    wear cord
  break
done
switch %random.2%
  case 1
    %load% obj 2714
  break
  case 2
    %load% obj 2761
    wear cloth
  break
default
    %load% obj 2761
    wear cloth
  break
done
wear all
Title: Re: Trigger of the .... something
Post by: Kvetch on June 29, 2011, 09:25:58 pm
Let them there Wild Wester's Pan for gold!!
Code: [Select]
Name: 'Panning for gold',  VNum: [  700], RNum: [  276]
Trigger Intended Assignment: Rooms
Trigger Type: Command , Numeric Arg: 100, Arg list: p
Commands:
* Don't let someone spam the trigger to make money Take some movement points away every round and stop when they get to 10
if %actor.move% <= 10
  %send% %actor% You are too exhausted to continue.
  halt
end
* Fire on pan gold or abbreviations of each word
if %cmd% /= pan && %arg% /= gold
  eval heldobj %actor.eq(hold)%
  * Make sure they picked up the gold pan in room 703 and are holding it
  if %heldobj.vnum% == 717
    %send% %actor% You dip your pan into the river and scoop up some of the river bed and begin swirling it in the water.
    %echoaround% %actor% %actor.name% dips a pan into the river and begins panning for gold.
    * Take 10 movement points away, wait 3 seconds and give a 1 in 10 chance of success.
    nop %actor.move(-10)%
    wait 3 sec
    if %random.10% == 1
      %send% %actor% You find a small gold nugget in the bottom of your pan.
      %echoaround% %actor% %actor.name% picks something out of %actor.hisher% pan.
      * Give them a nugget
      %load% obj 718 %actor% inv
    else
      %send% %actor% You find nothing of value.
    end
  else
    %send% %actor% You need a pan for that.
  end
end

Title: Re: Trigger of the .... something
Post by: Kvetch on July 10, 2011, 11:49:19 am
Isn't it always a torch or a bookcase that opens up a secret door?  Well, let's just give you the script for it then.

Code: [Select]
Name: 'Pull torch - 23840',  VNum: [23840], RNum: [ 2682]
Trigger Intended Assignment: Rooms
Trigger Type: Command , Numeric Arg: 100, Arg list: pu
Commands:
if pull /= %cmd% && torch /= %arg%
  %send% %actor% The torch turns easily in your hand revealing a trap door.
  %echoaround% %actor% As %actor.name% pulls the torch a trap door swings open leading upwards.
  %door% 23840 up room 23841
  %door% 23840 up name trap door
  wait 60s
  %echo% The trap door slams itself closed as if by magic.
  %door% 23840 up purge
else
  %send% %actor% OK!
  %echoaround% %actor% You start to question the sanity of %actor.name% as they fumble about the room.
Title: Re: Trigger of the .... something
Post by: Kvetch on July 12, 2011, 07:49:05 am
Here's a way to make a magic user mob useful.  The Numeric Arg of 10, is the percent chance the script will go off while the mob is fighting (fighting being the trigger type).  So, 10% of the time while fighting this mob will cast a spell.  Though, this does go off the level of the person the magic user is fighting and only goes up to level 22, so if it was used in 4D, it'd have to be changed a bit.

Code: [Select]
Name: 'Magic User - 7009, 7200-7202',  VNum: [ 7200], RNum: [ 1050]
Trigger Intended Assignment: Mobiles
Trigger Type: Fight , Numeric Arg: 10, Arg list: None
Commands:
switch %actor.level%
  case 1
  case 2
  case 3
  break
  case 4
    dg_cast 'magic missile' %actor%
  break
  case 5
    dg_cast 'chill touch' %actor%
  break
  case 6
    dg_cast 'burning hands' %actor%
  break
  case 7
  case 8
 dg_cast 'shocking grasp' %actor%
  break
  case 9
  case 10
  case 11
    dg_cast 'lightning bolt' %actor%
  break
  case 12
    dg_cast 'color spray' %actor%
  break
  case 13
    dg_cast 'energy drain' %actor%
  break
  case 14
    dg_cast 'curse' %actor%
  break
  case 15
    dg_cast 'poison' %actor%
  break
  case 16
if %actor.align% > 0
      dg_cast 'dispel good' %actor%
    else
      dg_cast 'dispel evil' %actor%
    end
 break
  case 17
  case 18
    dg_cast 'call lightning' %actor%
  break
  case 19
  case 20
  case 21
  case 22
    dg_cast 'harm' %actor%
  break
  default
    dg_cast 'fireball' %actor%
  break
done
Title: Re: Trigger of the .... something
Post by: Kvetch on August 05, 2011, 09:39:35 am
A potion that changes every time it loads or is dropped/gotten.  Rather devious if you ask me.  Of course, it's from the mind of Once.
Code: [Select]
Name: 'Potion script.',  VNum: [16928], RNum: [  982]
Trigger Intended Assignment: Objects
Trigger Type: GetLoad, Numeric Arg: 100, Arg list: None
Commands:
eval change1 %random.86%
eval change2 %random.86%
eval change3 %random.86%
if (%change1% || %change2% || %change3%) = 31
eval change1 %random.86%
eval change2 %random.86%
eval change3 %random.86%
osetval 1 %change1%
osetval 2 %change2%
osetval 3 %change3%
endif
Title: Re: Trigger of the .... something
Post by: Kvetch on August 19, 2011, 07:10:59 pm
I thought I'd go have a bit of fun when checking out the scripts I had my sweaty little building paws on and came across this little tidbit.  Not exactly sure who created it, but I am pretty sure I took it off TBAmud.
Code: [Select]
Name: 'water balloon sploosh!',  VNum: [57196], RNum: [ 4101]
Trigger Intended Assignment: Objects
Trigger Type: Drop , Numeric Arg: 100, Arg list: None
Commands:
set room_var %actor.room%
wait 1 s
* Send a message when the bomb goes off.
%echo% The water balloon breaks open and water sprays everywhere!
* Target the first char.
set target_char %room_var.people%
* Now loop through everyone in the room and hurt them.
while %target_char%
  * Set the next target before this one perhaps dies.
  set tmp_target %target_char.next_in_room%
  * This is where the 'magic' happens
  %echoaround% %target_char% gets hit with water!
  %send% %target_char% You get hit with water!
  * Set the next target.
  set target_char %tmp_target%
  * Loop back.
done
* After we go through everyone get rid of the water balloon.
%purge% %self%
Title: Re: Trigger of the .... something
Post by: Kvetch on October 18, 2011, 05:24:13 pm
This is Mord's OLC style journal
Code: [Select]

Name: 'Journal - OLC style',  VNum: [ 4499], RNum: [  437]
Trigger Intended Assignment: Objects
Trigger Type: Command, Numeric Arg: 1, Arg list: *
Commands:
if %actor.fighting%
return 0
unset edit
halt
end
set sa %send% %actor%
set ea %echoaround% %actor%
set pageheight 30
set pagewidth 80
if !%top_line%
set top_line 0
global top_line
end
if !%state%
switch %cmd%
case edit
if %arg.car%==journal
%sa% You start editing the journal.
%ea% %actor.name% starts editing %actor.hisher% journal.
set state edit
global state
else
return 0
end
break
case l
case look
if %arg.contains(journal)%
%sa% To add or edit a journal entry type:
%sa%    edit journal
%sa% To read the journal type:
%sa%     read journal
%sa% WHILE IN THE EDITOR:
%sa% To save a journal entry, and exit the editor type:
%sa%    :s
%sa% --
%sa% To clear all lines on this page of the journal type:
%sa% :c
%sa% --
%sa% To delete a single existing line on this page of the journal type:
%sa%    :d <line number>
%sa% --
%sa% To edit a single existing line on this page of the journal type:
%sa%    :e <line number> <new line text>
%sa% --
%sa% To view the current lines on this page of the journal type:
%sa%    :l
%sa% --
%sa% NOTE: The maximum lines per page is %pageheight%
else
return 0
end
break
case read
case examine
if %arg.contains(journal)%
if %top_line%==0
%sa% Sorry, but there is nothing yet to read.
halt
end
%sa% You read the page of the journal.
%sa% ---------------------------------------------
set li 0
while %li% < %top_line%
eval show %%line[%li%]%%
%sa% %show%
eval li %li%+1
done
%sa% ---------------------------------------------
%sa% Total lines: %top_line%
else
return 0
end
break
default
return 0
break
done
elseif %state% == edit
if %cmd% == :
set command %arg.car%
set arg %arg.cdr%
switch %command%
case s
case save
set state
unset state
%sa% You save the journal entry and exit the editor.
%ea% %actor.name% saves %actor.hisher% journal entry, and stops editing.
break
case c
set li 0
while %li% < %top_line%
unset line[%li%]
eval li %li%+1
done
unset top_line
%sa% All lines from page %page% cleared.
break
case l
if %top_line%==0
%sa% No lines to see.
halt
end
set li 0
while %li% < %top_line%
eval show %%line[%li%]%%
%sa% %li%] %show%
eval li %li%+1
done
break
case d
if %top_line% == 0
%sa% There are no lines to delete!
halt
end
eval del %arg%/1
%sa% Line %del% deleted.
set li %del%
while %li% < %top_line%
eval nxt %li%+1
set nxt_lne %%line[%nxt%]%%
eval line[%li%] %nxt_lne%
eval li %li%+1
done
eval top_line %top_line%-1
break
case e
if %top_line% == 0
%sa% There are no lines to edit/update!
halt
end
eval ed %arg.car%/1
if %ed% > %top_line% || %ed% < 0
%sa% Sorry but '%ed%' isn't a valid line.
%sa% You can only edit lines 0 through to %top_line%
halt
end
%sa% Line %ed% changed.
eval line[%ed%] %arg.cdr%
break
case f
*Format needs more while loops than the mud allows to complete
if %top_line% == 0
%sa% There are no lines to format!
halt
end
set li 0
while %li% < %top_line%
eval text %text% %%line[%li%]%%
*clear the variable
set line[%li%]
*remove the global
unset line[%li%]
eval li %li%+1
done
eval top_line 0
while %text.cdr%
eval cur_line %%line[%top_line%]%%
eval len %cur_line.strlen%
eval next_len %len% + %text.car.len%
if %next_len% > %pagewidth%
eval top_line %top_line%+1
end
*if a single word is longer than the limit, just save as is
if %text.car.len% > %pagewidth%
set line[%top_line%] %text.car%
eval top_line %top_line%+1
else
set line[%top_line%] %text.car%
end
global line
done
global top_line
break
default
%sa% That (%cmd%%arg.car%) is not a valid in-editor command :s :e :d :l
break
done
else
if %top_line% >= %pageheight%
%sa% Sorry, you can't add any more lines, you already have the maximum of %pageheight%.
%sa% To write any more, save what you have and start a new page.
halt
end
set line %cmd% %arg%
if %line.strlen% > %pagewidth%
%sa% Sorry, but you can't have lines longer than %pagewidth% characters.
%sa% %line% (%line.strlen%)
halt
end
set line[%top_line%] %line%
global line[%top_line%]
%sa% %top_line%] %line%
eval top_line %top_line%+1
global top_line
end
else
return 0
end
Title: Re: Trigger of the .... something
Post by: Kvetch on October 18, 2011, 06:44:08 pm
You have to hold the journal to be able to do anything with it (took me a while to figure that out - it's been years), but after you hold it, when you look at it you get this:
To add or edit a journal entry type:
Edit journal
To read the journal type:
Read journal
WHILE IN THE EDITOR:
To save a journal entry, and exit the editor type:
:s
--
To clear all lines on this page of the journal type:
:c
--
To delete a single existing line on this page of the journal type:
:d <line number>
--
To edit a single existing line on this page of the journal type:
:e <line number> <new line text>
--
To view the current lines on this page of the journal type:
:l
--
NOTE: The maximum lines per page is 30

I tested this out and ended up with this as a test for the journal:

You read the page of the journal.
---------------------------------------------
This is to test the journal.  This is the first line.
I am continuing to test the journal.  This is the second line.
This is the final line in the journal test.
---------------------------------------------
Total lines: 3
Title: Re: Trigger of the .... something
Post by: Molly on October 19, 2011, 02:07:37 am
I don't think that you guys have fully understood the problems with setting up a quest journal.

To give a hint, I'll post a list of the questflags I get when I check a couple of our older players, who happen to be on line right now, Tamyrlin and Tor.
Each of them have 5-6 pagelengths of different questflags, and the lists keep changing, because the last quest is always on top.

Also notice the varying numbers after some of the flags. It means that there are several different flags that needs to be checked for that quest, for instance we've got several 10 step quests.

Do you feel like setting up a script for all those flags, plus possibly about 50 more, since even oldbies like Tamyrlin  haven't done every single quest in the game?

I don't.

I honestly think that even trying would be a waste of time.
For a quest journal to work, you probably should have had a totally different - and consistent - system for the quests right from the start, code-run instead of script-run.
As it is, every builder has their own system for how the flags are set, and it even changes over the years for the same builder, after they figured out a better way of doing it.

This is another case of 4D being too old and too big to be turned around with a reasonable amount of work.

The lists are too long for the buffer here too, so I'll put them in a separate post.
Title: Re: Trigger of the .... something
Post by: Molly on October 19, 2011, 02:09:49 am
Here is the examples of questflag lists for Tamyrlin, I'll have to move Tor to a separate post:

Global Variables for Tamyrlin:
                                    levitate:                     1
                                     eleusis:                     3
                                         i11:                     1
                           kito_house_access:                     1
                                     countup:                     0
                                          fd:                     0
                                          fo:                     3
                                          fm:                     3
                                   gar_anger:                     1
                                  stealthmod:                     1
                               special_bonus:                     1
                                   damagemod:                     1
                                    speedmod:                    10
                                shadowdagger:                     1
                                   reformers:                     3
                                       grail:                     1
                                  amunpriest:                     2
                      hween2009billiardsdone:                     1
                             freepirateslave:                     1
                                 portal_exit:                  1701
                                     wreaths:                     1
                        freepiratevikingdone:                     1
                                     pillage:                    10
                                    rapunzel:                     1
                                      virgin:                     1
                                  spacecadet:                     1
                     mirkheim_heartquest_ask:                      
                                     marielf:                     1
                                 unknownpoet:                     1
                                       slate:                     4
                                      lapith:                    2
                                        syme:                     1
                                    damiskos:                     1
                                    iphinone:                     1
                                    disabled:                     1
                                     wabeeto:                     2
                                    overseer:                     1

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (1/6) ]

                                      anaphe:                     2
                                anaphehealer:                     1
                                      eunuch:                     4
                                     anchusa:                     1
                                  haremwomen:                     8
                                      slunch:                     6
                                   lovenbroy:                     2
                                      heart1:                     1
                                     tombnum:                    12
                                 tombcounter:                   121
                                  thasoswife:                     1
                                      spiros:                     3
                                          ka:                     1
                                       josua:                     5
                                      priest:                     1
                                        boba:                     1
                                       adia1:                     1
                                         i10:                     1
                                          i8:                     1
                                 done_slunch:                     1
                                          i5:                     1
                                          i1:                     1
                                    heracles:                    10
                                    poonbomb:                     1
                                     yudore1:                     1
                                   esmeralda:                     2
                                 changedring:                     1
                            pirateparrotdone:                     1
                               nafula_rescue:                     1
                                     darkpit:                     1
                                      nimue1:                     1
                                     player1:                     1
                                          i4:                     1
                              duq8_completed:                     1
                              duq6_completed:                     1
                            angelicblessings:                     1
                                robindagdone:                     1
                                   robinhood:                

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (2/6) ]

     1
                                      marion:                  2431
                               isis_complete:                     1
                                   teldomash:                     1
                                     donegan:                     1
                                         666:                     1
                                 bullcatcher:                     4
                                   greencoat:                     1
                                 dragonscale:                     1
                                      dopey1:                     1
                                   paulonote:                     1
                                     ricardo:                     1
                                       elena:                     1
                                    ricardo1:                     1
                                  cristianna:                     1
                                          77:                     5
                                          66:                     1
                                          55:                     6
                                    gameshow:                     1
                                       gift6:                     1
                                  zeddletter:                     1
                                   boneplate:                     1
                                   doneboxes:                     1
                                      kahlan:                     1
                                        jack:                     1
                                  greenhorne:                     1
                                  riddlebook:                     1
                                frenchknight:                     1
                                      claire:                     1
                                     marquis:                     1
                                    bashful1:                     1
                                        zera:                     1
                                       pris1:                     1
                               quest_academy:                     1
                                 mollyremote:                     1
                                     viagros:                     1
                                     unicorn:                     1
                                   bettygolf:                     1

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (3/6) ]

                                     orsini5:                     1
                                    baronkey:                     9
                                azizi_rescue:                     1
                             bamboo_bracelet:                     1
                                   bellehelp:                     1
                          midlands_greenglow:                     1
                                 kahlan_zedd:                     1
                                 kahlan_adie:                     1
                                      toff_2:                     1
                                      nexits:                     0
                                      sexits:                     0
                                      eexits:                     3
                                      wexits:                     9
                                    imunbug1:                     1
                            done_birds_tasks:                     1
                                  wear_paint:                     1
                                     mulmoki:                     1
                                summerville2:                     1
                                     tobias1:                     1
                          percyshelley1_done:                     1
                        jekyll_antidote_done:                     1
                                 jekyll_hyde:                     1
                        burkeandhare_corpses:                     0
                                  millicent1:                     1
                                amelia_done1:                     1
                                 ripper_done:                     1
                                 reflection1:                     1
                                  reflection:                     1
                                       curly:                     1
                                circus_quest:                     1
                                     gold001:                     1
                                     lowell1:                     1
                             lowell1_rocking:                     0
                                   duq9_help:                     1
                                 q7_boyscene:                     1
                                   q13sketch:                     1
                              duq2_completed:                     1
                                  slotcredit:                

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (4/6) ]

     0
                                     elysean:                     3
                                   odysseus1:                     1
                                       ajax2:                     1
                                    personal:                     1
                                      hades6:                     1
                                 q11killserp:                     1
                                    q7nugget:                     1
                                     deadred:                     1
                                q11skingiven:                     1
                             duq11_completed:                     1
                                       aswan:                    4
                                       cache:                     1
                                angelaletter:                     1
                                      augias:                     4
                                     gicave3:                     1
                            cardinal_absolve:                     2
                                  enter_quay:                     1
                               kermapolitics:                     1
                                      dundee:                     1
                                   meatballa:                     1
                             smithnailpolish:                     1
                                    imhotep2:                     1
                                     elftoys:                     1
                                          i6:                     1
                                       botta:                     1
                                       harem:                     1
                                    lysander:                     1
                               vikingjacktar:                     1
                                  frogstatue:                     1
                           midlandsfairyring:                     1
                                     liqueur:                     1
                                  athosabbot:                     1
                                   centaurea:                     1
                                  anitabobby:                     1
                           failed_apple_bite:                     2
                                  bit_apples:                    10
                                    appleexp:                180000

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (5/6) ]

                                 apple_count:                    49
                               hween2009soul:                      
                                     hween09:                     1
                               hweendoll2009:                     1
                        hween2009kidsrescued:                     1
                                  oriondeath:                     1
                                 gojiradeath:                     1
                                   golem_num:                     1
                                      gtierr:                     4
                                     gevolve:                  1930
                                       gtier:                     4
                                       moria:                     1
                                      asking:                     1
                                  baby_steal:                     3
                             calydnosspinner:                     1
                                  cat_follow:                     1
                                      avalon:                     7
                              done_reformers:                     1
                               bridget_spoon:                     1
Title: Re: Trigger of the .... something
Post by: Molly on October 19, 2011, 02:10:27 am
And here are Tor's flags:

-------------------------------------------------------------------------------
Global Variables for Tor:
                                 warelephant:                     1
                                       aswan:                    1
                               kermapolitics:                     1
                                    hunterba:                     4
                                   skincount:                     2
                                      arthur:                     6
                                   reformers:                     6
                                     hween09:                     1
                                 apple_count:                    46
                               hween2009soul:                      
                         hween2009billiards3:                     1
                                     lowell1:                     1
                             millicent1_done:                     1
                                     mother1:                     1
                                          89:                     4
                                killedabbess:                     1
                                      clock1:                     1
                            pirateparrotdone:                     1
                                  orsini_yes:                     1
                                     orsini1:                     1
                                     wreaths:                     2
                                       lycon:                     3
                                     islands:  MollyAndMordecaiRule
                                       hades:                     5
                                  poked_hook:                     1
                                   gorget144:                     1
                                   golem_num:                     1
                                 sabatons144:                     1
                                    rapunzel:                     1
                                     orsini2:                     1
                                     donegan:                     1
                                       curly:                     1
                                       shave:                     1
                                       josua:                     4
                                   streaking:                     1
                                  fisherbaby:                     1
                                   centaurea:                     1

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (1/5) ]

                                  piratemap3:                     1
                                bunny_killer:                     1
                                     marielf:                     1
                                   paulonote:                     1
                                 rrbluebells:                     1
                             sheriff_legend2:                     1
                             sheriff_legend1:                     1
                                     golfkey:                     1
                                   ali_money:                     8
                                       pris1:                     1
                                       brskn:                     1
                                      claire:                     1
                                   gar_anger:                     1
                                     marquis:                     1
                                  greenhorne:                     1
                                        jack:                     1
                             arch_apprentice:                     1
                                     robbies:                     1
                                   hannadone:                     1
                                     wolfies:                     1
                              wolf_ear_count:                     4
                            robber_ear_count:                     1
                                       joje1:                     1
                           sheriff_drygulch1:                     1
                               quest_academy:                     1
                                     hintnum:                    69
                                       gordy:                     2
                                  traveller2:                     1
                                  traveller1:                     1
                             smithnailpolish:                     1
                                        zera:                     1
                                gerardquest1:                      
                                gerardquest2:                      
                            royal_wolfhunter:                     1
                                          55:                     1
                                          66:                     1
                                          77:                     1
                                      earnum:                

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (2/5) ]

     2
                                     player1:                     1
                                 mudschooltp:                     1
                                 appointment:                     1
                                 koboldkills:                    23
                                   koboldrep:                   961
                                   goblinrep:                   967
                                 goblinkills:                    13
                                frenchknight:                     1
                                    petstats:  goldie 92 79 0 0 7 9 0 1 1
                                  fritztask1:                     1
                                      marion:                 21034
                                 dragonscale:                     1
                                   greencoat:                     1
                                   robinhood:                     1
                                robindagdone:                     1
                                          40:                     1
                                          41:                     0
                                          42:                     0
                                          43:                     1
                                          44:                     0
                                          45:                     0
                                       adia2:                     1
                                   mountain1:                     1
                                 bullcatcher:                     1
                                summerville2:                     1
                                summerville1:                     1
                                 saberskill1:                     1
                                  yodataught:                     1
                                 saberskill2:                     1
                                        urnc:                     1
                                  riddlebook:                     1
                                  slotcredit:                     0
                                       count:                     1
                                      augias:                     1
                                       moria:                     1
                                     viagros:                     1
                                     wabeeto:                     1

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (3/5) ]

                                    overseer:                     1
                                      spiros:                     1
                             calydnosspinner:                     1
                              calydnosweaver:                     1
                                  samothrace:                     1
                                    damiskos:                     1
                                      eunuch:                     4
                                      anaphe:                     1
                                 chiossultan:                     1
                                        syme:                     1
                                  frogstatue:                     1
                                     liqueur:                     1
                                  athosabbot:                     1
                                      nimue1:                     1
                                     bandana:                      
                             lowell1_rocking:                     0
                               prisonerbroth:                     1
                                       bravo:                     9
                                   odysseus1:                     1
                                       ajax2:                     1
                                          99:                     5
                                 gauntlet144:                     1
                                azizi_rescue:                     1
                                      asking:                     1
                                       book1:                     1
                                  baronchest:                     2
                                    anne_yes:                     1
                            child_shoes_done:                      
                        burkeandhare_corpses:                     4
                           lion_house_access:                     1
                                  easter_egg:                     1
                               hween2009four:                     1
                               hween2009five:                     1
                                hween2009two:                     1
                                hween2009cue:                     1
                                hween2009one:                     1
                         hween2009billiards2:                     1
                           failed_apple_bite:                 14

[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (4/5) ]

  
                                  bit_apples:                    43
                                    appleexp:               1296000
                                generalteeth:                     1
                                  enter_quay:                     1
                                    amunplot:                     2

Title: Re: Trigger of the .... something
Post by: Kvetch on October 19, 2011, 09:26:39 pm
I completely understand the problem with all the questflags, as I stated, I've got lists of my own that look a lot like those.  But, if we gave people a journal so they could write down what they know, we wouldn't have to deal with the questflags.  At least that's my thought and at least it's some way for them to keep track of things on the game instead of papers that they're constantly losing.  Or maybe that's only me.
Title: Re: Trigger of the .... something
Post by: Molly on October 20, 2011, 01:15:24 am
OK, to be a bit more constructive, here's an idea for how a scripted journal could actually work - at least for the Quests that have a questcard.

Since each Quest would need a unique identity, it would be simplest to just use the number of the Questcard for that.
It would take a bit of an effort on the player's side, to find the number of the quest they got stuck on from a long list, but from the player's point of view that would still be relatively easy.

It would however also take a lot of research to ferret out all the correct flags from the various script files and a lot of scripting to set up the scripts, but at least it is doable.

Step 1
We'd make an object called Quest Journal, which the player can get in the Questor's Office.
The journal itself would be similar for all players, but it has a number of scripts placed on it to check for the correct questflag of whoever is using it, and provide some guidance based on that.

The command 'look journal' would provide the following info:

This journal contains a list of all the Questcards.
First you need to find the number of the quest you are looking for.
Since there are over 100 Questcards, the journal has 7 pages,
and there are 15 quests on each page.
Type 'look Index' to view the Quest numbers on each page.
Type 'look #' (for instance 'look 4') to view the Quests on each page.
*
To find out your status on a certain Quest, you need to first HOLD the Journal.
Then you have to SAY the number of the Quest.
(for instance type 'SAY 5' to check your status on The Enchanted Frogs).

The command 'look index' would give the following list:
INDEX
Page 1. Card 1-15
Page 2. Card 16-30
Page 3. Card 31-45
Page 4. Card 46-60
Page 5. Card 61-75
Page 6. Card 76-90
Page 7. Card 91-105

Then 'look 1' would produce the following result:
1.   Wanted Poster I
2.   Wanted Poster II
3.   Cyrene's lover
4.   Robber Baron's prisoners
5.   The enchanted frogs
6.   Thetis' lover
7.   The Viking Quarrel
8.   The Lady in the Lake
9.   Nimue's quest
10.  The Tower of Rapunzel
11.  The bereaved woman
12.  Chief Arapahoola's Snake Elixir     
13.  The Secret Sword
14.  Llano Estacado
15.  Exoliath's armor

They would still have to look at the actual questcards to get the detailed info on each Quest.

Step 2.

Now we need to make a script - or several scripts - for the journal, based on the questflags that the quests set on the players.

Many of the easier quests just provide some limited stats item, and don't set any questflag. They are fully repeatable, meaning that you can do them over and over again, without any restrictions at all.
And this is also the info you'd get from saying the number of these quests.

However, if they also provide tokens and/or exp, they have a flag check to give a smaller reward after the first time.
The script would check for that flag, and dependant on the result you'd get the following info:
'You haven't completed this Quest yet.'    or
'You've already done this quest, but you can repeat it for a smaller reward.'

Yet others have a check on the item you get, to stop people who haven't done the quest from using the item. But otherwise they are similar to the former category. You can repeat them to get the item, but any exp and or tokens will be a lot less after the first time, so the message should be similar to the above category.

This gives us the beginning of the script:
*
if %arg%|= 1
 if !%actor.varexists(curly)%
  %send% %actor% You haven't completed this Quest yet.
 else
  %send% %actor% You have already done this Quest, but you can repeat it for a smaller reward.
 endif
elseif %arg%|= 2
 if !%actor.varexists(donegan)%
  %send% %actor% You haven't completed this Quest yet.
 else
  %send% %actor% You have already done this Quest, but you can repeat it for a smaller reward.
 endif
elseif (%arg%|= 3) || (%arg%|= 5) || (%arg%|= 6) || (%arg%|= 7)|| (%arg%|= 8 )
  %send% %actor% You can do this Quest as many times as you like.
etc. etc.

*
Then we get to the first problem:
Some of the Questcards have more than one Quest on them.
That is the case with for instance 5. The enchanted frogs and 14. Llano Estacado.
(Llano even has 6 different quests, but 3 of them, 'The legend of the deamon' and the two 'Wanted Posters' have their own questcards).

Anyhow, this problem could be handled by adding subheadings for each Quest on the Questbook, (and possibly also on the actual Questcard, which means additional build work). So the entry for Card 14 in the Questbook would then look like this:

14. Llano Estacado
-   14A The dying man
-   14B The lost medicine pouch
-   14C Jeff and Joe

In this case you'd need to say 14A to get info on that first quest.

Also the script on the journal will obviously be very long, which means that we have to work either with function scripts, or make several different journals, possibly both.

But then we come to the real problem; The multi-step quests. Usually, but not always, these use the same flags throughout the quest.

Let's take Quest 103 'Rebellion against Arthur' as an example. It is a multi step quest that you initiate by talking to the Captain of the Guards. This sets the flag rebellion, which then will increase or decrease dependant on which mobs you talk to.
Dependent on the number on the flag, the mobs will also give different responses.

When the rebellion number reaches 10 it is replaced by the flag reformers, which in turn increases one step for each task you perform.

When the reformers flag reaches 8, you are presented a choice to help either the Rebels or the Captain, by giving an item to either of them.  Choosing the Captain sets the flag reformers 9, while choosing the Rebels sets reformers 10, and in each case you get one last task to perform.

When the last task is done, reformers flag is replaced by the flag done_reformers, which allows you to redo the quest for a smaller reward.

So here is what the script for this single quest would have to look like:


if %arg%|=103
 if %actor.varexists(done_reformers)%
  %send% %actor% You have already completed this quest, but you can repeat it for a smaller reward.
 endif
 if %actor.varexists(rebellion)%
   %send% %actor% You need to talk to more more people to collect more info about the rebellion.
 endif
 if %actor.varexists(reformers)%
  if %actor.reformers% == 1
   %send% %actor% You should go and talk to the Silk Merchant about an assignment.
  elseif %actor.reformers% == 2
   %send% %actor% The Silk Merchant is expecting you to deliver an item to incriminate Morgan le Fay.
  elseif %actor.reformers% == 3
   %send% %actor% The Silk Merchant is expecting you to bring Nicolo Orsini to him.
   %send% %actor% If you've lost the letter, talk to the merchant who'll give you a new one.
  * and so on, until we get to reformers 10
  endif
 endif
endif

And this is just one of a large number of multi-step quests...

One more thing:

Quite often the questflags of a complex Quest get messed up beyond all help. This is sometimes caused by buggy scripts, but more often by players trying to take shortcuts. Another common reason is forgetting where they were in the quest, and starting it from scratch again, which then results in double flags, that make the questmobs refuse to interact with them.

Usually the only feasible way to fix this is to just remove all the flags for that particular quest from the player file. It means they have to start all over from the beginning again, but that's usually not a big problem.

However, rather than having to ask an imm to assist with this - (which is also frustrating for the imm, who has to sift through several pages of flags to find the right one) - we could make the script do it.
The command would be 'reset #', (for instance 'reset 103'), which would make the script check for all but the end flag and then remove them.
Using the Rebellion against Arthur example, the script would be like this:


if (%speech.contains(reset)% && %speech.contains(103)%
 if %actor.varexists(rebellion)%
  rdelete rebellion %actor.id%
 endif
 if %actor.varexists(reformers)%
  rdelete reformers %actor.id%
 endif
endif
 



Title: Re: Trigger of the .... something
Post by: Kvetch on December 28, 2011, 12:57:41 pm
A new trigger!!  Let's shake that magical eightball.  Yeah, I stole it from The Builder's Academy, but Rumble makes such neat triggers.
This one is very well documented on what it does and how, I just thought it had to be here.

Name: 'Obj Command Magic Eight Ball - O47',  VNum: [    6], RNum: [    6]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 2, Arg list: shake
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
* Numeric Arg: 2 means in character's carried inventory.
* Command trigs do not work for level 33 and above.
* There are 20 possible answers that the Magic Eight Ball can give.
* Of these, nine are full positive, two are full negative, one is
* mostly positive, three are mostly negative, and five are abstentions.
*
* Check arguments if they match. /= checks abbreviations.
if ball /= %arg% || eightball /= %arg%
  * Echo text to everyone else in the room and the actor.
  %echoaround% %actor% %actor.name% shakes %self.shortdesc% vigorously.
  %send% %actor% You shake %self.shortdesc% vigorously.
  * Use a switch to choose a random response (1-20).
  switch %random.20%
    * Send the answer! %self% is the 8ball, or whatever the trig is attached to.
    * Only the actor sees the answer.
* Case is what we are trying to match. Does %random.20% == 1?
    case 1
      %send% %actor% %self.shortdesc% reveals the answer: Outlook Good
      * We are done with this case so check the next one.
    break
    case 2
      %send% %actor% %self.shortdesc% reveals the answer: Outlook Not So Good
    break
    case 3
      %send% %actor% %self.shortdesc% reveals the answer: My Reply Is No
    break
    case 4
      %send% %actor% %self.shortdesc% reveals the answer: Don't Count On It
    break
    case 5
      %send% %actor% %self.shortdesc% reveals the answer: You May Rely On It
    break
    case 6
      %send% %actor% %self.shortdesc% reveals the answer: Ask Again Later
    break
case 7
      %send% %actor% %self.shortdesc% reveals the answer: Most Likely
    break
    case 8
      %send% %actor% %self.shortdesc% reveals the answer: Cannot Predict Now
    break
    case 9
      %send% %actor% %self.shortdesc% reveals the answer: Yes
    break
    case 10
      %send% %actor% %self.shortdesc% reveals the answer: Yes, definitely
    break
    case 11
      %send% %actor% %self.shortdesc% reveals the answer: Better Not Tell You Now
    break
    case 12
      %send% %actor% %self.shortdesc% reveals the answer: It Is Certain
    break
    case 13
%send% %actor% %self.shortdesc% reveals the answer: Very Doubtful
    break
    case 14
      %send% %actor% %self.shortdesc% reveals the answer: It Is Decidedly So
    break
    case 15
      %send% %actor% %self.shortdesc% reveals the answer: Concentrate And Ask Again
    break
    case 16
      %send% %actor% %self.shortdesc% reveals the answer: Signs Point To Yes
    break
    case 17
      %send% %actor% %self.shortdesc% reveals the answer: My Sources Say No
    break
    case 18
      %send% %actor% %self.shortdesc% reveals the answer: Without A Doubt
    break
    case 19
      %send% %actor% %self.shortdesc% reveals the answer: Reply Hazy, Try Again
break
    case 20
      %send% %actor% %self.shortdesc% reveals the answer: As I See It, Yes
    break
    * Every switch should have a default. A catch-all if the cases do not match.
    default
      %send% %actor% %self.shortdesc% explodes since your question is unanswerable.
    break
    * Every switch must have a done! Just like every if needs an end!
  done
  * The actor didn't use the command shake with arg ball or eightball.
else
  * Return 0 allows the command to continue through to the MUD. The player will
  * get the Huh!?! response or the shake social if you have one.
  return 0
end

Title: Re: Trigger of the .... something
Post by: Kvetch on February 18, 2014, 12:07:35 pm
Trying to get this back up and going again - which means I need to visit TBA mud more often.  I've not checked this trigger to make sure it works in 4Dimensions, but I believe it will - I have something similar to it when I have dragon's fighting.

Name: 'dg_cast fireball',  VNum: [  104], RNum: [  104]
Trigger Intended Assignment: Mobiles
Trigger Type: Fight , Numeric Arg: 100, Arg list: None
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
* Only cast the spell every 30 seconds.
if %already_cast%
  wait 30 s
  unset already_cast
else
  dg_cast 'fireball' %actor.name%
  set already_cast 1
  * By globalling the variable it can be accessed by other triggers or when
  * this trigger fires a second time.
  global already_cast
end

I do love the fact that Rumble comments everything he does and makes it a whole lot simpler to follow.  Basically, the first time the mob casts the fireball, it sets the variable on the mob already_cast, then it will wait 30 seconds before it is able to cast it again.  If I remember right, dg_cast doesn't give any action lines when the fireball is cast so you can input what you want it to say - whether it's "The great mage Xander casts a fireball at your face" or "The big red dragon breathes a cone of fire in your direction".  I could be wrong on that though so, if using this script - or creating one like it for other spells - you should check it out and see.
Title: Re: Trigger of the .... something
Post by: Kvetch on February 18, 2014, 12:24:44 pm
Trying to make up for the fact I hadn't had any of the scripts on here for a while, so here's a second one:

Name: 'Room Entry - sneak check',  VNum: [  306], RNum: [  227]
Trigger Intended Assignment: Rooms
Trigger Type: Enter , Numeric Arg: 25, Arg list: None
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
if %actor.is_pc%
  if %actor.skill(sneak)% > 50
    %send% %actor% You walk into the room, not waking any of the clerics.
  else
    %send% %actor% Your entry into the room wakes a few of the clerics.
    %load% mob 340
  end
end

Basically any player that's practiced their sneak skill above 50 will be able to walk into the room without waking the clerics.  If your sneak skill isn't that good, well, good luck fighting them off.
Title: Re: Trigger of the .... something
Post by: Kvetch on February 19, 2014, 06:15:24 pm
Name: 'Room Drop - Dg_cast for dropping objects by cost',  VNum: [  332], RNum: [  253]
Trigger Intended Assignment: Rooms
Trigger Type: Drop , Numeric Arg: 100, Arg list: None
Commands:
%%send%% %actor% As you drop the %object.shortdesc%, a loud humming starts to come from the walls.
wait 1
eval worth %object.cost% / 100
switch %worth%
  case 0
    %send% %actor% Your offering was NOT sufficient.
    dg_cast 'magic missile' %actor%
    break
  case 1
    %send% %actor% Your offering was just sufficient.
    dg_cast 'cure light' %actor%
    dg_cast 'clot minor' %actor%
    %purge% %object%
    break
    case 2
    %send% %actor% Your offering was sufficient.
    dg_cast 'refresh' %actor%
    %purge% %object%
    break
  default
    %send% %actor% Your offering was as it must be.
    dg_cast 'invisibility' %actor%
    %purge% %object%
    break
done

** An interesting script that allows you to drop objects and the cost of the object decides what spells you'll get cast on you.  If the object doesn't have sufficient cost then you could even be harmed. **
Title: Re: Trigger of the .... something
Post by: Kvetch on February 20, 2014, 04:11:39 pm
Name: 'Mob Command - spellcasting test',  VNum: [  312], RNum: [  233]
Trigger Intended Assignment: Mobiles
Trigger Type: Command , Numeric Arg: 100, Arg list: kill
Commands:
* This command trigger will disallow anyone from trying to
* use the kill command, and will toss a magic missile at them
* for trying.
dg_cast 'magic missile' %actor%
return 0

***Interesting idea for a !kill room***
Title: Re: Trigger of the .... something
Post by: Kvetch on February 22, 2014, 09:02:57 am
Name: 'Room Command - Anti-quit',  VNum: [  314], RNum: [  235]
Trigger Intended Assignment: Rooms
Trigger Type: Command , Numeric Arg: 100, Arg list: quit
Commands:
   %send% %actor% Powerful forces keep you here.

Name: 'Obj Command - No quit',  VNum: [  315], RNum: [  236]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 3, Arg list: q
Commands:
if %cmd.mudcommand% == quit
  %send% %actor% Divine forces prevent you from doing that.
else
  return 0
end

**The previous 2 scripts basically do the same thing – don't let the player quit.  One is on the room and one is on an object.  Either way, evil. **
Title: Re: Trigger of the .... something
Post by: Kvetch on February 23, 2014, 09:58:10 am
My main reason for putting this next trigger in is to show what to do when the command you want to use is something that is already a basic command in the game.  Things like pull, push, open, throw, or, as in this script, look. 

Name: 'Room Command - Look at Painting',  VNum: [  304], RNum: [  225]
Trigger Intended Assignment: Rooms
Trigger Type: Command , Numeric Arg: 100, Arg list: l
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
if %cmd.mudcommand% == look && painting /= %arg%
  %send% %actor% As you stare at the painting the figures seem to start moving and acting out the scenes they portray.
  %echoaround% %actor% %actor.name% stares at one of the paintings. A strange look coming over %actor.hisher% face.
else
  * If it doesn't match let the command continue. Without a return 0 a player
  * will not be able to "look" at anything else.
  return 0
end


The reason to put l in the arg list instead of just * is to limit the times this script will trigger.  If you put * in the arg list, it will trigger on any word put in as a command - which is useful if you have more than one command in a script.  If you put l in the arg list, then it'll only trigger when something that starts with l is used as a command: like look, listen, etc.

The return 0 is very important at the end because otherwise the player can't look at anything else - or even just look to refresh the room description. 
Title: Re: Trigger of the .... something
Post by: Kvetch on February 23, 2014, 10:45:57 am
I found this over at TBA and thought it was useful.  We probably have the help file in 4D as well, but I'm too lazy to look right now and I know I've needed this info before.  So, for everyone else:

Text Variable Fields

   These fields pertain to any variable that contains a string of text. These
are often the variables, such as %speech%, which are provided to a trigger, but
can also be variables that have been created by the trigger, such as
%room.north%

When using field - The variable returns
 
strlen     - Returns the number of characters in the string.
trim       - Returns the string without any leading or trailing whitespace.
             This is used to trim extra spaces from the beginning or end of a
             string.
car        - Returns the first word of the string. For %text%="this is the
             string"; %text.car% will yield "this".
cdr        - Returns all but the first word of the string, trimmed. For %text%=
             "this is the string"; %text.cdr% will yield "is the string".
contains() - Used to check if a string contains the subfield text.
mudcommand - Returns the mud command the string is shorthand for. Used to make
             sure the command you react to is the one you want: For %text%="o"
             %text.mudcommand% will yield "open".
charat     - set new variable %text/var.charat(index)% i.e. set phrase testing,
             set var1 %phrase.charat(2)% now %var1% == e
Title: Re: Trigger of the .... something
Post by: Kvetch on March 01, 2014, 11:01:39 am
Name: 'Napalm bomb - 317',  VNum: [  337], RNum: [  258]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 2, Arg list: nap
Commands:
if napalm /= %cmd%
  if %actor.fighting% && !%arg%
    set arg %actor.fighting%
  end
  if !%arg%
    %send% %actor% Throw it at Who?
    halt
  end
  if %arg.room% != %actor.room%
    %send% %actor% Throw it at who?
    halt
  end
  %send% %actor% You throw the napalm at %arg.name%, it strikes %arg.himher% and shatters, exploding into a ball of fire consuming %arg.himher% completely.
  %echoaround% %actor% %actor.name% throws the napalm at %arg.name%. It shatters and explodes into a ball of fire consuming %arg.himher%.
%asound% A large explosion is heard close by.
  set stunned %arg.hitp%
  %damage% %arg% %stunned%
  wait 5 sec
  %echoaround% %arg% %arg.name% collapses to the ground as the flames die down. %arg.heshe% seems to still be alive, but barely.
End

** I found this script interesting for a couple of reasons.  First, the ability to set an arg when it isn't explicitly given and the fact you can find out the himher on that arg.  Also, who doesn't like a Napalm bomb? **
Title: Re: Trigger of the .... something
Post by: Kvetch on March 01, 2014, 11:08:30 am
Name: 'Mob Act - 98 Teleporter Give',  VNum: [  398], RNum: [  265]
Trigger Intended Assignment: Mobiles
Trigger Type: Act , Numeric Arg: 0, Arg list: has entered the game.
Commands:
if !(%actor.inventory(82)%)
  wait 1s
  say You are not prepared to travel these realms to their fullest.
  wait 1s
  say Maybe I can help you.
  %load% obj 82
  give teleporter %actor.name%
*could actor carry the weight?
  if !%actor.inventory(82)%
  drop teleporter
  end
  wait 2s
  say With this you may teleport to areas that may not be accessible in
any other way.
  wait 2 sec
  say HELP AREAS
end

** I chose this script because I've always wondered what an ACT script actually was – since there never seems to be much detail behind any of them anywhere.  Looking at the Arg list, I can then assume that this script reacts to any time it sees “has entered the game”
Title: Re: Trigger of the .... something
Post by: Kvetch on March 03, 2014, 08:02:35 pm
Just a short trigger to keep this up as often as possible.

Name: 'Mob Greet direction',  VNum: [  302], RNum: [  223]
Trigger Intended Assignment: Mobiles
Trigger Type: Greet , Numeric Arg: 20, Arg list: None
Commands:
* By Rumble of The Builder Academy    tbamud.com 9091
if %actor.is_pc%
  wait 1 sec
  if %direction% == none
    * if the character popped in (word of recall) this will be hit
    say Where did YOU come from, %actor.name%?
  else
    say Hello, %actor.name%, how are things to the %direction%?
  end
end
Title: Re: Trigger of the .... something
Post by: Kvetch on March 06, 2014, 07:18:06 pm
Name: 'Panning for gold',  VNum: [  700], RNum: [  280]
Trigger Intended Assignment: Rooms
Trigger Type: Command , Numeric Arg: 100, Arg list: p
Commands:
* Don't let someone spam the trigger to make money Take some movement points away every round and stop when they get to 10
if %actor.move% <= 10
  %send% %actor% You are too exhausted to continue.
  halt
end
* Fire on pan gold or abbreviations of each word
if %cmd% /= pan && %arg% /= gold
  eval heldobj %actor.eq(hold)%
  * Make sure they picked up the gold pan in room 703 and are holding it
  if %heldobj.vnum% == 717
    %send% %actor% You dip your pan into the river and scoop up some of the river bed and begin swirling it in the water.
    %echoaround% %actor% %actor.name% dips a pan into the river and begins panning for gold.
    * Take 10 movement points away, wait 3 seconds and give a 1 in 10 chance of success.
    nop %actor.move(-10)%
    wait 3 sec
    if %random.10% == 1
      %send% %actor% You find a small gold nugget in the bottom of your pan.
      %echoaround% %actor% %actor.name% picks something out of %actor.hisher% pan.
      * Give them a nugget
      %load% obj 718 %actor% inv
    else
      %send% %actor% You find nothing of value.
    end
  else
    %send% %actor% You need a pan for that.
  end
end

** This would be an interesting script for an area in the Old West – if we don't already have it **
Title: Re: Trigger of the .... something
Post by: Molly on March 07, 2014, 02:04:01 am
** This would be an interesting script for an area in the Old West – if we don't already have it **

Well, we do, of course. Who said we didn't have pirates - I mean everything? :)

There is goldpanning in one of the Sutter zones, I forgot which one.
Probably set up in a different way, but still goldpanning.
Title: Re: Trigger of the .... something
Post by: Molly on March 07, 2014, 02:14:26 am
Here it is:
(There is a mob somewhere to teach the subskill softmining, of course)

Name: 'dip pan water',  VNum: [30973], RNum: [ 6335]
Trigger Intended Assignment: Rooms
Trigger Type: Command, Numeric Arg: 100, Arg list: dip
Commands:
if !%actor.is_pc%
  halt
end
set sa %send% %actor%
set se %echoaround% %actor%
set object %actor.inventory(30911)%
if !%object%
  %sa% With What??!?
  halt
end
if (!%actor.subskill(softmining)%)
  %sa% You don't know how to do that!
  halt
end
if %object.vnum(30911)%
  if %actor.varexists(ilana_muffs)%
    wait 5s
    %sa% You dip a tin pan into the water, scraping it along the bottom of the bed.
    wait 5s
    %se% %actor.name% dips a tin pan into the water, scraping it along the bottom of the bed.
    wait 5s
    %sa% You begin to swish the pan as Old Jack demonstrated, slopping some water over the sides.
    wait 5s
    if (%actor.subskill(softmining)% >= %random.700%)
      %sa% Pretty soon, all that remains is a bit of silt and a few pieces of shiny flakes on the bottom of the pan.
      wait 2s
      %force% %actor% whistle
      %load% obj 30992 %actor%
      eval am (%actor.level%*(%actor.subskill(softmining)%+1500+%random.200%))
      nop %actor.exp(%am%)%
      wait 1s
      %sa% You've successfully collected a few flakes of an undetermined substance!
    else
      %sa% Pretty soon, all that remains is a bit of silt on the bottom of the pan.
      wait 2s
      %force% %actor% frown
      wait 1s
      %sa% You look and look in the bottom of the pan, but nary a fleck of gold can be seen!
      wait 2s
      %sa% You were unsuccessful! Try again!
    end
  else
    %sa% You don't know what you are doing!
  end
else
  %sa% You can't do it with that!
end
Title: Re: Trigger of the .... something
Post by: Kvetch on March 31, 2014, 08:48:40 am
It has been a while since I posted so, here's another one.  I grabbed it a little too late for Valentines day, but it would have rocked if I'd seen it earlier.  Maybe next year.  Hope I haven't posted this yet.  I'm too lazy to go through all the old posts to see.

Name: 'Eat, look, read, candy',  VNum: [ 1309], RNum: [  382]
Trigger Intended Assignment: Objects
Trigger Type: Command , Numeric Arg: 2, Arg list: *
Commands:
if look /= %cmd.mudcommand% && heart /= %arg% && %arg% || read /= %cmd.mudcommand% && heart /= %arg% && %arg% || read /= %cmd.mudcommand% && candy /= %arg% && %arg% || look /= %cmd.mudcommand% && candy /= %arg% && %arg%
*
eval color %random.3%
set col[1] \
set col[2] \
set col[3] \
*
eval colors %%col[%color%]%%
*
eval heart %random.15%
set love[1] Be Mine
set love[2] I Love You
set love[3] I Wuv You
set love[4] Kiss Me
set love[5] Hug Me
set love[6] Be My Valentine
set love[7] Will You Be Mine
set love[8] You Are The Only One For Me
set love[9] I'm yours
set love[10] You're Special To Me
set love[11] I Really Like You
set love[12] I Luv U
set love[13] U R Mine
set love[14] With All My Heart
set love[15] Cutie Pie
eval candy %%love[%heart%]%%
*
%send% %actor% Written on the candy is:
%send% %actor% %colors% %candy% \
*
elseif eat /= %cmd.mudcommand% && heart /= %arg% && %arg% ||  eat /= %cmd.mudcommand% && candy /= %arg% && %arg%
*
eval message %random.10%
set word[1] It warms the cockles of your heart!
set word[2] It tastes wonderful!
set word[3] It melts in your mouth.
set word[4] It slowly disolves in your mouth.
set word[5] It tastes sweet and a little chalky.
set word[6] Mmmmm!
set word[7] You can feel the love!
set word[8] You feel warmer already!
set word[9] Mmm hearty goodness!
set word[10] Sweet like candy!
eval msg %%word[%message%]%%
*
%send% %actor% You eat %self.shortdesc%.
%echoaround% %actor% %actor.name% eats %self.shortdesc%.
%send% %actor% %msg%
%purge% self
*
else
return 0
end

Title: Re: Trigger of the .... something
Post by: Calypso on March 31, 2014, 09:54:13 am
I may snag this and work on it in bp soon so it is ready when we need it next time. Thanks for the great idea!! :)
Title: Re: Trigger of the .... something
Post by: erwin on June 23, 2014, 10:09:26 pm
Trigger of the Day:

A sliding puzzle, which can be modified for any m*n grid, and for any tile description. It also has a visually impaired toggle. I think this is interesting because it:

1. shows how to extract the first and second words the player types after entering a command and
2. shows what %%var%% and %%%var%%% do

Set up: Here's (part of) what the player sees when he looks at the object.

"puzzle board" - See the current layout of the board
"puzzle move up" - Move a tile up into the empty space.
"puzzle move down" - Move a tile down into the empty space.
"puzzle move left" - Move a tile left into the empty space.
"puzzle move right" - Move a tile right into the empty space.
"puzzle rules" - See the rules of this puzzle.
"puzzle toggle" - Toggle for visually impaired.

and below is the trigger! If anyone has any suggestions on how to improve this, it's much appreciated :)

Code: [Select]
Trigger Intended Assignment: Objects
Trigger Type: Command, Numeric Arg: 3, Arg list: puzzle
Commands:

extract firstphrase 1 %arg%
extract secondphrase 2 %arg%

if !%coordinatex%
  set coordinatex 4
  remote coordinatex %self.id%
endif

if !%coordinatey%
  set coordinatey 4
  remote coordinatey %self.id%
endif

if !%Cord11%
  set Cord11 01
  remote Cord11 %self.id%
endif

if !%Cord12%
  set Cord12 02
  remote Cord12 %self.id%
endif

if !%Cord13%
  set Cord13 03
  remote Cord13 %self.id%
endif

if !%Cord14%
  set Cord14 04
  remote Cord14 %self.id%
endif

if !%Cord21%
  set Cord21 05
  remote Cord21 %self.id%
endif

if !%Cord22%
  set Cord22 06
  remote Cord22 %self.id%
endif

if !%Cord23%
  set Cord23 07
  remote Cord23 %self.id%
endif

if !%Cord24%
  set Cord24 08
  remote Cord24 %self.id%
endif

if !%Cord31%
  set Cord31 09
  remote Cord31 %self.id%
endif

if !%Cord32%
  set Cord32 10
  remote Cord32 %self.id%
endif

if !%Cord33%
  set Cord33 11
  remote Cord33 %self.id%
endif

if !%Cord34%
  set Cord34 12
  remote Cord34 %self.id%
endif

if !%Cord41%
  set Cord41 13
  remote Cord41 %self.id%
endif

if !%Cord42%
  set Cord42 14
  remote Cord42 %self.id%
endif

if !%Cord43%
  set Cord43 15
  remote Cord43 %self.id%
endif

if !%Cord44%
  set Cord44 EE
  remote Cord44 %self.id%
endif

if %firstphrase% == toggle && !%secondphrase%

  if !%visimp% || %visimp% == 0
    set visimp 1
    %send% %actor% You are toggling this puzzle to cater to the visually impaired.
    remote visimp %self.id%
  elseif %visimp% == 1
    set visimp 0
    %send% %actor% You are toggling this puzzle to cater to the non visually impaired.
    remote visimp %self.id%
  endif

elseif %firstphrase% == rules && !%secondphrase%
  %send% %actor% This is a sliding puzzle game, and you want to get the following layout in the end.
  if !%visimp% || %visimp% == 0
    %send% %actor% -------------------------
    %send% %actor% |     |     |     |     |
    %send% %actor% | 01  | 02  | 03  | 04  |
    %send% %actor% |     |     |     |     |
    %send% %actor% -------------------------
    %send% %actor% |     |     |     |     |
    %send% %actor% | 05  | 06  | 07  | 08  |
    %send% %actor% |     |     |     |     |
    %send% %actor% -------------------------
    %send% %actor% |     |     |     |     |
    %send% %actor% | 09  | 10  | 11  | 12  |
    %send% %actor% |     |     |     |     |
    %send% %actor% -------------------------
    %send% %actor% |     |     |     |     |
    %send% %actor% | 13  | 14  | 15  | EE  |
    %send% %actor% |     |     |     |     |
    %send% %actor% -------------------------
    %send% %actor%
    %send% %actor% EE denotes the empty space.
  elseif %visimp% == 1
    %send% %actor% 01, 02, 03, 04
    %send% %actor% 05, 06, 07, 08
    %send% %actor% 09, 10, 11, 12
    %send% %actor% 13, 14, 15, EE
    %send% %actor%
    %send% %actor% EE denotes the empty space.
  endif

elseif %firstphrase% == board && !%secondphrase%
  %send% %actor% This is the current board layout.
  if !%visimp% || %visimp% == 0
    set border -------------------------
    set inbet |     |     |     |     |
    %send% %actor% %border%
    %send% %actor% %inbet%
    %send% %actor% | %Cord11%  | %Cord12%  | %Cord13%  | %Cord14%  |
    %send% %actor% %inbet%
    %send% %actor% %border%
    %send% %actor% %inbet%
    %send% %actor% | %Cord21%  | %Cord22%  | %Cord23%  | %Cord24%  |
    %send% %actor% %inbet%
    %send% %actor% %border%
    %send% %actor% %inbet%
    %send% %actor% | %Cord31%  | %Cord32%  | %Cord33%  | %Cord34%  |
    %send% %actor% %inbet%
    %send% %actor% %border%
    %send% %actor% %inbet%
    %send% %actor% | %Cord41%  | %Cord42%  | %Cord43%  | %Cord44%  |
    %send% %actor% %inbet%
    %send% %actor% %border%
  elseif %visimp% == 1
    %send% %actor% %Cord11%, %Cord12%, %Cord13%, %Cord14%
    %send% %actor% %Cord21%, %Cord22%, %Cord23%, %Cord24%
    %send% %actor% %Cord31%, %Cord32%, %Cord33%, %Cord34%
    %send% %actor% %Cord41%, %Cord42%, %Cord43%, %Cord44%
  endif

elseif %firstphrase% == move

  if %secondphrase% == down
    *let's check if we can move anything down into the empty square
    if %coordinatex% == 1
      %send% %actor% You cannot move anything down into the empty space!
    else
      *let's see what tile should be moved down
      eval newx %coordinatex% -1
      eval tiletomove Cord%newx%%coordinatey%
    endif

  elseif %secondphrase% == up
    *let's check if we can move anything up into the empty square
    if %coordinatex% == 4
      %send% %actor% You cannot move anything up into the empty space!
    else
      eval newx %coordinatex% + 1
      eval tiletomove Cord%newx%%coordinatey%
    endif

  elseif %secondphrase% == right
    *let's check if we can move anything right into the empty square
    if %coordinatey% == 1
      %send% %actor% You cannot move anything right into the empty space!
    else
      eval newy %coordinatey% - 1
      eval tiletomove Cord%coordinatex%%newy%
    endif

  elseif %secondphrase% == left
    *let's check if we can move anything left into the empty square
    if %coordinatey% == 4
      %send% %actor% You cannot move anything left into the empty space!
    else
      eval newy %coordinatey% + 1
      eval tiletomove Cord%coordinatex%%newy%
    endif

  else
    %send% %actor% This is not a valid move command. As a reminder, the board looks like this.
  endif

  *Check if previously we had a valid move. Means variable %tiletomove% must exist

  if %tiletomove%
    eval emptytile Cord%coordinatex%%coordinatey%
    eval tmp1 %%%tiletomove%%%
    eval tmp2 %%tiletomove%%
    eval tmp3 %%emptytile%%

    *update coordinates respectively
    if %newx%
      set coordinatex %newx%
    elseif %newy%
      set coordinatey %newy%
    endif

    set %tmp2% EE
    set %tmp3% %tmp1%

    remote coordinatex %self.id%
    remote coordinatey %self.id%

    *Here, we are actually updating the variable cordXY
    remote %tmp2% %self.id%
    remote %tmp3% %self.id%
  endif

  if !%visimp% || %visimp% == 0
    set border -------------------------
    set inbet |     |     |     |     |
    %send% %actor% %border%
    %send% %actor% %inbet%
    %send% %actor% | %Cord11%  | %Cord12%  | %Cord13%  | %Cord14%  |
    %send% %actor% %inbet%
    %send% %actor% %border%
    %send% %actor% %inbet%
    %send% %actor% | %Cord21%  | %Cord22%  | %Cord23%  | %Cord24%  |
    %send% %actor% %inbet%
    %send% %actor% %border%
    %send% %actor% %inbet%
    %send% %actor% | %Cord31%  | %Cord32%  | %Cord33%  | %Cord34%  |
    %send% %actor% %inbet%
    %send% %actor% %border%
    %send% %actor% %inbet%
    %send% %actor% | %Cord41%  | %Cord42%  | %Cord43%  | %Cord44%  |
    %send% %actor% %inbet%
    %send% %actor% %border%
  elseif %visimp% == 1
    %send% %actor% %Cord11%, %Cord12%, %Cord13%, %Cord14%
    %send% %actor% %Cord21%, %Cord22%, %Cord23%, %Cord24%
    %send% %actor% %Cord31%, %Cord32%, %Cord33%, %Cord34%
    %send% %actor% %Cord41%, %Cord42%, %Cord43%, %Cord44%
  endif
else
  %send% %actor% This is not a valid puzzle command.
  return 1
end
Title: Trigger of the .... something
Post by: erwin on July 02, 2014, 12:07:47 pm
This will be a post out of three posts, introducing functions, in order to achieve the goal of replacing characters of a sentence.

For example, given a string (of words, not sausages):

It was the best of times, it was the worst of times

and you want to replace the second letter of the tenth word by a u, eg to

It was the best of times, it was the wurst of times

how can you do so?

While this doesn't seem very useful from the sound of it, inventive scripters can script games (eg a game of battleship), by doing something like:

set grid .......... .......... .......... .......... .......... .......... .......... .......... .......... ..........

and if they want to fire at a position, and denote the fired position as an *, then the challenge is to convert 

.......... .......... .......... .......... .......... .......... .......... .......... .......... ..........

into

.......... .......... .......... .......... .......... .......... ...*...... .......... .......... ..........

for example.

Also, the best part about functions is that they can be reused again and again, and they just need to be called in the script. One idea is to have a zone full of (useful) functions, so all builders can call them (without taking up trigger vnums in their own zone), plus it gives some kind of signal to coders :P about which functions are useful to be added into the dg code.

As an aside, functions are very useful for doing the same things over and over again. If you have a main quest in a zone where the quest reward is only given when six side quests are done, you don't want to write the same script six times - to check if the main quest reward should be given when any of the six side quests have been completed.

So today's trigger of the day will focus on counting the number of "objects / words / items" in a variable. We will use this function in the next two posts to achieve our goal.

Input: findnumwords
Output: num

findnumwords will be the variable we are interested in finding the number of words of, and num the number of words.

Here is the function.

Code: [Select]
Name: 'function to check num words',  VNum: [33785], RNum: [ 2182]
Trigger Intended Assignment: Objects
Trigger Type: FUNCTION, Numeric Arg: 100, Arg list: None
Commands:
if !%findnumwords%
  %echo% We do not have any inputs!
  %echo% The input variable should be named findnumwords
  halt
endif
set stopping_criteria 1
set start 1
while %stopping_criteria% != stop
  extract num %start% %findnumwords%
  if !%num%
    eval num %start% - 1
    set stopping_criteria stop
  endif
  eval start %start% + 1
done

So to use the function, we just need to do this:

Code: [Select]
set findnumwords I want to be a pirate
function 33785
%echo% We have %num% of words

Of course, we can always do

Code: [Select]
set findnumwords %actor.thisvariable%
etc

The next post will be functions on replacing words in a sentence, and replacing characters in a word, before building up to the final post!
Title: Re: Trigger of the .... something
Post by: erwin on July 03, 2014, 11:17:59 am
Here is part 2, and it will be on function triggers to replace a word in a sentence, as well as to replace a character in a word.

Both function triggers are similar in execution, so hopefully it counts as one trigger of the day.

Some possibilities of these triggers (along with some modifications):

1. Make a mob rhyme with you (could replace / add on characters to the last word you say)
2. Dynamic passwords to go through a zone: (eg the second word of the password is always the day of the week)
3. Script a lot of (multi-player) games which rely on grids.

Anyway, here are these triggers!

The first trigger replaces a word in a sentence, as shown below.

Code: [Select]
Name: 'Replace word in sentence',  VNum: [33783], RNum: [ 2181]
Trigger Intended Assignment: Objects
Trigger Type: FUNCTION, Numeric Arg: 100, Arg list: None
Commands:
if !%sentence%
  %echo% Need a sentence to replace words.
  halt
endif

If !%word%
  %echo% Need a word to replace a word in the sentence.
  halt
endif

if !%replacenum%
  %echo% Need the position of the word to replace
  halt
endif

*First, find out how long the sentence is
*Recall our previous function took in the input findnumwords

set findnumwords %sentence%
function 33785

*We now have %num%, which is the length of the sentence
*Now we build up the sentence from the original sentence

if %replacenum% > 1
  extract newsentence 1 %sentence%
  set h 2
  while %h% < %replacenum%
    extract buildsentence %h% %sentence%
    set newsentence %newsentence% %buildsentence%
    eval h %h% + 1
  done
  set newsentence %newsentence% %word%
  eval h %h% + 1
elseif %replacenum% == 1
  set newsentence %word%
  set h 2
endif
while %h% <= %num%
  extract buildsentence %h% %sentence%
  set newsentence %newsentence% %buildsentence%
  eval h %h% + 1
done

This trigger takes in the inputs: sentence, replacenum, word.

sentence - Should be set to the sentence you are looking at
replacenum - The position number of the word you want to replace
word - The new word

The trigger gives the output: newsentence

So for example, suppose you have the phrase:

I am at the bottom of the world

and you want to replace the fifth word with the word top.

Then, you would do something like:

Code: [Select]
set sentence I am at the bottom of the world.
set word top
set replacenum 5
function 33783
%echo% %newsentence%

and you get your new sentence to be: I am at the top of the world

The second trigger replaces a character in a word.

Code: [Select]
Name: 'Replace character in word',  VNum: [33782], RNum: [ 2180]
Trigger Intended Assignment: Objects
Trigger Type: FUNCTION, Numeric Arg: 100, Arg list: None
Commands:

if !%word%
  %echo% Need a word to replace characters.
  halt
endif

If !%character%
  %echo% Need a character to replace a character in the sentence.
  halt
endif

if !%replacenum%
  %echo% Need the position of the word to replace
  halt
endif


set len %word.strlen%

*We now have %len%, which is the length of the word
*Now we build up the word from the original word

if %replacenum% > 1
  dg_letter newword 1 %word%
  set h 2
  while %h% < %replacenum%
    dg_letter buildword %h% %word%
    set newword %newword%%buildword%
    eval h %h% + 1
  done
  set newword %newword%%character%
  eval h %h% + 1
elseif %replacenum% == 1
  set newword %character%
  set h 2
endif
while %h% <= %len%
  dg_letter buildword %h% %word%
  set newword %newword%%buildword%
  eval h %h% + 1
done

This trigger takes in the following inputs: word, replacenum, character.

word - Should be set to the word you are looking at
replacenum - The position number of the character you want to replace
character - The new character

The trigger gives the output: newword

So for example, if you have the word

Candyland

and want something a bit more R rated, you could do the following:

Code: [Select]
set word Candyland
set character R
set replacenum 1
function 33782
%echo% newword
Title: Re: Trigger of the .... something
Post by: Kvetch on August 03, 2014, 01:03:21 pm
I got this script from a visitor from TBA that was asked to help out on another zone.  I've left in all of her comments on it even before the script because it all sounded like valuable information when dealing with the script.  This should be able to be adapted for any cooking anyone wants to do.  So, from Parnassus:

I've tried this on TBA and it seems to work.  First, you need to decide where to put it.  If you put it on a room, such as a kitchen,  or a mob, such as a cooking teacher, Numeric Arg is 100.  If you put it on something like a pot or a skillet, Numeric Arg is 2 (in inventory)  or a heatsource, such as a stove should be 4 (in the same room).

Next, set the vnums.  Each ingredient and each food needs a vnum.  On TBA, I just used various foods that seemed similar, just for experimenting with.

If it works the way you wanted it, create the items.  I've set up recipes for various dishes with an explanation of the bonus of each dish.  Wisdom is missing since I couldn't think of anything but the dishes I have probably don't seem connected either, such as Mario's mushrooms for a constitutional boost.  I'd have liked a nice dish of brains but I don't think that's an ingredient on 4d.  Of course though, the trigger is extremely expandable by inserting new ingredients in one section and recipes in two sections.

If you need any changes, let me know.  If it isn't what you were looking for at all, let me know that too.  I can think of places to use it so it won't be wasted if you can't use it.  One change might be to add a list of missing ingredients.  I was thinking of that but it would add about 3 to 5 lines to each recipe as well as another 5 to 10 lines in the error section.

If you try to /fi this, it won't format.  I think this is because of the mix of ifs/ends and switches/breaks.  I've tried to pre-format it in sections for easier reading.

1) Name         : Cooking
2) Intended for : Objects
3) Trigger types: Command
4) Numeric Arg  : 2
5) Arguments    : cook
6) Commands:
* Prep work - ingredients
* Insert proper vnums here.
set ing_almonds
set ing_cocoa
set ing_carrots
set ing_cheese
set ing_eggs
set ing_fish
set ing_flour
set ing_garlic
set ing_lemon
set ing_mushroom
set ing_potato
set ing_spinach
set ing_sugar
* Prep work - finished dishes
*Insert proper vnums here.
set dish_quiche
set dish_pancake
set dish_fish
set dish_mushroom
set dish_cake
set dish_fritter
* Prep work - recipes
set quiche _spinach _quiche
if %quiche.contains(_%arg%)%
  set food spinach quiche
  set quan a
end
set pancake _potato _pancakes
if %pancake.contains(_%arg%)%
  set food potato pancakes
  set quan some
end
set fish _fish _almondine
if %fish.contains(_%arg%)%
  set food fish almondine
  set quan some
end
set mushrooms _stuffed _mushrooms
if %mushrooms.contains(_%arg%)%
  set food stuffed mushrooms
  set quan some
end
set cake _chocolate _cake
if %cake.contains(_%arg%)%
  set food chocolate cake
  set quan a
end
set fritter _carrot _fritters
if %fritter.contains(_%arg%)%
  set food carrot fritters
  set quan some
end
** Start of Heatsource check
* If the trigger is on a room or a heatsource, delete this section.
* If the trigger is on an object, verify numeric arg.
* Numeric Arg 2 is in inventory, such as a pot.  Numeric Arg 4 is in the same room, such as a stove.
  set heatsource 0
  eval inroom %self.room%
  eval obj %inroom.contents%
  * find the first object in the room
  while %obj%
    set next_obj %obj.next_in_list%
    set objlist %obj.name%
  if %objlist.contains(fire)% || %objlist.contains(stove)% || %objlist.contains(oven)%
  eval heatsource heatsource + 1
  end
  * find the next object for the while to loop
  set obj %next_obj%
  done
if %heatsource% == 0
%send% %actor% You can't find any heat to cook with.
halt
end
** End of Heatsource check
switch %food%
  case spinach quiche
    * Strength - spinach quiche - eggs spinach cheese
    set ing1 %ing_cheese%
    set ing2 %ing_eggs%
    set ing3 %ing_spinach%
    set dishvnum %dish_quiche%
  break
  case potato pancakes
    * Dexterity - potato pancakes - potato eggs flour
    set ing1 %ing_eggs%
    set ing2 %ing_flour%
    set ing3 %ing_potato%
    set dishvnum %dish_pancake%
  break
  case fish almondine
    * Intelligence - fish almondine - fish almonds lemon
    set ing1 %ing_almonds%
    set ing2 %ing_fish%
    set ing3 %ing_lemon%
    set dishvnum %dish_fish%
  break
  case stuffed mushrooms
    * Constitution - stuffed mushrooms - mushrooms garlic cheese
    set ing1 %ing_cheese%
    set ing2 %ing_garlic%
    set ing3 %ing_mushroom%
    set dishvnum %dish_mushroom%
  break
  case chocolate cake
    * Charisma -  chocolate cake - flour sugar cocao
    set ing1 %ing_cocoa%
    set ing2 %ing_flour%
    set ing3 %ing_sugar%
    set dishvnum %dish_cake%
  break
  case carrot fritters
    * Night vision - carrot fritters - carrots flour eggs
    set ing1 %ing_carrots%
    set ing2 %ing_eggs%
    set ing3 %ing_flour%
    set dishvnum %dish_fritter%
  break
  default
    %send% %actor% You don't seem to know how to cook that.
    halt
  break
done
if %actor.has_item(%ing1%)% && %actor.has_item(%ing2%)% && %actor.has_item(%ing3%)%
  %send% %actor% You cook up %quan% %food%.
  %echoaround% %actor% %actor.name% cooks up %quan% %food%.
  %purge% %actor.inventory(%ing1%)%
  %purge% %actor.inventory(%ing2%)%
  %purge% %actor.inventory(%ing3%)%
  %load% obj %ing1%
  %load% obj %ing2%
  %load% obj %ing3%
  %load% obj %dishvnum% %actor% inv
else
  %send% %actor% You don't have what you need to make %quan% %food%.
  halt
end
Title: Re: Trigger of the .... something
Post by: erwin on December 28, 2014, 08:28:09 pm
A nice way of repeating (mostly) similar stuff. For example, suppose you have a zone that echoes similar stuff like:

The flight to <random country> leaves at Gate <random number>. You could do something like switching cases. But a cooler way would be to do something like

Code: [Select]
set vec1 Heathrow Moscow Edinburgh Frankfurt Dublin Paris Newark LAX Minneapolis Georgia Hell Amsterdam Sydney Salzburg Bratislava Japan Toronto
eval randnum1 %random.20%
eval randnum2 %random.17%
extract place %randnum2% %vec1%  *we're extracting a random city from the above vector
%echo% The flight to %place% leaves from Gate %randnum2%.
Tada! And you don't need to create 17 different cases for a minor change!
Title: Re: Trigger of the .... something
Post by: erwin 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

Title: Re: Trigger of the .... something
Post by: erwin on February 09, 2017, 10:44:08 pm
New Trigger Of The Day: Generic Craps Game.

You roll two dice. If you roll a 2, 3, or a 12, you lose. If you roll a 7 or a 11, you win. Otherwise, you keep on rolling the dice.

If you roll a 7, you lose. If you match the first number you rolled, you win.

Who knows? In some alternate universe, this might be a first homework question for an intro programming course. Or not.

Code: [Select]
* Trigger 59010

* waybread, potpie, grapes, lollipop, cookies and cream
set prize_vec 10 3009 6346 34080 1758
%send% %actor% You hand over some gold coins to the dealer.
nop %actor.gold(-10000)%
wait 2 s
%send% %actor% The dealer says, 'Right, let's play a game.'
wait 2 s
%send% %actor% The dealer takes out a pair of dice, and he throws them up in the air!
wait 2 s
%send% %actor% The dice come tumbling down...
wait 2 s
set d1 %random.6%
set d2 %random.6%
%send% %actor% The first die showed a {cR%d1%{cx!
wait 2 s
%send% %actor% The second die showed a {cR%d2%{cx!
eval first_roll %d1% + %d2%
wait 2 s
%send% %actor% The total sum is {cY%first_roll%{cx!
wait 2 s
if %first_roll% == 7 || %first_roll% == 11
  %send% %actor% You win! YAY!
  wait 2 s
  %send% %actor% The dealer gives you a prize!
  set pnum %random.5%
  %load% obj %prize_vec.wordat(%pnum%)% %actor%
  wait 2 s
  %send% %actor% Do you want to play again?
elseif %first_roll% == 2 || %first_roll% == 3 || %first_roll% == 12
  %send% %actor% You lose! Bummer!
  wait 2 s
  %send% %actor% The dealer smirks and says: Better luck next time, pal!
else
  * roll until you get back your previous roll
  set this_roll 0
  %send% %actor% The dealer says, 'Since the sum of the dice was not a 2,3,7,11, or 12, I'll roll them again!'
  wait 2 s
  %send% %actor% He continues, 'You will win if I roll back a %first_roll%, and lose if I roll a 7.
  wait 2 s
  %send% %actor% Otherwise, I'll keep on rolling the dice.'
  set counter 1
  while %counter% < 2
  *while (%this_roll% != 7 && %this_roll% != %first_roll%)
    wait 2 s
    %send% %actor% The dealer takes out a pair of dice, and he throws them up in the air!
    wait 2 s
    %send% %actor% The dice come tumbling down...
    wait 2 s
    set d1 %random.6%
    set d2 %random.6%
    %send% %actor% The first die showed a {cR%d1%{cx!
    wait 2 s
    %send% %actor% The second die showed a {cR%d2%{cx!
    eval this_roll %d1% + %d2%
    wait 2 s
    %send% %actor% The total sum is {cY%this_roll%{cx!
    wait 2s
    * some weird stuff about multi arguments for while
    if %this_roll% == %first_roll%
      set counter 10
    elseif %this_roll% == 7
      set counter 10
    else
      %send% %actor% The dealer says, 'Gotta roll again!'
    endif
  done
  if %this_roll% == 7
    %send% %actor% You lose! Bummer!
    wait 2 s
    %send% %actor% The dealer smirks and says: Better luck next time, pal!   
  else
    %send% %actor% You managed to get back the value of the first roll!
    wait 2 s
    %send% %actor% You win! YAY!
    wait 2 s
    %send% %actor% The dealer gives you a prize!
    set pnum %random.5%
    %load% obj %prize_vec.wordat(%pnum%)% %actor%
    wait 2 s
    %send% %actor% Do you want to play again?   
  endif
endif


* This mob will be 1s of Recall ; at least until a copyover is done.