コード例 #1
0
        // Function from file: monitor.dm
        public void record(  )
        {
            ByTable supply = null;
            ByTable demand = null;


            if (Game13.time >= this.next_record)
            {
                this.next_record = Game13.time + this.record_interval;
                supply           = this.history["supply"];
                supply.Add(this.attached.powernet.viewavail);

                if (supply.len > this.record_size)
                {
                    supply.Cut(1, 2);
                }
                demand = this.history["demand"];
                demand.Add(this.attached.powernet.viewload);

                if (demand.len > this.record_size)
                {
                    demand.Cut(1, 2);
                }
            }
            return;
        }
コード例 #2
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static dynamic pick_n_take( ByTable L = null ) {
			dynamic _default = null;
			int picked = 0;
			if ( L.len != 0 ) {
				picked = Rand13.Int( 1, L.len );
				_default = L[picked];
				L.Cut( picked, picked + 1 );
			}
			return _default;
		}
コード例 #3
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static void moveRange( ByTable L = null, dynamic fromIndex = null, dynamic toIndex = null, dynamic len = null ) {
			dynamic distance = null;
			dynamic i = null;
			dynamic i2 = null;
			if ( len == null ) {
				len = 1;
			}
			distance = Math.Abs( Lang13.Double( toIndex - fromIndex ) );
			if ( Lang13.Double( len ) >= Lang13.Double( distance ) ) {
				if ( Lang13.Double( fromIndex ) <= Lang13.Double( toIndex ) ) {
					return;
				}
				fromIndex += len;
				i = null;
				i = 0;
				while (Lang13.Double( i ) < Lang13.Double( distance )) {
					L.Insert( Lang13.Int( fromIndex ), null );
					L.Swap( Lang13.Int( fromIndex ), Lang13.Int( toIndex ) );
					L.Cut( Lang13.IntNullable( toIndex ), Lang13.Int( toIndex + 1 ) );
					i++;
				}
			} else {
				if ( Lang13.Double( fromIndex ) > Lang13.Double( toIndex ) ) {
					fromIndex += len;
				}
				i2 = null;
				i2 = 0;
				while (Lang13.Double( i2 ) < Lang13.Double( len )) {
					L.Insert( Lang13.Int( toIndex ), null );
					L.Swap( Lang13.Int( fromIndex ), Lang13.Int( toIndex ) );
					L.Cut( Lang13.IntNullable( fromIndex ), Lang13.Int( fromIndex + 1 ) );
					i2++;
				}
			}
			return;
		}
コード例 #4
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static void moveElement( ByTable L = null, dynamic fromIndex = null, dynamic toIndex = null ) {
			if ( fromIndex == toIndex || fromIndex + 1 == toIndex ) {
				return;
			}
			if ( Lang13.Double( fromIndex ) > Lang13.Double( toIndex ) ) {
				fromIndex++;
			}
			L.Insert( Lang13.Int( toIndex ), null );
			L.Swap( Lang13.Int( fromIndex ), Lang13.Int( toIndex ) );
			L.Cut( Lang13.IntNullable( fromIndex ), Lang13.Int( fromIndex + 1 ) );
			return;
		}
コード例 #5
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static void listclearnulls( ByTable L = null ) {
			int i = 0;
			dynamic thing = null;
			if ( L is ByTable ) {
				i = 1;
				thing = null;
				foreach (dynamic _a in L ) {
					thing = _a;
					if ( thing != null ) {
						i++;
						continue;
					}
					L.Cut( i, i + 1 );
				};
			}
			return;
		}
