Author Topic: A bug with object speech scripts using * as arg  (Read 4592 times)

0 Members and 1 Guest are viewing this topic.

Offline Molly

  • Administrator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
A bug with object speech scripts using * as arg
« on: November 16, 2008, 09:35:06 am »
Here is a weird bug, and I am not sure whether it is caused by context on the mob speech script, or the object speech scripts using * as arg. In any case the two scripts interfere with one another.

Hayato demonstrated it to me, and he says it's caused by % signs, but I don't really understand how that could be.

Anyhow, here is what happens:
We know of the bug affecting two items so far. (There might be others, but probably not many, since most objects with speech scripts set on them are !take).
The ones we know of are:
44591 the flying carpet from Aegean Island (script vnum 44531)
25645 a glowing silver-topped cane from Victorian England (script vnum 25620)

Both those objects react to speech scripts from whoever has them. Both the speech scripts have * as arg.
Both objects are also pretty good, so anyone who managed to acquire them is also likely to carry them around at most times.

But the speech scripts on the objects also interact with speech scripts on quest mobs in an undesirable way, meaning that the mobs won't respond to key phrases, unless you put the objects in question in a bag. Then the questmob suddenly acts normal again.

It's a very irritating bug that isn't very obvious, so a player could go around for ages, missing out on quest because of it.
It doesn't happen to all mobs with a speech script however, for instance the Time Guardian (3169, with the script 3366) still works fine. But as an example, Director Leatherwell (8225, with script 62212) doesn't. (There are probably several more examples, but for these you need to ask Hayato).

The time Guardian has a script that reacts to various keywords, with * as arg.
Leatherwell has a simpler script, reacting to one of the common greeting phrases, but it also uses context.

I've experimented by putting either return 0 or return 1 as elseif checks on the object script, but neither seems to work.
However Leatherwell works fine if Hayato puts the two objects in a bag.

At present I am stumped myself, and I don't really have the spare time toexperiment either. Hopefully one of our script gurus can figure out what's wrong and how we should set up the scripts in the future to prevent similar things from happening..

The scripts are below:



MOB SCRIPTS

This one works together with the objects:
Name: 'time guardian',  VNum: [ 3366], RNum: [  922]
Trigger Intended Assignment: Mobiles
Trigger Type: Speech, Numeric Arg: 100, Arg list: *
Commands:
eval ole old west
eval med medieval
eval fu future
eval pre pre historic
if %speech.car%==group
  eval goto %speech.cdr%
else
  eval goto %speech.car%
end
if (%ole% /= %goto% && %goto.contains(old)%)
  eval dest Old West
  eval loc 13000
elseif (%med% /= %goto% && %goto.contains(med)%)
  eval dest Medieval
  eval loc 3047
elseif (%pre% /= %goto% && %goto.contains(pre)%)
  eval dest Pre Historic
  eval loc 3084
elseif (%fu% /= %goto% && %goto.contains(fut)%)
  eval dest Future
  eval loc 38300
else
  halt
end
eval act %actor%
if !%actor.is_pc%
  %echo% Quick as a flash %actor.name% disappears!
else
  tell %actor.name% So, you want to explore %dest%?
  tell %actor.name% I shall send you there.
  %send% %actor% You are surrounded in a swirling vortex...
  %echoaround% %actor% %actor.name% is surrounded in a swirling vortex and vanishes.
end
%teleport% %actor% %loc%
%force% %actor% look
if %speech.car%==group
  eval rm %self.room%
  eval t %rm.people%
  while %t%
    eval p %t%
    eval t %t.next_in_room%
    if %p.master.name%==%act.name%
      %echoaround% %p% %p.name% is pulled in to %act.name%'s swirling vortex and is sent to %dest%.
      %send% %p% You are pulled in to %act.name%'s swirling vortex and sent to %dest%.
      %teleport% %p% %loc%
      %force% %p% look
      %send% %act% %p.name% climbs from a swirling vortex.
    end
  done
end

