record ckbstate {
location loc; //location
familiar fam; //familiar
int[slot] qip; //equipment
string[int] mod; //mood
boolean ode; //Ode to Booze
string ste; //source terminal educate
string hos; //horsery
string coe; //crown of ed
string buc; //back-up camera
string ret; //retrocape
string umb; //umbrella
string par; //parka
};
//list of all equipment in all slots
int[slot] GetEquip() {
//print("ckb-One: GetEquip","blue");
int[slot] eq;
string ge = "GetEquip: ";
foreach sl in $slots[hat,weapon,off-hand,back,shirt,pants,acc1,acc2,acc3,familiar] {
item it = equipped_item(sl);
int nn = to_int(it);
if (it!=$item[none]) {
ge += sl+" "+it+", ";
eq[sl] = nn;
}
}
if (have_equipped($item[Crown of Thrones])) {
eq[$slot[crown-of-thrones]] = to_int(my_enthroned_familiar());
ge += "crown-of-thrones "+my_enthroned_familiar()+", ";
}
if (have_equipped($item[Buddy Bjorn])) {
eq[$slot[buddy-bjorn]] = to_int(my_bjorned_familiar());
ge += "buddy-bjorn "+my_enthroned_familiar()+", ";
}
if (have_equipped($item[card sleeve])) {
eq[$slot[card-sleeve]] = to_int(equipped_item($slot[card-sleeve]));
ge += "card-sleeve "+equipped_item($slot[card-sleeve])+", ";
}
//print(ge,"olive");
return eq;
}
//equip equipment into all given slots
void SetEquip(int[slot] eq) {
print("ckb-One: SetEquip","blue");
//check if we have changed equipment, unequip any slots that are different
//need to unequip items first to avoid conflicts, unavailable items, and one-at-a-time items
boolean chkq = false;
foreach sl in $slots[hat,weapon,off-hand,back,shirt,pants,acc1,acc2,acc3,familiar] {
item it = to_item(eq[sl]);
if (it!=$item[none] && equipped_item(sl)!=it) {
equip(sl,$item[none]);
chkq = true;
}
}
if (chkq) {
string se = "SetEquip: ";
foreach sl,nn in eq {
item it = to_item(nn);
if ($slots[hat,weapon,off-hand,back,shirt,pants,acc1,acc2,acc3,familiar] contains sl && it!=$item[none]) {
if (equipped_item(sl)==it) {
//nothing
} else {
//print("se it = "+it,"olive");
if (available_amount(it)==0) {
if (count(get_related(it,"fold"))>0) {
cli_execute("fold "+it);
} else {
cli_execute("refresh inventory");
}
}
if (available_amount(it)==0) { abort("SetEquip error, missing: "+it); }
se += sl+" "+it+", ";
equip(sl,it);
}
}
}
if (have_equipped($item[Crown of Thrones])) {
enthrone_familiar(to_familiar(eq[$slot[crown-of-thrones]]));
}
if (have_equipped($item[Buddy Bjorn])) {
bjornify_familiar(to_familiar(eq[$slot[buddy-bjorn]]));
}
if (have_equipped($item[card sleeve])) {
equip($slot[card-sleeve],to_item(eq[$slot[card-sleeve]]));
}
//print(se,"olive");
}
}
string[int] GetMList() {
return mood_list();
}
//set mood from mood_list()
void SetMList(string[int] mlst) {
cli_execute("mood clear");
foreach ii,ss in mlst {
ss = to_string(replace_string(ss,",",""));
ss = to_string(replace_string(ss,"|",","));
cli_execute("trigger "+ss);
}
}
//record current character state, includes equipment and other customizables
ckbstate GetState() {
//print("ckb-One: GetState","blue");
ckbstate sta;
sta.loc = my_location();
sta.fam = my_familiar();
sta.qip = GetEquip();
sta.mod = mood_list();
sta.ode = (have_effect($effect[Ode to Booze])>0);
sta.ste = get_property("sourceTerminalEducate1")+"-"+get_property("sourceTerminalEducate2");
sta.hos = get_property("_horsery");
sta.coe = get_property("edPiece");
sta.buc = get_property("backupCameraMode");
sta.ret = get_property("retroCapeSuperhero")+" "+get_property("retroCapeWashingInstructions");
sta.umb = get_property("umbrellaState");
sta.par = get_property("parkaMode");
return sta;
}
//set character state, includes equipment and other customizables
void SetState(ckbstate sta) {
print("ckb-One: SetState","blue");
set_location(sta.loc);
if (!InPathQT() && my_familiar()!=sta.fam) { use_familiar(sta.fam); }
SetEquip(sta.qip);
SetMList(sta.mod);
if (sta.ode) { BuffUp(1,$skill[The Ode to Booze]); }
SetHorse(sta.hos);
SetTerm(sta.ste);
if (have_equipped($item[The Crown of Ed the Undying])) { cli_execute("edpiece "+sta.coe); }
if (have_equipped($item[backup camera])) { cli_execute("backupcamera "+sta.buc); }
if (have_equipped($item[unwrapped knock-off retro superhero cape])) { cli_execute("retrocape "+sta.ret); }
if (have_equipped($item[unbreakable umbrella])) { cli_execute("umbrella "+sta.umb); }
if (have_equipped($item[Jurassic Parka])) { cli_execute("parka "+sta.par); }
//mood_execute(-1);
}