コード例 #6
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static void setup_map_transitions(  ) {
			ByTable SLS = null;
			dynamic D = null;
			int conf_set_len = 0;
			int k = 0;
			dynamic A = null;
			ByTable point_grid = null;
			ByTable grid = null;
			dynamic P = null;
			int? i = null;
			int? j = null;
			Point pnt = null;
			ByTable possible_points = null;
			ByTable used_points = null;
			dynamic A2 = null;
			ByTable x_pos_beginning = null;
			ByTable y_pos_beginning = null;
			ByTable x_pos_ending = null;
			ByTable y_pos_ending = null;
			ByTable x_pos_transition = null;
			ByTable y_pos_transition = null;
			int? zlevelnumber = null;
			int? side = null;
			Tile beginning = null;
			Tile ending = null;
			ByTable turfblock = null;
			double dirside = 0;
			int? zdestination = null;
			Tile_Space S = null;
			dynamic A3 = null;
			SLS = new ByTable();
			conf_set_len = GlobalVars.map_transition_config.len;
			k = 1;
			A = null;
			foreach (dynamic _a in GlobalVars.map_transition_config ) {
				A = _a;
				D = new SpaceLevel( GlobalVars.map_transition_config[A] );
				D.name = A;
				D.z_value = k;
				if ( Lang13.Double( D.linked ) < 2 ) {
					GlobalVars.z_levels_list["" + D.z_value] = D;
				} else {
					SLS.Add( D );
				}
				k++;
			};
			point_grid = null;
			point_grid = new ByTable( conf_set_len * 2 + 1, conf_set_len * 2 + 1 );
			grid = new ByTable();
			P = null;
			i = null;
			i = 1;
			while (( i ??0) <= conf_set_len * 2 + 1) {
				j = null;
				j = 1;
				while (( j ??0) <= conf_set_len * 2 + 1) {
					P = new Point( i, j, point_grid );
					point_grid[i][j] = P;
					grid.Add( P );
					j++;
				}
				i++;
			}
			pnt = null;
			foreach (dynamic _b in grid ) {
				if ( !( _b is Point ) ) {
					continue;
				}
				pnt = _b;
				pnt.set_neigbours( point_grid );
			};
			P = point_grid[conf_set_len + 1][conf_set_len + 1];
			possible_points = new ByTable();
			used_points = new ByTable();
			grid.Cut();
			while (SLS.len != 0) {
				D = Rand13.pick( SLS );
				SLS.Remove( D );
				D.xi = P.x;
				D.yi = P.y;
				P.spl = D;
				possible_points |= P.neigbours;
				used_points |= P;
				possible_points.Remove( used_points );
				((SpaceLevel)D).set_neigbours( used_points );
				P = Rand13.pick( possible_points );
				grid["" + D.z_value] = D;
			}
			A2 = null;
			foreach (dynamic _c in GlobalVars.z_levels_list ) {
				A2 = _c;
				grid[A2] = GlobalVars.z_levels_list[A2];
			};
			x_pos_beginning = new ByTable(new object [] { 1, 1, Game13.map_size_x - 7, 1 });
			y_pos_beginning = new ByTable(new object [] { Game13.map_size_y - 7, 1, 7, 7 });
			x_pos_ending = new ByTable(new object [] { Game13.map_size_x, Game13.map_size_x, Game13.map_size_x, 7 });
			y_pos_ending = new ByTable(new object [] { Game13.map_size_y, 7, Game13.map_size_y - 7, Game13.map_size_y - 7 });
			x_pos_transition = new ByTable(new object [] { 1, 1, 9, Game13.map_size_x - 7 - 2 });
			y_pos_transition = new ByTable(new object [] { 9, Game13.map_size_y - 7 - 2, 1, 1 });
			zlevelnumber = null;
			zlevelnumber = 1;
			while (( zlevelnumber ??0) <= grid.len) {
				D = grid["" + zlevelnumber];
				if ( !Lang13.Bool( D ) ) {
					Task13.crash( "" + zlevelnumber + " position has no space level datum." );
				}
				if ( !Lang13.Bool( D.neigbours.len ) ) {
					
				} else {
					side = null;
					side = 1;
					while (( side ??0) < 5) {
						beginning = Map13.get_tile_at( Lang13.Int( x_pos_beginning[side] ), Lang13.Int( y_pos_beginning[side] ), zlevelnumber ??0 );
						ending = Map13.get_tile_at( Lang13.Int( x_pos_ending[side] ), Lang13.Int( y_pos_ending[side] ), zlevelnumber ??0 );
						turfblock = Map13.fetch_in_block( beginning, ending );
						dirside = Math.Pow( 2, ( side ??0) - 1 );
						zdestination = zlevelnumber;
						if ( Lang13.Bool( D.neigbours["" + dirside] ) && D.neigbours["" + dirside] != D ) {
							D = D.neigbours["" + dirside];
							zdestination = Lang13.IntNullable( D.z_value );
						} else {
							dirside = Num13.rotate_dir( dirside, 180 );
							while (Lang13.Bool( D.neigbours["" + dirside] ) && D.neigbours["" + dirside] != D) {
								D = D.neigbours["" + dirside];
							}
							zdestination = Lang13.IntNullable( D.z_value );
						}
						D = grid["" + zlevelnumber];
						S = null;
						foreach (dynamic _d in turfblock ) {
							if ( !( _d is Tile_Space ) ) {
								continue;
							}
							S = _d;
							S.destination_x = ( x_pos_transition[side] == 1 ? ((dynamic)S).x : x_pos_transition[side] );
							S.destination_y = ( y_pos_transition[side] == 1 ? ((dynamic)S).y : y_pos_transition[side] );
							S.destination_z = zdestination;
						};
						side++;
					}
				}
				zlevelnumber++;
			}
			A3 = null;
			foreach (dynamic _e in grid ) {
				A3 = _e;
				GlobalVars.z_levels_list[A3] = grid[A3];
			};
			return;
		}