This one doesn't:
Name: 'Leatherwell may the force',  VNum: [ 6212], RNum: [ 1668]
Trigger Intended Assignment: Mobiles
Trigger Type: Speech, Numeric Arg: 0, Arg list: may the force be with
Commands:
wait 1 s
context %actor.id%
if %done% == 0
  eval done 1
  global done
  wait 1 s
  emote eyes you up and down and nods curtly.
  wait 3 s
  emote says, 'Hmm, you look like you need to earn a buck.
  %echo% 'Wanna take this letter to Mr. Whaffle on Poon and return with his reply?'
  wait 5 s
  %load% obj 8296 %actor%
  emote gets a letter from his pocket and hands it over.
  wait 2 s
  give 50 coin %actor.name%
  say Here's some money for your expenses.
  wait 1 s
  %echo% Fifty quid??? The mean old skinflint!
  wait 2 s
  say Now don't go and spend it all on booze and gambling and women.
  say You'll be paid on your return.
  emote waves a dismissive hand.
else
  eyebrow
  say What are you? A parrot?
  say Trying to kiss up, to get a handout, are you?
endif
context 0

OBJECT SCRIPTS

Name: 'Carpet teleport',  VNum: [44531], RNum: [ 6468]
Trigger Intended Assignment: Objects
Trigger Type: Speech, Numeric Arg: 7, Arg list: *
Commands:
if %actor.varexists(levitate)%
  wait 1
  rdelete levitate %actor.id%
  if %speech.contains(thasos)%
    %echo% The carpet lifts with a sudden jerk and takes off into the sky.
    wait 3 s
    %send% %actor% You travel through the air with an amazing speed.
    wait 2 s
    %send% %actor% Better hold on to your hat - AND the mat!
    %teleport% %actor% 44301
    %force% %actor5 look
    wait 1 s
    %send% %actor% Far below you recognise the harbour town of Thasos.
    %send% %actor% People move around in the streets, looking small as ants.
    wait 1 s
    %send% %actor% The carpet slows down and starts descending to the ground.
    wait 1 s
    %send% %actor% The carpet lands neatly in the middle of the Agora.
    %echoaround% %actor% %actor.name% suddenly lands on a flying carpet.
    wait 1 s
    %send% %actor% You roll up the carpet.
    %echoaround% %actor% %actor.name% rolls up the carpet, looking smug.
    %load% obj 44591 %actor%
    %purge% self
  elseif %speech.contains(chios)%
    %echo% The carpet lifts with a sudden jerk and takes off into the clouds.
    wait 3 s
    %send% %actor% The speed of this carpet is truly amazing!
    wait 2 s
    %send% %actor% You grab hold of the sides of the carpet as the wind whistles past your ears.
    %teleport% %actor% 44423
    %force% %actor% look
    wait 1 s
    %send% %actor% Far below you see the Town of Chios, with the Sultan's impressive palace.
    %send% %actor% You can even see the girls plucking apricots in the harem garden.
    wait 1 s
    %send% %actor% The carpet tilts slightly and swoops downwards.
    wait 1 s
    %send% %actor% The carpet pulls up and lands at the entrance of the city.
    %echoaround% %actor% %actor.name% suddenly lands on a flying carpet.
    wait 1 s
    %send% %actor% You roll up the carpet.
    %echoaround% %actor% %actor.name% rolls up the carpet,looking smug.
    %load% obj 44591 %actor%
    %purge% self
  elseif %speech.contains(rhodes)%
    %echo% The carpet lifts off the ground like VTOL jet.
    wait 3 s
    %send% %actor% It seems almost as fast as a jet plane too.
    wait 2 s
    %send% %actor% Instinctively you hold on to the carpet.
    %teleport% %actor% 44735
    %force% %actor% look
    wait 1 s
    %send% %actor% Far below you see the lush valleys of Rhodes.
    %send% %actor% The city Lindos rests like a white pearl between the green hills and the blue sea.
    wait 1 s
    %send% %actor% The carpet descends so fast that you almost get your stomach in the mouth.
    wait 1 s
    %send% %actor% The carpet lands with precision right in the middle of the Market Place.
    %echoaround% %actor% %actor.name% suddenly lands on a flying carpet.
    wait 1 s
    %send% %actor% You roll up the carpet.
    %echoaround% %actor% %actor.name% rolls up the carpet, looking smug.
    %load% obj 44591 %actor%
    %purge% self
  elseif %speech.contains(carpathos)%
    %echo% With a violent jerk the carpet lifts off the ground.
    wait 3 s
    %send% %actor% For a worn old carpet it certainly has amazing flying capacity.
    wait 2 s
    %send% %actor% You swoop through the sky so fast it makes your eyes water.
    %teleport% %actor% 44574
    %force% %actor% look
    wait 1 s
    %send% %actor% Far below you see the barren grey rock that is Carpathos.
    %send% %actor% The Harbor Walk seems crowded as usual.
    wait 1 s
    %send% %actor% Majestically the carpet descends to the ground.
    wait 1 s
    %send% %actor% The carpet lands softly, without even the slightest thump.
    %echoaround% %actor% %actor.name% suddenly lands on a flying carpet.
    wait 1 s
    %send% %actor% You roll up the carpet.
    %echoaround% %actor% %actor.name% rolls up the carpet,looking smug.
    %load% obj 44591 %actor%
    %purge% self
  elseif %speech.contains(cyprus)%
    %echo% The carpet shudders violently and takes off at an amazing speed.
    wait 3 s
    %send% %actor% Must be the latest model, probably a Nimbus 22.
    wait 2 s
    %send% %actor% Better sit still and grab hold of the edges so you don't fall off.
    %teleport% %actor% 44583
    %force% %actor% look
    wait 1 s
    %send% %actor% Far below you see the island of Cyprus, close to the coast of the Middle East.
    %send% %actor% The market place with the Soukh seems to be right below.
    wait 1 s
    %send% %actor% As fast as it took off, the carpet sinks towards the ground.
    wait 1 s
    %send% %actor% It finds an opening in the canvas roof, and lands in the middle of the soukh.
    %echoaround% %actor% %actor.name% suddenly lands on a flying carpet.
    wait 1 s
    %send% %actor% You roll up the carpet.
    %echoaround% %actor% %actor.name% rolls up the carpet, looking smug. 
    %load% obj 44591 %actor%
    %purge% self
  else
 return 0
  endif
