public CharacterRelationship getRelationship(Character c, Character other) { CharacterRelationship CR = null; foreach (var rel in c.Relationships) { if (rel.otherChar == other.idkey) { return(rel); } } return(CR); }
public Character AddUpdateRelationship(Character peep, CharacterRelationship CR, float addvalue) { IList <CharacterRelationship> CRS = new List <CharacterRelationship>(); bool exists = false; foreach (var r in peep.Relationships) { CharacterRelationship rel = r; if (r.otherChar == CR.otherChar) { rel.lastAction = CR.lastAction; rel.value = r.value + addvalue; exists = true; } CRS.Add(rel); } if (exists == false) { CR.value = addvalue; CRS.Add(CR); } peep.Relationships = CRS; return(peep); }
public GameState addSocial(GameState gs, Character peep) { if (peep.current_task == "sleep") { return(gs); } Character ogpeep = peep; IList <Character> nearbys = getNearBys(gs, peep); if (nearbys.Count == 0) { return(gs); } float mood = getMood(gs, peep); var r1 = r.Next(2, 11); //social at all? if (gsi.GetPersonality(peep, PersonalityIdx.Outgoing) < r1) { return(gs); } r1 = r.Next(-2, 2); float secure = (gsi.GetPersonality(peep, PersonalityIdx.Confidence) + gsi.GetPersonality(peep, PersonalityIdx.Courage)) / 2; secure = moodMod(peep.mood, secure) + r1; float friendly = (gsi.GetPersonality(peep, PersonalityIdx.Friendly) + gsi.GetPersonality(peep, PersonalityIdx.Empathy)) / 2; friendly = moodMod(peep.mood, friendly) + r1; r1 = r.Next(-2, 2); float optimist = (gsi.GetPersonality(peep, PersonalityIdx.Trust) + gsi.GetPersonality(peep, PersonalityIdx.Confidence) + gsi.GetPersonality(peep, PersonalityIdx.Courage) + gsi.GetPersonality(peep, PersonalityIdx.Adaptability)) / 4; optimist = moodMod(peep.mood, optimist) + r1; r1 = r.Next(-2, 2); float outgoing = moodMod(peep.mood, gsi.GetPersonality(peep, PersonalityIdx.Outgoing)) + r1; r1 = r.Next(-2, 2); //not effected by mood or inversly effected float ammusing = (gsi.GetPersonality(peep, PersonalityIdx.Cunning) + (gsi.GetPersonality(peep, PersonalityIdx.Charisma))) / 2; optimist = ammusing + r1; float arrogance = (gsi.GetPersonality(peep, PersonalityIdx.Confidence) + gsi.GetPersonality(peep, PersonalityIdx.Leadership) + gsi.GetPersonality(peep, PersonalityIdx.Intelligence)) / 3; float r2; List <SocialQueue> SQS = new List <SocialQueue>(); int i = 0; foreach (var other in nearbys) { CharacterRelationship CR = getRelationship(peep, other); //chance to ignore for a higher acquantance int x = i + 1; if (other.current_task == "sleep") { continue; } if (nearbys.Count > x) { r1 = r.Next(1, 5); if (r1 != 3) { continue; } if (nearbys[x] != null) { if (getRelationship(peep, nearbys[x]) != null) { float val = 0; if (CR != null) { val = CR.value; } if (getRelationship(peep, nearbys[x]).value > val) { if (outgoing < 6 || friendly < 6) { continue; } } } } } SocialQueue SQ = new SocialQueue(); //no conditions: SQ.CharId = peep.idkey; SQ.Participater = other.idkey; SQ.Subject = "none"; SQ.PowerTrait = PersonalityIdx.Attractiveness; SQ.Power = gsi.GetPersonality(peep, PersonalityIdx.Attractiveness); ////////unmet char: if (CR == null) { CR = new CharacterRelationship(); CR.idkey = peep.Relationships.Count; CR.otherChar = other.idkey; //establish judging by cover float initial = 0; if (secure < peep.mood) { initial = (gsi.GetPersonality(other, PersonalityIdx.Attractiveness) - gsi.GetPersonality(peep, PersonalityIdx.Attractiveness)); } else { initial = gsi.GetPersonality(other, PersonalityIdx.Attractiveness); } CR.value = initial; //initial hello? r1 = r.Next(4, 11); r2 = r.Next(1, 6); //arrogant? if (initial <= 0 && secure > r1 && friendly < r2) { SQ.Subject = "looked_away"; SQ.PowerTrait = PersonalityIdx.Attractiveness; SQ.Power = gsi.GetPersonality(peep, PersonalityIdx.Attractiveness); SQS.Add(SQ); CR.lastAction = SQ.Subject; peep.Relationships.Add(CR); break; } r2 = r.Next(0, 6); //shy intro? if (friendly > r1 && outgoing <= r2) { SQ.Subject = "nod_hello"; SQ.PowerTrait = PersonalityIdx.Attractiveness; SQ.Power = gsi.GetPersonality(peep, PersonalityIdx.Attractiveness); SQS.Add(SQ); CR.lastAction = SQ.Subject; peep.Relationships.Add(CR); break; } r1 = r.Next(3, 7); r2 = r.Next(3, 7); //Friendly + intro? if (friendly > r1 && secure > r2) { SQ.Subject = "friendly_intro"; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = gsi.GetPersonality(peep, PersonalityIdx.Charisma); SQS.Add(SQ); CR.lastAction = SQ.Subject; peep.Relationships.Add(CR); break; } r1 = r.Next(5, 10); //Cynical + intro? if (ammusing > r1) { SQ.Subject = "cynical_intro"; SQ.PowerTrait = PersonalityIdx.Cunning; SQ.Power = gsi.GetPersonality(peep, (PersonalityIdx.Charisma)) + gsi.GetPersonality(peep, +PersonalityIdx.Cunning); SQS.Add(SQ); CR.lastAction = SQ.Subject; peep.Relationships.Add(CR); break; } r2 = r.Next(1, 7); //flirtatious intro if (initial >= -1 && outgoing > 5 && other.gender != peep.gender) { SQ.Subject = "flirtatious_intro"; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = gsi.GetPersonality(peep, (PersonalityIdx.Charisma)); SQS.Add(SQ); CR.lastAction = SQ.Subject; peep.Relationships.Add(CR); break; } } //acquantance if (CR != null) { r1 = r.Next(0, 2); //if (r1 == 1) return gs; if (CR.value > -10) { r1 = r.Next(4, 11); float power = 0; if (outgoing >= r1) { //work float work_attitude = ((5 - gsi.GetPersonality(peep, (PersonalityIdx.Ambition))) * -1) + ((5 - mood) * -1); if (peep.current_task == "work" && other.current_task == "work") { r1 = r.Next(0, 2); //if (r1 != 0) return gs; r1 = r.Next(0, 3); if (r1 == 0) { SQ.Subject = "work"; SQ.PowerTrait = PersonalityIdx.Ambition; SQ.Power = work_attitude; CR.lastAction = SQ.Subject; peep = AddUpdateRelationship(peep, CR, 0); SQS.Add(SQ); break; } if (r1 == 1) { //complain? if (work_attitude < 2) { SQ.Subject = "complain_about_work"; SQ.PowerTrait = PersonalityIdx.Ambition; SQ.Power = work_attitude; CR.lastAction = SQ.Subject; peep = AddUpdateRelationship(peep, CR, 0); SQS.Add(SQ); break; } else { SQ.Subject = "enthuse_about_work"; SQ.PowerTrait = PersonalityIdx.Ambition; SQ.Power = work_attitude; CR.lastAction = SQ.Subject; peep = AddUpdateRelationship(peep, CR, 0); SQS.Add(SQ); break; } } if (r1 == 2) { r2 = r.Next(4, 10); if (arrogance > r2) { SQ.Subject = "offer_advice"; SQ.PowerTrait = PersonalityIdx.Productivity; SQ.Power = peep.job_skill; SQS.Add(SQ); CR.lastAction = SQ.Subject; peep = AddUpdateRelationship(peep, CR, 0); break; } r2 = r.Next(0, 7); if (arrogance > r2) { SQ.Subject = "ask_advice"; SQ.PowerTrait = PersonalityIdx.Productivity; SQ.Power = peep.job_skill; SQS.Add(SQ); CR.lastAction = SQ.Subject; peep = AddUpdateRelationship(peep, CR, 0); break; } } } } } } i++; } if (ogpeep != peep) { IList <Character> characters = new List <Character>(); foreach (var c in gs.ship.Characters) { Character addchar = c; if (c.idkey == peep.idkey) { addchar = peep; } characters.Add(addchar); } gs.ship.Characters = characters; } gs.SocialQueue.AddRange(SQS); return(gs); }
public GameState SocialCheck(GameState gs, Character peep) { List <SocialQueue> SQS = new List <SocialQueue>(); bool changedone = false; int r1 = r.Next(-3, 3); var outgoing = gsi.GetPersonality(peep, PersonalityIdx.Outgoing) + r1; foreach (SocialQueue Q in gs.SocialQueue) { if (Q.Participater == peep.idkey) { Character other = getCharacter(gs, Q.CharId); CharacterRelationship CRi = getRelationship(peep, other); //add mods...responses float reaction = Q.Power; string response = ""; SocialQueue SQ = new SocialQueue(); float arrogance = (gsi.GetPersonality(peep, PersonalityIdx.Confidence) + gsi.GetPersonality(peep, PersonalityIdx.Leadership) + gsi.GetPersonality(peep, PersonalityIdx.Intelligence)) / 3; float mood = getMood(gs, peep); if (Q.Subject == "looked_away") { reaction = 10 - gsi.GetPersonality(peep, PersonalityIdx.Confidence); } if (Q.Subject == "friendly_intro" && CRi == null) { reaction = ((5 - Q.Power) * -1) + gsi.GetPersonality(peep, PersonalityIdx.Friendly); response = "friendly_intro"; } if (Q.Subject == "nod_hello" && CRi == null) { if (outgoing > 5) { response = "friendly_intro"; } else { response = "nod_hello"; } } if (Q.Subject == "cynical_intro" && CRi == null) { reaction = ((5 - Q.Power) * -1) + gsi.GetPersonality(peep, PersonalityIdx.Cunning); response = "friendly_intro"; } if (Q.Subject == "flirtatious_intro" && CRi == null) { reaction = gsi.GetPersonality(other, PersonalityIdx.Attractiveness) - gsi.GetPersonality(peep, PersonalityIdx.Attractiveness) + Q.Power; if (reaction > 0) { response = "flirtatious_intro"; } else { response = "friendly_intro"; } } if (response == "flirtatious_intro") { SQ.Subject = response; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = gsi.GetPersonality(peep, PersonalityIdx.Charisma); SQS.Add(SQ); } if (response == "nod_hello") { SQ.Subject = response; SQ.PowerTrait = PersonalityIdx.Attractiveness; SQ.Power = gsi.GetPersonality(peep, PersonalityIdx.Charisma); SQS.Add(SQ); } if (response == "friendly_intro") { SQ.Subject = response; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = gsi.GetPersonality(peep, PersonalityIdx.Charisma); SQS.Add(SQ); } if (Q.Subject == "work" || Q.Subject == "complain_about_work" || Q.Subject == "enthuse_about_work") { reaction = 5; float work_attitude = ((5 - gsi.GetPersonality(peep, (PersonalityIdx.Ambition))) * -1) + ((5 - mood) * -1); if (Q.Subject == "complain_about_work") { reaction = 10 - gsi.GetPersonality(peep, (PersonalityIdx.Ambition)); } if (Q.Subject == "enthuse_about_work") { reaction = gsi.GetPersonality(peep, (PersonalityIdx.Ambition)); } if (work_attitude > (Q.Power - 2) && work_attitude < (Q.Power + 2)) { //in agreeance SQ.Subject = "agree"; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = 5; SQS.Add(SQ); } else { reaction = reaction * -1; SQ.Subject = "dissagree"; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = -5; SQS.Add(SQ); } } if (Q.Subject == "offer_advice") { if (arrogance > 5 || mood < 5) { //didn't want advice reaction = arrogance * -1; } else { reaction = 5 - arrogance; } r1 = r.Next(0, 8); if (gsi.GetPersonality(peep, PersonalityIdx.Friendly) >= 5 && gsi.GetPersonality(peep, PersonalityIdx.Honesty) < r1) { SQ.Subject = "thank"; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = 5; SQS.Add(SQ); } else { r1 = r.Next(1, 7); if (gsi.GetPersonality(peep, PersonalityIdx.Observation) > r1 && peep.job_skill > other.job_skill) { if (gsi.GetPersonality(peep, PersonalityIdx.Honesty) >= 5) { SQ.Subject = "dissagree"; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = -5; SQS.Add(SQ); } } } } if (Q.Subject == "ask_advice") { reaction = gsi.GetPersonality(peep, PersonalityIdx.Ambition); if (gsi.GetPersonality(peep, PersonalityIdx.Confidence) > (10 - mood)) { SQ.Subject = "give_advice"; SQ.PowerTrait = PersonalityIdx.Charisma; SQ.Power = 5; SQS.Add(SQ); } } //////////enders/////////// if (Q.Subject == "agree" || Q.Subject == "dissagree" || Q.Subject == "thank" || Q.Subject == "give_advice") { reaction = Q.Power; } CharacterRelationship CR = new CharacterRelationship(); CR.idkey = peep.Relationships.Count; CR.otherChar = other.idkey; CR.lastAction = Q.Subject + "_response" + "_" + SQ.Subject; peep = AddUpdateRelationship(peep, CR, reaction); //negative-positive attitude adjustment peep.anxiety = peep.anxiety + (reaction / 100); peep.happiness = peep.happiness + (reaction / 100); peep = updateNeed(peep, NeedsIdx.Social, 1.0f); //move near - temp positioning //peep.dest_x = gs.ship.Characters[Q.CharId].pos_x + 20; //peep.dest_y = gs.ship.Characters[Q.CharId].pos_y; //answer-- if near? //remove/respond changedone = true; } else { SQS.Add(Q); } } if (changedone) { IList <Character> characters = new List <Character>(); foreach (var c in gs.ship.Characters) { Character addchar = c; if (c.idkey == peep.idkey) { addchar = peep; } characters.Add(addchar); } gs.ship.Characters = characters; } gs.SocialQueue = SQS; return(gs); }