1
0

set_npc_attraction.qsrc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # set_npc_attraction
  2. !! set_npc_attraction function.
  3. !!
  4. !! Modify the attraction (analogous to appearance) and relative pcs_hotcat (analogous to pcs_hotcat) using the various preferences (set in npc_set_preference, standard preferences set in npcstatic stored in npc_standard_preferences)
  5. !! How to use:
  6. !! gs 'set_npc_attraction', $npc_code, max_pcs_hotcat_change
  7. !! $npc_code: the code of the npc for which we calculate. Examles: 'A12', 'B3', 'C13'
  8. !! max_pcs_hotcat_change: the maximum difference between npc_rel_hotcat and normal pcs_hotcat.
  9. !! Defaults to 2. When set negative, it is unbounded instead.
  10. !!
  11. !! Sets the npc_attraction[$npc_code] and npc_rel_hotcat[$npc_code] variables
  12. !! We start with the player''s appearance and add modifiers based on the npc''s preferences.
  13. npc_attraction[$ARGS[0]] = pcs_apprnc
  14. !! Create the $npc_pref_traits and npc_trait_values arrays
  15. dynamic $npc_preferences[$ARGS[0]]
  16. if arrsize('$npc_pref_traits') > 0:
  17. set_attraction_loop_index = 0
  18. :preferences_loop_start
  19. !!Per preference, we see if the preference applies (the func() part) if so we add the attraction value.
  20. !!If the value is positive, then the npc likes that quality. If it is negative they dislike it.
  21. npc_attraction[$ARGS[0]] += npc_trait_values[$npc_pref_traits[set_attraction_loop_index]] * func( 'pcs_has_attr', $npc_pref_traits[set_attraction_loop_index] )
  22. set_attraction_loop_index +=1
  23. if set_attraction_loop_index < arrsize('$npc_pref_traits'): jump 'preferences_loop_start'
  24. killvar 'set_attraction_loop_index'
  25. end
  26. killvar '$npc_pref_traits'
  27. killvar 'npc_trait_values'
  28. if npc_attraction[$ARGS[0]] <= 40:
  29. npc_rel_hotcat[$ARGS[0]] = 1
  30. elseif npc_attraction[$ARGS[0]] <= 60:
  31. npc_rel_hotcat[$ARGS[0]] = 2
  32. elseif npc_attraction[$ARGS[0]] <= 80:
  33. npc_rel_hotcat[$ARGS[0]] = 3
  34. elseif npc_attraction[$ARGS[0]] <= 100:
  35. npc_rel_hotcat[$ARGS[0]] = 4
  36. elseif npc_attraction[$ARGS[0]] <= 125:
  37. npc_rel_hotcat[$ARGS[0]] = 5
  38. elseif npc_attraction[$ARGS[0]] <= 150:
  39. npc_rel_hotcat[$ARGS[0]] = 6
  40. elseif npc_attraction[$ARGS[0]] <= 165:
  41. npc_rel_hotcat[$ARGS[0]] = 7
  42. elseif npc_attraction[$ARGS[0]] <= 180:
  43. npc_rel_hotcat[$ARGS[0]] = 8
  44. elseif npc_attraction[$ARGS[0]] <= 199:
  45. npc_rel_hotcat[$ARGS[0]] = 9
  46. else
  47. npc_rel_hotcat[$ARGS[0]] = 10
  48. end
  49. if arrsize('ARGS') = 1: ARGS[1] = 2
  50. if ARGS[1] >= 0:
  51. if npc_rel_hotcat[$ARGS[0]] - pcs_hotcat > ARGS[1]:
  52. npc_rel_hotcat[$ARGS[0]] = pcs_hotcat + ARGS[1]
  53. elseif pcs_hotcat - npc_rel_hotcat[$ARGS[0]] > ARGS[1]:
  54. npc_rel_hotcat[$ARGS[0]] = pcs_hotcat - ARGS[1]
  55. end
  56. end
  57. --- set_npc_attraction ---------------------------------