Example #1
0
 private ItemUseResult UseWand(bool targets_enemies,bool visible_line,Actor user,List<Tile> line,WandTargetingDelegate wand_effect)
 {
     ItemUseResult result = new ItemUseResult(true,true);
     if(charges == 0){
         B.Add(TheName(true) + " is empty. Nothing happens. ",user);
         other_data = -1;
         result.IDed = false;
         return result;
     }
     TargetInfo info = null;
     if(user != player && line != null){
         info = new TargetInfo();
         info.extended_line = line;
         info.targeted = player.tile();
     }
     if(!identified[type]){
         targets_enemies = true;
         visible_line = false;
     }
     if(info == null){
         info = user.GetTarget(false,12,0,!visible_line,false,targets_enemies,"");
     }
     if(info != null){
         if(user != null && !user.HasLOE(info.targeted)){
             foreach(Tile t in info.extended_line){
                 if(!t.passable){
                     info.targeted = t;
                     break;
                 }
             }
         }
         if(user == null || user.HasLOE(info.targeted)){
             Tile LOE_tile = null;
             if(user != null){
                 LOE_tile = user.tile();
             }
             else{
                 LOE_tile = info.extended_line[0];
             }
             Tile prev = null;
             foreach(Tile t in info.extended_line){
                 if(!t.passable){
                     if(prev != null){
                         LOE_tile = prev;
                     }
                     break;
                 }
                 else{
                     if(t == info.targeted){
                         LOE_tile = t;
                         break;
                     }
                 }
                 prev = t;
             }
             wand_effect(LOE_tile,info,result);
         }
     }
     else{
         result.used = false;
     }
     return result;
 }
Example #2
0
 private ItemUseResult UseOrb(int radius,bool never_target_enemies,Actor user,List<Tile> line,OrbTargetingDelegate orb_effect)
 {
     ItemUseResult result = new ItemUseResult(true,true);
     if(line == null){
         if(!identified[type]){
             radius = 0;
         }
         line = user.GetTargetTile(12,radius,false,!(never_target_enemies && identified[type]));
     }
     if(line != null){
         Tile t = line.LastOrDefault();
         Tile prev = line.LastBeforeSolidTile();
         Actor first = null;
         bool trigger_trap = true;
         Screen.CursorVisible = false;
         if(user != null){
             first = user.FirstActorInLine(line);
             B.Add(user.You("fling") + " the " + SingularName() + ". ",user);
             if(first != null && first != user){
                 trigger_trap = false;
                 t = first.tile();
                 if(player.CanSee(user)){
                     B.Add("It shatters on " + first.the_name + "! ",first);
                 }
                 else{
                     B.Add("Something shatters on " + first.the_name + "! ",first);
                 }
                 first.player_visibility_duration = -1;
                 first.attrs[AttrType.PLAYER_NOTICED]++;
             }
             else{
                 if(player.CanSee(user)){
                     B.Add("It shatters on " + t.the_name + "! ",t);
                 }
                 else{
                     B.Add("Something shatters on " + t.the_name + "! ",t);
                 }
             }
             user.AnimateProjectile(line.ToFirstSolidTileOrActor(),'*',color);
             Screen.CursorVisible = false;
         }
         else{
             trigger_trap = false;
         }
         Tile LOE_tile = t;
         if(!t.passable && prev != null){
             LOE_tile = prev;
         }
         orb_effect(t,LOE_tile,result);
         t.MakeNoise(2);
         if(trigger_trap && t.IsTrap()){
             t.TriggerTrap();
         }
         if(!revealed_by_light){
             result.IDed = false;
         }
     }
     else{
         result.used = false;
     }
     return result;
 }