123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- # set_npc_attraction
- !! set_npc_attraction function.
- !!
- !! 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)
- !! How to use:
- !! gs 'set_npc_attraction', $npc_code, max_pcs_hotcat_change
- !! $npc_code: the code of the npc for which we calculate. Examles: 'A12', 'B3', 'C13'
- !! max_pcs_hotcat_change: the maximum difference between npc_rel_hotcat and normal pcs_hotcat.
- !! Defaults to 2. When set negative, it is unbounded instead.
- !!
- !! Sets the npc_attraction[$npc_code] and npc_rel_hotcat[$npc_code] variables
- !! We start with the player''s appearance and add modifiers based on the npc''s preferences.
- npc_attraction[$ARGS[0]] = pcs_apprnc
- !! Create the $npc_pref_traits and npc_trait_values arrays
- dynamic $npc_preferences[$ARGS[0]]
- if arrsize('$npc_pref_traits') > 0:
- set_attraction_loop_index = 0
- :preferences_loop_start
- !!Per preference, we see if the preference applies (the func() part) if so we add the attraction value.
- !!If the value is positive, then the npc likes that quality. If it is negative they dislike it.
- 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] )
- set_attraction_loop_index +=1
- if set_attraction_loop_index < arrsize('$npc_pref_traits'): jump 'preferences_loop_start'
- killvar 'set_attraction_loop_index'
- end
- killvar '$npc_pref_traits'
- killvar 'npc_trait_values'
- if npc_attraction[$ARGS[0]] <= 40:
- npc_rel_hotcat[$ARGS[0]] = 1
- elseif npc_attraction[$ARGS[0]] <= 60:
- npc_rel_hotcat[$ARGS[0]] = 2
- elseif npc_attraction[$ARGS[0]] <= 80:
- npc_rel_hotcat[$ARGS[0]] = 3
- elseif npc_attraction[$ARGS[0]] <= 100:
- npc_rel_hotcat[$ARGS[0]] = 4
- elseif npc_attraction[$ARGS[0]] <= 125:
- npc_rel_hotcat[$ARGS[0]] = 5
- elseif npc_attraction[$ARGS[0]] <= 150:
- npc_rel_hotcat[$ARGS[0]] = 6
- elseif npc_attraction[$ARGS[0]] <= 165:
- npc_rel_hotcat[$ARGS[0]] = 7
- elseif npc_attraction[$ARGS[0]] <= 180:
- npc_rel_hotcat[$ARGS[0]] = 8
- elseif npc_attraction[$ARGS[0]] <= 199:
- npc_rel_hotcat[$ARGS[0]] = 9
- else
- npc_rel_hotcat[$ARGS[0]] = 10
- end
- if arrsize('ARGS') = 1: ARGS[1] = 2
- if ARGS[1] >= 0:
- if npc_rel_hotcat[$ARGS[0]] - pcs_hotcat > ARGS[1]:
- npc_rel_hotcat[$ARGS[0]] = pcs_hotcat + ARGS[1]
- elseif pcs_hotcat - npc_rel_hotcat[$ARGS[0]] > ARGS[1]:
- npc_rel_hotcat[$ARGS[0]] = pcs_hotcat - ARGS[1]
- end
- end
- --- set_npc_attraction ---------------------------------
|