/******************************************************************* * Decompiled By: Bog * Decompiled File: codescripts\character.gsc * Game: Call of Duty: Black Ops 2 * Platform: PC * Function Count: 12 * Decompile Time: 1 ms * Timestamp: 10/28/2023 12:11:15 AM *******************************************************************/ //Function Number: 1 setmodelfromarray(a) { self setmodel(a[randomint(a.size)]); } //Function Number: 2 precachemodelarray(a) { for(i = 0;i < a.size;i++) { precachemodel(a[i]); } } //Function Number: 3 randomelement(a) { return a[randomint(a.size)]; } //Function Number: 4 attachfromarray(a) { self attach(randomelement(a),"",1); } //Function Number: 5 new() { self detachall(); oldgunhand = self.anim_gunhand; if(!(IsDefined(oldgunhand))) { return; } self.anim_gunhand = "none"; self [[ anim.putguninhand ]](oldgunhand); } //Function Number: 6 save() { info["gunHand"] = self.anim_gunhand; info["gunInHand"] = self.anim_guninhand; info["model"] = self.model; info["hatModel"] = self.hatmodel; info["gearModel"] = self.gearmodel; if(IsDefined(self.name)) { info["name"] = self.name; /# println("Save: Guy has name ",self.name); #/ } else { /# println("save: Guy had no name!"); } #/ attachsize = self getattachsize(); for(i = 0;i < attachsize;i++) { info["attach"][i]["model"] = self getattachmodelname(i); info["attach"][i]["tag"] = self getattachtagname(i); } return info; } //Function Number: 7 load(info) { self detachall(); self.anim_gunhand = info["gunHand"]; self.anim_guninhand = info["gunInHand"]; self setmodel(info["model"]); self.hatmodel = info["hatModel"]; self.gearmodel = info["gearModel"]; if(IsDefined(info["name"])) { self.name = info["name"]; /# println("Load: Guy has name ",self.name); #/ } else { /# println("Load: Guy had no name!"); } #/ attachinfo = info["attach"]; attachsize = attachinfo.size; for(i = 0;i < attachsize;i++) { self attach(attachinfo[i]["model"],attachinfo[i]["tag"]); } } //Function Number: 8 precache(info) { if(IsDefined(info["name"])) { /# println("Precache: Guy has name ",info["name"]); #/ } else { /# println("Precache: Guy had no name!"); } #/ precachemodel(info["model"]); attachinfo = info["attach"]; attachsize = attachinfo.size; for(i = 0;i < attachsize;i++) { precachemodel(attachinfo[i]["model"]); } } //Function Number: 9 get_random_character(amount) { self_info = strtok(self.classname,"_"); if(self_info.size <= 2) { return randomint(amount); } group = "auto"; index = undefined; prefix = self_info[2]; if(IsDefined(self.script_char_index)) { index = self.script_char_index; } if(IsDefined(self.script_char_group)) { type = "grouped"; group = "group_" + self.script_char_group; } if(!(IsDefined(level.character_index_cache))) { level.character_index_cache = []; } if(!(IsDefined(level.character_index_cache[prefix]))) { level.character_index_cache[prefix] = []; } if(!(IsDefined(level.character_index_cache[prefix][group]))) { initialize_character_group(prefix,group,amount); } if(!(IsDefined(index))) { index = get_least_used_index(prefix,group); if(!(IsDefined(index))) { index = randomint(5000); } } while(index >= amount) { index = index - amount; } level.character_index_cache[prefix][group][index]++; return index; } //Function Number: 10 get_least_used_index(prefix,group) { lowest_indices = []; lowest_use = level.character_index_cache[prefix][group][0]; lowest_indices[0] = 0; for(i = 1;i < level.character_index_cache[prefix][group].size;i++) { if(level.character_index_cache[prefix][group][i] > lowest_use) { } else { if(level.character_index_cache[prefix][group][i] < lowest_use) { lowest_indices = []; lowest_use = level.character_index_cache[prefix][group][i]; } lowest_indices[lowest_indices.size] = i; } } /# assert(lowest_indices.size,"Tried to spawn a character but the lowest indices didn\'t exist"); #/ return random(lowest_indices); } //Function Number: 11 initialize_character_group(prefix,group,amount) { for(i = 0;i < amount;i++) { level.character_index_cache[prefix][group][i] = 0; } } //Function Number: 12 random(array) { return array[randomint(array.size)]; }