コード例 #7
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static ByTable recursive_mob_check( dynamic O = null, bool? client_check = null, bool? sight_check = null, bool? include_radio = null ) {
			ByTable processing_list = null;
			ByTable processed_list = null;
			ByTable found_mobs = null;
			dynamic A = null;
			bool passed = false;
			dynamic A_tmp = null;
			BaseStatic B = null;
			if ( client_check == null ) {
				client_check = true;
			}
			if ( sight_check == null ) {
				sight_check = true;
			}
			if ( include_radio == null ) {
				include_radio = true;
			}
			processing_list = new ByTable(new object [] { O });
			processed_list = new ByTable();
			found_mobs = new ByTable();
			while (processing_list.len != 0) {
				A = processing_list[1];
				passed = false;
				if ( A is Mob ) {
					A_tmp = A;
					passed = true;
					if ( client_check == true && !Lang13.Bool( A_tmp.client ) ) {
						passed = false;
					}
					if ( sight_check == true && !GlobalFuncs.isInSight( A_tmp, O ) ) {
						passed = false;
					}
				} else if ( include_radio == true && A is Ent_Item_Device_Radio ) {
					passed = true;
					if ( sight_check == true && !GlobalFuncs.isInSight( A, O ) ) {
						passed = false;
					}
				}
				if ( passed ) {
					found_mobs |= A;
				}
				B = null;
				foreach (dynamic _a in A ) {
					if ( !( _a is BaseStatic ) ) {
						continue;
					}
					B = _a;
					if ( !Lang13.Bool( processed_list[B] ) ) {
						processing_list |= B;
					}
				};
				processing_list.Cut( 1, 2 );
				processed_list[A] = A;
			}
			return found_mobs;
		}
コード例 #8
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static ByTable recursive_hear_check( BaseDynamic O = null ) {
			ByTable _default = null;
			ByTable processing_list = null;
			dynamic A = null;
			processing_list = new ByTable(new object [] { O });
			_default = new ByTable();
			while (processing_list.len != 0) {
				A = processing_list[1];
				if ( Lang13.Bool( A.flags & 16 ) ) {
					_default += A;
				}
				processing_list.Cut( 1, 2 );
				processing_list += A.contents;
			}
			return _default;
		}
コード例 #9
0
        // Function from file: minimap.dm
        public void generate(dynamic z = null, int?x1 = null, int?y1 = null, int?x2 = null, int?y2 = null)
        {
            z  = z ?? 1;
            x1 = x1 ?? 1;
            y1 = y1 ?? 1;
            x2 = x2 ?? Game13.map_size_x;
            y2 = y2 ?? Game13.map_size_y;

            Icon    minimap   = null;
            ByTable obj_icons = null;
            int     counter   = 0;
            dynamic T         = null;
            dynamic tile      = null;
            Icon    tile_icon = null;
            dynamic obj       = null;
            dynamic I         = null;
            dynamic obj_icon  = null;
            Icon    flatten   = null;
            Icon    final     = null;

            minimap = new Icon("icons/minimap.dmi");
            minimap.Scale(GlobalVars.MINIMAP_SIZE, GlobalVars.MINIMAP_SIZE);
            obj_icons = new ByTable();
            counter   = 128;

            foreach (dynamic _b in Lang13.Enumerate(Map13.FetchInBlock(Map13.GetTile(x1 ?? 0, y1 ?? 0, Convert.ToInt32(z)), Map13.GetTile(x2 ?? 0, y2 ?? 0, Convert.ToInt32(z)))))
            {
                T = _b;

                tile      = T;
                tile_icon = null;
                obj       = null;

                if (tile is Tile_Space)
                {
                    obj = Lang13.FindIn(typeof(Obj_Structure_Lattice_Catwalk), tile);

                    if (Lang13.Bool(obj))
                    {
                        tile_icon = new Icon("icons/obj/smooth_structures/catwalk.dmi", "catwalk", GlobalVars.SOUTH);
                    }
                    obj = Lang13.FindIn(typeof(Obj_Structure_Lattice), tile);

                    if (Lang13.Bool(obj))
                    {
                        tile_icon = new Icon("icons/obj/smooth_structures/lattice.dmi", "lattice", GlobalVars.SOUTH);
                    }
                    obj = Lang13.FindIn(typeof(Obj_Structure_Grille), tile);

                    if (Lang13.Bool(obj))
                    {
                        tile_icon = new Icon("icons/obj/structures.dmi", "grille", GlobalVars.SOUTH);
                    }
                    obj = Lang13.FindIn(typeof(Obj_Structure_TransitTube), tile);

                    if (Lang13.Bool(obj))
                    {
                        tile_icon = new Icon("icons/obj/atmospherics/pipes/transit_tube.dmi", obj.icon_state, Lang13.DoubleNullable(obj.dir));
                    }
                }
                else
                {
                    tile_icon = new Icon(tile.icon, tile.icon_state, Lang13.DoubleNullable(tile.dir));
                    obj_icons.Cut();
                    obj = Lang13.FindIn(typeof(Obj_Structure), tile);

                    if (Lang13.Bool(obj))
                    {
                        obj_icons.Add(GlobalFuncs.getFlatIcon(obj));
                    }
                    obj = Lang13.FindIn(typeof(Obj_Machinery), tile);

                    if (Lang13.Bool(obj))
                    {
                        obj_icons.Add(new Icon(obj.icon, obj.icon_state, Lang13.DoubleNullable(obj.dir), 1, false));
                    }
                    obj = Lang13.FindIn(typeof(Obj_Structure_Window), tile);

                    if (Lang13.Bool(obj))
                    {
                        obj_icons.Add(new Icon("icons/obj/smooth_structures/window.dmi", "window", GlobalVars.SOUTH));
                    }

                    foreach (dynamic _a in Lang13.Enumerate(obj_icons))
                    {
                        I = _a;

                        obj_icon = I;
                        tile_icon.Blend(obj_icon, 3);
                    }
                }

                if (tile_icon != null)
                {
                    tile_icon.Scale(GlobalVars.TILE_SIZE, GlobalVars.TILE_SIZE);
                    minimap.Blend(tile_icon, 3, Lang13.DoubleNullable((tile.x - 1) * 8), Lang13.DoubleNullable((tile.y - 1) * 8));
                    Lang13.Delete(tile_icon);
                    tile_icon = null;
                }
                counter--;

                if (counter <= 0)
                {
                    counter = 128;
                    flatten = new Icon();
                    flatten.Insert(minimap, "", GlobalVars.SOUTH, 1, false);
                    Lang13.Delete(minimap);
                    minimap = null;
                    minimap = flatten;
                    Task13.Sleep(-1);
                }
            }
            final = new Icon();
            final.Insert(minimap, "", GlobalVars.SOUTH, 1, false);
            File13.Copy(final, this.map_path(z));
            return;
        }
