Below is a part of 3 skills, first one uses no return; The other only uses one near the end. And the last uses alot of return;
So when is it a good idea to use and when is it not ?
Code was found on circlemud, but made me wonder why the differences.
Code:
if (roll <= goal) {
success = TRUE;
if ((weap = GET_EQ(vict, WEAR_DWIELD))) {
if (IS_NPC(vict))
LOST_WEAPON(vict) = weap;
act("You disarm $p from $N's off-hand!", FALSE, ch, weap, vict, TO_CHAR);
act("$n disarms $p from your off-hand!", FALSE, ch, weap, vict, TO_VICT);
act("$n disarms $p from $N's off-hand!", FALSE, ch, weap, vict, TO_NOTVICT);
obj_to_room(unequip_char(vict, WEAR_DWIELD), IN_ROOM(vict));
} else if ((weap = GET_EQ(vict, WEAR_WIELD))) {
if (IS_NPC(vict))
LOST_WEAPON(vict) = weap;
act("You disarm $p from $N's hand!", FALSE, ch, weap, vict, TO_CHAR);
act("$n disarms $p from your hand!", FALSE, ch, weap, vict, TO_VICT);
act("$n disarms $p from $N's hand!", FALSE, ch, weap, vict, TO_NOTVICT);
obj_to_room(unequip_char(vict, WEAR_WIELD), IN_ROOM(vict));
} else {
log("SYSERR: do_disarm(), should have a weapon to be disarmed, but lost it!");
}
} else {
act("You fail to disarm $N.", FALSE, ch, weap, vict, TO_CHAR);
act("$n fails to disarm you.", FALSE, ch, weap, vict, TO_VICT);
act("$n fails to disarm $N.", FALSE, ch, weap, vict, TO_NOTVICT);
}
if (!IS_IMMORT(ch))
WAIT_STATE(ch, PULSE_VIOLENCE);
if (success && IS_NPC(vict))
set_fighting(ch, vict);
}
Code:
if (!obj)
GET_MOVE(ch) -= (GET_LEVEL(ch) / 2) + (GET_DEX(ch) * 2);
if (!obj)
GET_HIT(ch) += (GET_LEVEL(ch) / 2) + (GET_DEX(ch) * 2);
else
GET_HIT(ch) += (GET_LEVEL(ch) / 2);
if (!obj) {
send_to_char("You bandage yourself.\r\n", ch);
act("$n bandages $mself.", FALSE, ch, 0, 0, TO_ROOM);
} else {
act("You bandage yorself with $p.", FALSE, ch, obj, 0, TO_CHAR);
act("$n bandages $mself with $p.", FALSE, ch, obj, 0, TO_ROOM);
extract_obj(obj); }
if (GET_HIT(ch) >= GET_MAX_HIT(ch)) {
send_to_char("You are now at full health.\r\n", ch);
GET_HIT(ch) = GET_MAX_HIT(ch); }
WAIT_STATE(ch, PULSE_VIOLENCE * 1);
return;
}
}
Code:
if(!*buf) {
/* no argument means that the character is listening for
* hidden or invisible beings in the room he/she is in
*/
for(tch = world[ch->in_room].people; tch; tch = tch_next) {
tch_next = tch->next_in_room;
if((tch != ch) && !CAN_SEE(ch, tch) && (GET_LEVEL(tch) < LVL_IMMORT))
found++;
}
if(found) {
if(GET_LEVEL(ch) >= 15) {
/* being a higher level is better */
sprintf(buf, "You hear what might be %d creatures invisible, or hiding.\r\n", \
MAX(1,(found+number(0,1)-number(0,1))));
}
else sprintf(buf, "You hear an odd rustling in the immediate area.\r\n");
send_to_char(buf, ch);
}
else send_to_char(heard_nothing, ch);
act(room_spiel, TRUE, ch, 0, 0, TO_ROOM);
return;
}
else {
/* the argument must be one of the cardinal directions: north,
* south, etc.
*/
for(dir = 0; dir < NUM_OF_DIRS; dir++) {
if(!strncmp(buf, dirs[dir], strlen(buf)))
break;
}
if (dir == NUM_OF_DIRS) {
send_to_char("Listen where?\r\n", ch);
return;
}
if(CAN_GO(ch, dir) || CAN_LISTEN_BEHIND_DOOR(ch, dir)) {
for(tch = world[EXIT(ch, dir)->to_room].people; tch; tch=tch_next) {
tch_next = tch->next_in_room;
found++;
}
if(found) {
if(GET_LEVEL(ch) >= 15) {
sprintf(buf, "You hear what might be %d creatures %s%s.\r\n", \
MAX(1,(found+number(0,1)-number(0,1))),
((dir==5)?"below":(dir==4)?"above": "to the "),
((dir==5)?"":(dir==4)?"":dirs[dir]));
}
else sprintf(buf, "You hear sounds from %s%s.\r\n", \
((dir==5)?"below":(dir==4)?"above": "the "),
((dir==5)?"":(dir==4)?"":dirs[dir]));
send_to_char(buf, ch);
}
else send_to_char(heard_nothing, ch);
act(room_spiel, TRUE, ch, 0, 0, TO_ROOM);
return;
}
else send_to_char("You can't listen in that direction.\r\n", ch);
return;
}
return;
}