How to Add a Mob Flag
- Rumble
-
Topic Author
- Offline
- Administrator
-
Less
More
11 years 3 months ago #17
by Rumble
Rumble
The Builder Academy
tbamud.com 9091
This email address is being protected from spambots. You need JavaScript enabled to view it.
How to Add a Mob Flag was created by Rumble
Below is an example of how you can add/modify a mob flag. After initially creating a new NOKILL flag I changed my mind and instead renamed NOBASH to NOKILL and added checks to prevent attacking and spell casting. The only thing I left out was protection from triggers.
Index: fight.c
===================================================================
--- fight.c (revision 197)
+++ fight.c (working copy)
@@ -682,8 +682,9 @@
return (0);
}
- /* shopkeeper protection */
- if (!ok_damage_shopkeeper(ch, victim))
+ /* shopkeeper and MOB_NOKILL protection */
+ if (!ok_damage_shopkeeper(ch, victim) || MOB_FLAGGED(victim, MOB_NOKILL)) {
+ send_to_char(ch, "This mob is protected.\r\n");
return (0);
+ }
/* You can't damage an immortal! */
Index: structs.h
===================================================================
--- structs.h (revision 197)
+++ structs.h (working copy)
@@ -181,44 +181,44 @@
#define MOB_NOSUMMON 14 /**< Mob can't be summoned */
#define MOB_NOSLEEP 15 /**< Mob can't be slept */
-#define MOB_NOBASH 16 /**< Mob can't be bashed (e.g. trees) */
+#define MOB_NOKILL 16 /**< Mob can't be bashed (e.g. trees) */
#define MOB_NOBLIND 17 /**< Mob can't be blinded */
#define MOB_NOTDEADYET 18 /**< (R) Mob being extracted */
/** Total number of Mob Flags; it should be 1 less than MOB_NOT_DEADYET */
Index: constants.c
===================================================================
--- constants.c (revision 197)
+++ constants.c (working copy)
@@ -187,7 +187,7 @@
"NO_CHARM",
"NO_SUMMN",
"NO_SLEEP",
- "NO_BASH",
+ "NO_KILL",
"NO_BLIND",
"DEAD", /* You should never see this. */
"\n"
Index: spell_parser.c
===================================================================
--- spell_parser.c (revision 200)
+++ spell_parser.c (working copy)
@@ -212,6 +212,10 @@
act("White light from no particular source suddenly fills the room, then va
nishes.", FALSE, caster, 0, 0, TO_ROOM);
return (0);
}
+ if (cvict && MOB_FLAGGED(cvict, MOB_NOKILL)) {
+ send_to_char(caster, "This mob is protected.\r\n");
+ return (0);
+ }
/* determine the type of saving throw */
switch (casttype) {
case CAST_STAFF:
Index: act.offensive.c
===================================================================
--- act.offensive.c (revision 197)
+++ act.offensive.c (working copy)
@@ -294,12 +294,13 @@
send_to_char(ch, "Aren't we funny today...\r\n");
return;
}
+ if (MOB_FLAGGED(vict, MOB_NOKILL)) {
+ send_to_char(ch, "This mob is protected.\r\n");
+ return;
+ }
percent = rand_number(1, 101); /* 101% is a complete failure */
prob = GET_SKILL(ch, SKILL_BASH);
- if (MOB_FLAGGED(vict, MOB_NOBASH))
- percent = 101;
-
if (percent > prob) {
damage(ch, vict, 0, SKILL_BASH);
GET_POS(ch) = POS_SITTING;
Rumble
The Builder Academy
tbamud.com 9091
This email address is being protected from spambots. You need JavaScript enabled to view it.
Please Log in or Create an account to join the conversation.
Time to create page: 0.082 seconds