Mob reset by time

For builders to discuss and ask building questions.
Post Reply
Cret
Sword Grand Master
Sword Grand Master
Posts: 582
Joined: Sat Aug 09, 2003 4:31 am
Location: Waterdeep
Contact:

Mob reset by time

Post by Cret » Thu May 27, 2010 11:50 pm

How would one go about changing mobs in an area based on time with the reset?


If time > 2100 || < 600
Load MobX
Else
Load MobZ
Image
User avatar
Harroghty
Staff
Staff
Posts: 9695
Joined: Tue Jul 27, 2004 5:38 pm

Re: Mob reset by time

Post by Harroghty » Fri May 28, 2010 12:07 am

I would do it this way...

Place the day time mobile in the reset portion of your .ARE file.

Code: Select all

#RESETS
M 0 12340   1 12340 ;          a guard dude     
 E 1 23500   3 WEAR_LEFT_HAND ; a big sword
 E 1 23501   1 WEAR_BODY ; some cool armor
Then put a greet program on the rooms with the mobiles that you want to change at different times:

Code: Select all

>greet_prog 100~
if time() == 16
or time() == 17
or time() == 18
or time() == 19
or time() == 20
or time() == 21
or time() == 22
or time() == 23
or time() == 0
  mpforce m12340 goto 3
  mpecho Some echo about the switch.  Maybe they transform at night?
  mpmload m12341
endif
~
What you are doing here is that when someone enters (100% of the time) the program will check the time, it will send one m12340 (our day guy) away and load m12341 (our night guy) instead. Now, then you will have to add other programs on the mobiles themselves because the reset will still drop in new day guys. Maybe make the day guy check the time in his fight program and then have him transform if its night time?

I hope that this is helpful. I recommend looking at the lessons about "IF Checks" and "MP Commands" and messing around. Trial and error is a good method on the test port with something like this.
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
Cret
Sword Grand Master
Sword Grand Master
Posts: 582
Joined: Sat Aug 09, 2003 4:31 am
Location: Waterdeep
Contact:

Re: Mob reset by time

Post by Cret » Fri May 28, 2010 1:21 am

Can this be used to also change a race of a mobile?

A wiry sea-elf...
Gets into combat and rages into

a wereshark

Same mob.. just now really scarry
Image
User avatar
Harroghty
Staff
Staff
Posts: 9695
Joined: Tue Jul 27, 2004 5:38 pm

Re: Mob reset by time

Post by Harroghty » Fri May 28, 2010 1:34 am

Like I said, you can check out the lessons under "MUD Progams" like "IF Checks" and "MP Commands". This is from "MPSET and MPMADD FIelds"
Sets the race of the PC or mobile. If you are ever to change the race or class of a PC you should
consult with your Area Admin first. For a list of races refer to the Mobiles Race Lesson.
mpmset $i race elf
Of course, if you change the race then you should also mpmset long, mpmset short, and mpmset name to make sure it is described accurately. Be careful of making this too complicated though!
"A man may die yet still endure if his work enters the greater work, for time is carried upon a current of forgotten deeds, and events of great moment are but the culmination of a single carefully placed thought." - Chime of Eons
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Re: Mob reset by time

Post by Lathlain » Wed Jul 07, 2010 3:17 pm

Firstly, apologies for the massively belated reply!

This is a great idea, but a very tricky concept to master. As you've probably already noticed, there are many different ways to go about doing it - but each has its own distinct pitfalls.

My approach here would definitely be to use two different mobs, and simply switch between them - as Drew says, you don't want to over-complicate things. Given that the monstrous and non-monstrous forms will probably have different progs, stats and natural aggression, it's a lot easier for you just to toggle between the two mobiles. The other issue is that if the mobile then dies in its modified form, when it respawns again it'll return in its native form.

One potential issue with Drew's prog suggestion however is that the NPC will show up in their original form whenever the player enters the room, and then transform in front of them if the time criteria is met - for example, resulting in your wereshark being visible at 12 noon, and then becoming a human suddenly when someone walks in on them.

