Building & Scripting > Scripting Board

Advanced Scripts

<< < (7/10) > >>

Kvetch:

30. ZONE ECHO

There is now a way to send the same echo to an entire zone, or to a

range of rooms within a zone.

Use %zecho% for sending echos to the entire zone

and %zrecho% for sending echos to a range of rooms.



The syntax for them are:

%zecho% <zone#> <message>



%zrecho% <zone#> <first room> <last room> <message>

where first room is the first room that will get the message

and last room is the last room to get it.


Kvetch:
31. PREVENT FROM USING TWO OF THE SAME ITEM

This is useful if the item is very powerful, and there are more than one

location where you can wear/wield it (neck, wield, ear, ankle and legs/feet

for centaurs).

It can also be used for an action that is only triggered if the actor is

wearing/wielding a certain item.

The wear_loc numbers are the same that you get in ZEDIT when equipping a

mob.



EXAMPLE

if !%actor.varexists(whatever)%

 return 0

 %send% %actor% You are not worthy of using this item, %actor.name%

 %echoaround% %actor% {cR%actor.name% is a THIEF!{c0

else

 wait 1

 eval w1 %actor.eq(16)%

 */Primary

 eval w2 %actor.eq(28)%

 */Secondary

 if ((%w1.vnum%==5641)||(%w2.vnum%==5641))

  return 0

  %send% %actor% You are not a strong enough warrior to handle two of these items.

 endif

endif

Kvetch:
32. CHECK FOR PLAYERS IN THE ROOM

Here's how how to find out other than the actor and self are in a room:

You will need to make a LOOP that has a 'look' at all the people in the room

with it, using the '.next_in_room' variable.



for example:



eval this_room %self.room%

eval person %this_room.people%

while %person%

<do action>

eval person %person.next_in_room%

done



explained-->:



"eval this_room %self.room%"

this line creates a new local variable called 'this_room' that contains

the identity of the room that the mob (self) is in.

so whenever you refer to 'this_room' you mean the room the 'self' is in.

You can use any room fields with this variable as if it was the room itself.

IE. %this_room.<room field>%



"eval person %this_room.people%"

This line creates a new local variable called 'person' that contains the

identity of the first person in room 'this_room'.

'person' can be now used the same way you use character variables, like

%actor.name%, you can use %person.name% to return that value.



"while %person%"

This like starts a loop that runs IF %person% doesn't equal 0, or rather,

if %person% exists.



"<do action>"

these actions can be anything you like to happen to that particular individual.

I would suggest that if you want it to respond to ALL the players in

the room, you have a check like this next:



if %person.vnum%<0

say %person.name% is a player.

elseif %person.vnum%>0

say %person.name% is a mob.

else

say There is an invisible immortal in the room.

endif



"eval person %person.next_in_room%"

This line changes the data in the local variable called 'person', with the identity of the NEXT person in the room list.

so for example if you had in a room:



Bob the builder. //Bob being an pc.

Hector the heroic. //Hector being an pc.

Sally the annoying newbie. //Sally being an pc.

A young mouse nibbles at your toes. //A young mouse being a npc.



if these people were in the room, the first person in the loop would

be Bob (%person.name% == Bob), then when it did the

'eval person %person.next_in_room%' the person.next_in_room is Hector.

So (%person.name% == Hector) now.

when it gets to 'a young mouse' then %person.vnum% will be greater

than 0 (all mobs have positive vnums (as far as we are concerned) players

have a vnum equal to -1).

Once the loop gets to 'a young mouse' the next person in the room

doesn't exist. so %person%==0, or NULL, nothing.

And the loop will stop.



"Done"

Done shows the script where then end of the loop is. (not the end of

the script)

if you want the while loop to stop in the middle of looping you can

use the 'break' command.



--------------



OKAY so lets apply that to your script.



Your script is:



eval Xecks %xecks%

set xecks %xecks%

global xecks

while %xecks% !=3

mecho %self utters yada yada

wait 2

mload mob 12099

wait 10

mforce xecks say i will protect you master

wait 1

mforce xecks fol jupiter

group xecks

mforce xecks massist jupiter

eval xecks %xecks% +1

set xecks %xecks%

global xecks

done



Edited:

From the information there is, i am assuming it is a MOB

trigger set to go off in a fight.

(so i am going to offer an alternative script for you. Just

to make it 'easier'. heh.)



firstly, instead of your previous script (above), use this.

All it does is load the 'xecks' mobs.



for: mobs

type: hitperc (or fight)

narg: 99 // i put 99 because if its a hitperc trigger set at 100

arg: // it can be a lil bugged sometimes.

commands:



while (%xecks%<3)

%echo% %self.name% utters yada yada

wait 2

%load% mob 12099

eval xecks %xecks%+1

global xecks

wait 10

done



Then put THIS script on the xecks themselves:



for: Mobs

type: load

Narg: 100

arg:

commands:

wait 1

eval this_room %self.room%

eval person %this_room.people%

while %person%

wait 10

eval jupi_name %person.alias%

if %jupi_name.contains(jupiter)%

* This checks to see if the word jupiter is in 'person's' list of alias's

if %person.fighting%

* if this is true, 'jupiter' is currently fighting someone.

(and therefore is assistable)

say I will protect you master!

wait 1

assist jupiter

else

%purge% self

* The purge will remove the mob if Jupiter IS NOT fighting.

%echo% %self.name% dissappears.

end

else

%purge% self

* The purge will remove the mob if Jupiter isn't in the room.

%echo% %self.name% dissappears.

end

eval person %person.next_in_room%

done



Basically this script, goes through each person in the room that this

mob loads in, and if one of the people in the room is called jupiter

and they are fighting someone, then this mob will assist, otherwise it

will remove itself.

Kvetch:
33. STOP SCRIPT LOOP



A loop basically consists of an if-check and an endif.



If you want the loop to stop running the rest of the script if the

if-check is true, you put a 'halt' line at the end of the loop.

If you want the script to keep running after checking the loop, you put

a 'done' line at the end of it.

Kvetch:
34. %ACTOR% and %ACTOR.NAME%, HIS AND HERS



Some players, who have chosen names that are also used for mobs, sometimes

are having problems doing the Quests, because the script code confuses them

with the mobs. Below are some info to remedy this problem as far as possible.



The difference between %actor% and %actor.name%:

%actor% is a reference to the player exactly. It's like the players unique

soul, the id number.

The script can use it directly for sending messages to, damaging and whatever.



It is also possible for the script to locate that player by name.

Which is why %actor.name% usually works as well.



Basically use %actor% with 'imm' commmands, and %actor.name% with mortal

commands. I.e.

%actor.name% needs to be used in normal commands, like tell, whisper, kill,

look, give... etc.

But %actor% needs to be used with scripts commands like: mkill, mhunt, %send%,

%echoaround%, %damage% %teleport% etc etc...



THE SEX OF THE ACTOR:



The sex of the actor is determined with %actor.sex%.

Below is the easiest way to ensure that you also get the right sex on

expressions like his/her, so you don't have to use 'their' in a script.



if %actor.sex% == male

 eval he his

 else

 eval he her

end

%echo% %actor.name% looks very cool wielding %he% dagger!



You can use a similar loop for 'he' and 'she'.



if %actor.sex% == male

 eval se he

else

 eval se she

end

%echo% %actor.name% doesn't seem to know what %se% is doing!


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version