public static void Targeting_ShowLine(Tile tc,int radius,colorchar[,] mem,List<Tile> line,List<Tile> oldline,ref bool blocked,TileDelegate is_blocking) { foreach(Tile t in line){ if(t.row != player.row || t.col != player.col || tc.actor() != player){ colorchar cch = mem[t.row,t.col]; if(t.row == tc.row && t.col == tc.col){ if(!blocked){ cch.bgcolor = Color.Green; if(Global.LINUX && !Screen.GLMode){ //no bright bg in terminals cch.bgcolor = Color.DarkGreen; } if(cch.color == cch.bgcolor){ cch.color = Color.Black; } Screen.WriteMapChar(t.row,t.col,cch); } else{ cch.bgcolor = Color.Red; if(Global.LINUX && !Screen.GLMode){ cch.bgcolor = Color.DarkRed; } if(cch.color == cch.bgcolor){ cch.color = Color.Black; } Screen.WriteMapChar(t.row,t.col,cch); } } else{ if(!blocked){ cch.bgcolor = Color.DarkGreen; if(cch.color == cch.bgcolor){ cch.color = Color.Black; } Screen.WriteMapChar(t.row,t.col,cch); } else{ cch.bgcolor = Color.DarkRed; if(cch.color == cch.bgcolor){ cch.color = Color.Black; } Screen.WriteMapChar(t.row,t.col,cch); } } if(is_blocking(t)){ blocked = true; } } oldline.Remove(t); } if(radius > 0){ foreach(Tile t in tc.TilesWithinDistance(radius,true)){ if(!line.Contains(t)){ colorchar cch = mem[t.row,t.col]; if(blocked){ cch.bgcolor = Color.DarkRed; } else{ cch.bgcolor = Color.DarkGreen; } if(cch.color == cch.bgcolor){ cch.color = Color.Black; } Screen.WriteMapChar(t.row,t.col,cch); oldline.Remove(t); } } } }
public static void Targeting_RemoveLine(Tile tc,bool done,List<Tile> line,colorchar[,] mem,int radius) { if(done){ Screen.CursorVisible = false; foreach(Tile t in line){ Screen.WriteMapChar(t.row,t.col,mem[t.row,t.col]); } if(radius > 0){ foreach(Tile t in tc.TilesWithinDistance(radius,true)){ if(!line.Contains(t)){ Screen.WriteMapChar(t.row,t.col,mem[t.row,t.col]); } } } Screen.CursorVisible = true; } }
public bool ConfirmsSafetyPrompts(Tile t) { if(CanSee(t) && !HasAttr(AttrType.CONFUSED)){ if(t.IsKnownTrap() && !HasAttr(AttrType.FLYING,AttrType.BRUTISH_STRENGTH) && !t.name.Contains("(safe)")){ if(!B.YesOrNoPrompt("Really step on " + t.TheName(true) + "?")){ return false; } } if(t.IsBurning() && !IsBurning() && !HasAttr(AttrType.SLIMED,AttrType.NONLIVING)){ //nonliving indicates stoneform if(!B.YesOrNoPrompt("Really walk into the fire?")){ return false; } } if(HasAttr(AttrType.OIL_COVERED) && !HasAttr(AttrType.IMMUNE_BURNING,AttrType.IMMUNE_FIRE)){ bool fire = false; foreach(Tile t2 in t.TilesWithinDistance(1)){ if((t2.actor() != null && t2.actor().IsBurning()) || t2.IsBurning()){ fire = true; break; } } if(fire && !B.YesOrNoPrompt("Really step next to the fire?")){ return false; } } if(t.Is(FeatureType.WEB) && !HasAttr(AttrType.SLIMED,AttrType.OIL_COVERED,AttrType.BRUTISH_STRENGTH) && !B.YesOrNoPrompt("Really walk into the web?")){ return false; } if(!HasAttr(AttrType.NONLIVING)){ if(t.Is(FeatureType.CONFUSION_GAS) && !B.YesOrNoPrompt("Really walk into the confusion gas?")){ return false; } if(t.Is(FeatureType.POISON_GAS) && !HasAttr(AttrType.POISONED) && !B.YesOrNoPrompt("Really walk into the poison gas?")){ return false; } if(t.Is(FeatureType.SPORES) && (!HasAttr(AttrType.POISONED) || !HasAttr(AttrType.STUNNED)) && !B.YesOrNoPrompt("Really walk into the spores?")){ return false; } if(t.Is(FeatureType.THICK_DUST) && !B.YesOrNoPrompt("Really walk into the cloud of dust?")){ return false; } } } return true; }
public int GetDangerRating(Tile t) { //0 is no danger. 1 is minor danger, often ignored in favor of chasing the player. 2 is major danger, always avoided. if(HasAttr(AttrType.MINDLESS) || (type == ActorType.BERSERKER && HasAttr(AttrType.COOLDOWN_2)) || type == ActorType.FINAL_LEVEL_CULTIST){ return 0; } int dr = attrs[AttrType.DAMAGE_RESISTANCE]; int result = 0; if(HasAttr(AttrType.HUMANOID_INTELLIGENCE)){ if(!HasAttr(AttrType.NONLIVING,AttrType.PLANTLIKE)){ if(t.Is(FeatureType.CONFUSION_GAS) && !HasAttr(AttrType.MENTAL_IMMUNITY)){ return 2; } if(t.Is(FeatureType.SPORES) && (!HasAttr(AttrType.MENTAL_IMMUNITY) || dr < 2)){ if(HasAttr(AttrType.MENTAL_IMMUNITY,AttrType.STUNNED) && (HasAttr(AttrType.POISONED) || dr > 0)){ result = 1; } else{ return 2; } } if(t.Is(FeatureType.POISON_GAS) && type != ActorType.NOXIOUS_WORM && dr < 2){ if(HasAttr(AttrType.POISONED) || dr > 0){ result = 1; } else{ return 2; } } /*if(t.Is(TileType.POPPY_FIELD) && !HasAttr(AttrType.MAGICAL_DROWSINESS,AttrType.MENTAL_IMMUNITY)){ //todo int counter = attrs[AttrType.POPPY_COUNTER] + M.poppy_distance_map[t.p]; //todo: check for valid dijkstra int here? if(counter > 3){ return 2; } if(counter > 1){ result = 1; } }*/ if(t.Is(TileType.POPPY_FIELD) && !HasAttr(AttrType.MENTAL_IMMUNITY)){ if(M.poppy_distance_map[t.p] == 1){ //the outermost layer is considered less dangerous if(attrs[AttrType.POPPY_COUNTER] >= 3){ return 2; } else{ if(this != player){ //result = 1; } //result = 1; } } else{ if(M.poppy_distance_map[t.p].IsValidDijkstraValue()){ if(attrs[AttrType.POPPY_COUNTER] >= 2){ return 2; } else{ if(this != player){ result = 1; } //result = 1; } } } } } if(t.Is(FeatureType.THICK_DUST) && !HasAttr(AttrType.BLINDSIGHT,AttrType.PLANTLIKE)){ return 2; } foreach(Tile neighbor in t.TilesWithinDistance(1)){ if(neighbor.Is(FeatureType.GRENADE)){ return 2; } } } if(!HasAttr(AttrType.IMMUNE_FIRE) && dr < 3){ bool might_catch = false; int searing_tiles = 0; bool currently_flammable = (t.IsCurrentlyFlammable() || HasAttr(AttrType.OIL_COVERED)) && HasAttr(AttrType.HUMANOID_INTELLIGENCE); foreach(Tile neighbor in t.TilesWithinDistance(1)){ if(neighbor.IsBurning()){ searing_tiles++; if(currently_flammable){ might_catch = true; } } } if(dr == 0){ if(searing_tiles > 3){ return 2; } else{ if(searing_tiles > 0){ if(type == ActorType.ALASI_SCOUT && curhp == maxhp){ return 2; } result = 1; } } } if((might_catch || t.IsBurning()) && !HasAttr(AttrType.IMMUNE_BURNING)){ if(dr == 2){ result = 1; } else{ return 2; } } } return result; }
public bool NextStepIsDangerous(Tile next) { //todo: add vents and geysers to GetCost and GetDangerRating? if(HasAttr(AttrType.BLIND) && next != tile()){ return true; } if(HasAttr(AttrType.BURNING,AttrType.POISONED,AttrType.ACIDIFIED)){ return true; } if(HasAttr(AttrType.BLEEDING) && !HasAttr(AttrType.BANDAGED,AttrType.NONLIVING)){ return true; } if(next.IsKnownTrap() && !next.name.Contains("safe") && (!HasAttr(AttrType.FLYING) || HasAttr(AttrType.DESCENDING))){ return true; } if(GetDangerRating(next) > 0){ return true; } if(next.Is(FeatureType.FORASECT_EGG,FeatureType.STABLE_TELEPORTAL,FeatureType.TELEPORTAL,FeatureType.CONFUSION_GAS,FeatureType.THICK_DUST)){ return true; //todo: remove some of these once they're added to GetDangerRating } foreach(Tile t in next.TilesWithinDistance(3)){ //could calculate and store these to prevent checking so many tiles each step. if(t.Is(TileType.POISON_GAS_VENT,TileType.FIRE_GEYSER) && t.seen && next.HasLOE(t)){ return true; } if(t.inv != null && t.inv.type == ConsumableType.BLAST_FUNGUS && t.seen && next.HasLOE(t)){ return true; } } foreach(Actor a in M.AllActors()){ if(a != this && (!a.Is(ActorType.CARNIVOROUS_BRAMBLE,ActorType.MUD_TENTACLE) || next.DistanceFrom(a) <= 1) && CanSee(a) && HasLOS(a)){ return true; } } return false; }