コード例 #10
0
        // Function from file: dna_console.dm
        public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null)
        {
            Mob     viable_occupant             = null;
            double? num                         = null;
            string  last_change                 = null;
            bool    epinephrine_amount          = false;
            int     can_add                     = 0;
            string  text                        = null;
            dynamic buffer_slot                 = null;
            ByTable buffer_slot2                = null;
            dynamic buffer_slot3                = null;
            Obj_Item_Weapon_Dnainjector_Timed I = null;
            Mutation_Human HM                   = null;
            int?           time_coeff           = null;
            Mutation_Human HM2                  = null;
            dynamic        buffer_slot4         = null;
            dynamic        locked_state         = null;
            int            len                  = 0;
            int            block                = 0;
            double         subblock             = 0;
            string         hex                  = null;
            int            len2                 = 0;
            int            block2               = 0;
            double         subblock2            = 0;
            string         hex2                 = null;


            if (Lang13.Bool(base.Topic(href, href_list, (object)(hsrc))))
            {
                return(null);
            }

            if (!(Task13.User.loc is Tile))
            {
                return(null);
            }

            if (!(this.loc is Tile && Map13.GetDistance(this, Task13.User) <= 1 || Task13.User is Mob_Living_Silicon))
            {
                return(null);
            }

            if (this.current_screen == "working")
            {
                return(null);
            }
            this.add_fingerprint(Task13.User);
            Task13.User.set_machine(this);
            viable_occupant = this.get_viable_occupant();
            num             = Num13.Floor(String13.ParseNumber(href_list["num"]) ?? 0);

            dynamic _f = href_list["task"];             // Was a switch-case, sorry for the mess.

            if (_f == "togglelock")
            {
                if (Lang13.Bool(this.connected))
                {
                    this.connected.locked = !Lang13.Bool(this.connected.locked);
                }
            }
            else if (_f == "toggleopen")
            {
                if (Lang13.Bool(this.connected))
                {
                    ((Obj_Machinery_DnaScannernew)this.connected).toggle_open(Task13.User);
                }
            }
            else if (_f == "setduration")
            {
                if (!Lang13.Bool(num))
                {
                    num = Num13.Floor(Convert.ToDouble(Interface13.Input(Task13.User, "Choose pulse duration:", "Input an Integer", null, null, InputType.Num | InputType.Null)));
                }

                if (Lang13.Bool(num))
                {
                    this.radduration = GlobalFuncs.Wrap(num, true, 31);
                }
            }
            else if (_f == "setstrength")
            {
                if (!Lang13.Bool(num))
                {
                    num = Num13.Floor(Convert.ToDouble(Interface13.Input(Task13.User, "Choose pulse strength:", "Input an Integer", null, null, InputType.Num | InputType.Null)));
                }

                if (Lang13.Bool(num))
                {
                    this.radstrength = GlobalFuncs.Wrap(num, true, 16);
                }
            }
            else if (_f == "screen")
            {
                this.current_screen = href_list["text"];
            }
            else if (_f == "rejuv")
            {
                if (viable_occupant != null && viable_occupant.reagents != null)
                {
                    epinephrine_amount = viable_occupant.reagents.get_reagent_amount("epinephrine");
                    can_add            = Num13.MaxInt(Num13.MinInt(90 - (epinephrine_amount ?1:0), 15), 0);
                    viable_occupant.reagents.add_reagent("epinephrine", can_add);
                }
            }
            else if (_f == "setbufferlabel")
            {
                text = GlobalFuncs.sanitize(Interface13.Input(Task13.User, "Input a new label:", "Input an Text", null, null, InputType.Str | InputType.Null));

                if (Lang13.Bool(num) && Lang13.Bool(text))
                {
                    num         = Num13.MaxInt(1, Num13.MinInt(((int)(num ?? 0)), 3));
                    buffer_slot = this.buffer[num];

                    if (buffer_slot is ByTable)
                    {
                        buffer_slot["label"] = text;
                    }
                }
            }
            else if (_f == "setbuffer")
            {
                if (Lang13.Bool(num) && viable_occupant != null)
                {
                    num = Num13.MaxInt(1, Num13.MinInt(((int)(num ?? 0)), 3));
                    this.buffer[num] = new ByTable()
                                       .Set("label", "Buffer" + num + ":" + viable_occupant.real_name)
                                       .Set("UI", ((dynamic)viable_occupant).dna.uni_identity)
                                       .Set("SE", ((dynamic)viable_occupant).dna.struc_enzymes)
                                       .Set("UE", ((dynamic)viable_occupant).dna.unique_enzymes)
                                       .Set("name", viable_occupant.real_name)
                                       .Set("blood_type", ((dynamic)viable_occupant).dna.blood_type)
                    ;
                }
            }
            else if (_f == "clearbuffer")
            {
                if (Lang13.Bool(num))
                {
                    num          = Num13.MaxInt(1, Num13.MinInt(((int)(num ?? 0)), 3));
                    buffer_slot2 = this.buffer[num];

                    if (buffer_slot2 is ByTable)
                    {
                        buffer_slot2.Cut();
                    }
                }
            }
            else if (_f == "transferbuffer")
            {
                if (Lang13.Bool(num) && viable_occupant != null)
                {
                    dynamic _a = href_list["text"];                     // Was a switch-case, sorry for the mess.
                    if (_a == "se")
                    {
                        this.apply_buffer(1, num);
                    }
                    else if (_a == "ui")
                    {
                        this.apply_buffer(2, num);
                    }
                    else if (_a == "ue")
                    {
                        this.apply_buffer(3, num);
                    }
                    else if (_a == "mixed")
                    {
                        this.apply_buffer(4, num);
                    }
                }
            }
            else if (_f == "injector")
            {
                if (Lang13.Bool(num) && this.injectorready)
                {
                    num          = Num13.MaxInt(1, Num13.MinInt(((int)(num ?? 0)), 3));
                    buffer_slot3 = this.buffer[num];

                    if (buffer_slot3 is ByTable)
                    {
                        I = null;

                        dynamic _d = href_list["text"];                         // Was a switch-case, sorry for the mess.
                        if (_d == "se")
                        {
                            if (Lang13.Bool(buffer_slot3["SE"]))
                            {
                                I = new Obj_Item_Weapon_Dnainjector_Timed(this.loc);

                                foreach (dynamic _b in Lang13.Enumerate(GlobalVars.good_mutations + GlobalVars.bad_mutations + GlobalVars.not_good_mutations, typeof(Mutation_Human)))
                                {
                                    HM = _b;


                                    if (HM.check_block_string(buffer_slot3["SE"]))
                                    {
                                        I.add_mutations.Add(HM);
                                    }
                                    else
                                    {
                                        I.remove_mutations.Add(HM);
                                    }
                                }
                                time_coeff = null;

                                foreach (dynamic _c in Lang13.Enumerate(I.add_mutations, typeof(Mutation_Human)))
                                {
                                    HM2 = _c;


                                    if (!Lang13.Bool(time_coeff))
                                    {
                                        time_coeff = HM2.time_coeff;
                                        continue;
                                    }
                                    time_coeff = Num13.MinInt(time_coeff ?? 0, HM2.time_coeff);
                                }

                                if (Lang13.Bool(this.connected))
                                {
                                    I.duration     = I.duration * (time_coeff ?? 0) * Convert.ToDouble(this.connected.damage_coeff);
                                    I.damage_coeff = Convert.ToDouble(this.connected.damage_coeff);
                                }
                            }
                        }
                        else if (_d == "ui")
                        {
                            if (Lang13.Bool(buffer_slot3["UI"]))
                            {
                                I        = new Obj_Item_Weapon_Dnainjector_Timed(this.loc);
                                I.fields = new ByTable().Set("UI", buffer_slot3["UI"]);

                                if (Lang13.Bool(this.connected))
                                {
                                    I.damage_coeff = Convert.ToDouble(this.connected.damage_coeff);
                                }
                            }
                        }
                        else if (_d == "ue")
                        {
                            if (Lang13.Bool(buffer_slot3["name"]) && Lang13.Bool(buffer_slot3["UE"]) && Lang13.Bool(buffer_slot3["blood_type"]))
                            {
                                I        = new Obj_Item_Weapon_Dnainjector_Timed(this.loc);
                                I.fields = new ByTable().Set("name", buffer_slot3["name"]).Set("UE", buffer_slot3["UE"]).Set("blood_type", buffer_slot3["blood_type"]);

                                if (Lang13.Bool(this.connected))
                                {
                                    I.damage_coeff = Convert.ToDouble(this.connected.damage_coeff);
                                }
                            }
                        }
                        else if (_d == "mixed")
                        {
                            if (Lang13.Bool(buffer_slot3["UI"]) && Lang13.Bool(buffer_slot3["name"]) && Lang13.Bool(buffer_slot3["UE"]) && Lang13.Bool(buffer_slot3["blood_type"]))
                            {
                                I        = new Obj_Item_Weapon_Dnainjector_Timed(this.loc);
                                I.fields = new ByTable().Set("UI", buffer_slot3["UI"]).Set("name", buffer_slot3["name"]).Set("UE", buffer_slot3["UE"]).Set("blood_type", buffer_slot3["blood_type"]);

                                if (Lang13.Bool(this.connected))
                                {
                                    I.damage_coeff = Convert.ToDouble(this.connected.damage_coeff);
                                }
                            }
                        }

                        if (I != null)
                        {
                            this.injectorready = false;
                            Task13.Schedule(100, (Task13.Closure)(() => {
                                this.injectorready = true;
                                return;
                            }));
                        }
                    }
                }
            }
            else if (_f == "loaddisk")
            {
                if (Lang13.Bool(num) && Lang13.Bool(this.diskette) && Lang13.Bool(this.diskette.fields))
                {
                    num = Num13.MaxInt(1, Num13.MinInt(((int)(num ?? 0)), 3));
                    this.buffer[num] = this.diskette.fields.Copy();
                }
            }
            else if (_f == "savedisk")
            {
                if (Lang13.Bool(num) && Lang13.Bool(this.diskette) && !this.diskette.read_only)
                {
                    num          = Num13.MaxInt(1, Num13.MinInt(((int)(num ?? 0)), 3));
                    buffer_slot4 = this.buffer[num];

                    if (buffer_slot4 is ByTable)
                    {
                        this.diskette.name   = "data disk [" + buffer_slot4["label"] + "]";
                        this.diskette.fields = buffer_slot4.Copy();
                    }
                }
            }
            else if (_f == "ejectdisk")
            {
                if (Lang13.Bool(this.diskette))
                {
                    this.diskette.loc = GlobalFuncs.get_turf(this);
                    this.diskette     = null;
                }
            }
            else if (_f == "setdelayed")
            {
                if (Lang13.Bool(num))
                {
                    this.delayed_action = new ByTable().Set("action", String13.ParseNumber(href_list["delayaction"])).Set("buffer", num);
                }
            }
            else if (_f == "pulseui" || _f == "pulsese")
            {
                if (Lang13.Bool(num) && viable_occupant != null && Lang13.Bool(this.connected))
                {
                    this.radduration      = GlobalFuncs.Wrap(this.radduration, true, 31);
                    this.radstrength      = GlobalFuncs.Wrap(this.radstrength, true, 16);
                    locked_state          = this.connected.locked;
                    this.connected.locked = 1;
                    this.current_screen   = "working";
                    this.ShowInterface(Task13.User);
                    Task13.Sleep(((int)((this.radduration ?? 0) * 10)));
                    this.current_screen = "mainmenu";

                    if (viable_occupant != null && Lang13.Bool(this.connected) && this.connected.occupant == viable_occupant)
                    {
                        viable_occupant.radiation += (this.radduration ?? 0) * (this.radstrength ?? 0) * 0.2 / Math.Pow(Convert.ToDouble(this.connected.damage_coeff), 2);

                        dynamic _e = href_list["task"];                         // Was a switch-case, sorry for the mess.
                        if (_e == "pulseui")
                        {
                            len          = Lang13.Length(((dynamic)viable_occupant).dna.uni_identity);
                            num          = GlobalFuncs.Wrap(num, true, len + 1);
                            num          = this.randomize_radiation_accuracy(num, (this.radduration ?? 0) + Math.Pow(Convert.ToDouble(this.connected.precision_coeff), 2), len);
                            block        = Num13.Floor(((num ?? 0) - 1) / 3) + 1;
                            subblock     = (num ?? 0) - block * 3;
                            last_change  = "UI #" + block + "-" + subblock + "; ";
                            hex          = String13.SubStr(((dynamic)viable_occupant).dna.uni_identity, ((int)(num ?? 0)), ((int)((num ?? 0) + 1)));
                            last_change += "" + hex;
                            hex          = this.scramble(hex, this.radstrength, this.radduration);
                            last_change += "->" + hex;
                            ((dynamic)viable_occupant).dna.uni_identity = String13.SubStr(((dynamic)viable_occupant).dna.uni_identity, 1, ((int)(num ?? 0))) + hex + String13.SubStr(((dynamic)viable_occupant).dna.uni_identity, ((int)((num ?? 0) + 1)), 0);
                            new ByTable().Set("mutations_overlay_update", 1).Apply(Lang13.BindFunc(viable_occupant, "updateappearance"));
                        }
                        else if (_e == "pulsese")
                        {
                            len2         = Lang13.Length(((dynamic)viable_occupant).dna.struc_enzymes);
                            num          = GlobalFuncs.Wrap(num, true, len2 + 1);
                            num          = this.randomize_radiation_accuracy(num, (this.radduration ?? 0) + Math.Pow(Convert.ToDouble(this.connected.precision_coeff), 2), len2);
                            block2       = Num13.Floor(((num ?? 0) - 1) / 3) + 1;
                            subblock2    = (num ?? 0) - block2 * 3;
                            last_change  = "SE #" + block2 + "-" + subblock2 + "; ";
                            hex2         = String13.SubStr(((dynamic)viable_occupant).dna.struc_enzymes, ((int)(num ?? 0)), ((int)((num ?? 0) + 1)));
                            last_change += "" + hex2;
                            hex2         = this.scramble(hex2, this.radstrength, this.radduration);
                            last_change += "->" + hex2;
                            ((dynamic)viable_occupant).dna.struc_enzymes = String13.SubStr(((dynamic)viable_occupant).dna.struc_enzymes, 1, ((int)(num ?? 0))) + hex2 + String13.SubStr(((dynamic)viable_occupant).dna.struc_enzymes, ((int)((num ?? 0) + 1)), 0);
                            viable_occupant.domutcheck();
                        }
                    }
                    else
                    {
                        this.current_screen = "mainmenu";
                    }

                    if (Lang13.Bool(this.connected))
                    {
                        this.connected.locked = locked_state;
                    }
                }
            }
            this.ShowInterface(Task13.User, last_change);
            return(null);
        }
