npc_set_preference.qsrc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. # npc_set_preference
  2. !! npc_code = 'A***', 'B***', 'C***', etc.
  3. !! Full reset of npc preferences:
  4. !! gs 'npc_set_preference', 'reset', npc_code
  5. !!
  6. !! Add a preference to an npc:
  7. !! gs 'npc_set_preference', npc_code, trait, amount
  8. !! trait: = 'strong', 'cum_on_face', 'tits_big', 'ass_bubble', etc.
  9. !!
  10. !! amount = 'hate', 'dislike', 'neutral', 'like', 'love'
  11. if $ARGS[0] = 'reset':
  12. $npc_preferences[$ARGS[1]] = ''
  13. end
  14. !! $ARGS[0] = 'A***', 'B***', 'C***', etc.
  15. if isnum(mid($ARGS[0], 2)):
  16. !!Dynamically create the $npc_pref_traits and npc_trait_values arrays
  17. dynamic $npc_preferences[$ARGS[0]]
  18. dynamic $npc_pref_values[$ARGS[0]]
  19. !! Example of these created arrays.
  20. !!$npc_pref_traits: npc_pref_traits[i] = 'strong'
  21. !!npc_trait_values: npc_trait_values['strong'] = -15
  22. !! Translate 'hate, dislike, etc. into a number and store it.'
  23. temp_trait_value = func('npc_set_preference', 'get_value', $ARGS[1], $ARGS[2])
  24. !! If the trait_value is 0 (aka 'neutral'), it doesn''t add anything to the attraction system. So we don''t bother adding it.
  25. if temp_trait_value ! 0:
  26. temp_skip_loop = 0
  27. :skip_start
  28. !! Escape the preference loops when overwriting a preference.
  29. if temp_skip_loop = 0:
  30. !!if the npc has no preferences, create the $npc_preferences and $npc_pref_values entries from scratch.
  31. if arrsize('$npc_pref_traits') = 0:
  32. !!replace(..., ' ', '') is there to remove the tabs from the string.
  33. $npc_preferences[$ARGS[0]] = replace({killvar '$npc_pref_traits'
  34. $npc_pref_traits[] = } + "'<<$ARGS[1]>>'" + {
  35. }, ' ', '')
  36. $npc_pref_values[$ARGS[0]] = replace({killvar 'npc_trait_values'
  37. npc_trait_values} + "['<<$ARGS[1]>>'] = <<temp_trait_value>>" + {
  38. }, ' ', '')
  39. else
  40. !!loop over every preference to check if the npc already has a preference for that trait.
  41. i = 0
  42. :preference_loop
  43. !!The npc already has a preference for the trait.
  44. !!We overwrite the trait and then escape the preference_loop
  45. if $npc_pref_traits = $ARGS[1]:
  46. if temp_trait_value ! 0:
  47. npc_trait_values[$ARGS[1]] = temp_trait_value
  48. !!Rebuild the $npc_pref....[$ARGS[0]] strings from the grounds up
  49. gs 'npc_set_preference', 'rebuild_preferences', $ARGS[0]
  50. temp_skip_loop = 1
  51. jump 'skip_start'
  52. end
  53. i += 1
  54. if i < arrsize('$npc_pref_traits'): jump 'preference_loop'
  55. !!We have checked that the npc has no preference for the trait.
  56. !!We add the preference to the npc.
  57. $npc_preferences[$ARGS[0]] += replace({$npc_pref_traits[] = } + "'<<$ARGS[1]>>'" + {
  58. }, ' ', '')
  59. $npc_pref_values[$ARGS[0]] += replace({npc_trait_values} + "['<<$ARGS[1]>>'] = <<temp_trait_value>>" + {
  60. }, ' ', '')
  61. end
  62. end
  63. killvar '$npc_pref_traits'
  64. killvar 'npc_trait_values'
  65. killvar 'i'
  66. killvar 'temp_skip_loop'
  67. killvar 'skip_start'
  68. !! 'neutral' preference removes the preference from our list.
  69. else
  70. gs 'npc_set_preference', 'remove_preference', $ARGS[0], ARGS[1]
  71. end
  72. killvar 'temp_trait_value'
  73. end
  74. if $ARGS[0] = 'rebuild_preferences':
  75. !!Rebuild the $npc_pref....[$ARGS[0]] strings from the grounds up
  76. $temp_npc_pref_traits = {killvar '$npc_pref_traits'
  77. }
  78. $temp_npc_trait_values = {killvar 'npc_trait_values'
  79. }
  80. !!Loop over every preference and add it to the $npc_pref....[$ARGS[0]] strings.
  81. i = 0
  82. :pref_loop_2
  83. $temp_npc_pref_traits += {$npc_pref_traits[] = } + "'<<$npc_pref_traits[i]>>'" + {
  84. }
  85. $temp_npc_trait_values += {npc_trait_values} + "['<<$npc_pref_traits[i]>>'] = <<npc_trait_values[i]>>" + {
  86. }
  87. i += 1
  88. if i < arrsize('$npc_pref_traits'): jump 'pref_loop_2'
  89. !!Overwrite the $npc_pref....[$ARGS[0]] strings with the rebuild string.
  90. $npc_preferences[$ARGS[0]] = replace($temp_npc_pref_traits, ' ', '')
  91. $npc_pref_values[$ARGS[0]] = replace($temp_npc_trait_values, ' ', '')
  92. killvar '$temp_npc_pref_traits'
  93. killvar '$temp_npc_trait_values'
  94. killvar 'pref_loop_2'
  95. end
  96. if $ARGS[0] = 'remove_preference':
  97. !! Check the position of the preference in the preference array.
  98. temp_trait_position = arrpos('$npc_pref_traits', $ARGS[1])
  99. !! If the preference exists:
  100. if temp_trait_position ! -1:
  101. !! Remove the preference from the array.
  102. killvar '$npc_pref_traits', temp_trait_position
  103. killvar 'npc_trait_values', $ARGS[1]
  104. !! Then rebuild the dynamic string.
  105. gs 'npc_set_preference', 'rebuild_preferences', $ARGS[0]
  106. end
  107. end
  108. !!====================================!!
  109. !! !!
  110. !! Calculate pref_value !!
  111. !! !!
  112. !!====================================!!
  113. if $ARGS[0] = 'get_value':
  114. temp_pref_values['hate'] = -30
  115. temp_pref_values['dislike'] = -15
  116. temp_pref_values['neutral'] = 0
  117. temp_pref_values['like'] = 15
  118. temp_pref_values['love'] = 30
  119. if $ARGS[1] = 'body_fit' or $ARGS[1] = 'body_piercing':
  120. temp_pref_values['hate'] = -30
  121. temp_pref_values['dislike'] = -15
  122. end
  123. if $ARGS[2] = 'hate':
  124. result = temp_pref_values['hate']
  125. elseif $ARGS[2] = 'dislike':
  126. result = temp_pref_values['dislike']
  127. elseif $ARGS[2] = 'like':
  128. result = temp_pref_values['like']
  129. elseif $ARGS[2] = 'love':
  130. result = temp_pref_values['love']
  131. else
  132. result = temp_pref_values['neutral']
  133. end
  134. killvar 'temp_pref_values'
  135. end
  136. !! To be updated
  137. !! 'body_tits_big'
  138. !! 'body_ass_bubble'
  139. !! Body
  140. !! 'body_fit'
  141. !! 'body_piercing'
  142. !! 'body_pregnant'
  143. !! 'body_strong'
  144. !! 'body_tan'
  145. !! 'body_tatoo'
  146. !! Clothes
  147. !! 'clothes_bimbo'
  148. !! 'clothes_goth'
  149. !! 'clothes_punk'
  150. !! 'clothes_skirt_short'
  151. !! 'clothes_thin'
  152. !! Cosmetics
  153. !! 'cosmetics_makeup'
  154. !! Cum
  155. !! 'cum_face'
  156. !! 'cum_clothes'
  157. --- npc_set_preference ---------------------------------