Date sent: Wed, 16 Jul 1997 18:42:41 -0200 To: "Liner/Nosferatu" From: Rick Rogers (by way of Rick Rogers ) Subject: RCL 4: Communication and damage Before I continue I must mention that having a mob talk when no one is around is a waste of computing power. That was done in the last email as an example. (Thanks for pointing it out Lem) Now the moment most of you have been waiting for - damage specs. Communication ------------- First you have to understand the advance communication routine. This routine is call act. It takes the form void act(char *str, int hide_invisible, struct char_data *ch, void *ob, void *vict_obj, int type); Yeah a mouthful I know. Perhaps a call to act would make it better understood. The usage for act might be... act("The guard hits you and sends you flying.",FALSE,mob,0,ch,TO_VICT); This is a pretty basic usage. In the first string we can add variables that parse the name, sex, etc of the pointers. A little more on that later. Anyway the command in detail. Obviously the string is the text you want players to see. The hide invisible means - do you want the mob or victim referred to as "someone" if they can't be seen. Next is a pointer to the "main character" then a pointer to the "main object" and after that a pointer to the "secondary character or object". The last thing (the type) indicates where the text is sent. Ok, first the string variables that can be in the text. These are In the case of Characters $n - name of main char $N - name of secondary vict $m - him/her (main char) $M - him/her (secondary vict) $s - his/hers (main char) $S - his/hers (secondary vict) $e - he/she (main char) $E - he/she (secondary vict) You might see a pattern by now. Lower case always refers to the main char (the first pointer in the procedure), upper case always refers to the third. Now for Objects. $o - object name (main obj) $O - object name (secondary obj) $p - object short name (main obj) $P - object short name (secondary obj) $a - a/an (ob) $A - A/An (ob) $$ - to get a $ in your text The type takes the following forms... TO_VICT (secondary char) TO_CHAR (main char) TO_OTHER (main obj) TO_ROOM - all in room TO_NOTVICT - all in room except secondary char I'm sure your wondering how to use all this so I'll throw out a bunch of examples. 1) mob==kraken vict==Buff no object act("$n gives $N a large kick in the groin",0,mob,0,vict,TO_NOTVICT); The Kraken gives Buff a large kick in the groin. (to all but the kraken and Buff) act("$n gives you a large kick in the groin",0,mob,0,vict,TO_VICT); The Kraken gives you a large kick in the groin. (sent only to Buff) 2) ch==Burnout obj==Runt sword vict==Amphora act("$n takes $s $o and splits $N from $S head to $S toes." ,0,ch,obj,vict,TO_NOTVICT) Burnout takes his Runt sword and splits Amphora from his head to his toes. (To all but Amphora and Burnout) Anyway enough of that, you'll see more examples in later specs. Damage Specs ------------ In the next example I'm going to show three specs that a mob might have. I'm going to skip all the includes and the assign statments to save bandwidth (and me cutting and pasting) /* Damage specs for the QA, she's pissed and the specs tell the tale. Given info is the following. 1) 10% chance the QA attacks the first Warrior entering for 200 damage 2) 25% chance on the tank - for 400 damage 3) 20% chance on the whole group (but not tank) for 150 damage. */ int queen_ant(CHAR *qa, CHAR *ch, int cmd, char *arg) { CHAR *vict, *next_vict; if(cmd==MSG_ENTER) { if(!ch) return FALSE; /* Check for a character moving as in last spec*/ if(IS_NPC(ch)) return FALSE; /* If its a mob, return */ if(GET_CLASS(ch)!=CLASS_WARRIOR) return FALSE; /* we are picking on Wa*/ if(qa->specials.fighting) return FALSE; /* If shes fighting, return */ if(number(0,9)==0) { /* 10% chance */ act("$n hits $N as soon as $E enters.",0,qa,0,ch,TO_NOTVICT); act("$n hits you as soon as you enter.",0,qa,0,ch,TO_VICT); act("You hit $N as soon as $E enters.",0,qa,0,ch,TO_CHAR); damage(qa,ch,200,TYPE_UNDEFINED); /* The damage function is damage(attacker,victim,amount,type) the amount is the amount of hps a player would lose unsanct'd and the type is normally meant for spells or weapons so we use TYPE_UNDEFINED for spec damage */ return FALSE; } } if(cmd!=MSG_MOBACT) return FALSE; /* The rest of the specs activate on MOBACT so if the cmd isn't that, we return */ if(!qa->specials.fighting) return FALSE; /* Make sure QA is already fighting for the specs to activate */ if(number(0,3)==0) { vict=qa->specials.fighting; /* the tank */ act("$n slams $N against the wall.",0,qa,0,vict,TO_NOTVICT); act("$n slams you against the wall.",0,qa,0,vict,TO_VICT); act("You slam $N against the wall.",0,qa,0,vict,TO_CHAR); damage(qa,ch,400,TYPE_UNDEFINED); return FALSE; } if(number(0,4)==0) { act("$n spins around in a circle.",0,qa,0,0,TO_ROOM); act("You spin around in a circle.",0,qa,0,0,TO_CHAR); /* This for loop is how we go thru every character in the same room as the Queen Ant - CHAR_REAL_ROOM(qa) returns the room number */ for(vict = world[CHAR_REAL_ROOM(qa)].people; vict;vict = next_vict) { next_vict = vict->next_in_room; if(!vict) return FALSE; if(vict == mob) continue; if(vict == qa->specials.fighting) continue; if(IS_NPC(vict)) continue; /* Above we don't want to damage the tank, the qa or any other mobs */ act("$n's legs knock you off your feet.",0, qa, 0, vict, TO_VICT); act("Your legs knock $N off #S feet.",0, qa, 0, vict, TO_CHAR); damage(qa, vict, 150, TYPE_UNDEFINED); } return FALSE; } return FALSE; } If anything is unclear in these specs, let me know. This is the basis for most (if not all mob attacks). Instead of doing damage, the mob might disarm, or make you unequip your weapon and steal it. Next time I'll show you some of those functions. Rick (Ranger)