else
 return 0
endif

Name: 'Object damage',  VNum: [25620], RNum: [ 5117]
Trigger Intended Assignment: Objects
Trigger Type: Command, Numeric Arg: 7, Arg list: *
Commands:
return 0
if %cmd.mudcommand%==say||%cmd.mudcommand%==gossip||%cmd.mudcommand%==tell||%cmd.mudcommand%==shout||%cmd.mudcommand%==holler||%cmd.mudcommand%==ctell||%cmd.mudcommand%=='
  if (%arg.contains(bitch)%||%arg.contains(whore)%||%arg.contains(fuck)%||%arg.contains(faggot)%||%arg.contains(wanker)%||%arg.contains(gay)%||%arg.contains(gosh)%)
    wait 1
    eval num %random.2%
    switch %num%
      case 1
        eval fine %actor.gold%
        %force% %actor% donate %fine% coin
      break
      case 2
        eval amount (%actor.hitp%/3)
        %damage% %actor% %amount%
        %send% %actor% A bolt of lightning falls from the heavens and strikes you.
        %echoaround% %actor% A bolt of lightning falls from the heavens and strikes %actor.name%.
      break
    done
  end
  return 0
else
  return 0
end

Offline Mordecai

  • Administrator
  • Full Member
  • *****
  • Posts: 107
  • Has delusions of adequacy
    • View Profile
    • Multiplayer Online Game Anyone?
    • Email
Re: A bug with object speech scripts using * as arg
« Reply #1 on: November 16, 2008, 03:15:06 pm »
this has always been the case, it happens with command scripts too.

There isn't a way to change the code to get around it, that is how the trigger system works.

Obviously the way to change it is to change the arg to not be an *, but instead be the list of words you expect the person to say.

To find all of the triggers affected this way do a tsearch:

Code: [Select]
tsearch arg *

Offline Molly

  • Administrator
  • Hero Member
  • *****
  • Posts: 690
    • View Profile
Re: A bug with object speech scripts using * as arg
« Reply #2 on: November 17, 2008, 10:07:57 am »
Heh, it seems the scripts, as they stand, work fine even with the * in the arg list.

The whole issue was caused by two mistakes, me not putting a return 0 as elseif, and Hayato typoing with the greet phrase.

But at least I learned something from it; having all the arguments you want the object to react to in the arg list instead of the *, is a much safer way to set up scripts like this.