コード例 #11
0
ファイル: RoundEvent_Ninja.cs プロジェクト: Somnium13/SS13
        // Function from file: ninja_event.dm
        public override bool start(  )
        {
            ByTable             spawn_locs           = null;
            Obj_Effect_Landmark L                    = null;
            ByTable             candidates           = null;
            dynamic             C                    = null;
            Mind                    Mind             = null;
            ByTable                 possible_targets = null;
            Mind                    M                = null;
            ByTable                 objectives       = null;
            Objective_Download      O                = null;
            Objective_Steal_Special O2               = null;
            int?    selected              = null;
            Mind    M2                    = null;
            dynamic is_bad_guy            = null;
            Objective_Assassinate O3      = null;
            Objective_Protect     O4      = null;
            int?              selected2   = null;
            dynamic           M3          = null;
            dynamic           is_bad_guy2 = null;
            Objective_Debrain O5          = null;
            Objective_Capture O6          = null;
            Objective_Survive O7          = null;
            dynamic           N           = null;


            if (!Lang13.Bool(this.spawn_loc))
            {
                spawn_locs = new ByTable();

                foreach (dynamic _b in Lang13.Enumerate(GlobalVars.landmarks_list, typeof(Obj_Effect_Landmark)))
                {
                    L = _b;


                    if (L.loc is Tile)
                    {
                        switch ((string)(L.name))
                        {
                        case "ninjaspawn":
                        case "carpspawn":
                            spawn_locs.Add(L.loc);
                            break;
                        }
                    }
                }

                if (!(spawn_locs.len != 0))
                {
                    this.kill(); return(false);
                }
                this.spawn_loc = Rand13.PickFromTable(spawn_locs);
            }

            if (!Lang13.Bool(this.spawn_loc))
            {
                this.kill(); return(false);
            }

            if (!Lang13.Bool(this.key))
            {
                candidates = GlobalFuncs.get_candidates("space ninja");

                if (!(candidates.len != 0))
                {
                    this.kill(); return(false);
                }
                C        = Rand13.PickFromTable(candidates);
                this.key = C.key;
            }

            if (!Lang13.Bool(this.key))
            {
                this.kill(); return(false);
            }
            Mind             = GlobalFuncs.create_ninja_mind(this.key);
            Mind.active      = true;
            possible_targets = new ByTable();

            foreach (dynamic _c in Lang13.Enumerate(GlobalVars.ticker.minds, typeof(Mind)))
            {
                M = _c;


                if (Lang13.Bool(M.current) && Convert.ToInt32(M.current.stat) != 2)
                {
                    if (M.current is Mob_Living_Carbon_Human)
                    {
                        if (Lang13.Bool(M.special_role))
                        {
                            possible_targets[M] = 0;
                        }
                        else if (GlobalVars.command_positions.Contains(M.assigned_role))
                        {
                            possible_targets[M] = 1;
                        }
                    }
                }
            }
            objectives = new ByTable(new object [] { 1, 2, 3, 4 });

            while (Mind.objectives.len < 6)
            {
                dynamic _d = GlobalFuncs.pick_n_take(objectives);                   // Was a switch-case, sorry for the mess.
                if (_d == 1)
                {
                    O       = new Objective_Download();
                    O.owner = Mind;
                    O.gen_amount_goal();
                    Mind.objectives.Add(O);
                }
                else if (_d == 2)
                {
                    O2       = new Objective_Steal_Special();
                    O2.owner = Mind;
                    Mind.objectives.Add(O2);
                }
                else if (_d == 3)
                {
                    if (!(possible_targets.len != 0))
                    {
                        continue;
                    }
                    selected   = Rand13.Int(1, possible_targets.len);
                    M2         = possible_targets[selected];
                    is_bad_guy = possible_targets[M2];
                    possible_targets.Cut(selected, (selected ?? 0) + 1);

                    if (Lang13.Bool(is_bad_guy ^ this.helping_station))
                    {
                        O3                  = new Objective_Assassinate();
                        O3.owner            = Mind;
                        O3.target           = M2;
                        O3.explanation_text = new Txt("Slay ").the(M2.current.real_name).item().str(", the ").item(M2.assigned_role).str(".").ToString();
                        Mind.objectives.Add(O3);
                    }
                    else
                    {
                        O4                  = new Objective_Protect();
                        O4.owner            = Mind;
                        O4.target           = M2;
                        O4.explanation_text = new Txt("Protect ").the(M2.current.real_name).item().str(", the ").item(M2.assigned_role).str(", from harm.").ToString();
                        Mind.objectives.Add(O4);
                    }
                }
                else if (_d == 4)
                {
                    if (!(possible_targets.len != 0))
                    {
                        continue;
                    }
                    selected2   = Rand13.Int(1, possible_targets.len);
                    M3          = possible_targets[selected2];
                    is_bad_guy2 = possible_targets[M3];
                    possible_targets.Cut(selected2, (selected2 ?? 0) + 1);

                    if (Lang13.Bool(is_bad_guy2 ^ this.helping_station))
                    {
                        O5                  = new Objective_Debrain();
                        O5.owner            = Mind;
                        O5.target           = M3;
                        O5.explanation_text = "Steal the brain of " + M3.current.real_name + ".";
                        Mind.objectives.Add(O5);
                    }
                    else
                    {
                        O6       = new Objective_Capture();
                        O6.owner = Mind;
                        O6.gen_amount_goal();
                        Mind.objectives.Add(O6);
                    }
                }
                else
                {
                    break;
                }
            }
            O7       = new Objective_Survive();
            O7.owner = Mind;
            Mind.objectives.Add(O7);
            Mind.store_memory("I am an elite mercenary assassin of the mighty Spider Clan. A <font color='red'><B>SPACE NINJA</B></font>!");
            Mind.store_memory("Suprise is my weapon. Shadows are my armor. Without them, I am nothing. (//initialize your suit by right clicking on it, to use abilities like stealth)!");
            Mind.store_memory("Officially, " + (this.helping_station != 0 ? "Nanotrasen" : "The Syndicate") + " are my employer.");
            this.Ninja = GlobalFuncs.create_space_ninja(this.spawn_loc);
            Mind.transfer_to(this.Ninja);

            if (this.Ninja.wear_suit is Obj_Item_Clothing_Suit_Space_SpaceNinja)
            {
                N = this.Ninja.wear_suit;
                ((Obj_Item_Clothing_Suit_Space_SpaceNinja)N).randomize_param();
            }
            this.Ninja.v_internal = this.Ninja.s_store;
            this.Ninja.update_internals_hud_icon(true);

            if (this.Ninja.mind != Mind)
            {
                throw new Exception("Ninja created with incorrect mind");
                return(false);
            }
            this.Ninja.WriteMsg(new Sound("sound/effects/ninja_greeting.ogg"));
            this.success_spawn = true;
            return(false);
        }
