[CF-Devel] rodlike and wandlike items

Todd Mitchell temitchell at sympatico.ca
Sun Jul 14 12:01:27 CDT 2002


I was checking out the code that returns messages for rods and wands and horns (in player.c) because I wanted to make an item that recharged like a rod.  Looking at the code the messages for ranged attacks are hard coded and there are case statements to spit them out depending on the item type. 
looks like this:

case range_wand:
    for(weap=op->inv;weap!=NULL;weap=weap->below)
      if(weap->type==WAND&&QUERY_FLAG(weap, FLAG_APPLIED))
 break;
    if(weap==NULL) {
      new_draw_info(NDI_UNIQUE, 0,op,"You have no wand readied.");
      op->contr->count_left=0;
      return;
    }
    if(weap->stats.food<=0) {
      play_sound_player_only(op->contr, SOUND_WAND_POOF,0,0);
      new_draw_info(NDI_UNIQUE, 0,op,"The wand says poof.");
      return;
    }
    if(cast_spell(op,weap,dir,op->contr->chosen_item_spell,0,spellWand,NULL)) {
      SET_FLAG(op, FLAG_BEEN_APPLIED); /* You now know something about it */
      if (!(--weap->stats.food))
      {
 object *tmp;
 if (weap->arch) {
   CLEAR_FLAG(weap, FLAG_ANIMATE);
   weap->face = weap->arch->clone.face;
   weap->speed = 0;
   update_ob_speed(weap);
 }
 if ((tmp=is_player_inv(weap)))
     esrv_update_item(UPD_ANIM, tmp, weap);
      }
    }

  case range_rod:
  case range_horn:
    for(weap=op->inv;weap!=NULL;weap=weap->below)
      if(QUERY_FLAG(weap, FLAG_APPLIED)&&
  weap->type==(op->contr->shoottype==range_rod?ROD:HORN))
 break;
    if(weap==NULL) {
      char buf[MAX_BUF];
      sprintf(buf, "You have no %s readied.",
 op->contr->shoottype == range_rod ? "rod" : "horn");
      new_draw_info(NDI_UNIQUE, 0,op, buf);
      op->contr->count_left=0;
      return;
    }
    if(weap->stats.hp<spells[weap->stats.sp].sp) {
#if 0
      LOG(llevDebug,"Horn/rod: %d < %d (%d)\n", weap->stats.hp, spells[weap->stats.sp].sp, weap->stats.sp);
#endif
      play_sound_player_only(op->contr, SOUND_WAND_POOF,0,0);
      if (op->contr->shoottype == range_rod)
 new_draw_info(NDI_UNIQUE, 0,op,"The rod whines for a while, but nothing happens.");
      else
 new_draw_info(NDI_UNIQUE, 0,op,
           "No matter how hard you try you can't get another note out.");
      return;
    }
    if(cast_spell(op,weap,dir,op->contr->chosen_item_spell,0,
       op->contr->shoottype == range_rod ? spellRod : spellHorn,NULL)) {
      SET_FLAG(op, FLAG_BEEN_APPLIED); /* You now know something about it */
      drain_rod_charge(weap);
    }
    return;

 I propose a small change here which I am not yet competent to execute.

1. Like to see two new item types - rodlike (for recharging items) and wandlike (for rechargable items).  not sure what the best actual names should be... 'misc_rodlike' and 'misc_wandlike' ?
2. the player.c range code changed adding in a second case called 'range_misc_wandlike' to the wand portion and a third case called 'range_misc_rodlike' to the rod/horn portion which works off the else statement which will spit out generic messages like 
' the %s seems to be out of juice'  rather than the specific ones.  
In the wand section there would be an 'if - else'  similar to the way the rod/horn section works, and for the rod/horn section there would be an 'if - if - else' if you get my drift here.

something like this for wands

case range_wand
case range_misc_wandlike
    do this:
        if (op->contr->shoottype == range_wand)
            do this:
       else
            do this:
    do this:

and this for rods/horns

case range_rod
case range_horn
case range_misc_wandlike
    do this:
       if (op->contr->shoottype == range_rod)
            do this:
       if (op->contr->shoottype == range_horn)
            do this:
       else
            do this:
    do this:

This I think would be pretty simple to change but then again there could be more to it than that since I am still puzzling my way along here.  Any thoughts?
It would allow for a whole bunch of new special items to be made which would be fun if not functionally too different.How about a magic stone of summoning or a teakettle of steambolt, or what I was trying to make 'Lythander's pipe of wonder' and 'Lythander's pipe of mass confusion'

Just a suggestion.
-tm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
     
     http://shadowknight.real-time.com/pipermail/crossfire/attachments/20020714/665c23dd/attachment.html
     
     
    


More information about the crossfire mailing list