-
Notifications
You must be signed in to change notification settings - Fork 6
/
Kissable.cs
356 lines (285 loc) · 10.2 KB
/
Kissable.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
using System;
using XRL.Core;
using XRL.UI;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using Qud.API;
using XRL.World.Effects;
using XRL.Rules;
using XRL.World.Parts;
using XRL.World.Anatomy;
namespace XRL.World.Parts
{
[Serializable]
public class acegiak_Kissable : IPart
{
[NonSerialized]
public List<acegiak_KissingPreference> preferences = null;
public acegiak_Kissable()
{
}
public override bool SameAs(IPart p)
{
return false;
}
public override bool AllowStaticRegistration()
{
return true;
}
// public override bool FireEvent(Event E){
// if (E.ID == "GetInventoryActions")
// {
// if(ParentObject.pBrain.GetFeeling(E.GetGameObjectParameter("Owner")) > 0){
// E.GetParameter<EventParameterGetInventoryActions>("Actions").AddAction("Kiss", 'k', false, "&Wk&yiss", "InvCommandKiss");
// }
// }
// if (E.ID == "InvCommandKiss" && Kiss(E.GetGameObjectParameter("Owner")))
// {
// if(ParentObject.pBrain.GetFeeling(E.GetGameObjectParameter("Owner")) > 0){
// E.RequestInterfaceExit();
// }
// }
// return base.FireEvent(E);
// }
public override bool WantEvent(int ID, int cascade)
{
if (!base.WantEvent(ID, cascade) && ID != GetInventoryActionsEvent.ID)
{
return ID == InventoryActionEvent.ID;
}
return true;
}
public override bool HandleEvent(GetInventoryActionsEvent E)
{
if(ParentObject.pBrain.GetFeeling(E.Actor) > 0){
E.AddAction("Kiss", "kiss", "Kiss", null, 'k', false, 10);
}
return base.HandleEvent(E);
}
public override bool HandleEvent(InventoryActionEvent E)
{
if (E.Command == "Kiss" && ParentObject.pBrain.GetFeeling(E.Actor) > 0 && Kiss(E.Actor))
{
E.RequestInterfaceExit();
} return base.HandleEvent(E);
}
public void KissBuff(GameObject who){
if(!who.HasEffect("acegiak_EffectGay")){
who.ApplyEffect(new acegiak_EffectGay());
}
}
public bool Kiss(GameObject who)
{
if (!hasPart(ParentObject,"face")){
if (who.IsPlayer())
{
Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + "&y doesn't have a face.");
}
return true;
}
if (!hasPart(who,"face")){
if (who.IsPlayer())
{
Popup.Show("You don't have a face.");
}
return true;
}
string beguiled = "";
string hbeguiled = " &Mkissed you back&y.";
if(ParentObject.GetIntProperty("BeguilingBonusApplied") >0){
beguiled = "\n"+ParentObject.It+ParentObject.GetVerb("quake")+" with fear and manic ecstasy.";
hbeguiled = " could not resist.";
}else{
if (ParentObject.pBrain.GetFeeling(who) < 20)
{
if (who.IsPlayer())
{
Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + "&y" + ParentObject.GetVerb("shy") + " away from you.");
}
ParentObject.pBrain.AdjustFeeling(who,-5);
if(ParentObject.pBrain.GetFeeling(who) < 0){
Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + "&Y is upset by your advances!");
}
return true;
}
if(!isAttractedTo(who)){
if (who.IsPlayer())
{
Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + "&Y isn't attracted to you.");
}
ParentObject.pBrain.AdjustFeeling(who,-10);
if(ParentObject.pBrain.GetFeeling(who) < 0){
Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + "&Y is upset by your advances!");
}
return true;
}
}
if(ParentObject.GetPart<acegiak_Romancable>() != null){
if(ParentObject.GetPart<acegiak_Romancable>().patience<=0){
ParentObject.pBrain.AdjustFeeling(who,-5);
Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + "&Y doesn't want to kiss you right now.");
if(ParentObject.pBrain.GetFeeling(who) < 0){
Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + "&Y is upset by your advances!");
}
}
ParentObject.GetPart<acegiak_Romancable>().patience--;
}
string verb = "kiss";
GameObject parentObject = ParentObject;
IPart.XDidYToZ(who, verb, parentObject);
if (who.IsPlayer())
{
if (ParentObject.HasPropertyOrTag("SpecialKissResponse"))
{
Popup.Show(ParentObject.GetTag("SpecialKissResponse"));
}
else
{
KissBuff(who);
Popup.Show(ParentObject.The + ParentObject.DisplayNameOnlyDirect + "&y " + ParentObject.GetPropertyOrTag("KissResponse", "&Mkisses you back") + "."+beguiled);
JournalAPI.AddAccomplishment("&y You kissed "+ParentObject.a + ParentObject.DisplayNameOnlyDirect +" and "+ParentObject.it+hbeguiled, "general", null);
}
}
ParentObject.Heartspray();
if(ParentObject.pBrain.GetFeeling(who) < 50){
ParentObject.pBrain.AdjustFeeling(who,10);
}
who.UseEnergy(1000, "Kissing");
ParentObject.FireEvent(Event.New("ObjectKissed", "Object", ParentObject, "Kisser", who));
return true;
}
public void havePreference(){
if(preferences == null){
preferences = new List<acegiak_KissingPreference>();
List<acegiak_KissingPreference> possible = new List<acegiak_KissingPreference>();
if(GameObjectFactory.Factory == null || GameObjectFactory.Factory.BlueprintList == null){
return;
}
foreach (GameObjectBlueprint blueprint in GameObjectFactory.Factory.BlueprintList)
{
if (!blueprint.IsBaseBlueprint() && blueprint.DescendsFrom("KissingPreference"))
{
//IPart.AddPlayerMessage(blueprint.Name);
GameObject sample = GameObjectFactory.Factory.CreateSampleObject(blueprint.Name);
if(sample.HasTag("classname") && sample.GetTag("classname") != null && sample.GetTag("classname") != ""){
acegiak_KissingPreference preference = Activator.CreateInstance(Type.GetType(sample.GetTag("classname")),ParentObject) as acegiak_KissingPreference;
possible.Add(preference);
}
}
}
int count = Stat.Rnd2.Next(5);
for(int i = 0; i<count;i++){
int w = Stat.Rnd2.Next(possible.Count());
preferences.Add(possible[w]);
}
}
}
public float attractionAmount(GameObject kisser){
havePreference();
float sum = 0;
IPart.AddPlayerMessage("" + ParentObject.the + ParentObject.DisplayNameOnly + "&c examines you.");
List<string> many = new List<string>();
foreach(acegiak_KissingPreference pref in preferences){
acegiak_KissingPreferenceResult output = pref.attractionAmount(ParentObject,kisser);
sum += output.amount;
if(kisser.IsPlayer() && !many.Contains(output.explanation)){
IPart.AddPlayerMessage("" + ParentObject.the + ParentObject.DisplayNameOnly + " "+output.explanation+".");
}
many.Add(output.explanation);
}
return sum;
}
public bool isAttractedTo(GameObject kisser){
float sum = attractionAmount(kisser);
if(sum > 0){
return true;
}
return false;
}
private bool hasPart(GameObject GO, string partname){
Body part = GO.GetPart<Body>();
if (part == null)
{
return false;
}
BodyPart bpart = part.GetBody();
return bpart != null;
}
private bool partHasPart(BodyPart part, string partname){
if(part.Type == partname){
return true;
}
foreach(BodyPart subpart in part.Parts){
if(subpart != part && partHasPart(subpart,partname)){
return true;
}
}
return false;
}
// public Conversation InjectRomance(Conversation conversation){
// if(conversation == null
// || conversation.NodesByID == null
// || ! conversation.NodesByID.ContainsKey("Start")
// || conversation.NodesByID["Start"].Choices == null){
// return conversation;
// }
// ConversationChoice returntostart = new ConversationChoice();
// returntostart.Text = "Ok.";
// returntostart.GotoID = "Start";
// ConversationNode aboutme = new ConversationNode();
// aboutme.ID = "acegiak_aboutme";
// aboutme.Text = "I like long walks on the beach where sometimes I look back and there's only one set of footprints";
// aboutme.Choices.Add(returntostart);
// ConversationChoice romanticEnquiry = new ConversationChoice();
// romanticEnquiry.Text = "Tell me a little about yourself.";
// romanticEnquiry.GotoID = "acegiak_about";
// conversation.NodesByID["Start"].Choices.Add(romanticEnquiry);
// conversation.AddNode(aboutme);
// return conversation;
// }
// SaveData is called when the game is ready to save this object, so we override it here.
public override void SaveData(SerializationWriter Writer)
{
this.havePreference();
if(Writer == null){
throw new Exception("The Writer is null!");
}
if(preferences == null){
throw new Exception("The preferences list is null!");
}
this.preferences.RemoveAll(d=>d==null);
// We have to call base.SaveData to save all normally serialized fields on our class
base.SaveData(Writer);
// Writing out the number of items in this list lets us know how many items we need to read back in on Load
Writer.Write(preferences.Count);
foreach (acegiak_KissingPreference preference in preferences)
{
preference.Save(Writer);
}
}
// Load data is called when loading the save game, we also need to override this
public override void LoadData(SerializationReader Reader)
{
// Load our normal data
base.LoadData(Reader);
this.preferences = new List<acegiak_KissingPreference>();
if(Reader == null){
throw new Exception("The Reader is null!");
}
if(preferences == null){
throw new Exception("The preferences list is null!");
}
if(this == null){
throw new Exception("This is null!");
}
// Read the number we wrote earlier telling us how many items there were
int arraySize = Reader.ReadInt32();
for (int i = 0; i < arraySize; i++)
{
acegiak_KissingPreference.Read(Reader,this);
// Similar to above, if we had a basic type in our list, we would instead use the Reader.Read function specific to our object type.
}
}
}
}