My suggestion would be to put an invisible mob (you can make a mob invisible to all but immortal eyes by including the 'ACT_MOBINVIS' flag on it) in the room with a prog to manage the wereshark/human deployment and transition. This may seem a little complicated, but the result will be far cleaner:

Mobs:
QQ00 - a human (no resets)
QQ01 - a wereshark (no resets)
QQ02 - an invisible mob (reset to load into room QQ00)

The following prog will go onto mQQ02:

Code: Select all

>time_prog 21~                 (triggers at 9.00pm)
if mobinroom(QQ00) > 0     (if the human is in the same room as the invisible mob)
  mpforce mQQ00 goto 3       (sends human to 'void' room to be destroyed)
  mpecho {F0}A benign looking human transforms into a hideous wereshark!
  mpmload mQQ01                 (spawns angry wereshark)
endif
~

also

>time_prog 5~
if mobinroom(QQ01) > 0     (if the wereshark is in the same room as the invisible mob)
  mpforce mQQ01 goto 3       (sends wereshark to 'void' room to be destroyed)
  mpecho {F0}A hideous wereshark transforms into a benign human!
  mpmload mQQ00                 (spawns benign human)
endif
~
Of course this means that your mob won't have an actual reset, which means you'll also want to create a series of progs on the invisible mob to simulate the 'repop' effect, such as:

Code: Select all

>time_prog 7~
if mobinroom(QQ00) == 0     (If the human NPC isn't in the room)
  mpmload mQQ00               (load a new one)
endif
~
>time_prog 9~
if mobinroom(QQ00) == 0     (If the human NPC isn't in the room)
  mpmload mQQ00               (load a new one)
endif
~
>time_prog 11~
if mobinroom(QQ00) == 0     (If the human NPC isn't in the room)
  mpmload mQQ00               (load a new one)
endif
~

and so on, until:

>time_prog 23~
if mobinroom(QQ00) == 1     (If the wereshark NPC isn't in the room)
  mpmload mQQ01               (load a new one)
endif
~
>time_prog 1~
if mobinroom(QQ00) == 1     (If the wereshark NPC isn't in the room)
  mpmload mQQ01               (load a new one)
endif
~

etc.
You can play with the times if you want a higher or lower reset rate of course. The resulting effect of this set-up is that the mobile will transform itself automatically at the designated times, and respawn as whatever creature it should be if it happens to die. The main downside to my approach though is that the mobile in question needs to be static. If you have it wandering around, it'll create an army of marauding weresharks before you know it!

I hope that gives you some insight into some of the alternatives available to you. If you need any help putting it into practice, feel free to ask!
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
Mask
Staff
Staff
Posts: 2649
Joined: Tue Jul 15, 2003 9:21 pm

Re: Mob reset by time

Post by Mask » Wed Jul 07, 2010 5:21 pm

This should probably be a room_prog rather than an invisible mob prog? It does sound somewhat over-complex though!

I think the simplest thing to do is have the reset be the human, add a 'time_prog -1' (a time prog which triggers every hour) on both the human and the wereshark. In that prog, check the time and if it you are the wrong mob at the wrong time, load your replacement and the mpgoto 3, with an appropriate echo as Ed suggested:

Code: Select all

>time_prog -1~
if time() == 19
or time() == 20
or time() == 21
  mpmload othermob
  smote changes into a violent nutcase.
  mpgoto 3
~
User avatar
Lathlain
Sword Grand Master
Sword Grand Master
Posts: 1169
Joined: Sun Aug 10, 2003 4:25 pm
Location: Zhentil Keep

Re: Mob reset by time

Post by Lathlain » Wed Jul 07, 2010 5:37 pm

My main reason for suggesting that the prog go on a constant was to stop the NPC dying, then coming back as the wrong beastie - though it would transform eventually of course, so it's not the end of the world. I'm just fussy :wink:

Good point re: invisible mob versus room prog though. I've always found invisible mobs to be more versatile - but in this case you're dead right!
"This is General Lath'lain Dy'nesir, of the Ebon Spur. Walking Murder surrounded by a thin veneer of civility."
-Miriel
Post Reply