コード例 #12
0
        // Function from file: seeds.dm
        public override void on_chem_reaction(Reagents S = null)
        {
            ByTable           temp_mut_list = null;
            SpacevineMutation SM            = null;
            SpacevineMutation SM2           = null;
            SpacevineMutation SM3           = null;

            temp_mut_list = new ByTable();

            if (Lang13.Bool(S.has_reagent("sterilizine", 5)))
            {
                foreach (dynamic _a in Lang13.Enumerate(this.mutations, typeof(SpacevineMutation)))
                {
                    SM = _a;


                    if (SM.quality == 2)
                    {
                        temp_mut_list.Add(SM);
                    }
                }

                if (Rand13.PercentChance(20))
                {
                    this.mutations.Remove(Rand13.PickFromTable(temp_mut_list));
                }
                temp_mut_list.Cut();
            }

            if (Lang13.Bool(S.has_reagent("welding_fuel", 5)))
            {
                foreach (dynamic _b in Lang13.Enumerate(this.mutations, typeof(SpacevineMutation)))
                {
                    SM2 = _b;


                    if (SM2.quality == 1)
                    {
                        temp_mut_list.Add(SM2);
                    }
                }

                if (Rand13.PercentChance(20))
                {
                    this.mutations.Remove(Rand13.PickFromTable(temp_mut_list));
                }
                temp_mut_list.Cut();
            }

            if (Lang13.Bool(S.has_reagent("phenol", 5)))
            {
                foreach (dynamic _c in Lang13.Enumerate(this.mutations, typeof(SpacevineMutation)))
                {
                    SM3 = _c;


                    if (SM3.quality == 3)
                    {
                        temp_mut_list.Add(SM3);
                    }
                }

                if (Rand13.PercentChance(20))
                {
                    this.mutations.Remove(Rand13.PickFromTable(temp_mut_list));
                }
            }

            if (Lang13.Bool(S.has_reagent("blood", 15)))
            {
                this.production += Rand13.Int(15, -5);
            }

            if (Lang13.Bool(S.has_reagent("amatoxin", 5)))
            {
                this.production += Rand13.Int(5, -15);
            }

            if (Lang13.Bool(S.has_reagent("plasma", 5)))
            {
                this.potency += Rand13.Int(5, -15);
            }

            if (Lang13.Bool(S.has_reagent("holywater", 10)))
            {
                this.potency += Rand13.Int(15, -5);
            }
            return;
        }