Removed: client datas moved to RyzomDatas repository
--HG-- branch : compatibility-develophg/compatibility-develop
parent
033bd1f373
commit
3b9550ca2a
@ -1,33 +0,0 @@
|
||||
|
||||
# for the bot
|
||||
BC_INTRO "Hello sir, what can I do for you ?"
|
||||
BC_TRADE "Choose something to buy, or maybe you've got something to sell ?"
|
||||
BC_BRICKS "Here are my bricks."
|
||||
BC_SKILLS "For what skill do you need training ?"
|
||||
BC_AVAILABLE_MISSIONS "Pick a mission."
|
||||
BC_MISSION_DESCRIPTION "Here's the mission description :"
|
||||
BC_MISSION_DETAILS "Here's the reason for this mission :"
|
||||
BC_MISSION_ITEM_DESCRIPTION "To get this, you should :"
|
||||
BC_MISSION_ITEM_DETAILS "Here's the reason for this mission :"
|
||||
BC_MISSION_PROGRESS "Which point did you reach in your mission ?"
|
||||
BC_NEXT_STEP "Here's the following step of your mission :"
|
||||
BC_COMPLETED_MISSION "Which mission did you complete ?"
|
||||
BC_MISSION_REWARD "Here's your reward"
|
||||
BC_PACTS "Choose a pact."
|
||||
|
||||
# for the player
|
||||
BC_BUY_BRICKS "I want to buy bricks."
|
||||
BC_ASK_TRADE "Let's trade."
|
||||
BC_ASK_MISSION_LIST "Do you have any mission for me ?"
|
||||
BC_ASK_TELEPORT "I want to teleport somewhere ?"
|
||||
BC_ASK_PACTS "Let's talk about pacts."
|
||||
BC_ASK_SKILL "Can you train me ?"
|
||||
BC_ASK_MISSION_PROGRESS "I've completed steps in a mission."
|
||||
BC_ASK_MISSION_COMPLETED "I've completed a mission."
|
||||
BC_QUIT "See you later."
|
||||
BC_TO_INTRO "Let's talk about something else."
|
||||
BC_ACCEPT_MISSION "I accept this mission."
|
||||
BC_TELL_ME_MORE "Tell me more."
|
||||
BC_BACK_TO_MISSIONS "Can I see what missions you propose again ?"
|
||||
BC_NEXT_PAGE "Next page"
|
||||
BC_PREVIOUS_PAGE "Previous page"
|
@ -1,40 +0,0 @@
|
||||
#CMS down
|
||||
EGS_COMBAT_CMS_DOWN "&RG&(Server Debug) The combat move service is down, cannot engage melee combat..."
|
||||
|
||||
# when an entity attacks another entity
|
||||
BS_YOU_ATTACK_E "&BC&You attack $0e."
|
||||
BS_ATTACKS_YOU_E "&RG&$0e attacks you."
|
||||
BS_ATTACKS_EE "&BC&$0e attacks $1e."
|
||||
|
||||
# when an entity leaves combat
|
||||
BS_YOU_END_ATTACK_E "&BC&You stop attacking $0e."
|
||||
BS_END_ATTACKS_YOU_E "&RG&$0e leaves combat."
|
||||
BS_END_ATTACKS_EE "&BC&$0e stops attacking $1e."
|
||||
|
||||
# when damage is done to/by an entity
|
||||
BS_HIT_EEI "&BC&$0e hits $1e for $2i damage."
|
||||
BS_YOU_HIT_EI "&BC&You inflict $1i points of damage on $0e."
|
||||
BS_HITS_YOU_EI "&RG&$0e hits you for $1i damage."
|
||||
BS_HIT_NULL_EE "&BC&$0e hits $1e but does no damage."
|
||||
BS_YOU_HIT_NULL_E "&BC&You hit $0e but do no damage."
|
||||
BS_HITS_YOU_NULL_E "&RG&$0e hits you but does no damage."
|
||||
|
||||
# when an entity misses his/her enemy in combat
|
||||
BS_YOU_MISS_E "&BC&You miss $0e."
|
||||
BS_MISSES_YOU_E "&RG&$0e misses you."
|
||||
BS_MISSES_EE "&BC&$0e misses $1e."
|
||||
|
||||
# critical hit
|
||||
EGS_YOU_CRITICAL_HIT_E "&BC&You perform a critical strike on $0e."
|
||||
EGS_CRITICAL_HIT_YOU_E "&RG&$0e performs a critical strike on you."
|
||||
EGS_CRITICAL_HIT_EE "&BC&$0e performs a critical strike on $1e."
|
||||
|
||||
# Fumble
|
||||
EGS_YOU_FUMBLE "&RG&You fumble."
|
||||
EGS_ENEMY_FUMBLE_E "&BC&$0e fumbles."
|
||||
EGS_FUMBLE_E "&BC&$0e fumbles."
|
||||
|
||||
EGS_START_DEFAULT_ATTACK "&BL& you return to basic fighting style."
|
||||
BS_SUFFER_PENALTY_NO_STAMINA "&RG&You are low on stamina and suffer a penalty on your combat skills."
|
||||
|
||||
EGS_RANGE_CLOSE_COMBAT_LEAVE "You cannot use a range weapon against an opponent engaged in close combat with you."
|
@ -1,80 +0,0 @@
|
||||
# when an entity resists a spell
|
||||
BS_U_RESIST_SPELL_E "&BC&You resist the spell from $0e."
|
||||
BS_UR_RESIST_SPELL_E "&RG&$0e resists your spell."
|
||||
BS_RESIST_SPELL_EE "&BC&$0e resists the spell from $1e."
|
||||
BS_RESIST_SPELL_E "&BC&$0e resists a spell."
|
||||
|
||||
# when an entity is protected against a special effect
|
||||
BS_TARGET_PROTECTED "&RG&Your target is protected against this type of effect."
|
||||
BS_U_PROTECTED "&VE&You are protected against this type of effect."
|
||||
|
||||
# magic shield
|
||||
BS_MAGIC_SHIELD_I "&VE&Your magic shield has absorbed $0i damage."
|
||||
BS_MAGIC_SHIELD_DEAD "&VE&Your magic shield has been destroyed."
|
||||
|
||||
# when an entity is hit by a spell
|
||||
BS_SUFFER_OFFENSIVE_SPELL_E "&BC&An aggressive spell is cast on $0e."
|
||||
BS_SUFFER_NEUTRAL_SPELL_E "&BC&A neutral spell is cast on $0e."
|
||||
BS_SUFFER_BENEFICIAL_SPELL_E "&BC&A beneficial spell is cast on $0e."
|
||||
|
||||
# when the player is hit by a spell
|
||||
BS_U_SUFFER_OFFENSIVE_SPELL_E "&RG&$0e casts an aggressive spell on you."
|
||||
BS_U_SUFFER_NEUTRAL_SPELL_E "&BC&$0e casts a neutral spell on you."
|
||||
BS_U_SUFFER_BENEFICIAL_SPELL_E "&BC&$0e casts a beneficial spell on you."
|
||||
|
||||
BS_SELF_CAST_S "&BC&The $0s magic hits you."
|
||||
|
||||
# when an entity is casting
|
||||
BS_CASTING_OFFENSIVE_E "&BL&$0e casts an aggressive spell"
|
||||
BS_CASTING_NEUTRAL_E "&BL&$0e casts a neutral spell"
|
||||
BS_CASTING_BENEFICIAL_E "&BL&$0e casts a beneficial spell"
|
||||
|
||||
|
||||
# when an entity is healed
|
||||
BS_HEAL_EEI "&BC&$0e heals $1e by $2i hp"
|
||||
BS_YOU_HEAL_EI "&BC&You heal $0e by $1i hp."
|
||||
BS_HEALS_YOU_EI "&BC&$0e heals you by $1i hp."
|
||||
|
||||
|
||||
# break cast
|
||||
BS_CAST_BREAK "&RG&Your spell casting has been broken."
|
||||
BS_TARGET_HIGHER_LEVEL "&RG&This spell has no effect because the target level is too high."
|
||||
|
||||
|
||||
EGS_MAGIC_U_SUFFER_OFFENSIVE_SPELL_SAP_EI "&RG&$0e inflicts you $1i magic sap damage."
|
||||
EGS_MAGIC_U_CAST_OFFENSIVE_SPELL_SAP_EI "&BC&You inflict $1i magic sap damage to $0e."
|
||||
EGS_MAGIC_U_SUFFER_OFFENSIVE_SPELL_STA_EI "&RG&$0e inflicts you $1i magic stamina damage."
|
||||
EGS_MAGIC_U_CAST_OFFENSIVE_SPELL_STA_EI "&BC&You inflict $1i magic stamina damage to $0e."
|
||||
EGS_MAGIC_U_SUFFER_OFFENSIVE_SPELL_HP_EI "&RG&$0e inflicts you $1i magic hit points damage."
|
||||
EGS_MAGIC_U_CAST_OFFENSIVE_SPELL_HP_EI "&BC&You inflict $1i magic hit points damage to $0e."
|
||||
|
||||
EGS_MAGIC_U_SELFCAST_OFFENSIVE_SPELL_HP_I "&BC&You inflict yourself $0i magic hit points damage."
|
||||
EGS_MAGIC_U_SELFCAST_OFFENSIVE_SPELL_SAP_I "&BC&You inflict yourself $0i magic sap points damage."
|
||||
EGS_MAGIC_U_SELFCAST_OFFENSIVE_SPELL_STA_I "&BC&You inflict yourself $0i magic stamina points damage."
|
||||
|
||||
EGS_MAGIC_CAST_OFFENSIVE_SPELL_HP_EEI "&BC&$0e inflicts $2i magic hit points damage on $1e."
|
||||
EGS_MAGIC_CAST_OFFENSIVE_SPELL_SAP_EEI "&BC&$0e inflicts $2i magic sap points damage on $1e."
|
||||
EGS_MAGIC_CAST_OFFENSIVE_SPELL_STA_EEI "&BC&$0e inflicts $2i magic stamina points damage on $1e."
|
||||
|
||||
EGS_MAGIC_SELFCAST_OFFENSIVE_SPELL_HP_EI "&BC&$0e inflicts himself $1i magic hit points damage."
|
||||
EGS_MAGIC_SELFCAST_OFFENSIVE_SPELL_SAP_EI "&BC&$0e inflicts himself $1i magic sap points damage."
|
||||
EGS_MAGIC_SELFCAST_OFFENSIVE_SPELL_STA_EI "&BC&$0e inflicts himself $1i magic stamina points damage."
|
||||
|
||||
EGS_MAGIC_U_SUFFER_HEAL_SPELL_SAP_EI "&BC&$0e heals you $1i sap."
|
||||
EGS_MAGIC_U_CAST_HEAL_SPELL_SAP_EI "&BC&You heal $0e $1i sap."
|
||||
EGS_MAGIC_U_SUFFER_HEAL_SPELL_STA_EI "&BC&$0e heals you $1i stamina."
|
||||
EGS_MAGIC_U_CAST_HEAL_SPELL_STA_EI "&BC&You heal $0e $1i stamina."
|
||||
EGS_MAGIC_U_SUFFER_HEAL_SPELL_HP_EI "&BC&$0e heals you $1i hit points."
|
||||
EGS_MAGIC_U_CAST_HEAL_SPELL_HP_EI "&BC&You heal $0e $1i hit points."
|
||||
|
||||
EGS_MAGIC_HEAL_SPELL_HP_EEI "&BC&$0e heals $1e $2i hit points."
|
||||
EGS_MAGIC_HEAL_SPELL_SAP_EEI "&BC&$0e heals $1e $2i sap points."
|
||||
EGS_MAGIC_HEAL_SPELL_STA_EEI "&BC&$0e heals $1e $2i stamina points."
|
||||
|
||||
EGS_MAGIC_U_SELF_HEAL_HP_I "&BC&You heal yourself $0i hit points."
|
||||
EGS_MAGIC_U_SELF_HEAL_SAP_I "&BC&You regain $0i sap points."
|
||||
EGS_MAGIC_U_SELF_HEAL_STA_I "&BC&You regain $0i stamina points."
|
||||
EGS_MAGIC_SELF_HEAL_HP_EI "&BC&$0e regains $1i hit points."
|
||||
EGS_MAGIC_SELF_HEAL_SAP_EI "&BC&$0e regains $1i sap points."
|
||||
EGS_MAGIC_SELF_HEAL_STA_EI "&BC&$0e regains $1i stamina points."
|
||||
|
@ -1,15 +0,0 @@
|
||||
# code for sentence difficulty
|
||||
BS_CHILD_PLAY "&VE&Child's play"
|
||||
BS_REAL_EASY "&VE&Really Easy"
|
||||
BS_EASY "&BL&Easy"
|
||||
BS_FAIRLY_EASY "&BL&Fairly easy"
|
||||
BS_AVERAGE "&BC&Average"
|
||||
BS_QUITE_DIFF "&BC&Quite difficult"
|
||||
BS_DIFFICULT "&JA&Difficult"
|
||||
BS_REALLY_DIFF "&JA&Really Difficult"
|
||||
BS_HARSH "&RG&Harsh"
|
||||
BS_EXTR_DIFF "&RG&Keep dreaming!"
|
||||
|
||||
BS_SENTENCE_FAILED "&RG&You failed to use this formula or action phrase."
|
||||
BS_SENTENCE_FAILED_S "&RG&You failed to use the brick $0s."
|
||||
BS_SENTENCE_MAGIC_FAILED_S "&RG&You failed to cast the spell $0s."
|
@ -1,4 +0,0 @@
|
||||
# occ test file
|
||||
"toto" 2
|
||||
"titi" 5
|
||||
|
Binary file not shown.
@ -1,705 +0,0 @@
|
||||
BC_ACCEPT_MISSION 1
|
||||
BC_ASK_MISSION_COMPLETED 1
|
||||
BC_ASK_MISSION_LIST 1
|
||||
BC_ASK_MISSION_PROGRESS 1
|
||||
BC_ASK_PACTS 1
|
||||
BC_ASK_SKILL 1
|
||||
BC_ASK_TELEPORT 1
|
||||
BC_ASK_TRADE 1
|
||||
BC_AVAILABLE_MISSIONS 1
|
||||
BC_BACK_TO_MISSIONS 1
|
||||
BC_BRICKS 1
|
||||
BC_BUY_BRICKS 1
|
||||
BC_COMPLETED_MISSION 1
|
||||
BC_INTRO 1
|
||||
BC_MISSION_DESCRIPTION 1
|
||||
BC_MISSION_DETAILS 1
|
||||
BC_MISSION_ITEM_DESCRIPTION 1
|
||||
BC_MISSION_ITEM_DETAILS 1
|
||||
BC_MISSION_PROGRESS 1
|
||||
BC_MISSION_REWARD 1
|
||||
BC_NEXT_PAGE 1
|
||||
BC_NEXT_STEP 1
|
||||
BC_PACTS 1
|
||||
BC_PREVIOUS_PAGE 1
|
||||
BC_QUIT 1
|
||||
BC_SKILLS 1
|
||||
BC_TELL_ME_MORE 1
|
||||
BC_TO_INTRO 1
|
||||
BC_TRADE 1
|
||||
BS_AMMO_INCOMPATIBLE 1
|
||||
BS_ATTACKS_EE 1
|
||||
BS_ATTACKS_YOU_E 1
|
||||
BS_AVERAGE 1
|
||||
BS_CASTING_BENEFICIAL_E 1
|
||||
BS_CASTING_NEUTRAL_E 1
|
||||
BS_CASTING_OFFENSIVE_E 1
|
||||
BS_CAST_BREAK 1
|
||||
BS_CHILD_PLAY 1
|
||||
BS_DIFFICULT 1
|
||||
BS_EASY 1
|
||||
BS_END_ATTACKS_EE 1
|
||||
BS_END_ATTACKS_YOU_E 1
|
||||
BS_EXTR_DIFF 1
|
||||
BS_FABER_BEGIN_S 1
|
||||
BS_FABER_CANCEL 1
|
||||
BS_FABER_END_ITEM_SI 1
|
||||
BS_FABER_INVALID_MODE 1
|
||||
BS_FABER_LACK_RM_QTY_S 1
|
||||
BS_FABER_LACK_RM_TYPE_S 1
|
||||
BS_FABER_MP_QUALITY_TOO_LOW 1
|
||||
BS_FABER_NEED_TOOL 1
|
||||
BS_FABER_NEED_WORKSHOP 1
|
||||
BS_FABER_PLAYER_LEVEL_TOO_LOW 1
|
||||
BS_FABER_RM_QUALITY_TOO_LOW_S 1
|
||||
BS_FABER_STACK_END_ITEM_ISI 1
|
||||
BS_FABER_TOOL_QUALITY_TOO_LOW 1
|
||||
BS_FAIRLY_EASY 1
|
||||
BS_HARSH 1
|
||||
BS_HARVEST_BEGIN_S 47
|
||||
BS_HARVEST_CANCEL 1
|
||||
BS_HARVEST_FUMBLE 1
|
||||
BS_HARVEST_INVALID_INDEX 1
|
||||
BS_HARVEST_INVALID_MODE 1
|
||||
BS_HARVEST_INVALID_SOURCE 3
|
||||
BS_HARVEST_NEED_TOOL 2
|
||||
BS_HARVEST_NEED_TOOL_S 1
|
||||
BS_HEALS_YOU_EI 1
|
||||
BS_HEAL_EEI 1
|
||||
BS_HITS_YOU_EI 285
|
||||
BS_HITS_YOU_NULL_E 18
|
||||
BS_HIT_EEI 36
|
||||
BS_HIT_NULL_EE 1
|
||||
BS_INVALID 1
|
||||
BS_INVALID_TARGET 4
|
||||
BS_ITEM_INCOMPATIBLE 1
|
||||
BS_ITEM_INCOMPATIBLE_FOR_2_HANDS 1
|
||||
BS_LACK_STAMINA 1
|
||||
BS_MAGIC_SHIELD_DEAD 1
|
||||
BS_MAGIC_SHIELD_I 1
|
||||
BS_MISSES_EE 1
|
||||
BS_MISSES_YOU_E 222
|
||||
BS_NEED_WEAPON 25
|
||||
BS_NO_AMMO 1
|
||||
BS_QUITE_DIFF 1
|
||||
BS_REALLY_DIFF 1
|
||||
BS_REAL_EASY 1
|
||||
BS_REFINE_BEGIN_S 1
|
||||
BS_REFINE_CANCEL 1
|
||||
BS_REFINE_FAILED 1
|
||||
BS_REFINE_INVALID_MODE 1
|
||||
BS_REFINE_NEED_TOOL 1
|
||||
BS_REFINE_PLAYER_LEVEL_TOO_LOW 1
|
||||
BS_REFINE_STACK_SUCCESS_IIS 1
|
||||
BS_REFINE_STACK_SUCCESS_IISI 1
|
||||
BS_REFINE_SUCCESS_SI 1
|
||||
BS_REFINE_SUCCESS_SII 1
|
||||
BS_REPAIR_BEGIN_S 1
|
||||
BS_REPAIR_CANCEL 1
|
||||
BS_REPAIR_FAILED_S 1
|
||||
BS_REPAIR_INVALID_MODE 1
|
||||
BS_REPAIR_NEED_TOOL 1
|
||||
BS_REPAIR_PERFECT_CONDITION 1
|
||||
BS_REPAIR_STACK_SUCCESS_IIS 1
|
||||
BS_REPAIR_STACK_SUCCESS_IISI 1
|
||||
BS_REPAIR_SUCCESS_IS 1
|
||||
BS_REPAIR_SUCCESS_ISI 1
|
||||
BS_RESIST_SPELL_E 1
|
||||
BS_RESIST_SPELL_EE 1
|
||||
BS_SELF_CAST_S 8
|
||||
BS_SENTENCE_FAILED 62
|
||||
BS_SENTENCE_FAILED_S 1
|
||||
BS_SENTENCE_MAGIC_FAILED_S 1
|
||||
BS_SUFFER_BENEFICIAL_SPELL_E 1
|
||||
BS_SUFFER_NEUTRAL_SPELL_E 1
|
||||
BS_SUFFER_OFFENSIVE_SPELL_E 1
|
||||
BS_SUFFER_PENALTY_NO_STAMINA 1
|
||||
BS_TARGET_HIGHER_LEVEL 1
|
||||
BS_TARGET_NOT_ATTACKABLE 1
|
||||
BS_TARGET_PROTECTED 1
|
||||
BS_TARGET_TOO_FAR 1
|
||||
BS_TARGET_TOO_FAR_OR 1
|
||||
BS_TOO_EXPENSIVE 7
|
||||
BS_UNCOMPLETE 1
|
||||
BS_UR_RESIST_SPELL_E 2
|
||||
BS_U_PROTECTED 1
|
||||
BS_U_RESIST_SPELL_E 1
|
||||
BS_U_SUFFER_BENEFICIAL_SPELL_E 1
|
||||
BS_U_SUFFER_NEUTRAL_SPELL_E 1
|
||||
BS_U_SUFFER_OFFENSIVE_SPELL_E 1
|
||||
BS_YOU_ATTACK_E 1
|
||||
BS_YOU_END_ATTACK_E 1
|
||||
BS_YOU_HEAL_EI 1
|
||||
BS_YOU_HIT_EI 225
|
||||
BS_YOU_HIT_NULL_E 4
|
||||
BS_YOU_MISS_E 251
|
||||
EGS_ABANDON_TITLE_FAILED 1
|
||||
EGS_ACTOR_BEGIN_CASTING_BAD_E 1
|
||||
EGS_ACTOR_BEGIN_CASTING_GOOD_E 1
|
||||
EGS_ACTOR_BEGIN_CASTING_NEUTRAL_E 1
|
||||
EGS_ACTOR_BEGIN_CASTING_S 1
|
||||
EGS_ACTOR_BEGIN_SELFCAST_BAD 1
|
||||
EGS_ACTOR_BEGIN_SELFCAST_GOOD 1
|
||||
EGS_ACTOR_BEGIN_SELFCAST_NEUTRAL 1
|
||||
EGS_ACTOR_CASTING_CRITICAL_SUCCESS_S 1
|
||||
EGS_ACTOR_CASTING_FAIL_S 1
|
||||
EGS_ACTOR_CASTING_FUMBLE_S 1
|
||||
EGS_ACTOR_CASTING_INTERUPT 1
|
||||
EGS_ACTOR_CASTING_INTERUPT_S 1
|
||||
EGS_ACTOR_CASTING_RESIST_E 1
|
||||
EGS_ACTOR_CASTING_RESIST_ES 1
|
||||
EGS_ACTOR_CASTING_SUCCESS_S 1
|
||||
EGS_ACTOR_CAST_END_FAILED 1
|
||||
EGS_ACTOR_CAST_END_FUMBLE 1
|
||||
EGS_ACTOR_CAST_END_SUCCESS 1
|
||||
EGS_ACTOR_COMBAT_BRICK_CYCLIC_FAIL_S 1
|
||||
EGS_ACTOR_COMBAT_BRICK_CYCLIC_SUCCESS_S 1
|
||||
EGS_ACTOR_COMBAT_BRICK_FAIL_S 1
|
||||
EGS_ACTOR_COMBAT_BRICK_S 1
|
||||
EGS_ACTOR_COMBAT_BRICK_SUCCESS_EES 1
|
||||
EGS_ACTOR_COMBAT_BRICK_SUCCESS_S 1
|
||||
EGS_ACTOR_COMBAT_CYCLIC_BRICK_S 1
|
||||
EGS_ACTOR_COMBAT_DODGE_E 1
|
||||
EGS_ACTOR_COMBAT_PARRY_E 1
|
||||
EGS_ACTOR_END_FAILED 1
|
||||
EGS_ACTOR_END_FUMBLE 1
|
||||
EGS_ACTOR_END_SUCCESS 1
|
||||
EGS_ACTOR_HIT_CHEST_EI 1
|
||||
EGS_ACTOR_HIT_HEAD_EI 1
|
||||
EGS_ACTOR_HIT_LARM_EI 1
|
||||
EGS_ACTOR_HIT_LFOOT_EI 1
|
||||
EGS_ACTOR_HIT_LLEG_EI 1
|
||||
EGS_ACTOR_HIT_RARM_EI 1
|
||||
EGS_ACTOR_HIT_RFOOT_EI 1
|
||||
EGS_ACTOR_HIT_RLEG_EI 1
|
||||
EGS_ACTOR_VAMPIRISE_EI 1
|
||||
EGS_ALREADY_GUILD_MEMBER 1
|
||||
EGS_ALREADY_HAS_JOIN_PROPOSAL 1
|
||||
EGS_ALREADY_HAVE_MOUNT 1
|
||||
EGS_ALREADY_IN_A_GUILD 1
|
||||
EGS_ANSWER_WHERE 2
|
||||
EGS_ANSWER_WHERE_BUILDING 1
|
||||
EGS_ANSWER_WHERE_NO_PLACE 1
|
||||
EGS_BAD_EFFECT_ALREADY_PRESENT_E 1
|
||||
EGS_BRICKS_ALREADY_KNOWN_S 1
|
||||
EGS_CANNOT_ENGAGE_COMBAT_YET 1
|
||||
EGS_CANNOT_MUST_TARGET_ENTITY_IDLE 1
|
||||
EGS_CANNOT_TARGET_CREATURE_COMBAT_S 1
|
||||
EGS_CANNOT_TARGET_CREATURE_MAGIC_S 1
|
||||
EGS_CANNOT_TARGET_ENEMY_MAGIC 1
|
||||
EGS_CANNOT_TARGET_ENTITY_CASTING 1
|
||||
EGS_CANNOT_TARGET_ENTITY_DOING_FABER 1
|
||||
EGS_CANNOT_TARGET_ENTITY_HARVESTING 1
|
||||
EGS_CANNOT_TARGET_ENTITY_IDLE 1
|
||||
EGS_CANNOT_TARGET_ENTITY_MELEE_COMBAT 1
|
||||
EGS_CANNOT_TARGET_ENTITY_RANGE_COMBAT 1
|
||||
EGS_CANNOT_TARGET_ENTITY_RUNNING 1
|
||||
EGS_CANNOT_TARGET_ENTITY_TRACKING 1
|
||||
EGS_CANNOT_TARGET_ENTITY_WALKING 1
|
||||
EGS_CANNOT_TARGET_HIGHER_LVL 1
|
||||
EGS_CANNOT_TARGET_HOMIN_COMBAT_S 1
|
||||
EGS_CANNOT_TARGET_HOMIN_MAGIC_S 1
|
||||
EGS_CANNOT_TARGET_KAMI_COMBAT_S 1
|
||||
EGS_CANNOT_TARGET_KAMI_MAGIC_S 1
|
||||
EGS_CANNOT_USE_ACTION_ON_MEKTOUB 1
|
||||
EGS_CANNOT_USE_NULL_SKILL_S 1
|
||||
EGS_CANT_BUY_ANOTHER_PACKER 1
|
||||
EGS_CANT_SELL_ANYTHING 1
|
||||
EGS_CH_HIGH_REGEN_LIFE_E 1
|
||||
EGS_CH_HIGH_REGEN_SAP_E 1
|
||||
EGS_CH_HIGH_REGEN_STAMINA_E 1
|
||||
EGS_CH_HIGH_U_REGEN_LIFE_E 1
|
||||
EGS_CH_HIGH_U_REGEN_SAP_E 1
|
||||
EGS_CH_HIGH_U_REGEN_STAMINA_E 1
|
||||
EGS_CH_MAJOR_STEAL_HP_E 1
|
||||
EGS_CH_MAJOR_STEAL_HP_END 1
|
||||
EGS_CH_MAJOR_STEAL_SAP_E 1
|
||||
EGS_CH_MAJOR_STEAL_SAP_END 1
|
||||
EGS_CH_MAJOR_STEAL_STAMINA_E 1
|
||||
EGS_CH_MAJOR_STEAL_STAMINA_END 1
|
||||
EGS_CH_MAJOR_U_STEAL_HP_E 1
|
||||
EGS_CH_MAJOR_U_STEAL_SAP_E 1
|
||||
EGS_CH_MAJOR_U_STEAL_STAMINA_E 1
|
||||
EGS_CH_MINOR_ALCHEMY_HP_EI 1
|
||||
EGS_CH_MINOR_ALCHEMY_SAP_EI 1
|
||||
EGS_CH_MINOR_ALCHEMY_STA_EI 33
|
||||
EGS_CH_MINOR_LIFE_HEAL_EI 1
|
||||
EGS_CH_MINOR_LIFE_HEAL_SELF_I 1
|
||||
EGS_CH_MINOR_REGEN_LIFE_E 1
|
||||
EGS_CH_MINOR_REGEN_SAP_E 1
|
||||
EGS_CH_MINOR_REGEN_STAMINA_E 1
|
||||
EGS_CH_MINOR_SAP_HEAL_EI 1
|
||||
EGS_CH_MINOR_SAP_HEAL_SELF_I 1
|
||||
EGS_CH_MINOR_STAMINA_HEAL_EI 1
|
||||
EGS_CH_MINOR_STAMINA_HEAL_SELF_I 1
|
||||
EGS_CH_MINOR_STEAL_HP_EI 1
|
||||
EGS_CH_MINOR_STEAL_SAP_EI 1
|
||||
EGS_CH_MINOR_STEAL_STAMINA_EI 1
|
||||
EGS_CH_MINOR_U_ALCHEMY_HP_EI 1
|
||||
EGS_CH_MINOR_U_ALCHEMY_SAP_EI 1
|
||||
EGS_CH_MINOR_U_ALCHEMY_STA_EI 33
|
||||
EGS_CH_MINOR_U_LIFE_HEAL_EI 1
|
||||
EGS_CH_MINOR_U_REGEN_LIFE_E 1
|
||||
EGS_CH_MINOR_U_REGEN_SAP_E 1
|
||||
EGS_CH_MINOR_U_REGEN_STAMINA_E 1
|
||||
EGS_CH_MINOR_U_SAP_HEAL_EI 1
|
||||
EGS_CH_MINOR_U_STAMINA_HEAL_EI 1
|
||||
EGS_CH_MINOR_U_STEAL_HP_EI 1
|
||||
EGS_CH_MINOR_U_STEAL_SAP_EI 1
|
||||
EGS_CH_MINOR_U_STEAL_STAMINA_EI 1
|
||||
EGS_CH_SPECTATORS_MINOR_LIFE_HEAL_EEI 1
|
||||
EGS_CH_SPECTATORS_MINOR_LIFE_HEAL_SELF_EI 1
|
||||
EGS_CH_SPECTATORS_MINOR_SAP_HEAL_EEI 1
|
||||
EGS_CH_SPECTATORS_MINOR_SAP_HEAL_SELF_EI 1
|
||||
EGS_CH_SPECTATORS_MINOR_STAMINA_HEAL_EEI 1
|
||||
EGS_CH_SPECTATORS_MINOR_STAMINA_HEAL_SELF_EI 1
|
||||
EGS_COMBAT_CMS_DOWN 1
|
||||
EGS_COMBAT_HITS_YOU_EIS 1
|
||||
EGS_COMBAT_HITS_YOU_NULL_ES 1
|
||||
EGS_COMBAT_HIT_EEIS 1
|
||||
EGS_COMBAT_HIT_NULL_EES 1
|
||||
EGS_COMBAT_NO_VALID_SLOT 1
|
||||
EGS_COMBAT_YOU_HIT_EIS 1
|
||||
EGS_COMBAT_YOU_HIT_NULL_ES 1
|
||||
EGS_CREATURE_ALREADY_BEING_LOOTED_EE 1
|
||||
EGS_CRITICAL_HIT_EE 1
|
||||
EGS_CRITICAL_HIT_YOU_E 1
|
||||
EGS_DARK_MAGIC 1
|
||||
EGS_EFFECT_BLEED 1
|
||||
EGS_EFFECT_BLEED_END 1
|
||||
EGS_EFFECT_BLINDING_BLADE_PARRY_E 1
|
||||
EGS_EFFECT_BLINDING_BLADE_PARRY_END_E 1
|
||||
EGS_EFFECT_BULLYRAGGING_BLAST_E 1
|
||||
EGS_EFFECT_BULLYRAGGING_BLAST_END 1
|
||||
EGS_EFFECT_BULLYRAGGING_E 1
|
||||
EGS_EFFECT_BULLYRAGGING_END 1
|
||||
EGS_EFFECT_ENTER_FRENZY_E 1
|
||||
EGS_EFFECT_FEAR 1
|
||||
EGS_EFFECT_FEAR_END 1
|
||||
EGS_EFFECT_FEAR_FRENZY 1
|
||||
EGS_EFFECT_FEAR_FRENZY_END 1
|
||||
EGS_EFFECT_FURIOUS_BOOST_E 1
|
||||
EGS_EFFECT_FURIOUS_BOOST_END_E 1
|
||||
EGS_EFFECT_LEAVES_FRENZY_E 1
|
||||
EGS_EFFECT_LIGHTNING_PARRY_E 1
|
||||
EGS_EFFECT_LIGHTNING_PARRY_END_E 1
|
||||
EGS_EFFECT_LOSE_HP_BLEED 1
|
||||
EGS_EFFECT_MAJOR_FURIOUS_BOOST_E 1
|
||||
EGS_EFFECT_MAJOR_FURIOUS_BOOST_END_E 1
|
||||
EGS_EFFECT_MAJOR_RAPID_BURST_E 1
|
||||
EGS_EFFECT_MAJOR_RAPID_BURST_END_E 1
|
||||
EGS_EFFECT_RAPID_BURST_E 1
|
||||
EGS_EFFECT_RAPID_BURST_END_E 1
|
||||
EGS_EFFECT_RESISTS_BLEED 1
|
||||
EGS_EFFECT_RESISTS_FEAR 1
|
||||
EGS_EFFECT_RESIST_FEAR_FRENZY 1
|
||||
EGS_EFFECT_STUN_RESIST 1
|
||||
EGS_EFFECT_SYLPHIC_SIDESLIP_E 1
|
||||
EGS_EFFECT_SYLPHIC_SIDESLIP_END_E 1
|
||||
EGS_EFFECT_U_BLEED_E 1
|
||||
EGS_EFFECT_U_BLEED_END 1
|
||||
EGS_EFFECT_U_ENTER_FRENZY 1
|
||||
EGS_EFFECT_U_FEAR_E 1
|
||||
EGS_EFFECT_U_FEAR_END 1
|
||||
EGS_EFFECT_U_FEAR_FRENZY_E 1
|
||||
EGS_EFFECT_U_FEAR_FRENZY_END 1
|
||||
EGS_EFFECT_U_LEAVE_FRENZY 1
|
||||
EGS_EFFECT_U_LOSE_HP_BLEED 1
|
||||
EGS_EFFECT_U_RESIST_BLEED_E 1
|
||||
EGS_EFFECT_U_RESIST_FEAR_E 1
|
||||
EGS_EFFECT_U_RESIST_FEAR_FRENZY_E 1
|
||||
EGS_EFFECT_U_STUN_RESIST_E 1
|
||||
EGS_EFFECT_U_SYLPHIC_SIDESLIP 1
|
||||
EGS_EFFECT_U_SYLPHIC_SIDESLIP_END 1
|
||||
EGS_EFFECT_WIND_BUFFET_E 1
|
||||
EGS_EFFECT_WIND_BUFFET_END 1
|
||||
EGS_EFFECT_WIND_SHEAR_E 1
|
||||
EGS_EFFECT_WIND_SHEAR_END 1
|
||||
EGS_EFFECT_YOU_BLINDING_BLADE_PARRY 1
|
||||
EGS_EFFECT_YOU_BLINDING_BLADE_PARRY_END 1
|
||||
EGS_EFFECT_YOU_BULLYRAGGING 1
|
||||
EGS_EFFECT_YOU_BULLYRAGGING_BLAST 1
|
||||
EGS_EFFECT_YOU_BULLYRAGGING_BLAST_END 1
|
||||
EGS_EFFECT_YOU_BULLYRAGGING_END 1
|
||||
EGS_EFFECT_YOU_FURIOUS_BOOST 1
|
||||
EGS_EFFECT_YOU_FURIOUS_BOOST_END 1
|
||||
EGS_EFFECT_YOU_LIGHTNING_PARRY 1
|
||||
EGS_EFFECT_YOU_LIGHTNING_PARRY_END 1
|
||||
EGS_EFFECT_YOU_MAJOR_FURIOUS_BOOST 1
|
||||
EGS_EFFECT_YOU_MAJOR_FURIOUS_BOOST_END 1
|
||||
EGS_EFFECT_YOU_MAJOR_RAPID_BURST 1
|
||||
EGS_EFFECT_YOU_MAJOR_RAPID_BURST_END 1
|
||||
EGS_EFFECT_YOU_RAPID_BURST 1
|
||||
EGS_EFFECT_YOU_RAPID_BURST_END 1
|
||||
EGS_EFFECT_YOU_WIND_BUFFET 1
|
||||
EGS_EFFECT_YOU_WIND_BUFFET_END 1
|
||||
EGS_EFFECT_YOU_WIND_SHEAR 1
|
||||
EGS_EFFECT_YOU_WIND_SHEAR_END 1
|
||||
EGS_ENEMY_FUMBLE_E 1
|
||||
EGS_ENTER_CONTINENT 4
|
||||
EGS_ENTER_PLACE 3
|
||||
EGS_ENTER_REGION 4
|
||||
EGS_FABER_FAILED_LOW_QUALITY_ISI 1
|
||||
EGS_FABER_FAILED_LOW_QUALITY_SI 1
|
||||
EGS_FABER_NOT_ENOUGH_ROOM 1
|
||||
EGS_FEATURE_UNDER_CONSTRUCTION 1
|
||||
EGS_FORAGE_INTERRUPTED 1
|
||||
EGS_FUMBLE_E 1
|
||||
EGS_GOOD_EFFECT_ALREADY_PRESENT_E 1
|
||||
EGS_GUILD_CREATED 1
|
||||
EGS_GUILD_ENTER_LIFT 1
|
||||
EGS_GUILD_EVENT_ACCEPTJOINPROPOSAL 1
|
||||
EGS_GUILD_EVENT_ACCEPTJOINPROPOSAL_SELF 1
|
||||
EGS_GUILD_EVENT_DECLINEJOINPROPOSAL 1
|
||||
EGS_GUILD_EVENT_DECLINEJOINPROPOSAL_SELF 1
|
||||
EGS_GUILD_EVENT_JOINPROPOSAL 1
|
||||
EGS_GUILD_EVENT_JOINPROPOSAL_SRC_SELF 1
|
||||
EGS_GUILD_EVENT_KICKMEMBER 1
|
||||
EGS_GUILD_EVENT_LOG 1
|
||||
EGS_GUILD_EVENT_QUITGUILD 1
|
||||
EGS_GUILD_EVENT_QUITGUILD_SELF 1
|
||||
EGS_GUILD_EVENT_QUITLEADERSHIP 1
|
||||
EGS_GUILD_EVENT_QUITLEADERSHIP_SRC_SELF 1
|
||||
EGS_GUILD_INVALID 1
|
||||
EGS_GUILD_JOIN_DECLINE_OK 1
|
||||
EGS_GUILD_JOIN_PROPOSAL 1
|
||||
EGS_GUILD_KICKER 1
|
||||
EGS_GUILD_KICK_FAILED 1
|
||||
EGS_GUILD_LEADER_CANT_DISMISS 1
|
||||
EGS_GUILD_LEADER_DISMISS 1
|
||||
EGS_GUILD_LEAVE 1
|
||||
EGS_GUILD_LEAVE_LIFT 1
|
||||
EGS_GUILD_NAME_EXISTS 1
|
||||
EGS_HARVEST_CORPSE_TOO_FAR 1
|
||||
EGS_HARVEST_WOS_DOWN 1
|
||||
EGS_HARVEST_YOU_HURT_E_APPLY 1
|
||||
EGS_HARVEST_YOU_HURT_E_BEGIN 1
|
||||
EGS_HARVEST_YOU_STUN_E_APPLY 1
|
||||
EGS_HARVEST_YOU_STUN_E_BEGIN 1
|
||||
EGS_HARVEST_YOU_TRACK_E 1
|
||||
EGS_HARVEST_YOU_TRACK_E_END 1
|
||||
EGS_INVALID_GUILD_JOIN_PROPOSAL 1
|
||||
EGS_ITEM_ALREADY_BEING_LOOTED_E 1
|
||||
EGS_ITEM_QUALITY_DECREASE_SI 1
|
||||
EGS_LEARN_BRICK_S 1
|
||||
EGS_LEARN_PLAN_S 1
|
||||
EGS_LEAVE_CONTINENT 1
|
||||
EGS_LEAVE_PLACE 1
|
||||
EGS_LEAVE_REGION 1
|
||||
EGS_LOOT_BS_I 1
|
||||
EGS_LOOT_LS_I 1
|
||||
EGS_LOOT_MS_I 1
|
||||
EGS_LOOT_VBS_I 1
|
||||
EGS_LOSE_SAP_EI 1
|
||||
EGS_LOSE_STA_EI 1
|
||||
EGS_MAGIC_BAD_TARGET 1
|
||||
EGS_MAGIC_CASTER_NEW_LINK_E 1
|
||||
EGS_MAGIC_CASTER_REMOVE_LINK_E 1
|
||||
EGS_MAGIC_CAST_OFFENSIVE_SPELL_HP_EEI 1
|
||||
EGS_MAGIC_CAST_OFFENSIVE_SPELL_SAP_EEI 1
|
||||
EGS_MAGIC_CAST_OFFENSIVE_SPELL_STA_EEI 1
|
||||
EGS_MAGIC_HEAL_SPELL_HP_EEI 1
|
||||
EGS_MAGIC_HEAL_SPELL_SAP_EEI 1
|
||||
EGS_MAGIC_HEAL_SPELL_STA_EEI 1
|
||||
EGS_MAGIC_SELFCAST_OFFENSIVE_SPELL_HP_EI 1
|
||||
EGS_MAGIC_SELFCAST_OFFENSIVE_SPELL_SAP_EI 1
|
||||
EGS_MAGIC_SELFCAST_OFFENSIVE_SPELL_STA_EI 1
|
||||
EGS_MAGIC_SELF_HEAL_HP_EI 1
|
||||
EGS_MAGIC_SELF_HEAL_SAP_EI 1
|
||||
EGS_MAGIC_SELF_HEAL_STA_EI 1
|
||||
EGS_MAGIC_TARGET_NEW_LINK_E 1
|
||||
EGS_MAGIC_TARGET_OUT_OF_RANGE 1
|
||||
EGS_MAGIC_TARGET_REMOVE_LINK_E 1
|
||||
EGS_MAGIC_U_CAST_HEAL_SPELL_HP_EI 1
|
||||
EGS_MAGIC_U_CAST_HEAL_SPELL_SAP_EI 1
|
||||
EGS_MAGIC_U_CAST_HEAL_SPELL_STA_EI 1
|
||||
EGS_MAGIC_U_CAST_OFFENSIVE_SPELL_HP_EI 1
|
||||
EGS_MAGIC_U_CAST_OFFENSIVE_SPELL_SAP_EI 1
|
||||
EGS_MAGIC_U_CAST_OFFENSIVE_SPELL_STA_EI 1
|
||||
EGS_MAGIC_U_SELFCAST_OFFENSIVE_SPELL_HP_I 1
|
||||
EGS_MAGIC_U_SELFCAST_OFFENSIVE_SPELL_SAP_I 1
|
||||
EGS_MAGIC_U_SELFCAST_OFFENSIVE_SPELL_STA_I 1
|
||||
EGS_MAGIC_U_SELF_HEAL_HP_I 1
|
||||
EGS_MAGIC_U_SELF_HEAL_SAP_I 1
|
||||
EGS_MAGIC_U_SELF_HEAL_STA_I 1
|
||||
EGS_MAGIC_U_SUFFER_HEAL_SPELL_HP_EI 1
|
||||
EGS_MAGIC_U_SUFFER_HEAL_SPELL_SAP_EI 1
|
||||
EGS_MAGIC_U_SUFFER_HEAL_SPELL_STA_EI 1
|
||||
EGS_MAGIC_U_SUFFER_OFFENSIVE_SPELL_HP_EI 1
|
||||
EGS_MAGIC_U_SUFFER_OFFENSIVE_SPELL_SAP_EI 1
|
||||
EGS_MAGIC_U_SUFFER_OFFENSIVE_SPELL_STA_EI 1
|
||||
EGS_MELEE_BESTIAL_RAGE_E 1
|
||||
EGS_MELEE_BLIND_FURY_E 1
|
||||
EGS_MELEE_DEFLECT_E 1
|
||||
EGS_MELEE_DEFLECT_INEFFECTIVE 1
|
||||
EGS_MELEE_KAMI_FIST_E 1
|
||||
EGS_MELEE_KAMI_FIST_END_E 1
|
||||
EGS_MELEE_MANDRAKE_FIST_E 1
|
||||
EGS_MELEE_MANDRAKE_FIST_END_E 1
|
||||
EGS_MELEE_SPINNING_STROKE_E 1
|
||||
EGS_MELEE_SPINNING_STROKE_END_E 1
|
||||
EGS_MELEE_THRUST_OF_EBONY_E 1
|
||||
EGS_MELEE_THRUST_OF_EBONY_END_E 1
|
||||
EGS_MELEE_WHIRLING_BLOW_E 1
|
||||
EGS_MELEE_WHIRLING_BLOW_END_E 1
|
||||
EGS_MELEE_YOU_BESTIAL_RAGE 1
|
||||
EGS_MELEE_YOU_BESTIAL_RAGE_END 1
|
||||
EGS_MELEE_YOU_BLIND_FURY 1
|
||||
EGS_MELEE_YOU_BLIND_FURY_END 1
|
||||
EGS_MELEE_YOU_DEFLECT 1
|
||||
EGS_MELEE_YOU_KAMI_FIST 1
|
||||
EGS_MELEE_YOU_KAMI_FIST_END 1
|
||||
EGS_MELEE_YOU_MANDRAKE_FIST 1
|
||||
EGS_MELEE_YOU_MANDRAKE_FIST_END 1
|
||||
EGS_MELEE_YOU_SPINNING_STROKE 1
|
||||
EGS_MELEE_YOU_SPINNING_STROKE_END 1
|
||||
EGS_MELEE_YOU_THRUST_OF_EBONY 1
|
||||
EGS_MELEE_YOU_THRUST_OF_EBONY_END 1
|
||||
EGS_MELEE_YOU_WHIRLING_BLOW 1
|
||||
EGS_MELEE_YOU_WHIRLING_BLOW_END 1
|
||||
EGS_MISSION_FAILED 1
|
||||
EGS_MISSION_STEP_SUCCESS 2
|
||||
EGS_MISSION_SUCCESS 1
|
||||
EGS_NAME_OFFICER_FAILED 1
|
||||
EGS_NEED_FULL_ARMOR_SET 1
|
||||
EGS_NEED_FULL_HEAVY_ARMOR_SET 1
|
||||
EGS_NEED_FULL_LIGHT_ARMOR_SET 4
|
||||
EGS_NEED_FULL_MEDIUM_ARMOR_SET 1
|
||||
EGS_NEED_WEAPON_S 1
|
||||
EGS_NEW_SKILL_UNLOCKED_S 1
|
||||
EGS_NOTHING_TO_LOOT_E 1
|
||||
EGS_NOTHING_TO_QUARTER_E 1
|
||||
EGS_NOT_ENOUGHT_SP 1
|
||||
EGS_NOT_ENOUGH_AMMO 1
|
||||
EGS_NOT_GUILD_LEADER 1
|
||||
EGS_NOT_GUILD_LEADER_NOR_OFFICER 1
|
||||
EGS_NOT_GUILD_MEMBER 1
|
||||
EGS_NOT_HAVE_JOB 1
|
||||
EGS_NOT_SET_JOB_STATUS 1
|
||||
EGS_NO_GUILD_JOIN_PROPOSAL 1
|
||||
EGS_NO_ROOM_FOR_FLAG 1
|
||||
EGS_OPENING_DODGE_FAILED 1
|
||||
EGS_OPENING_PARRY_FAILED 1
|
||||
EGS_OPENING_SUCCESS 1
|
||||
EGS_PLAN_ALREADY_KNOWN_S 1
|
||||
EGS_PVP_NOT_ALLOWED 1
|
||||
EGS_QUARTER_INTERRUPTED 1
|
||||
EGS_RANGE_AIM_ARM_E 1
|
||||
EGS_RANGE_AIM_E 1
|
||||
EGS_RANGE_AIM_HEAD_E 1
|
||||
EGS_RANGE_AIM_HEAVY_ARMOR_DEFECT_E 1
|
||||
EGS_RANGE_AIM_LEGS_RANGE_E 1
|
||||
EGS_RANGE_AIM_LIGHT_ARMOR_DEFECT_E 1
|
||||
EGS_RANGE_AIM_MEDIUM_ARMOR_DEFECT_E 1
|
||||
EGS_RANGE_AIM_POINT_BLANK_E 1
|
||||
EGS_RANGE_AIM_TORSO_E 1
|
||||
EGS_RANGE_CLOSE_COMBAT_LEAVE 1
|
||||
EGS_RANGE_FAR_THROW_GRENADE_S 1
|
||||
EGS_RANGE_FAST_SHOT_E 1
|
||||
EGS_RANGE_HIT_ARM_E 1
|
||||
EGS_RANGE_HIT_HEAD_E 1
|
||||
EGS_RANGE_HIT_LEGS_RANGE_E 1
|
||||
EGS_RANGE_HIT_TORSO_E 1
|
||||
EGS_RANGE_MASSIVE_THROW_GRENADE_S 1
|
||||
EGS_RANGE_QUICK_THROW_GRENADE_S 1
|
||||
EGS_RANGE_SHOOT_AND_RUN_E 1
|
||||
EGS_REFINE_BAD_MP 1
|
||||
EGS_REFINE_INVALID_MANUFACTURER 1
|
||||
EGS_REFINE_INVALID_MANUFACTURER_IGNORE 1
|
||||
EGS_REFINE_MAX_QUALITY 1
|
||||
EGS_REFINE_NEED_MP 1
|
||||
EGS_REFINE_OBJECT_DAMAGED 1
|
||||
EGS_REFINE_RM_QUALITY_TOO_LOW 1
|
||||
EGS_REMOVE_OFFICER_FAILED 1
|
||||
EGS_SENTENCE_LATENT 51
|
||||
EGS_SET_SUCCESSOR_FAIL 1
|
||||
EGS_SPECTATORS_BEGIN_CASTING_ES 1
|
||||
EGS_SPECTATORS_CASTING_CRITICAL_SUCCESS_ES 1
|
||||
EGS_SPECTATORS_CASTING_FAIL_ES 1
|
||||
EGS_SPECTATORS_CASTING_FUMBLE_ES 1
|
||||
EGS_SPECTATORS_CASTING_INTERUPT_ES 1
|
||||
EGS_SPECTATORS_CASTING_RESIST_EE 1
|
||||
EGS_SPECTATORS_CASTING_RESIST_ESE 1
|
||||
EGS_SPECTATORS_CASTING_SUCCESS_SEE 1
|
||||
EGS_SPECTATORS_COMBAT_BRICK_CYCLIC_FAIL_ES 1
|
||||
EGS_SPECTATORS_COMBAT_BRICK_CYCLIC_SUCCESS_EES 1
|
||||
EGS_SPECTATORS_COMBAT_BRICK_ESE 1
|
||||
EGS_SPECTATORS_COMBAT_BRICK_FAIL_ES 1
|
||||
EGS_SPECTATORS_COMBAT_CYCLIC_BRICK_ESE 1
|
||||
EGS_SPECTATORS_COMBAT_DODGE_EE 1
|
||||
EGS_SPECTATORS_COMBAT_PARRY_EE 1
|
||||
EGS_SPECTATORS_HIT_CHEST_EEI 1
|
||||
EGS_SPECTATORS_HIT_HEAD_EEI 1
|
||||
EGS_SPECTATORS_HIT_LARM_EEI 1
|
||||
EGS_SPECTATORS_HIT_LFOOT_EEI 1
|
||||
EGS_SPECTATORS_HIT_LLEG_EEI 1
|
||||
EGS_SPECTATORS_HIT_RARM_EEI 1
|
||||
EGS_SPECTATORS_HIT_RFOOT_EEI 1
|
||||
EGS_SPECTATORS_HIT_RLEG_EEI 1
|
||||
EGS_SPECT_BEGIN_CASTING_BAD_EE 1
|
||||
EGS_SPECT_BEGIN_CASTING_GOOD_EE 1
|
||||
EGS_SPECT_BEGIN_CASTING_NEUTRAL_EE 1
|
||||
EGS_SPECT_BEGIN_SELFCASTING_BAD_E 1
|
||||
EGS_SPECT_BEGIN_SELFCASTING_GOOD_E 1
|
||||
EGS_SPECT_BEGIN_SELFCASTING_NEUTRAL_E 1
|
||||
EGS_SPECT_CAST_END_FAILED_E 1
|
||||
EGS_SPECT_CAST_END_FUMBLE_E 1
|
||||
EGS_SPECT_CAST_END_SUCCESS_EE 1
|
||||
EGS_START_DEFAULT_ATTACK 1
|
||||
EGS_TAMING_CONVOY_END 1
|
||||
EGS_TAMING_CONVOY_FAIL 1
|
||||
EGS_TAMING_CONVOY_REFUSE 1
|
||||
EGS_TAMING_CONVOY_SUCCESS 1
|
||||
EGS_TAMING_INVALID_MODE_COMBAT 1
|
||||
EGS_TAMING_TOOL_NEEDED_S 1
|
||||
EGS_TARGET_BEGIN_CASTING_BAD_E 1
|
||||
EGS_TARGET_BEGIN_CASTING_ES 1
|
||||
EGS_TARGET_BEGIN_CASTING_GOOD_E 1
|
||||
EGS_TARGET_BEGIN_CASTING_NEUTRAL_E 1
|
||||
EGS_TARGET_CASTING_CRITICAL_SUCCESS_ES 1
|
||||
EGS_TARGET_CASTING_FAIL_ES 1
|
||||
EGS_TARGET_CASTING_FUMBLE_ES 1
|
||||
EGS_TARGET_CASTING_INTERUPT_ES 1
|
||||
EGS_TARGET_CASTING_RESIST_E 1
|
||||
EGS_TARGET_CASTING_RESIST_SE 1
|
||||
EGS_TARGET_CASTING_SUCCESS_SE 1
|
||||
EGS_TARGET_CAST_END_FAILED_E 1
|
||||
EGS_TARGET_CAST_END_FUMBLE_E 1
|
||||
EGS_TARGET_CAST_END_SUCCESS_E 1
|
||||
EGS_TARGET_COMBAT_BRICK_CYCLIC_FAIL_ES 1
|
||||
EGS_TARGET_COMBAT_BRICK_CYCLIC_SUCCESS_ES 1
|
||||
EGS_TARGET_COMBAT_BRICK_ES 1
|
||||
EGS_TARGET_COMBAT_BRICK_FAIL_ES 1
|
||||
EGS_TARGET_COMBAT_BRICK_SUCCESS_ES 1
|
||||
EGS_TARGET_COMBAT_CYCLIC_BRICK_ES 1
|
||||
EGS_TARGET_COMBAT_DODGE_E 1
|
||||
EGS_TARGET_COMBAT_PARRY_E 1
|
||||
EGS_TARGET_HIT_CHEST_EI 1
|
||||
EGS_TARGET_HIT_HEAD_EI 1
|
||||
EGS_TARGET_HIT_LARM_EI 1
|
||||
EGS_TARGET_HIT_LFOOT_EI 1
|
||||
EGS_TARGET_HIT_LLEG_EI 1
|
||||
EGS_TARGET_HIT_RARM_EI 1
|
||||
EGS_TARGET_HIT_RFOOT_EI 1
|
||||
EGS_TARGET_HIT_RLEG_EI 1
|
||||
EGS_TMP_GENERIC_EFFECT_BEGIN 1
|
||||
EGS_TMP_GENERIC_EFFECT_END 1
|
||||
EGS_TOO_EXPENSIVE_HP 1
|
||||
EGS_TOO_EXPENSIVE_SAP 1
|
||||
EGS_TOO_EXPENSIVE_STAMINA 1
|
||||
EGS_TRACKING_DIRECTION_ES 1
|
||||
EGS_TRACKING_END_E 1
|
||||
EGS_TRACKING_START_E 1
|
||||
EGS_TRACKING_TOO_FAR 1
|
||||
EGS_TRAINING_BEGIN_S 1
|
||||
EGS_TRAINING_CANCEL 1
|
||||
EGS_TRAINING_FAILED_S 1
|
||||
EGS_TRAINING_HIGH_DIFFICULTY 1
|
||||
EGS_TRAINING_INVALID_MODE 1
|
||||
EGS_TRAINING_LOW_QUALITY_TOOL 1
|
||||
EGS_TRAINING_NOT_ENOUGH_SAP 1
|
||||
EGS_TRAINING_NOT_ENOUGH_STAMINA 1
|
||||
EGS_TRAINING_SUCCESS 1
|
||||
EGS_USE_LAST_AMMO 1
|
||||
EGS_U_LOSE_SAP_EI 1
|
||||
EGS_U_LOSE_STA_EI 1
|
||||
EGS_YOU_CRITICAL_HIT_E 1
|
||||
EGS_YOU_EFFECT_ALREADY_PRESENT 1
|
||||
EGS_YOU_FUMBLE 1
|
||||
HELLO 1
|
||||
IOS_NEWS_FOOTBALL_LONG_EEII 1
|
||||
IOS_NEWS_FOOTBALL_SHORT_EEII 1
|
||||
IOS_TELL_UNKNOWN_S 1
|
||||
OPS_ALREADY_HAS_A_TEAM 1
|
||||
OPS_ALREADY_HAS_PROPOSAL_E 1
|
||||
OPS_ALREADY_HAS_TEAM_E 1
|
||||
OPS_BUY_REPORT_U 1
|
||||
OPS_CHEATER 1
|
||||
OPS_CONS_FOUR_LEVEL_AND_MORE_ABOVE 11
|
||||
OPS_CONS_FOUR_LEVEL_AND_MORE_LESS 28
|
||||
OPS_CONS_ONE_LEVEL_ABOVE 1
|
||||
OPS_CONS_ONE_LEVEL_LESS 20
|
||||
OPS_CONS_SAME_LEVEL 69
|
||||
OPS_CONS_TWO_THREE_LEVEL_ABOVE 14
|
||||
OPS_CONS_TWO_THREE_LEVEL_LESS 1
|
||||
OPS_CREATE_TEAM 1
|
||||
OPS_DEATH_CARAVAN_RESURECT 4
|
||||
OPS_DEATH_KAMI_RESURECT 1
|
||||
OPS_DEATH_KILLED_E 6
|
||||
OPS_DEATH_KILLED_EE 1
|
||||
OPS_DEATH_KILLED_EEE 1
|
||||
OPS_DEATH_KILLER_E 36
|
||||
OPS_DEATH_KILL_EE 1
|
||||
OPS_DEATH_KILL_EEE 1
|
||||
OPS_DEATH_KILL_EEEE 1
|
||||
OPS_DEATH_OLD 1
|
||||
OPS_DEATH_PERMANENT_KILLED 1
|
||||
OPS_DEATH_PERMANENT_KILL_E 1
|
||||
OPS_EFFECT_SLOW_BEGIN 1
|
||||
OPS_EFFECT_SLOW_BEGIN_E 1
|
||||
OPS_EFFECT_SLOW_END 1
|
||||
OPS_EFFECT_SLOW_END_E 1
|
||||
OPS_EFFECT_STUN_BEGIN 1
|
||||
OPS_EFFECT_STUN_BEGIN_E 1
|
||||
OPS_EFFECT_STUN_END 1
|
||||
OPS_EFFECT_STUN_END_E 1
|
||||
OPS_ERROR_NON_HARVESTABLE_E 1
|
||||
OPS_EXCHANGE_ACCEPT_TOO_FAR 1
|
||||
OPS_EXCHANGE_BUSY 1
|
||||
OPS_EXCHANGE_DECLINE 1
|
||||
OPS_EXCHANGE_END 1
|
||||
OPS_EXCHANGE_HAND 1
|
||||
OPS_EXCHANGE_IMPOSSIBLE 1
|
||||
OPS_EXCHANGE_LOCKED 1
|
||||
OPS_EXCHANGE_OK 13
|
||||
OPS_EXCHANGE_TOO_FAR 1
|
||||
OPS_FABER_INVENTORY_LOCKED 1
|
||||
OPS_HARVEST_ALREADY_IN_PROGRESS_EE 12
|
||||
OPS_HARVEST_BAG_FULL 1
|
||||
OPS_HARVEST_INTERRUPTED 10
|
||||
OPS_HARVEST_MP_IN_PROGRESS_E 2
|
||||
OPS_HARVEST_SUCESS_ISI 11
|
||||
OPS_JOIN_TEAM_ACCEPT_E 1
|
||||
OPS_JOIN_TEAM_DECLINE_E 1
|
||||
OPS_JOIN_TEAM_E 1
|
||||
OPS_JOIN_TEAM_PROPOSAL_F_E 1
|
||||
OPS_JOIN_TEAM_PROPOSAL_M_E 1
|
||||
OPS_JOIN_TEAM_U_DECLINE_E 1
|
||||
OPS_KICKED_TEAM_E 1
|
||||
OPS_LEAVE_TEAM_E 1
|
||||
OPS_NOT_ENOUGHT_SEED 1
|
||||
OPS_PACT_GAIN_U 1
|
||||
OPS_SALE_REPORT_U 1
|
||||
OPS_TEAM_DISOLVED 1
|
||||
OPS_TEAM_INVITE_E 1
|
||||
OPS_TEAM_MAX_SIZE_REACHED 1
|
||||
OPS_TEAM_NEW_LEADER_EE 1
|
||||
OPS_TEAM_NOT_A_PLAYER_E 1
|
||||
OPS_TEAM_U_NEW_LEADER 1
|
||||
OPS_U_KICKED_TEAM_E 1
|
||||
OPS_U_LEAVE_TEAM_E 1
|
||||
OPS_WELCOME 66
|
||||
OPS_XP_BIG_GAINXP_SKILL_S 1
|
||||
OPS_XP_LITTLE_GAINXP_SKILL_S 1
|
||||
OPS_XP_MISSION_GAINXP_SKILL_S 1
|
||||
OPS_XP_NORMAL_GAINXP_SKILL_S 1
|
||||
OPS_XP_NO_GAINXP_SKILL_S 1
|
||||
OPS_XP_PROGRESS_CHARACTERISTIC_S 1
|
||||
OPS_XP_PROGRESS_HP 1
|
||||
OPS_XP_PROGRESS_RESIST_S 1
|
||||
OPS_XP_PROGRESS_SAP 1
|
||||
OPS_XP_PROGRESS_SKILL_S 70
|
||||
OPS_XP_PROGRESS_STAMINA 1
|
||||
WOS_HARVEST_ALREADY_IN_PROGRESS 1
|
||||
WOS_HARVEST_ALREADY_IN_PROGRESS_E 1
|
||||
WOS_HARVEST_FAILED 5
|
||||
WOS_HARVEST_FOUND_MP 1
|
||||
WOS_HARVEST_FOUND_MP_S 4
|
||||
WOS_HARVEST_FOUND_NOTHING 1
|
||||
WOS_HARVEST_SEARCHING 16
|
||||
WOS_KAMI_ALERTE 1
|
||||
WOS_KAMI_ANGRY 1
|
||||
WOS_KAMI_BLACK_KAMI 1
|
||||
WOS_KAMI_FURY 1
|
||||
WOS_MISSION_FAILURE_S 1
|
||||
WOS_MISSION_SUCCESS_S 1
|
@ -1,8 +0,0 @@
|
||||
# test file
|
||||
HELLO "Hello"
|
||||
|
||||
OPS_CHEATER "&RG&Cheating is bad, you know..."
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
..\..\occ2huff_df chat_static.txt news_static.txt bs_static.txt bs_combat.txt bs_magic.txt harvest_static.txt report_progression_static.txt death_static.txt identify_creature_static.txt faber_static.txt wos_static.txt egs_brick_error_msg.txt egs_static.txt egs_effect_static.txt bot_chat.txt chat_static.occ
|
||||
|
||||
REM PLEEZZZ, PAS DE PAUSE ICI !!!
|
||||
REM pause1
|
||||
pause
|
@ -1,16 +0,0 @@
|
||||
# these sentences are used in the death system
|
||||
|
||||
OPS_DEATH_KILLER_E "&BC&you have killed $0e."
|
||||
OPS_DEATH_KILLED_E "&RG&you have been killed by $0e."
|
||||
OPS_DEATH_KILLED_EE "&RG&you have been killed by $0e and $1e."
|
||||
OPS_DEATH_KILLED_EEE "&RG&you have been killed by $0e, $1e and $2e."
|
||||
|
||||
OPS_DEATH_KILL_EE "&BC&$0e has killed $1e."
|
||||
OPS_DEATH_KILL_EEE "&BC&$0e and $1e have killed $2e."
|
||||
OPS_DEATH_KILL_EEEE "&BC&$0e, $1e and $2e have killed $3e."
|
||||
|
||||
#OPS_DEATH_KAMI_RESURECT "&JA&The Kamis honor the pact: Sap flows through you once again as you resuscitate."
|
||||
#OPS_DEATH_CARAVAN_RESURECT "&JA&The Karavan works its craft and you exist once more."
|
||||
OPS_DEATH_OLD "&RG&Old age has taken its toll, your Sap has run its course. Neither the Kamis nor the Karavan can reverse your fate... You return to the humus from which you first emerged."
|
||||
#OPS_DEATH_PERMANENT_KILLED "&RG&You no longer have a valid resurrection pact. You return to the humus from which you first emerged."
|
||||
OPS_DEATH_PERMANENT_KILL_E "&RG&$0e died without a valid resurrection pact. There is very little time left to bring $0e back among the living."
|
@ -1,76 +0,0 @@
|
||||
# error code for sentence validation
|
||||
# BS_TARGET_TOO_FAR "&RG&Your target is too far away."
|
||||
# BS_TARGET_TOO_FAR_OR "&RG&Your target is too far away or you are not facing it."
|
||||
BS_TOO_EXPENSIVE "&RG&You cannot afford this formula or action phrase."
|
||||
EGS_TOO_EXPENSIVE_SAP "&RG&You do not have enough sap for this action."
|
||||
# EGS_TOO_EXPENSIVE_STAMINA "&RG&You do not have enough stamina for this action."
|
||||
# EGS_TOO_EXPENSIVE_HP "&RG&You do not have enough hp to pay this action cost."
|
||||
|
||||
# BS_INVALID_TARGET "&RG&Invalid Target."
|
||||
# BS_ITEM_INCOMPATIBLE "&RG&This formula or action phrase is incompatible with the item in your hand."
|
||||
BS_NEED_WEAPON "&RG&This strategy needs a weapon."
|
||||
# BS_NO_AMMO "&RG&This weapon needs ammo."
|
||||
BS_AMMO_INCOMPATIBLE "&RG&The selected weapon is incompatible with the selected ammo."
|
||||
BS_ITEM_INCOMPATIBLE_FOR_2_HANDS "&RG&You must carry a sword in your right hand and a dagger in the left to perform this action"
|
||||
# EGS_NOT_ENOUGH_AMMO "&RG&This strategy needs more ammunition."
|
||||
EGS_COMBAT_NO_VALID_SLOT "&RG&Cannot enter combat as there is no available weapon or empty sheath for hand to hand combat."
|
||||
|
||||
EGS_CANNOT_ENGAGE_COMBAT_YET "&RG&You cannot engage combat yet."
|
||||
|
||||
BS_LACK_STAMINA "&RG&You need to regain stamina to do this. Rest first."
|
||||
# BS_TARGET_NOT_ATTACKABLE "&RG&You cannot use offensive action against your current target."
|
||||
|
||||
#
|
||||
BS_INVALID "&RG&Invalid sentence."
|
||||
BS_UNCOMPLETE "&RG&Uncomplete formula, mandatory bricks are missing."
|
||||
|
||||
# player need a full armor set
|
||||
EGS_NEED_FULL_LIGHT_ARMOR_SET "&RG&You need a full light armor set to use this strategy."
|
||||
EGS_NEED_FULL_MEDIUM_ARMOR_SET "&RG&You need a full medium armor set to use this strategy."
|
||||
EGS_NEED_FULL_HEAVY_ARMOR_SET "&RG&You need a full heavy armor set to use this strategy."
|
||||
EGS_NEED_FULL_ARMOR_SET "&RG&You need a full armor set to use this strategy."
|
||||
|
||||
# invalid target action state
|
||||
EGS_CANNOT_TARGET_ENTITY_RANGE_COMBAT "&RG&You cannot target an entity engaged in range combat."
|
||||
EGS_CANNOT_TARGET_ENTITY_MELEE_COMBAT "&RG&You cannot target an entity engaged in melee combat."
|
||||
EGS_CANNOT_TARGET_ENTITY_CASTING "&RG&You cannot target an entity which is casting a spell."
|
||||
EGS_CANNOT_TARGET_ENTITY_DOING_FABER "&RG&You cannot target an entity which is crafting."
|
||||
EGS_CANNOT_TARGET_ENTITY_HARVESTING "&RG&You cannot target an entity which is harvesting."
|
||||
EGS_CANNOT_TARGET_ENTITY_TRACKING "&RG&You cannot target an entity which is tracking."
|
||||
EGS_CANNOT_TARGET_ENTITY_WALKING "&RG&You cannot target a walking entity."
|
||||
EGS_CANNOT_TARGET_ENTITY_RUNNING "&RG&You cannot target a running entity."
|
||||
EGS_CANNOT_TARGET_ENTITY_IDLE "&RG&You cannot target an idle entity."
|
||||
EGS_CANNOT_MUST_TARGET_ENTITY_IDLE "&RG&You must target an idle entity."
|
||||
|
||||
#invalid target nature
|
||||
EGS_CANNOT_TARGET_KAMI_COMBAT_S "&RG&The strategy $0s cannot be used against a Kami."
|
||||
EGS_CANNOT_TARGET_HOMIN_COMBAT_S "&RG&The strategy $0s cannot be used against a homin."
|
||||
EGS_CANNOT_TARGET_CREATURE_COMBAT_S "&RG&The strategy $0s cannot be used against a creature."
|
||||
EGS_CANNOT_TARGET_KAMI_MAGIC_S "&RG&The spell $0s cannot be cast on a Kami."
|
||||
EGS_CANNOT_TARGET_HOMIN_MAGIC_S "&RG&The spell $0s cannot be cast on a homin."
|
||||
EGS_CANNOT_TARGET_CREATURE_MAGIC_S "&RG&The spell $0s cannot be cast on a creature."
|
||||
|
||||
EGS_CANNOT_TARGET_ENEMY_MAGIC "&RG&This spell cannot be cast on a enemy."
|
||||
|
||||
#insuficient level
|
||||
EGS_CANNOT_TARGET_HIGHER_LVL "&RG&You cannot use this formula on an higher level entity."
|
||||
|
||||
|
||||
# feature under construction
|
||||
EGS_FEATURE_UNDER_CONSTRUCTION "&RG&This feature is under construction."
|
||||
|
||||
# more accurate comments
|
||||
EGS_NEED_WEAPON_S "&RG&This strategy needs a weapon using skill $0s."
|
||||
|
||||
#PVP
|
||||
# EGS_PVP_NOT_ALLOWED "&RG&You cannot enter combat with or use offensive actions against another player in this area."
|
||||
|
||||
# cannot use a skill with a score of 0
|
||||
EGS_CANNOT_USE_NULL_SKILL_S "&RG&You cannot do this action as you don't have the necessary skill $0s."
|
||||
|
||||
# cannot act while on mektoub (debug)
|
||||
EGS_CANNOT_USE_ACTION_ON_MEKTOUB "&RG&You cannot carry out actions while riding a mektoub."
|
||||
|
||||
# need opening
|
||||
EGS_OPENING_DODGE_FAILED "&RG&You can only use this action after you successfully dodge your opponent."
|
||||
EGS_OPENING_PARRY_FAILED "&RG&You can only use this action after you successfully parry your opponent."
|
@ -1,53 +0,0 @@
|
||||
BS_FABER_INVALID_MODE "&RG&You cannot use Faber while in combat."
|
||||
BS_FABER_MP_QUALITY_TOO_LOW "&RG&You must use raw materials with a greater quality than that of the crafted item minimum quality."
|
||||
BS_FABER_RM_QUALITY_TOO_LOW_S "&RG&The $0s is of insufficient quality for this object."
|
||||
BS_FABER_LACK_RM_QTY_S "&RG&You don't have enough $0s to craft this object."
|
||||
BS_FABER_LACK_RM_TYPE_S "&RG&You need $0s to craft this object."
|
||||
BS_FABER_TOOL_QUALITY_TOO_LOW "&RG&The tool you are using is of insufficient quality to work on this object."
|
||||
BS_FABER_NEED_TOOL "&RG&Your don't have the right tool to craft this object."
|
||||
BS_FABER_NEED_WORKSHOP "&RG&You must be in a workshop in order to work on this object."
|
||||
BS_FABER_BEGIN_S "&BL&You begin to craft the $0s."
|
||||
EGS_FABER_FAILED_LOW_QUALITY_SI "&RG&You barely managed to craft the item $0s with its minimal quality $1i."
|
||||
EGS_FABER_FAILED_LOW_QUALITY_ISI "&RG&You barely managed to craft $0i objects $1s with their minimal quality $2i."
|
||||
BS_FABER_END_ITEM_SI "&BC&You have crafted the object $0s with a quality of $1i."
|
||||
BS_FABER_STACK_END_ITEM_ISI "&BC&You have crafted $0i objects $1s with a quality of $2i."
|
||||
BS_FABER_PLAYER_LEVEL_TOO_LOW "&RG&Your skill must improve before you can craft this object."
|
||||
|
||||
BS_FABER_CANCEL "&RG&You stopped before you finished crafting the object."
|
||||
|
||||
|
||||
BS_REPAIR_INVALID_MODE "&RG&You cannot repair an object while in combat."
|
||||
BS_REPAIR_PERFECT_CONDITION "&RG&This object is in perfect condition, there is no need to repair it."
|
||||
BS_REPAIR_BEGIN_S "&BL&You begin repairing the object $0s."
|
||||
BS_REPAIR_SUCCESS_IS "&BC&You have restored $0i life points to the object $1s."
|
||||
BS_REPAIR_SUCCESS_ISI "&JA&You have restored $0i life points to the object $1s and increased it's quality by $2i."
|
||||
BS_REPAIR_STACK_SUCCESS_IIS "&BC&You have restored $0i life points to the $1i objects $2s."
|
||||
BS_REPAIR_STACK_SUCCESS_IISI "&JA&You have restored $0i life points to your $1i $2s and increased their qualities by $3i."
|
||||
|
||||
BS_REPAIR_FAILED_S "&RG&You failed to repair the object $0s."
|
||||
BS_REPAIR_CANCEL "&RG&You stopped before you finished repairing the object."
|
||||
BS_REPAIR_NEED_TOOL "&RG&You do not have the right tool to repair this object."
|
||||
|
||||
|
||||
|
||||
EGS_REFINE_RM_QUALITY_TOO_LOW "&RG&You must use raw material of a quality at least equal to the quality of the item to upgrade."
|
||||
BS_REFINE_INVALID_MODE "&RG&You cannot refine an item while in combat."
|
||||
BS_REFINE_BEGIN_S "&BL&You begin to upgrade the object $0s."
|
||||
EGS_REFINE_OBJECT_DAMAGED "&RG&This object is used or damaged and cannot be upgraded. Repair it first."
|
||||
EGS_REFINE_INVALID_MANUFACTURER "&RG&You cannot upgrade this object. It was created by another."
|
||||
EGS_REFINE_INVALID_MANUFACTURER_IGNORE "&RG&(you can continue upgrade action though...this test is ignored for testing purposes..)"
|
||||
EGS_REFINE_MAX_QUALITY "&RG&This object is of maximum quality and cannot be upgraded."
|
||||
BS_REFINE_FAILED "&RG&Your upgrade has failed."
|
||||
BS_REFINE_PLAYER_LEVEL_TOO_LOW "&RG&Your skill must improve before you can upgrade this object."
|
||||
BS_REFINE_SUCCESS_SI "&BC&You have upgraded the object $0s with $1i additional life points."
|
||||
BS_REFINE_SUCCESS_SII "&JA&You have upgraded the object $0s with $1i additional life points and increased it's quality by $2i."
|
||||
BS_REFINE_STACK_SUCCESS_IIS "&BC&You have upgraded your $1i objects $2s with $0i additional life points."
|
||||
BS_REFINE_STACK_SUCCESS_IISI "&JA&You have upgraded your $1i objects $2s with $0i additional life points and increased it's quality by $3i."
|
||||
|
||||
BS_REFINE_NEED_TOOL "&RG&You do not have the right tool to upgrade this object."
|
||||
EGS_REFINE_NEED_MP "&RG&You need a raw material compatible with upgrade to upgrade your item."
|
||||
EGS_REFINE_BAD_MP "&RG&The raw material you have selected is incompatible with upgrading."
|
||||
BS_REFINE_CANCEL "&RG&You stopped before you finished upgrading the object."
|
||||
|
||||
EGS_FABER_NOT_ENOUGH_ROOM "&RG&You need to have enough empty slots in your bags to store the built items."
|
||||
OPS_FABER_INVENTORY_LOCKED "&RG&You cannot manipulate your inventories while the Faber interface is opened."
|
@ -1,44 +0,0 @@
|
||||
# texts relative to the harvest
|
||||
|
||||
BS_HARVEST_BEGIN_S "&VE&You begin to harvest $0s."
|
||||
BS_HARVEST_FUMBLE "&RG&You have fumbled and all the resources you were harvesting are lost."
|
||||
BS_HARVEST_CANCEL "&RG&Your recovering action has been cancelled."
|
||||
BS_HARVEST_INVALID_SOURCE "&RG&Invalid entity for harvest."
|
||||
BS_HARVEST_INVALID_INDEX "&RG&Invalid raw material index."
|
||||
BS_HARVEST_NEED_TOOL "&RG&You need the right tool in one of your sheaths to harvest."
|
||||
BS_HARVEST_NEED_TOOL_S "&RG&You need a tool using skill $0s in one of your sheaths."
|
||||
BS_HARVEST_INVALID_MODE "&RG&You cannot harvest in this mode."
|
||||
# EGS_HARVEST_CORPSE_TOO_FAR "&RG&The corpse you are trying to skin is too far away, get closer."
|
||||
|
||||
OPS_HARVEST_SUCESS_ISI "&VE&You obtain $0i $1s of quality $2i."
|
||||
OPS_ERROR_NON_HARVESTABLE_E "&RG&$0e cannot be harvested."
|
||||
OPS_HARVEST_ALREADY_IN_PROGRESS_EE "&RG&$0e is already being harvested by $1e."
|
||||
# OPS_HARVEST_MP_IN_PROGRESS_E "&RG&You are already harvesting raw material on $0e."
|
||||
OPS_HARVEST_INTERRUPTED "&RG&Your harvesting action has been interrupted."
|
||||
# EGS_FORAGE_INTERRUPTED "&RG&Your foraging action has been interrupted."
|
||||
# EGS_QUARTER_INTERRUPTED "&RG&Your quartering action has been interrupted."
|
||||
|
||||
OPS_HARVEST_BAG_FULL "&RG&You don't have a free bag slot inventory, action cancelled."
|
||||
|
||||
EGS_HARVEST_WOS_DOWN "&RG&(Server Debug) The world service is down, cannot harvest any deposit..."
|
||||
|
||||
WOS_HARVEST_ALREADY_IN_PROGRESS_E "&RG&This deposit is already being harvested by $1e."
|
||||
WOS_HARVEST_ALREADY_IN_PROGRESS "&RG&You are already harvesting."
|
||||
# WOS_HARVEST_FOUND_NOTHING "&RG&You found nothing."
|
||||
# WOS_HARVEST_FAILED "&RG&You failed to take the ressources you were trying to harvest."
|
||||
# WOS_HARVEST_SEARCHING "&VE&Looking for resources ..."
|
||||
# WOS_HARVEST_FOUND_MP_S "&VE&You found $0s."
|
||||
WOS_HARVEST_FOUND_MP "&VE&You found resources."
|
||||
|
||||
|
||||
# texts relative to loot
|
||||
|
||||
EGS_NOTHING_TO_LOOT_E "&RG&There is nothing to loot on $0e."
|
||||
EGS_NOTHING_TO_QUARTER_E "&RG&There is nothing to quarter on $0e."
|
||||
EGS_CREATURE_ALREADY_BEING_LOOTED_EE "&RG&$0e is already being looted by $1e."
|
||||
# EGS_ITEM_ALREADY_BEING_LOOTED_E "&RG&$This bag is already being looted by $1e."
|
||||
|
||||
EGS_LOOT_VBS_I "&JA&You loot $0i very big seeds."
|
||||
EGS_LOOT_BS_I "&JA&You loot $0i big seeds."
|
||||
EGS_LOOT_MS_I "&JA&You loot $0i medium seeds."
|
||||
EGS_LOOT_LS_I "&JA&You loot $0i little seeds."
|
@ -1,9 +0,0 @@
|
||||
# these sentences are used in the xp gain system
|
||||
|
||||
OPS_CONS_FOUR_LEVEL_AND_MORE_ABOVE "&RG&This adversary is beyond your strength."
|
||||
OPS_CONS_TWO_THREE_LEVEL_ABOVE "&JA&This adversary is a formidable foe."
|
||||
OPS_CONS_ONE_LEVEL_ABOVE "&BC&This adversary will be tough to overwhelm."
|
||||
OPS_CONS_SAME_LEVEL "&BC&This adversary is of equal strength."
|
||||
OPS_CONS_ONE_LEVEL_LESS "&BL&You can handle this adversary."
|
||||
OPS_CONS_TWO_THREE_LEVEL_LESS "&BL&This adversary presents little danger to you."
|
||||
OPS_CONS_FOUR_LEVEL_AND_MORE_LESS "&VE&This adversary is beneath your contempt."
|
@ -1,4 +0,0 @@
|
||||
# these sentences are used in the news system
|
||||
|
||||
IOS_NEWS_FOOTBALL_SHORT_EEII "The last football match result between $0e and $1e is $2i-$3i"
|
||||
IOS_NEWS_FOOTBALL_LONG_EEII "The last football match result between $0e and $1e is $2i-$3i. yeah, that's great ! "
|
@ -1,16 +0,0 @@
|
||||
# these sentences are used in the xp gain system
|
||||
|
||||
OPS_XP_NO_GAINXP_SKILL_S "&RG&you don't gain experience in '$0s', this action is too easy."
|
||||
OPS_XP_LITTLE_GAINXP_SKILL_S "&JA&you gain a little experience in '$0s'."
|
||||
OPS_XP_NORMAL_GAINXP_SKILL_S "&JA&you gain experience in '$0s'."
|
||||
OPS_XP_BIG_GAINXP_SKILL_S "&JA&you gain much experience in '$0s'."
|
||||
OPS_XP_MISSION_GAINXP_SKILL_S "&JA&the success of this mission has given you experience for the '$0s' skill."
|
||||
|
||||
OPS_XP_PROGRESS_SKILL_S "&JA&your '$0s' skill improves."
|
||||
OPS_XP_PROGRESS_CHARACTERISTIC_S "&JA&your '$0s' progresses."
|
||||
OPS_XP_PROGRESS_HP "&JA&your life force increases."
|
||||
OPS_XP_PROGRESS_STAMINA "&JA&your endurance increases."
|
||||
OPS_XP_PROGRESS_SAP "&JA&your Sap increases."
|
||||
OPS_XP_PROGRESS_RESIST_S "&JA&your '$0s' resistance increases."
|
||||
|
||||
EGS_NEW_SKILL_UNLOCKED_S "&JA&Well done! You gain the new advanced skill '$0s'."
|
@ -1,2 +0,0 @@
|
||||
WOS_MISSION_SUCCESS_S "&JA&You succeeded in accomplishing the mission $0s."
|
||||
WOS_MISSION_FAILURE_S "&RG&You failed to accomplish the mission $0s."
|
File diff suppressed because it is too large
Load Diff
@ -1,493 +0,0 @@
|
||||
FY_S1_baobab_A.pacs_prim
|
||||
FY_S1_baobab_B.pacs_prim
|
||||
FY_S1_baobab_C.pacs_prim
|
||||
FY_S1_burnedtree_A.pacs_prim
|
||||
FY_S1_burnedtree_B.pacs_prim
|
||||
FY_S2_coconuts_A.pacs_prim
|
||||
FY_S2_coconuts_B.pacs_prim
|
||||
FY_S2_palmtree_A.pacs_prim
|
||||
FY_S2_palmtree_B.pacs_prim
|
||||
FY_S2_palmtree_C.pacs_prim
|
||||
FY_S2_palmtree_D.pacs_prim
|
||||
FY_S2_palmtree_E.pacs_prim
|
||||
FY_S3_Termitiere_A.pacs_prim
|
||||
FY_S3_Termitiere_B.pacs_prim
|
||||
FY_S3_Termitiere_C.pacs_prim
|
||||
FY_S3_Termitiere_D.pacs_prim
|
||||
fy_acc_asc_appart_joueur.pacs_prim
|
||||
fy_acc_asc_hall_conseil.pacs_prim
|
||||
fy_acc_asc_hall_vitrine_hall_reunion_rdc_1.pacs_prim
|
||||
fy_acc_asc_hall_vitrine_hall_reunion_rdc_2.pacs_prim
|
||||
fy_acc_asc_hall_vitrine_hall_reunion_ss_1.pacs_prim
|
||||
fy_acc_asc_hall_vitrine_hall_reunion_ss_2.pacs_prim
|
||||
fy_acc_asc_hall_vitrine_hall_reunion_ss_3.pacs_prim
|
||||
fy_acc_asc_hall_vitrine_hall_reunion_ss_4.pacs_prim
|
||||
fy_acc_asc_oasis_1er.pacs_prim
|
||||
fy_acc_asc_oasis_rdc.pacs_prim
|
||||
fy_acc_asc_salle_npc.pacs_prim
|
||||
fy_acc_ascenseur_01_city.pacs_prim
|
||||
fy_acc_ascenseur_01_war.pacs_prim
|
||||
fy_acc_ascenseur_02_city.pacs_prim
|
||||
fy_acc_ascenseur_02_war.pacs_prim
|
||||
fy_acc_ascenseur_03_city.pacs_prim
|
||||
fy_acc_ascenseur_04_city.pacs_prim
|
||||
fy_acc_ascenseur_05_city.pacs_prim
|
||||
fy_acc_ascenseur_06_city.pacs_prim
|
||||
fy_acc_ascenseur_07_city.pacs_prim
|
||||
fy_acc_ascenseur_08_city.pacs_prim
|
||||
fy_acc_ascenseur_09_city.pacs_prim
|
||||
fy_acc_ascenseur_10_city.pacs_prim
|
||||
fy_acc_ascenseur_11_city.pacs_prim
|
||||
fy_acc_ascenseur_12_city.pacs_prim
|
||||
fy_asc_151_dy.pacs_prim
|
||||
fy_asc_161_dy.pacs_prim
|
||||
fy_asc_164_eg.pacs_prim
|
||||
fy_asc_168_ew.pacs_prim
|
||||
fy_asc_1porte.pacs_prim
|
||||
fy_asc_fortress_1er.pacs_prim
|
||||
fy_asc_fortress_rdc.pacs_prim
|
||||
fy_asc_village_nb01.pacs_prim
|
||||
fy_asc_village_nb02.pacs_prim
|
||||
fy_asc_village_nb03.pacs_prim
|
||||
fy_asc_village_nb04.pacs_prim
|
||||
fy_asc_village_nb05.pacs_prim
|
||||
fy_bt_sheriff_ok_ascen_1er.pacs_prim
|
||||
fy_bt_sheriff_ok_ascen_rdc.pacs_prim
|
||||
fy_bt_sheriff_ok_elevator_armurie_1er.pacs_prim
|
||||
fy_bt_sheriff_ok_elevator_armurie_rdc.pacs_prim
|
||||
fy_ecorce_collision.pacs_prim
|
||||
fy_s1_burnedtree_c.pacs_prim
|
||||
fy_s1_burnedtree_d.pacs_prim
|
||||
fy_s1_burnedtree_growth_a.pacs_prim
|
||||
fy_s1_burnedtree_growth_b.pacs_prim
|
||||
fy_s2_lovejail_a.pacs_prim
|
||||
fy_s2_lovejail_b.pacs_prim
|
||||
fy_s2_lovejail_c.pacs_prim
|
||||
fy_s2_papaleaf_a.pacs_prim
|
||||
fy_s2_papaleaf_b.pacs_prim
|
||||
fy_s2_savantree_a.pacs_prim
|
||||
fy_s2_savantree_b.pacs_prim
|
||||
fy_s2_savantree_c.pacs_prim
|
||||
fy_s2_savantree_d.pacs_prim
|
||||
fy_smoke_elevateur_1er.pacs_prim
|
||||
fy_smoke_elevateur_rdc.pacs_prim
|
||||
FO_S1_giant_tree.pacs_prim
|
||||
FO_S1_giant_trunk.pacs_prim
|
||||
FO_S2_arbragrelot.pacs_prim
|
||||
FO_S2_big_tree.pacs_prim
|
||||
FO_S2_bigroot_A.pacs_prim
|
||||
FO_S2_bigroot_B.pacs_prim
|
||||
FO_S2_bigroot_C.pacs_prim
|
||||
FO_S2_birch.pacs_prim
|
||||
FO_S2_spiketree.pacs_prim
|
||||
FO_S3_birch.pacs_prim
|
||||
FO_S3_buissonaepine.pacs_prim
|
||||
FO_S3_champignou_A.pacs_prim
|
||||
FO_S3_champignou_B.pacs_prim
|
||||
FO_S3_fougere.pacs_prim
|
||||
JU_S1_bamboo.pacs_prim
|
||||
JU_S1_canopy_tree.pacs_prim
|
||||
JU_S2_big_tree.pacs_prim
|
||||
JU_S2_young_tree.pacs_prim
|
||||
JU_S3_Banana_tree.pacs_prim
|
||||
JU_S3_Bush_tree.pacs_prim
|
||||
JU_S3_bamboo.pacs_prim
|
||||
JU_S3_dead_tree.pacs_prim
|
||||
JU_S3_fantree.pacs_prim
|
||||
JU_S3_plante.pacs_prim
|
||||
JU_S3_plantegrasse.pacs_prim
|
||||
JU_S3_tree.pacs_prim
|
||||
Ma_barriere_A_02.pacs_prim
|
||||
Ma_barriere_B_02.pacs_prim
|
||||
fo_s1_arbragrelot.pacs_prim
|
||||
gen_bt_col_ext.pacs_prim
|
||||
ma_asc_17_portal_trykers.pacs_prim
|
||||
ma_asc_3portes.pacs_prim
|
||||
ma_asc_3portes_bourgeons.pacs_prim
|
||||
ma_asc_6_portal_prime_racine.pacs_prim
|
||||
ma_asc_appart_joueur.pacs_prim
|
||||
ma_asc_hall_du_conseil.pacs_prim
|
||||
ma_asc_hall_vitrine_hall_reunion_1ss_d.pacs_prim
|
||||
ma_asc_hall_vitrine_hall_reunion_1ss_g.pacs_prim
|
||||
ma_asc_hall_vitrine_hall_reunion_rdc_d.pacs_prim
|
||||
ma_asc_hall_vitrine_hall_reunion_rdc_g.pacs_prim
|
||||
ma_asc_hall_vitrine_hall_reunion_ss_d.pacs_prim
|
||||
ma_asc_hall_vitrine_hall_reunion_ss_g.pacs_prim
|
||||
ma_asc_nb_01_a.pacs_prim
|
||||
ma_asc_nb_01_b.pacs_prim
|
||||
ma_asc_nb_01_c.pacs_prim
|
||||
ma_asc_nb_02_a.pacs_prim
|
||||
ma_asc_nb_02_b.pacs_prim
|
||||
ma_asc_nb_02_c.pacs_prim
|
||||
ma_asc_nb_03_a.pacs_prim
|
||||
ma_asc_nb_03_b.pacs_prim
|
||||
ma_asc_nb_03_c.pacs_prim
|
||||
ma_asc_nb_04_a.pacs_prim
|
||||
ma_asc_nb_04_b.pacs_prim
|
||||
ma_asc_nb_04_c.pacs_prim
|
||||
ma_asc_nb_05_a.pacs_prim
|
||||
ma_asc_nb_05_b.pacs_prim
|
||||
ma_asc_nb_05_c.pacs_prim
|
||||
ma_asc_plateau-frontiere-2.pacs_prim
|
||||
ma_asc_salle_npc.pacs_prim
|
||||
ma_asc_village_a_bar_ext_1.pacs_prim
|
||||
ma_asc_village_a_bar_ext_2.pacs_prim
|
||||
ma_asc_village_a_bar_int_1.pacs_prim
|
||||
ma_asc_village_a_bar_int_2.pacs_prim
|
||||
ma_asc_village_a_imm1_a.pacs_prim
|
||||
ma_asc_village_a_imm1_b.pacs_prim
|
||||
ma_asc_village_a_imm1_c.pacs_prim
|
||||
ma_asc_village_a_imm2_a.pacs_prim
|
||||
ma_asc_village_a_imm2_b.pacs_prim
|
||||
ma_asc_village_a_imm2_c.pacs_prim
|
||||
ma_asc_village_a_imm3_a.pacs_prim
|
||||
ma_asc_village_a_imm3_b.pacs_prim
|
||||
ma_asc_village_a_imm3_c.pacs_prim
|
||||
ma_asc_village_a_imm4_a.pacs_prim
|
||||
ma_asc_village_a_imm4_b.pacs_prim
|
||||
ma_asc_village_a_imm4_c.pacs_prim
|
||||
ma_asc_village_a_mairie_1er.pacs_prim
|
||||
ma_asc_village_a_mairie_rdc.pacs_prim
|
||||
ma_asc_village_a_serre_1.pacs_prim
|
||||
ma_asc_village_a_serre_2.pacs_prim
|
||||
ma_asc_village_a_serre_npc1.pacs_prim
|
||||
ma_asc_village_a_serre_npc2.pacs_prim
|
||||
ma_asc_village_b_bar_ext_1.pacs_prim
|
||||
ma_asc_village_b_bar_ext_2.pacs_prim
|
||||
ma_asc_village_b_bar_int_1.pacs_prim
|
||||
ma_asc_village_b_bar_int_2.pacs_prim
|
||||
ma_asc_village_b_imm1_a.pacs_prim
|
||||
ma_asc_village_b_imm1_b.pacs_prim
|
||||
ma_asc_village_b_imm1_c.pacs_prim
|
||||
ma_asc_village_b_imm2_a.pacs_prim
|
||||
ma_asc_village_b_imm2_b.pacs_prim
|
||||
ma_asc_village_b_imm2_c.pacs_prim
|
||||
ma_asc_village_b_mairie_1er.pacs_prim
|
||||
ma_asc_village_b_mairie_rdc.pacs_prim
|
||||
ma_asc_village_c_bar_ext_1.pacs_prim
|
||||
ma_asc_village_c_bar_ext_2.pacs_prim
|
||||
ma_asc_village_c_bar_int_1.pacs_prim
|
||||
ma_asc_village_c_bar_int_2.pacs_prim
|
||||
ma_asc_village_c_imm1_a.pacs_prim
|
||||
ma_asc_village_c_imm1_b.pacs_prim
|
||||
ma_asc_village_c_imm1_c.pacs_prim
|
||||
ma_asc_village_c_imm2_a.pacs_prim
|
||||
ma_asc_village_c_imm2_b.pacs_prim
|
||||
ma_asc_village_c_imm2_c.pacs_prim
|
||||
ma_asc_village_c_mairie_1er.pacs_prim
|
||||
ma_asc_village_c_mairie_rdc.pacs_prim
|
||||
ma_asc_village_d_bar_ext_1.pacs_prim
|
||||
ma_asc_village_d_bar_ext_2.pacs_prim
|
||||
ma_asc_village_d_bar_int_1.pacs_prim
|
||||
ma_asc_village_d_bar_int_2.pacs_prim
|
||||
ma_asc_village_d_imm1_a.pacs_prim
|
||||
ma_asc_village_d_imm1_b.pacs_prim
|
||||
ma_asc_village_d_imm1_c.pacs_prim
|
||||
ma_asc_village_d_imm2_a.pacs_prim
|
||||
ma_asc_village_d_imm2_b.pacs_prim
|
||||
ma_asc_village_d_imm2_c.pacs_prim
|
||||
ma_asc_village_d_mairie_1er.pacs_prim
|
||||
ma_asc_village_d_mairie_rdc.pacs_prim
|
||||
ma_lampadaire_blue.pacs_prim
|
||||
ma_lampadaire_red.pacs_prim
|
||||
ma_lampadaire_white.pacs_prim
|
||||
ma_lampadaire_yellow.pacs_prim
|
||||
ma_milestone.pacs_prim
|
||||
ma_paneau_armure.pacs_prim
|
||||
ma_paneau_melee.pacs_prim
|
||||
ma_paneau_object.pacs_prim
|
||||
ma_paneau_range.pacs_prim
|
||||
ma_paneau_tool.pacs_prim
|
||||
nx_asc_40_cg.pacs_prim
|
||||
nx_asc_44_by.pacs_prim
|
||||
nx_asc_51_cd.pacs_prim
|
||||
zo_acc_asc-01_hall_reunion.pacs_prim
|
||||
zo_acc_asc-02_hall_reunion.pacs_prim
|
||||
zo_acc_asc-03_hall_reunion.pacs_prim
|
||||
zo_acc_asc-04_hall_reunion.pacs_prim
|
||||
zo_acc_asc-05_hall_reunion.pacs_prim
|
||||
zo_acc_asc-06_hall_reunion.pacs_prim
|
||||
zo_acc_asc_appart_joueur.pacs_prim
|
||||
zo_acc_asc_hall_du_conseil.pacs_prim
|
||||
zo_acc_asc_salle_npc.pacs_prim
|
||||
zo_acc_rdc_mairie_village_c.pacs_prim
|
||||
zo_acc_ss_mairie_village_c.pacs_prim
|
||||
zo_acc_village_a_imm1_a.pacs_prim
|
||||
zo_acc_village_a_imm1_b.pacs_prim
|
||||
zo_acc_village_a_imm1_c.pacs_prim
|
||||
zo_acc_village_a_imm2_a.pacs_prim
|
||||
zo_acc_village_a_imm2_b.pacs_prim
|
||||
zo_acc_village_a_imm2_c.pacs_prim
|
||||
zo_acc_village_a_imm3_a.pacs_prim
|
||||
zo_acc_village_a_imm3_b.pacs_prim
|
||||
zo_acc_village_a_imm3_c.pacs_prim
|
||||
zo_acc_village_a_imm4_a.pacs_prim
|
||||
zo_acc_village_a_imm4_b.pacs_prim
|
||||
zo_acc_village_a_imm4_c.pacs_prim
|
||||
zo_acc_village_b_imm1_a.pacs_prim
|
||||
zo_acc_village_b_imm1_b.pacs_prim
|
||||
zo_acc_village_b_imm1_c.pacs_prim
|
||||
zo_acc_village_b_imm2_a.pacs_prim
|
||||
zo_acc_village_b_imm2_b.pacs_prim
|
||||
zo_acc_village_b_imm2_c.pacs_prim
|
||||
zo_acc_village_c_imm1_a.pacs_prim
|
||||
zo_acc_village_c_imm1_b.pacs_prim
|
||||
zo_acc_village_c_imm1_c.pacs_prim
|
||||
zo_acc_village_c_imm2_a.pacs_prim
|
||||
zo_acc_village_c_imm2_b.pacs_prim
|
||||
zo_acc_village_c_imm2_c.pacs_prim
|
||||
zo_acc_village_d_imm1_a.pacs_prim
|
||||
zo_acc_village_d_imm1_b.pacs_prim
|
||||
zo_acc_village_d_imm1_c.pacs_prim
|
||||
zo_acc_village_d_imm2_a.pacs_prim
|
||||
zo_acc_village_d_imm2_b.pacs_prim
|
||||
zo_acc_village_d_imm2_c.pacs_prim
|
||||
zo_asc_13_cp.pacs_prim
|
||||
zo_asc_15_by.pacs_prim
|
||||
zo_asc_29_cq.pacs_prim
|
||||
zo_asc_2portes.pacs_prim
|
||||
zo_asc_nb_01_a.pacs_prim
|
||||
zo_asc_nb_01_b.pacs_prim
|
||||
zo_asc_nb_01_c.pacs_prim
|
||||
zo_asc_nb_02_a.pacs_prim
|
||||
zo_asc_nb_02_b.pacs_prim
|
||||
zo_asc_nb_02_c.pacs_prim
|
||||
zo_asc_nb_03_a.pacs_prim
|
||||
zo_asc_nb_03_b.pacs_prim
|
||||
zo_asc_nb_03_c.pacs_prim
|
||||
zo_asc_nb_04_a.pacs_prim
|
||||
zo_asc_nb_04_b.pacs_prim
|
||||
zo_asc_nb_04_c.pacs_prim
|
||||
zo_asc_nb_05_a.pacs_prim
|
||||
zo_asc_nb_05_b.pacs_prim
|
||||
zo_asc_nb_05_c.pacs_prim
|
||||
zo_asc_plateau-frontiere-13_br.pacs_prim
|
||||
zo_asc_village_a_rdc.pacs_prim
|
||||
zo_asc_village_a_ss.pacs_prim
|
||||
zo_asc_village_b_rdc.pacs_prim
|
||||
zo_asc_village_b_ss.pacs_prim
|
||||
zo_asc_village_d_rdc.pacs_prim
|
||||
zo_asc_village_d_ss.pacs_prim
|
||||
zo_lampadaire_black.pacs_prim
|
||||
zo_lampadaire_blue.pacs_prim
|
||||
zo_lampadaire_green.pacs_prim
|
||||
zo_lampadaire_yellow.pacs_prim
|
||||
zo_paneau_armure.pacs_prim
|
||||
zo_paneau_melee.pacs_prim
|
||||
zo_paneau_object.pacs_prim
|
||||
zo_paneau_range.pacs_prim
|
||||
zo_paneau_tool.pacs_prim
|
||||
tr_asc_186_ep.pacs_prim
|
||||
tr_asc_187_ea.pacs_prim
|
||||
tr_asc_188_ed.pacs_prim
|
||||
tr_asc_192_ea.pacs_prim
|
||||
tr_asc_193_ec.pacs_prim
|
||||
tr_asc_194_dy.pacs_prim
|
||||
tr_asc_194_el.pacs_prim
|
||||
tr_asc_194_eo.pacs_prim
|
||||
tr_asc_196_ea.pacs_prim
|
||||
tr_asc_197_ds.pacs_prim
|
||||
tr_asc_198_dq.pacs_prim
|
||||
tr_asc_1porte.pacs_prim
|
||||
tr_asc_201_dq.pacs_prim
|
||||
tr_asc_201_dt.pacs_prim
|
||||
tr_asc_203_di.pacs_prim
|
||||
tr_asc_208_dl.pacs_prim
|
||||
tr_asc_208_ek.pacs_prim
|
||||
tr_asc_210_el.pacs_prim
|
||||
tr_asc_212_dm.pacs_prim
|
||||
tr_asc_214_dw.pacs_prim
|
||||
tr_asc_214_ea.pacs_prim
|
||||
tr_asc_215_du.pacs_prim
|
||||
tr_asc_217_ec.pacs_prim
|
||||
tr_asc_appart_joueur.pacs_prim
|
||||
tr_asc_hall_conseil.pacs_prim
|
||||
tr_asc_hall_vitrine_hall_reunion_rdc_1.pacs_prim
|
||||
tr_asc_hall_vitrine_hall_reunion_rdc_2.pacs_prim
|
||||
tr_asc_hall_vitrine_hall_reunion_ss_1.pacs_prim
|
||||
tr_asc_hall_vitrine_hall_reunion_ss_2.pacs_prim
|
||||
tr_asc_hall_vitrine_hall_reunion_ss_3.pacs_prim
|
||||
tr_asc_salle_npc.pacs_prim
|
||||
tr_asc_saucisse_fond_ilot_4_a.pacs_prim
|
||||
tr_asc_saucisse_fond_ilot_4_b.pacs_prim
|
||||
tr_asc_saucisse_fond_ilot_4_c.pacs_prim
|
||||
tr_asc_saucisse_fond_ilot_4_d.pacs_prim
|
||||
tr_asc_saucisse_fond_ilot_4_e.pacs_prim
|
||||
tr_asc_saucisse_fond_ilot_4_f.pacs_prim
|
||||
tr_asc_saucisse_village_nb01_a.pacs_prim
|
||||
tr_asc_saucisse_village_nb01_b.pacs_prim
|
||||
tr_asc_saucisse_village_nb01_c.pacs_prim
|
||||
tr_asc_saucisse_village_nb01_d.pacs_prim
|
||||
tr_asc_saucisse_village_nb01_e.pacs_prim
|
||||
tr_asc_saucisse_village_nb01_f.pacs_prim
|
||||
tr_asc_saucisse_village_nb02_a.pacs_prim
|
||||
tr_asc_saucisse_village_nb02_b.pacs_prim
|
||||
tr_asc_saucisse_village_nb02_c.pacs_prim
|
||||
tr_asc_saucisse_village_nb02_d.pacs_prim
|
||||
tr_asc_saucisse_village_nb02_e.pacs_prim
|
||||
tr_asc_saucisse_village_nb02_f.pacs_prim
|
||||
tr_asc_saucisse_village_nb03_a.pacs_prim
|
||||
tr_asc_saucisse_village_nb03_b.pacs_prim
|
||||
tr_asc_saucisse_village_nb03_c.pacs_prim
|
||||
tr_asc_saucisse_village_nb03_d.pacs_prim
|
||||
tr_asc_saucisse_village_nb03_e.pacs_prim
|
||||
tr_asc_saucisse_village_nb03_f.pacs_prim
|
||||
tr_asc_saucisse_village_nb04_a.pacs_prim
|
||||
tr_asc_saucisse_village_nb04_b.pacs_prim
|
||||
tr_asc_saucisse_village_nb04_c.pacs_prim
|
||||
tr_asc_saucisse_village_nb04_d.pacs_prim
|
||||
tr_asc_saucisse_village_nb04_e.pacs_prim
|
||||
tr_asc_saucisse_village_nb04_f.pacs_prim
|
||||
tr_asc_saucisse_village_nb05_a.pacs_prim
|
||||
tr_asc_saucisse_village_nb05_b.pacs_prim
|
||||
tr_asc_saucisse_village_nb05_c.pacs_prim
|
||||
tr_asc_saucisse_village_nb05_d.pacs_prim
|
||||
tr_asc_saucisse_village_nb05_e.pacs_prim
|
||||
tr_asc_saucisse_village_nb05_f.pacs_prim
|
||||
tr_mairie_asc_00_village_a.pacs_prim
|
||||
tr_mairie_asc_01_village_a.pacs_prim
|
||||
tr_mairie_asc_01_village_b.pacs_prim
|
||||
tr_mairie_asc_01_village_d.pacs_prim
|
||||
tr_mairie_asc_02_village_a.pacs_prim
|
||||
tr_mairie_asc_02_village_b.pacs_prim
|
||||
tr_mairie_asc_02_village_d.pacs_prim
|
||||
tr_mairie_asc_03_village_a.pacs_prim
|
||||
tr_mairie_asc_03_village_b.pacs_prim
|
||||
tr_mairie_asc_03_village_d.pacs_prim
|
||||
tr_mairie_asc_04_village_a.pacs_prim
|
||||
tr_mairie_asc_04_village_b.pacs_prim
|
||||
tr_mairie_asc_04_village_d.pacs_prim
|
||||
tr_mairie_asc_05_village_a.pacs_prim
|
||||
tr_mairie_asc_05_village_b.pacs_prim
|
||||
tr_mairie_asc_05_village_d.pacs_prim
|
||||
tr_mairie_asc_06_village_a.pacs_prim
|
||||
tr_mairie_asc_06_village_b.pacs_prim
|
||||
tr_mairie_asc_06_village_d.pacs_prim
|
||||
tr_mairie_asc_07_village_a.pacs_prim
|
||||
tr_mairie_asc_07_village_b.pacs_prim
|
||||
tr_mairie_asc_07_village_d.pacs_prim
|
||||
tr_mairie_asc_08_village_b.pacs_prim
|
||||
tr_mairie_asc_08_village_d.pacs_prim
|
||||
tr_mairie_ascr_01_village_c.pacs_prim
|
||||
tr_mairie_ascr_02_village_c.pacs_prim
|
||||
tr_mairie_ascr_03_village_c.pacs_prim
|
||||
tr_mairie_ascr_04_village_c.pacs_prim
|
||||
tr_mairie_ascr_05_village_c.pacs_prim
|
||||
tr_mairie_ascr_06_village_c.pacs_prim
|
||||
tr_mairie_ascr_07_village_c.pacs_prim
|
||||
tr_mairie_ascr_08_village_c.pacs_prim
|
||||
tr_s1_bambo_a.pacs_prim
|
||||
tr_s1_bamboo_a.pacs_prim
|
||||
tr_s2_bamboo_a.pacs_prim
|
||||
tr_s2_champiflot_a.pacs_prim
|
||||
tr_s2_lokness_a.pacs_prim
|
||||
tr_s2_lokness_b.pacs_prim
|
||||
tr_s2_lokness_c.pacs_prim
|
||||
tr_s2_mangrove_a.pacs_prim
|
||||
tr_s2_mangrove_b.pacs_prim
|
||||
tr_s2_nenufly_a.pacs_prim
|
||||
tr_s2_palmtree_a.pacs_prim
|
||||
tr_s2_palmtree_b.pacs_prim
|
||||
tr_s2_palmtree_c.pacs_prim
|
||||
tr_s2_palmtree_d.pacs_prim
|
||||
tr_s2_palmtree_e.pacs_prim
|
||||
tr_s2_palmtree_f.pacs_prim
|
||||
tr_s2_sailtree_a.pacs_prim
|
||||
tr_s2_wigweed_a.pacs_prim
|
||||
tr_s3_aquabole_a.pacs_prim
|
||||
tr_s3_aquabole_b.pacs_prim
|
||||
tr_s3_nenufly_b.pacs_prim
|
||||
tr_saucisse_asc01_01_village_a.pacs_prim
|
||||
tr_saucisse_asc01_01_village_d.pacs_prim
|
||||
tr_saucisse_asc01_02_village_a.pacs_prim
|
||||
tr_saucisse_asc01_02_village_d.pacs_prim
|
||||
tr_saucisse_asc01_03_village_a.pacs_prim
|
||||
tr_saucisse_asc01_04_village_a.pacs_prim
|
||||
tr_saucisse_asc01_village_a.pacs_prim
|
||||
tr_saucisse_asc01_village_b.pacs_prim
|
||||
tr_saucisse_asc02_01_village_d.pacs_prim
|
||||
tr_saucisse_asc02_02_village_a.pacs_prim
|
||||
tr_saucisse_asc02_02_village_d.pacs_prim
|
||||
tr_saucisse_asc02_03_village_a.pacs_prim
|
||||
tr_saucisse_asc02_04_village_a.pacs_prim
|
||||
tr_saucisse_asc02_village_a.pacs_prim
|
||||
tr_saucisse_asc02_village_b.pacs_prim
|
||||
tr_saucisse_asc03_01_village_d.pacs_prim
|
||||
tr_saucisse_asc03_02_village_a.pacs_prim
|
||||
tr_saucisse_asc03_02_village_d.pacs_prim
|
||||
tr_saucisse_asc03_03_village_a.pacs_prim
|
||||
tr_saucisse_asc03_04_village_a.pacs_prim
|
||||
tr_saucisse_asc03_village_a.pacs_prim
|
||||
tr_saucisse_asc03_village_b.pacs_prim
|
||||
tr_saucisse_asc04_01_village_d.pacs_prim
|
||||
tr_saucisse_asc04_02_village_a.pacs_prim
|
||||
tr_saucisse_asc04_02_village_d.pacs_prim
|
||||
tr_saucisse_asc04_03_village_a.pacs_prim
|
||||
tr_saucisse_asc04_04_village_a.pacs_prim
|
||||
tr_saucisse_asc04_village_a.pacs_prim
|
||||
tr_saucisse_asc04_village_b.pacs_prim
|
||||
tr_saucisse_asc05_01_village_d.pacs_prim
|
||||
tr_saucisse_asc05_02_village_a.pacs_prim
|
||||
tr_saucisse_asc05_02_village_d.pacs_prim
|
||||
tr_saucisse_asc05_03_village_a.pacs_prim
|
||||
tr_saucisse_asc05_04_village_a.pacs_prim
|
||||
tr_saucisse_asc05_village_a.pacs_prim
|
||||
tr_saucisse_asc05_village_b.pacs_prim
|
||||
tr_saucisse_asc06_01_village_d.pacs_prim
|
||||
tr_saucisse_asc06_02_village_a.pacs_prim
|
||||
tr_saucisse_asc06_02_village_d.pacs_prim
|
||||
tr_saucisse_asc06_03_village_a.pacs_prim
|
||||
tr_saucisse_asc06_04_village_a.pacs_prim
|
||||
tr_saucisse_asc06_village_b.pacs_prim
|
||||
tr_saucisse_asc_01_app_02_village_c.pacs_prim
|
||||
tr_saucisse_asc_02_app_02_village_c.pacs_prim
|
||||
tr_saucisse_asc_03_app_02_village_c.pacs_prim
|
||||
tr_saucisse_asc_04_app_02_village_c.pacs_prim
|
||||
tr_saucisse_asc_05_app_02_village_c.pacs_prim
|
||||
tr_saucisse_asc_06_app_02_village_c.pacs_prim
|
||||
tr_saucisse_asr01_02_village_b.pacs_prim
|
||||
tr_saucisse_asr02_02_village_b.pacs_prim
|
||||
tr_saucisse_asr03_02_village_b.pacs_prim
|
||||
tr_saucisse_asr04_02_village_b.pacs_prim
|
||||
tr_saucisse_asr05_02_village_b.pacs_prim
|
||||
tr_saucisse_asr06_02_village_b.pacs_prim
|
||||
tr_saucisse_asr_01_app_01_village_c.pacs_prim
|
||||
tr_saucisse_asr_02_app_01_village_c.pacs_prim
|
||||
tr_saucisse_asr_03_app_01_village_c.pacs_prim
|
||||
tr_saucisse_asr_04_app_01_village_c.pacs_prim
|
||||
tr_saucisse_asr_05_app_01_village_c.pacs_prim
|
||||
tr_saucisse_asr_06_app_01_village_c.pacs_prim
|
||||
PR_S1_rotaflore_A.pacs_prim
|
||||
PR_S1_rotaflore_B.pacs_prim
|
||||
PR_S1_rotaflore_C.pacs_prim
|
||||
PR_S2_Mycotree_A.pacs_prim
|
||||
PR_S2_Mycotree_B.pacs_prim
|
||||
PR_S2_Toopetz_A.pacs_prim
|
||||
PR_S2_Toopetz_B.pacs_prim
|
||||
PR_S2_Toopetz_C.pacs_prim
|
||||
PR_S3_cokamool_A.pacs_prim
|
||||
PR_S3_cokamool_B.pacs_prim
|
||||
PR_S3_cokamool_C.pacs_prim
|
||||
PR_S3_ploomweed_A.pacs_prim
|
||||
PR_S3_ploomweed_B.pacs_prim
|
||||
pr_asc_104_bi.pacs_prim
|
||||
pr_asc_105_bs.pacs_prim
|
||||
pr_asc_61_bj.pacs_prim
|
||||
pr_asc_62_ai.pacs_prim
|
||||
pr_asc_62_av.pacs_prim
|
||||
pr_asc_70_ae.pacs_prim
|
||||
pr_asc_71_au.pacs_prim
|
||||
pr_asc_77_bp.pacs_prim
|
||||
pr_asc_89_ar.pacs_prim
|
||||
pr_asc_91_ad.pacs_prim
|
||||
pr_s1_lumiseed_a.pacs_prim
|
||||
pr_s1_lumiseed_b.pacs_prim
|
||||
pr_s1_lumiseed_c.pacs_prim
|
||||
pr_s1_lumiseed_d.pacs_prim
|
||||
pr_s3_amoeba_a.pacs_prim
|
||||
pr_s3_amoeba_b.pacs_prim
|
||||
pr_s3_amoeba_c.pacs_prim
|
||||
pr_s3_small_lumiseed_a.pacs_prim
|
||||
pr_s3_small_lumiseed_b.pacs_prim
|
||||
ma_asc_to_kitiniere.pacs_prim
|
||||
pr_asc_kitiniere.pacs_prim
|
File diff suppressed because it is too large
Load Diff
@ -1,27 +0,0 @@
|
||||
SearchPaths =
|
||||
{
|
||||
"r:/code/ryzom/data_common/r2", // entry points file
|
||||
"R:/code/ryzom/data_shard/collisions",
|
||||
"F:/r2 daily",
|
||||
};
|
||||
|
||||
Continents = {"r2_jungle", "r2_forest", "r2_lakes", "r2_desert","r2_roots"};
|
||||
|
||||
SeasonSuffixes = { "_sp"}; //{ "_sp", "_su", "_au", "_wi" };
|
||||
|
||||
MeterPixelSize = 2;
|
||||
|
||||
OutDir = "F:/perso/code/HelloWorld/Affichage/Final";
|
||||
|
||||
CompleteIslandsFile= "r2_islands.xml";
|
||||
|
||||
EntryPointsFile= "r2_entry_points.txt";
|
||||
|
||||
Vegetation = true;
|
||||
|
||||
InverseZTest = true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
-- if not r2.Actions then r2.Actions={} end
|
||||
|
||||
-- obsolete
|
||||
r2._obsolete_Actions_createActionWithCondition = function(name, conditions, actions)
|
||||
assert(name)
|
||||
assert(type(conditions) == "table")
|
||||
assert(actions)
|
||||
|
||||
local first = nil
|
||||
local previous = nil
|
||||
|
||||
local k, condition = next(conditions, nil)
|
||||
while condition do
|
||||
local condition_if = r2.newComponent("RtNpcEventHandlerAction")
|
||||
condition_if.Action = "condition_if"
|
||||
condition_if.Parameters = condition
|
||||
if (previous) then table.insert(previous, condition_if) end
|
||||
if (first == nil) then first = condition_if end
|
||||
previous = condition_if.Children
|
||||
k, condition = next(conditions, k)
|
||||
end
|
||||
|
||||
do
|
||||
local multi_actions = r2.newComponent("RtNpcEventHandlerAction")
|
||||
multi_actions.Action = "multi_actions"
|
||||
multi_actions.Parameters = ""
|
||||
multi_actions.Children = actions
|
||||
assert(multi_actions)
|
||||
if (previous) then table.insert(previous, multi_actions) end
|
||||
if (first == nil) then first = multi_actions end
|
||||
end
|
||||
|
||||
-- table.insert(multi_actions.Children, actions)
|
||||
return first
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--debugInfo("actions ok!!")
|
File diff suppressed because it is too large
Load Diff
@ -1,870 +0,0 @@
|
||||
---------------------------------------------
|
||||
-- Base class for R2 components / features --
|
||||
---------------------------------------------
|
||||
|
||||
-- NB : throughout the file 'this' is used instead of the lua 'self' to denote the fact
|
||||
-- that method are not called on the class definition, but on the instances of this class
|
||||
|
||||
baseClass = -- not local here because of the implementation ...
|
||||
{
|
||||
----------------------
|
||||
-- CLASS PROPERTIES --
|
||||
----------------------
|
||||
|
||||
BaseClass = "", -- Name of the base class
|
||||
Version = 0,
|
||||
Name = "BaseClass", -- Name of the class
|
||||
BuildPropertySheet = true, -- True if objects of this class should be editable by using a generic property sheet
|
||||
-- Setting to 'true' will cause the framework to create the property sheet ui at launch
|
||||
Menu="", -- ui path of the contextual menu for this class
|
||||
--
|
||||
DisplayerUI = "", -- name of the C++ class that displays this object in the ui
|
||||
DisplayerUIParams = "", -- parameters passed to the ui displayer when it is created
|
||||
--
|
||||
DisplayerProperties = "R2::CDisplayerLua", -- 'lua' type of displayer takes the name of a lua function that must return the class of the displayer
|
||||
DisplayerPropertiesParams = "propertySheetDisplayer", -- name of the function that build the displayer that update the property sheet.
|
||||
--
|
||||
TreeIcon="", -- icon to be displayed in the tree (or a method returning it)
|
||||
PermanentTreeIcon="", -- icon to be displayed in the tree if in permanent content (or a method returning it)
|
||||
SelectBarType = "", -- type in select bar
|
||||
-- rollout header for the generic property sheet (a string giving the xml code for the header)
|
||||
PropertySheetHeader = nil,
|
||||
|
||||
-------------------
|
||||
-- CLASS METHODS --
|
||||
-------------------
|
||||
ClassMethods = {},
|
||||
|
||||
--------------------------
|
||||
-- INSTANCES PROPERTIES --
|
||||
--------------------------
|
||||
-- * Unlike class properties above, they are created in each instance of the class. They are directly accessible in the objects.
|
||||
-- * They are C++ objects exposed through the metatable mechanism
|
||||
-- * They are *READ-ONLY*. They should be modified by network commands like r2.requestSetNode and the like
|
||||
-- To store client side transcient values, use the native property 'User' (detailed below) instead
|
||||
-- TODO complete doc (available types, widgets ...)
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Category="Advanced", Visible=false },
|
||||
},
|
||||
|
||||
|
||||
-- 'VIRTUAL' PROPERTIES (NOT IMPLEMENTED)
|
||||
-- Not really properties of this class, but 'shortcuts' to other, real properties
|
||||
-- The virtual properties are use by the property sheet to display properties than are jnot directly in the object,
|
||||
-- but that can be found in another place. (son object for example, or object that require an indirection)
|
||||
-- each virtual prop should provide a 'getPath' function which takes the InstanceId of the instance in which it is contained as its parameter
|
||||
-- It should return a couple : realOwnerInstanceId, realPropName (arrays not supported yet)
|
||||
-- an observer is placed on the real property to take its changes in account in the property sheet
|
||||
-- IMPORTANT: the getPath function will be called each frame to see if observers should be removed
|
||||
-- and placed on another target
|
||||
|
||||
-- Example : indirection to fictive string property 'Toto' in the Scenario
|
||||
--VirtualProp =
|
||||
--{
|
||||
-- {Name="InstanceId", Type="String", WidgetStyle="StaticText", Category="Advanced", Visible=true,
|
||||
-- getPath = function()
|
||||
-- return r2.Scenario.InstanceId, "Toto"
|
||||
-- end,
|
||||
-- },
|
||||
--},
|
||||
|
||||
---------------------------------
|
||||
-- NATIVE / SPECIAL PROPERTIES --
|
||||
---------------------------------
|
||||
|
||||
-- They are implemented in C++ (thanks to the lua metatables)
|
||||
-- Parent : (R/O) : The direct parent of this object. If parent object is in a table, returns the table
|
||||
-- ParentInstance : (R/O) : Next parent of this object with an InstanceId. In object is contained in a property that
|
||||
-- is a table, the object containing the table will be returned, not the table
|
||||
-- IndexInParent : (R/O) : If parent is a table, then return index into it, -1 otherwise
|
||||
-- User : Read/Write lua table attached to the object. The 'User' field itself is R/O This is the place to store client side
|
||||
-- edition variables.
|
||||
-- Size : (R/O) : If object is a table, returns its size, nil otherwise
|
||||
-- DisplayerUI : (R/O) : for instances : returns reference to the ui displayer. May be nil.
|
||||
-- In the case where the field 'DisplayerUI' of this class definition id 'R2::CDisplayerLua', it would return
|
||||
-- the displayer object created by a call to the function defined in 'DisplayerUIParams' (in this class definition)
|
||||
-- DisplayerVisual : (R/O) : Same as DisplayerUI but for 'in scene' displayer
|
||||
-- DisplayerProperties : (R/O) : Same as DisplayerUI but for the properties displayer
|
||||
-- Selectable : (R/W) : default is true. When false, the object can't be selected in the scene. This flag is local to the instance (ancestor state not inherited)
|
||||
-- SelectableFromRoot : (R/O) : True if this object and also its ancestor are selectable
|
||||
|
||||
------------
|
||||
-- EVENTS --
|
||||
------------
|
||||
-- Events that are sent to the displayers, are also sent to instances that hold those displayers :
|
||||
-- By default they are not handled
|
||||
-- To handle, one shouldd redefine :
|
||||
-- function baseClass.onCreate(this)
|
||||
-- function baseClass.onErase(this)
|
||||
-- etc ...
|
||||
-- see r2_ui_displayers.lua for details
|
||||
|
||||
}
|
||||
|
||||
---------------------
|
||||
-- GENERAL METHODS --
|
||||
---------------------
|
||||
|
||||
-- Methods are defined in the class definition and are nevertheless callable on instances as follow :
|
||||
-- instance:methodName(params ...)
|
||||
-- In the class, the method would be defined as follow:
|
||||
-- methodName = function(this, param1, param2 ...) ... some code ... end
|
||||
-- 'this' will be filled at runtime by a reference on the instance on which the method is called.
|
||||
-- Method calling is possible thanks to the metamethod mechanism (in this case it is implemented in C++)
|
||||
-- Calling a method is in fact equivalent to doing the following :
|
||||
-- r2:getClass(instance).methodName(instance, param1, param2 ..)
|
||||
|
||||
|
||||
---------------------------------------
|
||||
-- TYPE / CLASS / PROPERTIES METHODS --
|
||||
---------------------------------------
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- return a reference to the class of this object
|
||||
function baseClass.getClass(this)
|
||||
return r2:getClass(this)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get description of a property (as found in the 'Prop' table of the class definition) from its name
|
||||
function baseClass.getPropDesc(this, propName)
|
||||
return this:getClass().NameToProp[propName]
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- return name of the parent class
|
||||
function baseClass.getClassName(this)
|
||||
return this.Class
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- test if object is of the given class (or derived from the class)
|
||||
-- param 'class' should be a string identifying the class
|
||||
function baseClass.isKindOf(this, className)
|
||||
|
||||
assert( type(this) == "userdata")
|
||||
local currClass = this:getClass()
|
||||
while currClass do
|
||||
if currClass.Name == className then
|
||||
return true
|
||||
end
|
||||
currClass = r2.Classes[currClass.BaseClass]
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- return a 'this' of the base class
|
||||
-- Use this to access a method defined in a base class from a derived class
|
||||
--
|
||||
-- example : this:delegate():doThis() -- Call the doThis function in the parent class
|
||||
--
|
||||
-- Expected behavior is the same than with C++ :
|
||||
-- Call from a delegated pointer is static
|
||||
-- any further call is the call chain is polymorphic
|
||||
-- Calls to delegate can be chained
|
||||
-- NB : this function shouldn't be redefined in derived classes (the delegation mechanism uses a pointer on this function)
|
||||
--function baseClass.delegate(this)
|
||||
-- return __baseClassImpl.delegate(this) -- implementation defined in "r2_base_class_private.lua"
|
||||
--end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Get actual C++ "this" for this object. Because of the delegation mechanism, this may be a raw C++ object
|
||||
-- or a lua table that performs the delegation
|
||||
-- OBSOLETE, TO REMOVE
|
||||
function baseClass.getRawThis(this)
|
||||
-- return __baseClassImpl.getRawThis(this) -- implementation defined in "r2_base_class_private.lua"
|
||||
return this
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- compare current "this", with another "this" pointer
|
||||
-- This should be the standard way to compare instance in memory because 'this' may sometime be a userdata
|
||||
-- (raw C++ pointer to internal C++ object), or a table (delegated 'this' pointer)
|
||||
-- OBSOLETE, TO REMOVE
|
||||
function baseClass.isSameObjectThan(this, other)
|
||||
--if this:isKindOf("Act") then
|
||||
-- breakPoint()
|
||||
--end
|
||||
--return this:getRawThis() == other:getRawThis()
|
||||
return this == other
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Helper : Return world position (that is, absolute position). By default, object deriving from the base class have no position
|
||||
function baseClass.getWorldPos()
|
||||
return { x = 0, y = 0, z = 0 }
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- When adding content, pionneer have a limited budget. This method gives the 'cost' of this object (0 by default)
|
||||
--function baseClass.getUsedQuota(this)
|
||||
-- return 0
|
||||
--end
|
||||
|
||||
-------------------
|
||||
-- SCENARIO COST --
|
||||
-------------------
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- See wether this element has a cost in the scenario
|
||||
function baseClass.hasScenarioCost(this)
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get local cost cached in object
|
||||
function baseClass.getLocalCost(this)
|
||||
return defaulting(this.User.Cost, 0)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- set local cost in object
|
||||
function baseClass.setLocalCost(this, cost)
|
||||
this.User.Cost = cost
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get local static cost cached in object
|
||||
function baseClass.getLocalStaticCost(this)
|
||||
return defaulting(this.User.StaticCost, 0)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- set local static cost in object
|
||||
function baseClass.setLocalStaticCost(this, cost)
|
||||
this.User.StaticCost = cost
|
||||
end
|
||||
|
||||
|
||||
|
||||
function baseClass.getStaticObjectCost(this)
|
||||
return 0
|
||||
end
|
||||
|
||||
function baseClass.getAiCost(this)
|
||||
return 0
|
||||
end
|
||||
|
||||
----------------------
|
||||
-- OBJECT HIERARCHY --
|
||||
----------------------
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- append all sub-content that is "kind of" 'kind' to 'destTable'
|
||||
-- NB : this is very SLOW!!! please use iterators instead (see r2:enumInstances)
|
||||
function baseClass.appendInstancesByType(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
if this.CompareClass and this.CompareClass == true then
|
||||
if this.Class == kind then
|
||||
if destTable == nil then
|
||||
dumpCallStack(1)
|
||||
end
|
||||
table.insert(destTable, this:getRawThis())
|
||||
end
|
||||
elseif this:isKindOf(kind) then
|
||||
if destTable == nil then
|
||||
dumpCallStack(1)
|
||||
end
|
||||
table.insert(destTable, this:getRawThis())
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Append all instances rooted at this object (including this one)
|
||||
|
||||
function baseClass.getSons(this, destTable)
|
||||
r2:exploreInstanceTree(this, destTable)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Search first ancestor of the wanted kind (that is of class 'className' or a derived class)
|
||||
function baseClass.getParentOfKind(this, className)
|
||||
local parent = this.ParentInstance
|
||||
while parent do
|
||||
assert(parent.isKindOf)
|
||||
if parent:isKindOf(className) then return parent end
|
||||
parent = parent.ParentInstance
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Search parent until an act is found
|
||||
function baseClass.getParentAct(this)
|
||||
return this:getParentOfKind("Act")
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Search parent until a scenario is found
|
||||
function baseClass.getParentScenario(this)
|
||||
return this:getParentOfKind("Scenario")
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- See if hits object is inserted in the default feature (that is : single npcs, bot objects, roads etc. with no enclosing group or feature)
|
||||
function baseClass.isInDefaultFeature(this)
|
||||
return this.ParentInstance:isKindOf('DefaultFeature')
|
||||
end
|
||||
|
||||
|
||||
--------------------------
|
||||
-- UI METHODS / DISPLAY --
|
||||
--------------------------
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Called by the contextual menu/toolbar when the 'delete' option is chosen by the user
|
||||
-- on THIS client
|
||||
-- This is the place to perform additionnal deletion tasks
|
||||
-- Example : a vertex may want to delete its containing region when there are 2 vertices left only
|
||||
-- default -> just call 'r2.requestEraseNode'
|
||||
function baseClass.onDelete(this)
|
||||
if this.User.DeleteInProgress == true then return end
|
||||
this.User.DeleteInProgress = true
|
||||
this:setDeleteActionName()
|
||||
this:selectNext()
|
||||
r2.requestEraseNode(this.InstanceId, "", -1)
|
||||
r2.requestEndAction()
|
||||
end
|
||||
|
||||
-- helper : add "delete : name_of_the_thing_being_deleted" in the action historic as the name of the delete action that is about
|
||||
-- to be done
|
||||
function baseClass.setDeleteActionName(this)
|
||||
r2.requestNewAction(concatUCString(i18n.get("uiR2EDDeleteAction"), this:getDisplayName()))
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Test wether the user can delete this object
|
||||
function baseClass.isDeletable(this)
|
||||
if this.Deletable and this.Deletable == 0 then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- called when the instance is selected (default is no op)
|
||||
function baseClass.onSelect(this)
|
||||
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Tell if object can be selected as next object if a predecessor object
|
||||
-- has been selected in the parent list
|
||||
function baseClass.isNextSelectable(this)
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get next selectable object (or nil else)
|
||||
function baseClass.getNextSelectableObject(this)
|
||||
local startIndex = this.IndexInParent
|
||||
if type(startIndex) ~= "number" then return nil end
|
||||
local currIndex = startIndex
|
||||
while true do
|
||||
currIndex = currIndex + 1
|
||||
if currIndex == this.Parent.Size then
|
||||
currIndex = 0
|
||||
end
|
||||
local instance = this.Parent[currIndex]
|
||||
if currIndex == startIndex then break end
|
||||
if instance ~= nil then
|
||||
local firstSon = instance:getFirstSelectableSon()
|
||||
if firstSon ~= nil and firstSon:isNextSelectable() then
|
||||
return firstSon
|
||||
elseif instance.Selectable and instance:isNextSelectable() then
|
||||
return instance
|
||||
end
|
||||
end
|
||||
end
|
||||
if this.ParentInstance:isKindOf("DefaultFeature") then
|
||||
return this.ParentInstance:getNextSelectableObject()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- select object next to this one, if there's one
|
||||
function baseClass.selectNext(this)
|
||||
local nextSelection = this
|
||||
while 1 do
|
||||
nextSelection = nextSelection:getNextSelectableObject()
|
||||
if not nextSelection or nextSelection == this then
|
||||
r2:setSelectedInstanceId("")
|
||||
return
|
||||
end
|
||||
if nextSelection then
|
||||
-- should not be frozen or hiden
|
||||
if (not nextSelection.DisplayerVisual) or (nextSelection.DisplayerVisual.DisplayMode ~= 1 and nextSelection.DisplayerVisual.DisplayMode ~= 2) then
|
||||
r2:setSelectedInstanceId(nextSelection.InstanceId)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- if an object is not selectable if may nevertheless contain selectable object, the first one is returned by this method
|
||||
function baseClass.getFirstSelectableSon(this)
|
||||
return nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get select bar type
|
||||
function baseClass.getSelectBarType(this)
|
||||
return r2:evalProp(this:getClass().SelectBarType, this, "")
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get name of tree icon
|
||||
function baseClass.getTreeIcon(this)
|
||||
return r2:evalProp(this:getClass().TreeIcon, this, "")
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get name of tree icon
|
||||
function baseClass.getPermanentTreeIcon(this)
|
||||
return r2:evalProp(this:getClass().PermanentTreeIcon, this, "")
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get name of tree icon according to permanent or current act
|
||||
function baseClass.getContextualTreeIcon(this)
|
||||
if this:getParentAct() and this:getParentAct():isBaseAct() then
|
||||
return this:getPermanentTreeIcon()
|
||||
else
|
||||
return this:getTreeIcon()
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get name of permanent statut icon
|
||||
function baseClass.getPermanentStatutIcon(this)
|
||||
return ""
|
||||
end
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get name of icon to be displayed in the slect bar
|
||||
function baseClass.getSelectBarIcon(this)
|
||||
return this:getContextualTreeIcon()
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Get the display name (in i18n format). This name will be displayed in the property sheet or inthe instance tree
|
||||
function baseClass.getDisplayName(this)
|
||||
local displayName = ucstring()
|
||||
if this.Name ~= nil and this.Name ~= "" then
|
||||
displayName:fromUtf8(this.Name)
|
||||
else
|
||||
return i18n.get("uiR2EDNoName")
|
||||
-- local className = this.Class
|
||||
-- -- tmp patch
|
||||
-- if this:isKindOf("Npc") then
|
||||
-- if this:isBotObject() then
|
||||
-- className = "Bot object"
|
||||
-- end
|
||||
-- end
|
||||
-- className = className .. " : " .. this.InstanceId
|
||||
-- displayName:fromUtf8(className)
|
||||
end
|
||||
return displayName
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Get the base name for instance name generation (should return a ucstring)
|
||||
function baseClass.getBaseName(this)
|
||||
return ucstring("")
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- return true if this instance can by displayed as a button in the select bar
|
||||
function baseClass.displayInSelectBar(this)
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get first parent that is selectable in the select bar
|
||||
function baseClass.getFirstSelectBarParent(this)
|
||||
local curr = this.ParentInstance
|
||||
while curr and not curr:displayInSelectBar() do
|
||||
curr = curr.ParentInstance
|
||||
end
|
||||
return curr
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- search the first son that could be inserted in the select bar
|
||||
-- default is to look recursively in the 'son select bar container'
|
||||
function baseClass.getFirstSelectBarSon(this)
|
||||
local sons = this:getSelectBarSons()
|
||||
if not sons then return nil end
|
||||
for k, v in specPairs(sons) do
|
||||
if v:displayInSelectBar() then
|
||||
return v
|
||||
end
|
||||
local firstSelectBarSon = v:getFirstSelectBarSon()
|
||||
if firstSelectBarSon ~= nil then
|
||||
return firstSelectBarSon
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- test if object can have sons than are displayable in the select bar
|
||||
function baseClass.canHaveSelectBarSons(this)
|
||||
return false;
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- return the default container that may contain object displayable in the select bar
|
||||
function baseClass.getSelectBarSons()
|
||||
return nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- called by the select bar when it displays its menu. Additionnal can be added there
|
||||
function baseClass.completeSelectBarMenu(rootMenu)
|
||||
-- no-op
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- The following method is called when the default ui displayer wants to know where to attach an object in the instance tree
|
||||
-- Default behaviour is to return the tree node of the parent object when one is found
|
||||
function baseClass.getParentTreeNode(this)
|
||||
parent = this.ParentInstance
|
||||
while parent ~= nil do
|
||||
if parent.User.TreeNodes ~= nil then
|
||||
return parent.User.TreeNodes
|
||||
end
|
||||
parent = parent.ParentInstance
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- Helper function for features : return the feature parent tree node in their act
|
||||
function baseClass.getFeatureParentTreeNode(this)
|
||||
|
||||
--return this:getParentAct():getContentTreeNodes("macro_components")
|
||||
return this:getParentAct():getContentTreeNodes()
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- TODO: test if the object can be exported (true by default)
|
||||
function baseClass.isExportable(this)
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- This method is called by the C++ when the contextual menu is about to be displayed
|
||||
function baseClass.onSetupMenu(this)
|
||||
local class = r2:getClass(this)
|
||||
local menuName = class.Menu
|
||||
if menuName == nil then return end
|
||||
local menu = getUI(menuName)
|
||||
-- setup menu entries to select parents
|
||||
--for i = 1,8 do
|
||||
-- menu["selectParent" .. tostring(i)].active = false
|
||||
--end
|
||||
-- local parent = this.ParentInstance
|
||||
-- for i = 1,9 do
|
||||
-- if parent == nil or parent.Parent == nil then break end
|
||||
-- menu["selectParent" .. tostring(i)].active = true
|
||||
-- menu["selectParent" .. tostring(i)].uc_hardtext = i18n.get("uimR2EDSelectParent") + (parent.InstanceId .. " (" .. parent.Class .. ")")
|
||||
-- --debugInfo(colorTag(0, 255, 255) .. tostring(i))
|
||||
-- parent = parent.ParentInstance
|
||||
-- end
|
||||
-- -- setup cut & paste entries
|
||||
-- local cuttedSelection = r2:getCuttedSelection()
|
||||
-- if cuttedSelection and this.accept ~= nil then
|
||||
-- local canPaste = this:accept(cuttedSelection)
|
||||
-- debugInfo("canPaste = " .. tostring(canPaste))
|
||||
-- menu.paste.grayed = not canPaste
|
||||
-- else
|
||||
-- menu.paste.grayed = true
|
||||
-- end
|
||||
-- debug options
|
||||
local extDebug = config.R2EDExtendedDebug == 1
|
||||
menu.dump_lua_table.active = extDebug
|
||||
menu.inspect_lua_table.active = extDebug
|
||||
menu.translateFeatures.active = extDebug
|
||||
menu.dump_dialogs_as_text.active = extDebug
|
||||
menu.update_dialogs_from_text.active = extDebug
|
||||
|
||||
menu.cut.active = extDebug
|
||||
menu.paste.active = extDebug
|
||||
|
||||
|
||||
|
||||
r2.ContextualCommands:setupMenu(this, menu)
|
||||
|
||||
|
||||
|
||||
-- delete entries for dynamic content
|
||||
-- local menuRoot = menu:getRootMenu()
|
||||
-- local startLine = menuRoot:getLineFromId("dynamic_content_start")
|
||||
-- local endLine = menuRoot:getLineFromId("dynamic_content_end")
|
||||
-- assert(startLine ~= -1 and endLine ~= -1)
|
||||
-- for lineToDel = endLine - 1, startLine + 1, -1 do
|
||||
-- menuRoot:removeLine(lineToDel)
|
||||
-- end
|
||||
-- retrieve dynamic commands
|
||||
-- local commands = this:getAvailableCommands()
|
||||
-- local currentLine = startLine + 1
|
||||
-- local commandIndex = 1
|
||||
-- for commandIndex, command in commands do
|
||||
-- menuRoot:addLineAtIndex(currentLine, i18n.get(command.TextId), "lua", "", "dyn_command_" .. tostring(commandIndex))
|
||||
-- if there's a bitmap, build a group with the buitmap in it, and add to menu
|
||||
-- if command.ButtonBitmap and command.ButtonBitmap ~= "" then
|
||||
-- local menuButton = createGroupInstance("r2_menu_button", "", { bitmap = command.ButtonBitmap, })
|
||||
-- if menuButton then
|
||||
-- menuRoot:setUserGroupLeft(currentLine, menuButton)
|
||||
-- end
|
||||
-- end
|
||||
--currentLine = currentLine + 1
|
||||
--end
|
||||
end
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Show the property window for this instance
|
||||
-- (react to the event 'show properties' triggered in the ui, by contextual menu or toolbar)
|
||||
function baseClass.onShowProperties(this)
|
||||
-- for now a global (see r2_ui_property_sheet.lua)
|
||||
r2:showProperties(this)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Return list of currently available commands to launch on that instance.
|
||||
-- such commands are displayed in the contextual toolbar or in the contextual menu.
|
||||
-- Returned value should be an array (starting at index 1) with commands of the following format :
|
||||
--
|
||||
-- { DoCommand = function(instance) ..., -- code to execute when the command is triggered (by menu or toolbar)
|
||||
-- -- Because the function takes 'instance' as a parameter, it may be
|
||||
-- -- either a global function or a method of this class
|
||||
-- Id = "", -- Id of the action. The action "r2ed_context_command" defined in actions.xml
|
||||
-- -- will search for this id when a key is pressed to find the good action
|
||||
-- TextId = "...", -- Text id for entry menu & toolbar tooltip
|
||||
-- ButtonBitmap = "filename.tga", -- Name of the button to display in the toolbar, nil
|
||||
-- -- or "" if the command should not appear in the contextual toolbar
|
||||
-- Separator = "true", -- optionnal, false by default : specify if there should be a separator
|
||||
-- -- between this button and previous buttons
|
||||
-- ShowInMenu = false, -- false if the entry shouldn't be displayed in the menu
|
||||
-- IsActivity = false -- true if event is an activity
|
||||
-- }
|
||||
--
|
||||
-- 'getAvailableCommands' should be called by derived class, possibly adding their
|
||||
-- own commands
|
||||
--
|
||||
-- See also : 'buildCommand'
|
||||
|
||||
function baseClass.getAvailableCommands(this, dest)
|
||||
if this.ParentInstance:isKindOf("UserComponentHolder") then
|
||||
table.insert(dest, this:buildCommand(this.onRemoveFromUserComponent, "removeFromUserComponent", "uimR2EDRemoveFromUserComponent", ""))
|
||||
end
|
||||
if this:isDeletable() and this.User.DeleteInProgress ~= true then
|
||||
table.insert(dest, this:buildCommand(this.onDelete, "delete", "uimR2EDMenuDelete", "r2_toolbar_delete.tga"))
|
||||
end
|
||||
if this:getClass().BuildPropertySheet then
|
||||
table.insert(dest, this:buildCommand(this.onShowProperties, "properties", "uimR2EDMenuProperties", "r2_toolbar_properties.tga", true))
|
||||
end
|
||||
|
||||
if this:isKindOf("NpcCustom") then
|
||||
table.insert(dest, this:buildCommand(this.customizeLook, "customize_look", "uiR2EDCustomizeLook", "r2_toolbar_customize_look.tga", false))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Build a single command entry to be used by 'getAvailableCommands'
|
||||
-- A command entry translates into a button in the contextual toolbar
|
||||
function baseClass.buildCommand(this, command, id, textId, bitmap, separator, showInMenu)
|
||||
if showInMenu == nil then showInMenu = true end
|
||||
return
|
||||
{
|
||||
DoCommand = command,
|
||||
TextId = textId,
|
||||
Id = id,
|
||||
ButtonBitmap = bitmap,
|
||||
Separator = separator,
|
||||
ShowInMenu = showInMenu,
|
||||
IsActivity = false
|
||||
}
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- same as 'buildCommand', but for activities
|
||||
function baseClass.buildActivityCommand(this, command, id, textId, bitmap, separator, showInMenu)
|
||||
local result = this:buildCommand(command, id, textId, bitmap, separator, showInMenu)
|
||||
result.IsActivity = true
|
||||
return result
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Special, class method (not instance method) for dev : returns a table containing all infos on which the xml generic property sheet depends
|
||||
-- When this table is modified, then the xml property sheet will be rebuild for this class (when 'resetEditor'
|
||||
-- is called for example.
|
||||
function baseClass.ClassMethods.getGenericPropertySheetCacheInfos(this)
|
||||
local infos = {}
|
||||
infos.Prop = this.Prop -- if one of the properties change, then must rebuild the property sheet
|
||||
infos.PropertySheetHeader = this.PropertySheetHeader -- if the xml header change, then must rebuild the sheet, too
|
||||
return infos
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get list of command for display in the mini toolbar
|
||||
function baseClass.getAvailableMiniCommands(this, result)
|
||||
-- OBSOLETE
|
||||
-- table.insert(result, this:buildCommand(this.editDialogs, "edit_dialogs", "uiR2EDEditDialogs", "r2_icon_dialog_mini.tga"))
|
||||
-- table.insert(result, this:buildCommand(this.editActions, "edit_actions", "uiR2EDEditActions", "r2_icon_action_mini.tga"))
|
||||
-- table.insert(result, this:buildCommand(this.editReactions, "edit_reactions", "uiR2EDEditReactions", "r2_icon_reaction_mini.tga"))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Return true if sequences can be edited on that object
|
||||
function baseClass.isSequencable(this)
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- For sequencable object only (baseClass.isSequencable) : return the lookup string for a verb from an activity name
|
||||
-- Indeed, an activity may have different name depending on who performs it
|
||||
-- for example, the "Feed In Zone" activity will be name "work" for a worker kitin instead of "feed" for a carnivore
|
||||
function baseClass.getActivityVerbLookupName(this, activityName)
|
||||
return activityName
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- is the object global to the scenario ? The select bar will call this to force the good update
|
||||
-- for global objects that are selectable (plot items ...)
|
||||
function baseClass.isGlobalObject(this)
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
|
||||
function baseClass.onRemoveFromUserComponent(this)
|
||||
r2_core.CurrentHolderId = this.ParentInstance.InstanceId
|
||||
r2_core:removeUserComponentElement(this.InstanceId)
|
||||
end
|
||||
|
||||
-------------
|
||||
-- REF IDS --
|
||||
-------------
|
||||
|
||||
-- Set the value of a refId inside this object. (empty string to delete)
|
||||
-- This will push a new action name & call r2.requestNode
|
||||
function baseClass.setRefIdValue(this, refIdName, targetId)
|
||||
local name = this:getDisplayName()
|
||||
local refIdUCName = r2:getPropertyTranslation(this:getClass().NameToProp[refIdName])
|
||||
if targetId == "" then
|
||||
r2.requestNewAction(concatUCString(i18n.get("uiR2EDRemovingTargetAction"), name,
|
||||
i18n.get("uiR2EDAddingReferenceSeparator"), refIdname))
|
||||
else
|
||||
local targetName = r2:getInstanceFromId(targetId):getDisplayName()
|
||||
r2.requestNewAction(concatUCString(i18n.get("uiR2EDAddingReferenceAction"), name,
|
||||
i18n.get("uiR2EDAddingReferenceSeparator"), refIdUCName,
|
||||
i18n.get("uiR2EDAddingReferenceToAction"), targetName))
|
||||
end
|
||||
r2.requestSetNode(this.InstanceId, refIdName, targetId)
|
||||
|
||||
end
|
||||
|
||||
|
||||
---------------------------
|
||||
-- COPY / PASTE HANDLING --
|
||||
---------------------------
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- see if this object support copy (false by default)
|
||||
function baseClass.isCopyable(this)
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Create a canonical copy of this object, this copy can be used by subsequent calls to 'newCopy'
|
||||
function baseClass.copy(this)
|
||||
-- implementation in "r2_base_class_private.lua"
|
||||
end
|
||||
|
||||
|
||||
-- Create a new copy from a canonical copy
|
||||
-- New instance ids are generated
|
||||
-- Default behavior is to remove all external dependencies and to rename
|
||||
-- internal dependencies
|
||||
-- The result can be used as input to 'paste' & 'ghostPaste'
|
||||
function baseClass.newCopy(canonicalCopy)
|
||||
-- implementation in "r2_base_class_private.lua"
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Paste the current clipboard
|
||||
-- not really a method here, because 'src' id a lua table (should be the content of the clipboard ...) that can be used with
|
||||
-- a r2.request.. command.
|
||||
-- - this function should copy the result in a suitable place (maybe into current selection, or at global scope)
|
||||
-- NB : if newPlace is not true, then the result should be past at the coordinates found in src
|
||||
-- - It should check that there is some room in the scenario before doing the copy
|
||||
function baseClass.paste(src, newPlace, srcInstanceId)
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function baseClass.pasteGhost(src)
|
||||
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- TMP TMP : move events test
|
||||
|
||||
--
|
||||
function baseClass.onTargetInstancePreHrcMove(this, targetAttr, targetIndexInArray)
|
||||
debugInfo(string.format("instance: pre hrc move : %s", targetAttr))
|
||||
end
|
||||
--
|
||||
function baseClass.onTargetInstancePostHrcMove(this, targetAttr, targetIndexInArray)
|
||||
debugInfo(string.format("instance : post hrc move : %s", targetAttr))
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- IMPLEMENTATION
|
||||
r2.doFile("r2_base_class_private.lua")
|
||||
|
||||
|
||||
r2.registerComponent(baseClass)
|
||||
|
||||
baseClass = nil
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,146 +0,0 @@
|
||||
------------------------------
|
||||
-- 'BaseClass' private code --
|
||||
------------------------------
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- copy default implementation
|
||||
|
||||
-- privates, used by baseClass.copy :
|
||||
local srcToCopyMapping = {} -- map each instance in the src tree to its shallow vopy
|
||||
|
||||
local function isInstance(inst)
|
||||
return (type(inst) == "table" or type(inst) == "userdata") and inst.InstanceId ~= nil
|
||||
end
|
||||
|
||||
local function isArray(inst)
|
||||
return type(inst) == "table" and inst.InstanceId == nil
|
||||
end
|
||||
|
||||
local function isInstanceArray(array)
|
||||
return type(array) == "userdata" and array.Size ~= nil
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- create canonical copy
|
||||
local function canonicalCopy(node)
|
||||
if isInstance(node) then
|
||||
assert(node.Class ~= nil)
|
||||
local newNode = {}
|
||||
for k, v in specPairs(node) do
|
||||
-- special case for refId in class definition
|
||||
--inspect(node:getClass())
|
||||
local prop = r2.Classes[node.Class].NameToProp[k]
|
||||
if prop and prop.Type == "RefId" then
|
||||
newNode[k] = r2.RefId(v)
|
||||
else
|
||||
newNode[k] = canonicalCopy(v)
|
||||
end
|
||||
end
|
||||
return newNode
|
||||
elseif isInstanceArray(node) then
|
||||
local newArray = {}
|
||||
for k, v in specPairs(node) do
|
||||
newArray[k] = canonicalCopy(v)
|
||||
end
|
||||
return newArray
|
||||
else
|
||||
return node
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- clone an object into clipboard, refid are unmodified
|
||||
local function cloneNode(node, mapping)
|
||||
if isInstance(node) then
|
||||
assert(node.Class ~= nil)
|
||||
local newNode = r2.newComponent(node.Class)
|
||||
for k, v in pairs(node) do
|
||||
-- special case for refId in class definition
|
||||
--inspect(node:getClass())
|
||||
local prop = r2.Classes[node.Class].NameToProp[k]
|
||||
if prop and prop.Type == "RefId" then
|
||||
newNode[k] = r2.RefId(v)
|
||||
elseif k ~= "InstanceId" and k ~= "Class" then
|
||||
newNode[k] = cloneNode(v, mapping)
|
||||
end
|
||||
end
|
||||
mapping[node.InstanceId] = newNode.InstanceId
|
||||
return newNode
|
||||
elseif isArray(node) then
|
||||
local newArray = {}
|
||||
-- workaround here : if there are only numbers in the table keys, then sort and insert
|
||||
-- this allow to preserve order when duplicating a road / place
|
||||
local plainArray = true
|
||||
for k, v in pairs(node) do
|
||||
if type(k) ~= "number" then
|
||||
plainArray = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if plainArray then
|
||||
local indices = {}
|
||||
for k, v in pairs(node) do
|
||||
table.insert(indices, k)
|
||||
end
|
||||
table.sort(indices)
|
||||
for i = 1, table.getn(indices) do
|
||||
table.insert(newArray, cloneNode(node[indices[i]], mapping))
|
||||
end
|
||||
else
|
||||
for k, v in pairs(node) do
|
||||
newArray[k] = cloneNode(v, mapping)
|
||||
end
|
||||
end
|
||||
return newArray
|
||||
else
|
||||
return node
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------
|
||||
-- remap refid for internal refs, external refs are left unmodified
|
||||
local function renameRefIds(node, mapping)
|
||||
if isInstance(node) then
|
||||
assert(node.Class ~= nil)
|
||||
for k, v in pairs(node) do
|
||||
-- special case for refId in class definition
|
||||
local prop = r2.Classes[node.Class].NameToProp[k]
|
||||
if prop and prop.Type == "RefId" then
|
||||
--debugInfo("***" .. tostring(v))
|
||||
if mapping[tostring(v)] ~= nil then
|
||||
--debugInfo("###")
|
||||
node[k] = mapping[tostring(v)] -- remap internal ref
|
||||
end
|
||||
else
|
||||
renameRefIds(v, mapping)
|
||||
end
|
||||
end
|
||||
mapping[node] = newNode
|
||||
elseif type(node) == "table" then
|
||||
for k, v in specPairs(node) do
|
||||
renameRefIds(v, mapping)
|
||||
end
|
||||
return newArray
|
||||
end
|
||||
end
|
||||
|
||||
function baseClass.copy(this)
|
||||
return canonicalCopy(this)
|
||||
end
|
||||
|
||||
function baseClass.newCopy(this)
|
||||
table.clear(srcToCopyMapping)
|
||||
local result = cloneNode(this, srcToCopyMapping)
|
||||
renameRefIds(result, srcToCopyMapping)
|
||||
-- if the name is a generated one, create a new name
|
||||
if result.Name ~= nil and r2:isPostFixedByNumber(ucstring(result.Name)) then
|
||||
result.Name = r2:genInstanceName(ucstring(result.Name)):toUtf8()
|
||||
end
|
||||
|
||||
-- the copy of a undeletable object is a deltable object
|
||||
if result.Deletable ~= nil and result.Deletable==0 then
|
||||
result.Deletable = 1
|
||||
end
|
||||
return result
|
||||
end
|
@ -1,34 +0,0 @@
|
||||
|
||||
r2.BasicBricks = {}
|
||||
|
||||
r2.BasicBricks["RtScenario"] = { acts = {} }
|
||||
|
||||
r2.BasicBricks["RtAct"] =
|
||||
{
|
||||
id="", npc_grps={}, fauna_grps={}, ai_states={}, npcs={}
|
||||
}
|
||||
|
||||
r2.BasicBricks["RtNpcGrp"] =
|
||||
{
|
||||
id="", Name="", children={},
|
||||
autospawn=1, bot_chat_parameters="", bot_equipment="",
|
||||
bot_sheet_client="", bot_vertical_pos="auto",
|
||||
count = 0, grp_keywords =""
|
||||
}
|
||||
|
||||
r2.BasicBricks["RtNpc"]=
|
||||
{
|
||||
id="", Name="",
|
||||
chat_parameters="", equipment="", is_stuck=0,
|
||||
keywords="", sheet_client="", bot_vertical_pos="auto",
|
||||
angle=0, pt = {x=0,y=0,z=0}
|
||||
}
|
||||
|
||||
r2.BasicBricks["RtAiState"]=
|
||||
{
|
||||
id="", Name="", children={},
|
||||
ai_activity="no_change", ai_movement="stand_on_start_point",
|
||||
ai_profile_params = 0, keywords="", vertical_pos="auto",
|
||||
pt = {}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,127 +0,0 @@
|
||||
-- config file for the r2 environment
|
||||
|
||||
|
||||
verboseDebugInfo = false -- when set to true, debug infos will be preceded by the number of the line that generated them
|
||||
traceFunctions = false -- when set to true, each function enter / function leave are dumped to the stack
|
||||
|
||||
|
||||
-- TODO nico : a table with predefined colors
|
||||
r2.Config =
|
||||
{
|
||||
PrimDisplayEnabled = true, -- should route and zones be displayed ?
|
||||
FloatingShapeRefScale = 1.0, -- size of the floating mesh displayed at the mouse position when view-ray didn't hit a valid pos (in creation mode)
|
||||
RegionFadeTimeInMs = 300, -- time in ms needed for a region to get higlighted
|
||||
TestPaletteSelection = false, -- complete the palette for a test for selection by ecosystem & level
|
||||
VerboseGetUI = false, -- some getUI can be made silent when they fail by turning this option to 'false'
|
||||
ResetWindowPos = true, -- TMP : should windows pos be reseted at startup ?
|
||||
ActMaxQuota = 99, -- 'hardcoded" : max content that can be added into an act (checked by server too, but value is not taken from this file of course ..)
|
||||
-- decals look
|
||||
HightlightDecalLook =
|
||||
{
|
||||
DurationInMs = 1000,
|
||||
Texture = "r2_highlight_decal.tga",
|
||||
EndScaleFactor = 1,
|
||||
EndAngleInDegrees = 0,
|
||||
StartDiffuse = CRGBA(255, 255, 255),
|
||||
EndDiffuse = CRGBA(127, 0, 255),
|
||||
StartEmissive = CRGBA(0, 0, 0),
|
||||
EndEmissive = CRGBA(0, 0, 0),
|
||||
},
|
||||
SelectDecalLook =
|
||||
{
|
||||
DurationInMs = 1000,
|
||||
Texture = "r2_select_decal.tga",
|
||||
EndScaleFactor = 1.2,
|
||||
EndAngleInDegrees = 0,
|
||||
StartDiffuse = CRGBA(255, 0, 0),
|
||||
EndDiffuse = CRGBA(255, 0, 0, 127),
|
||||
StartEmissive = CRGBA(0, 0, 0),
|
||||
EndEmissive = CRGBA(127, 127, 127),
|
||||
},
|
||||
SelectingDecalLook =
|
||||
{
|
||||
DurationInMs = 200,
|
||||
Texture = "r2_select_decal.tga",
|
||||
EndScaleFactor = 1.2,
|
||||
EndAngleInDegrees = 90,
|
||||
StartDiffuse = CRGBA(255, 255, 255),
|
||||
EndDiffuse = CRGBA(255, 255, 255, 0),
|
||||
StartEmissive = CRGBA(0, 0, 0),
|
||||
EndEmissive = CRGBA(0, 0, 0)
|
||||
},
|
||||
PionneerDecalLook =
|
||||
{
|
||||
DurationInMs = 3000,
|
||||
Texture = "r2_pionneer_edit.tga",
|
||||
EndScaleFactor = 1.05,
|
||||
EndAngleInDegrees = 0,
|
||||
StartDiffuse = CRGBA(255, 0, 0, 255),
|
||||
EndDiffuse = CRGBA(255, 0, 0, 192),
|
||||
StartEmissive = CRGBA(0, 64, 0),
|
||||
EndEmissive = CRGBA(0, 0, 0)
|
||||
},
|
||||
--
|
||||
MapEntityInvalidTexture = "r2_icon_map_invalid.tga", -- over displayed on minimap when object in on invalid pos
|
||||
MapEntityInvalidTextureSmall = "r2_icon_map_invalid_small.tga", -- over displayed on minimap when object in on invalid pos, small version
|
||||
MapEntityFrozenColor = CRGBA(0, 255, 255, 80),
|
||||
MapEntityLockedColor = CRGBA(127, 0, 200, 80),
|
||||
ArrayInstanceColor = CRGBA(255, 255, 255, 127),
|
||||
MapEntityDefaultTexture = "brick_default.tga"; -- Bitmap to be used when one of the following bitmaps wasn't found
|
||||
MapEntitySelectTexture = "r2_icon_select.tga", -- The 'circle' bitmap draw on the map over selected / highlighted entities
|
||||
MapEntityHighlightColor = CRGBA(255, 255, 255, 255), -- Color of selection bitmap over an entity on the map
|
||||
MapEntitySelectColor = CRGBA(255, 0, 0, 255), -- Color of highlight bitmap over an entity on the map
|
||||
MapEntityFarTexture = "r2_icon_far.tga", -- Texture to display on the border of the map when the current selection is out
|
||||
-- ... of the current visible world part in the map
|
||||
MapEntityFarArrowSize = 10, -- Size of the "MapEntityFarTexture" texture in pixels (scale applied ..)
|
||||
MapEntitySmallTexture = "r2_icon_map_entity_small.tga", -- Texture for entities when map is zoomed out
|
||||
MapEntitySmallHighlightTexture = "r2_icon_map_entity_small_highlight.tga",
|
||||
MapEntityOrientTexture = "r2_icon_map_entity_orient.tga", -- arrow to signal entity orientation in close view
|
||||
MapEntityOrientOriginDist = 9, -- distance from entity to its orient texture
|
||||
MapEntityOrientOriginDistSmall = 5, -- distance from entity to its orient texture when the entity is small and wihle it is being rotated
|
||||
MapEntityOrientBlendTimeInMs = 300, -- time that the orientation arrow need to get back to alpha = 0 when rotation is stopped
|
||||
MapEntityCloseDist = 0.24, -- number of meter per pixel for the close view
|
||||
MapGlowStarTexture = "r2_glow_star.tga", -- Texture displayed in the border of the map to signal that an object is too far to be seen
|
||||
MapGlowStarSpeed1 = 0.50, -- rotation speed of first map glow star
|
||||
MapGlowStarSpeed2 = -0.60, -- rotation speed of second map glow star
|
||||
MapGlowStarSize = 7, -- size of glow star
|
||||
-- color of regions in the 3D scene
|
||||
FocusedRegionColor = CRGBA(63, 127, 255, 100),
|
||||
SelectedRegionColor = CRGBA(192, 127, 64, 100),
|
||||
UnselectedRegionColor = CRGBA(0, 0, 255, 80),
|
||||
FrozenRegionColor = CRGBA(0, 255, 255, 80),
|
||||
LockedRegionColor = CRGBA(127, 0, 200, 80),
|
||||
-- colors for selected / focused entities / instance in scene (such as creature & npcs)
|
||||
FocusedInstanceColor = CRGBA(200, 32, 64, 127),
|
||||
SelectedInstanceColor = CRGBA(127, 127, 127),
|
||||
UnselectedInstanceColor = CRGBA(0, 0, 0),
|
||||
FrozenInstanceColor = CRGBA(0, 255, 255, 80),
|
||||
LockedInstanceColor = CRGBA(127, 0, 200, 80),
|
||||
-- world map auto pan
|
||||
MapAutoPanBorder = 20, -- number of pixels in the border of the map for which the auto pan is tested
|
||||
MapAutoPanDeltaInMs = 300, -- delta between each map pan when the mouse is on an auto-pan region
|
||||
MapAutoPanFastDeltaInMs = 100, -- delta between each map pan when fast pan is active
|
||||
MapAutoPanSpeedInPixels = 15, -- number of pixel to pan the map
|
||||
MapAutoFastPanNumTicks = 4, -- number of 'slow' pan to do before entering fast pan mode
|
||||
-- foot steps / wander look
|
||||
FootStepMapTexture = "r2_map_foot_steps.tga",
|
||||
FootStepDecalTexture = "r2_foot_steps.tga",
|
||||
FootStepMapWidth = 3,
|
||||
FootStepDecalUScale = 1.5,
|
||||
FootStepDecalWidth = 0.15,
|
||||
FootStepDecalSelectedColor = CRGBA(255, 255, 255, 255),
|
||||
FootStepDecalHiddenColor = CRGBA(0, 0, 255, 120),
|
||||
FootStepDecalFocusedColor = CRGBA(255, 255, 255, 127),
|
||||
FootStepMapSelectedColor = CRGBA(180, 0, 192, 255),
|
||||
FootStepMapHiddenColor = CRGBA(150, 0, 192, 100),
|
||||
FootStepMapFocusedColor = CRGBA(150, 0, 192, 160),
|
||||
WanderDecalTexture = "r2_wander.tga",
|
||||
WanderDecalSize = 0.55,
|
||||
AutoGroupMaxDist = 4,
|
||||
-- display of inaccessible pos on map
|
||||
InaccessiblePosColor0 = CRGBA(255, 0, 0, 255),
|
||||
InaccessiblePosColor1 = CRGBA(200, 217, 0, 255),
|
||||
InaccessiblePosAnimDurationInMS = 500,
|
||||
DecalTopBlendStartDist = 3, -- Distance in meters at which the color starts to fade for player & selection decals (at top)
|
||||
DecalBottomBlendStartDist = 1, -- Distance in meters at which the color starts to fade for player & selection decals (at bottom)
|
||||
DecalBlendLength = 1.5 -- Length for decal color fading (player & selection decals)
|
||||
}
|
@ -1,173 +0,0 @@
|
||||
-- console & printing related functions
|
||||
|
||||
---------------
|
||||
-- FUNCTIONS --
|
||||
---------------
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- alias for 'debugInfo'
|
||||
log = debugInfo
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- Build color tag for use with debugInfo
|
||||
function colorTag(r, g, b, a)
|
||||
local function compToLetter(comp)
|
||||
if comp == nil then
|
||||
return 'F'
|
||||
end
|
||||
comp = math.floor(clamp(comp, 0, 255) / 16) + 1
|
||||
--debugInfo("Comp = " .. tostring(comp))
|
||||
return ComponentToLetter[comp]
|
||||
end
|
||||
return "@{" .. compToLetter(r) .. compToLetter(g) .. compToLetter(b) .. compToLetter(a) .. "}"
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
-- Display a string, splitting it when too long
|
||||
function dumpSplittedString(str)
|
||||
local splitSize = 50
|
||||
local numParts = math.floor(string.len(str) / splitSize) + 1
|
||||
for i = 0, numParts do
|
||||
debugInfo(string.sub(str, i * splitSize, i * splitSize + splitSize - 1))
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
-- display debug info with warning color
|
||||
function debugWarning(msg)
|
||||
debugInfo(warningTag .. msg)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
-- dump content of a lua object
|
||||
function luaObject(obj, maxDepth)
|
||||
dumpCallStack(0)
|
||||
if runCommand == nil
|
||||
then
|
||||
r2.print(obj)
|
||||
else
|
||||
__tmpInstance = obj
|
||||
runCommand("luaObject", "__tmpInstance", select(maxDepth, maxDepth, 10))
|
||||
__tmpInstance = nil
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
-- dump content of a lua object (other version)
|
||||
-- output : object with a "write" function that display the result. if nil, 'output' default to the global 'io'
|
||||
|
||||
function writeTable(t, output)
|
||||
if output == nil then output = io end
|
||||
function writeSpace(n)
|
||||
for i = 1, n do
|
||||
output.write("\t")
|
||||
end
|
||||
end
|
||||
|
||||
function writeTableR(t, n)
|
||||
if (type(t) == "table")
|
||||
then
|
||||
|
||||
output.write("{\n")
|
||||
for key, value in pairs(t) do
|
||||
if ( type(value) == "table")
|
||||
then
|
||||
writeSpace(n+1)
|
||||
output.write (key)
|
||||
output.write ("=")
|
||||
writeTableR(value, n+1)
|
||||
|
||||
elseif (type(value) == "string")
|
||||
then
|
||||
value = "\"" ..value .. "\""
|
||||
writeSpace(n+1)
|
||||
output.write(key, "=", value,", \n")
|
||||
elseif (type(value) == "number")
|
||||
then
|
||||
writeSpace(n+1)
|
||||
output.write(key, "=", value,", \n")
|
||||
end
|
||||
end
|
||||
writeSpace(n)
|
||||
output.write("},\n");
|
||||
end
|
||||
end
|
||||
|
||||
writeTableR(t, 0)
|
||||
end
|
||||
|
||||
|
||||
--function loadTable(fileName)
|
||||
|
||||
-- local file = io.open(fileName, "r")
|
||||
|
||||
-- function loadTableR(file)
|
||||
|
||||
-- local line
|
||||
-- while (line=file:read("*l")) ~= "}" then
|
||||
|
||||
-- if line == "{" then
|
||||
-- loadTableR(file)
|
||||
-- else
|
||||
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- if file:read("*l") ~= "{" then
|
||||
-- debugInfo("file doesn't store a valid table")
|
||||
-- return
|
||||
-- end
|
||||
|
||||
-- local resultT = loadTableR(file)
|
||||
-- io.close(file)
|
||||
-- return resultT
|
||||
--end
|
||||
|
||||
|
||||
-------------
|
||||
-- STATICS --
|
||||
-------------
|
||||
|
||||
|
||||
ComponentToLetter = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }
|
||||
warningTag = colorTag(255, 127, 0)
|
||||
|
||||
----------
|
||||
-- INIT --
|
||||
----------
|
||||
|
||||
|
||||
-- for vianney's tests : if debugInfo function wasn't registered externally, then use the standard 'print' instead
|
||||
if debugInfo == nil then
|
||||
debugInfo = r2.print
|
||||
else
|
||||
function print(a0, a1, a2, a3, a4, a5)
|
||||
local result = ""
|
||||
if a0 ~= nil then result = result .. tostring(a0) end
|
||||
if a1 ~= nil then result = result .. " " ..tostring(a1) end
|
||||
if a2 ~= nil then result = result .. " " ..tostring(a2) end
|
||||
if a3 ~= nil then result = result .. " " ..tostring(a3) end
|
||||
if a4 ~= nil then result = result .. " " ..tostring(a4) end
|
||||
if a5 ~= nil then result = result .. " " ..tostring(a5) end
|
||||
if result ~= nil then debugInfo(result) end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function gotoFile(name, line)
|
||||
local path = fileLookup(name)
|
||||
if path ~= "" then
|
||||
local luaEditorPath = os.getenv("R2ED_LUA_EDITOR_PATH")
|
||||
if luaEditorPath == nil then
|
||||
debugInfo([[ Can't launch editor to edit lua file, please set ]] ..
|
||||
[[ the environment variable R2ED_LUA_EDITOR_PATH ]] ..
|
||||
[[ with the path of your editor. ]])
|
||||
|
||||
else
|
||||
launchProgram(luaEditorPath, path .. "/" .. tostring(line))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,89 +0,0 @@
|
||||
|
||||
r2.doFile("r2_refid.lua")
|
||||
|
||||
if r2.InClient == true then
|
||||
r2.doFile("r2_ui_reset.lua")
|
||||
end
|
||||
|
||||
r2.doFile("r2_config.lua")
|
||||
r2.doFile("r2_debug.lua")
|
||||
--
|
||||
r2.doFile("r2_misc.lua")
|
||||
r2.doFile("r2_console.lua")
|
||||
--
|
||||
r2.doFile("r2_environment.lua") -- main tables & general editor functions
|
||||
--
|
||||
r2.doFile("r2_prim_render.lua")
|
||||
r2.doFile("r2_components.lua")
|
||||
|
||||
|
||||
if defaulting(config.R2EDLightPalette, 0) ~= 0 then
|
||||
r2.doFile("r2_palette_light.lua")
|
||||
else
|
||||
r2.doFile("r2_palette.lua")
|
||||
end
|
||||
|
||||
r2.doFile("r2_translator.lua")
|
||||
r2.doFile("r2_utils.lua")
|
||||
r2.doFile("r2_features.lua")
|
||||
r2.doFile("r2_base_class.lua")
|
||||
r2.doFile("r2_world_object.lua")
|
||||
r2.doFile("r2_logic_entities.lua")
|
||||
r2.doFile("r2_version.lua")
|
||||
r2.doFile("r2_init.lua")
|
||||
r2.doFile("r2_plot_item.lua")
|
||||
|
||||
if r2.InClient == true then
|
||||
-- edit time
|
||||
r2.doFile("r2_ui.lua")
|
||||
r2.doFile("r2_ui_forms.lua")
|
||||
r2.doFile("r2_ui_misc.lua")
|
||||
r2.doFile("r2_ui_tools.lua")
|
||||
r2.doFile("r2_ui_palette.lua")
|
||||
|
||||
r2.doFile("r2_ui_features_tree.lua")
|
||||
|
||||
r2.doFile("r2_ui_displayers.lua")
|
||||
r2.doFile("r2_ui_property_sheet.lua")
|
||||
r2.doFile("r2_ui_windows.lua")
|
||||
r2.doFile("r2_ui_event_handlers.lua")
|
||||
r2.doFile("r2_ui_lua_inspector.lua")
|
||||
r2.doFile("r2_ui_displayer_npc.lua")
|
||||
r2.doFile("r2_activities.lua")
|
||||
r2.doFile("r2_mini_activities.lua")
|
||||
r2.doFile("r2_dialogs.lua")
|
||||
r2.doFile("r2_events.lua")
|
||||
r2.doFile("r2_logic_comp.lua")
|
||||
r2.doFile("r2_logic_ui.lua")
|
||||
r2.doFile("r2_ui_acts.lua")
|
||||
r2.doFile("r2_ui_custom_selection_bbox.lua")
|
||||
r2.doFile("r2_ui_scenario.lua")
|
||||
r2.doFile("r2_ui_main_loop.lua")
|
||||
r2.doFile("r2_ui_toolbar_base.lua")
|
||||
r2.doFile("r2_ui_select_bar_2.lua")
|
||||
r2.doFile("r2_ui_mini_toolbar.lua")
|
||||
-- animation time
|
||||
r2.doFile("r2_ui_dm_gift.lua")
|
||||
r2.doFile("r2_ui_anim_bar.lua")
|
||||
r2.doFile("r2_ui_anim_acts.lua")
|
||||
r2.doFile("r2_ui_anim_user_triggers.lua")
|
||||
--r2.doFile("r2_ui_contextual_commands.lua")
|
||||
r2.doFile("r2_ui_contextual_commands_new.lua")
|
||||
r2.CustomBBox:load() -- custom bbox for ojbect selection
|
||||
end
|
||||
|
||||
|
||||
|
||||
profileFunction(r2.init, "r2.init")
|
||||
|
||||
|
||||
if r2.InClient == true then
|
||||
|
||||
profileMethod(r2, "initUI", "r2:initUI")
|
||||
profileMethod(r2, "initNpcEditor", "r2:initNpcEditor")
|
||||
profileMethod(r2.logicComponents, "initLogicEditors", "r2.logicComponents:initLogicEditors")
|
||||
profileMethod(r2.acts, "initActsEditor", "r2.acts:initActsEditor")
|
||||
profileMethod(r2.ScenarioWindow, "initScenarioWindow", "r2.ScenarioWindow:initScenarioWindow")
|
||||
end
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,170 +0,0 @@
|
||||
-- debugging aid
|
||||
|
||||
---------------
|
||||
-- FUNCTIONS --
|
||||
---------------
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- function tracing asked in config file ?
|
||||
-- if traceFunctions == true then
|
||||
-- local function traceFunction(what)
|
||||
-- debug.sethook()
|
||||
-- local di = debug.getinfo(2)
|
||||
-- --luaObject(di)
|
||||
-- if di.name ~= nil and di.name ~= 'getmetatable' then
|
||||
-- debugInfo(what .. " : " .. tostring(di.name) .. " : " .. tostring(di.short_src) .. " : " .. tostring(di.currentline))
|
||||
-- end
|
||||
-- debug.sethook(traceFunction, "cr")
|
||||
-- end
|
||||
-- debugInfo("turning debug hook on")
|
||||
-- debug.sethook(traceFunction, "c")
|
||||
--else
|
||||
-- --debugInfo("turning debug hook off")
|
||||
-- debug.sethook()
|
||||
--end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- dump objects cycles for the given object
|
||||
function dumpCycles(base, visitedSet, infos)
|
||||
local function fullName(infos)
|
||||
local result = ""
|
||||
while infos do
|
||||
result = infos.Name .. "." .. result
|
||||
infos = infos.Parent
|
||||
end
|
||||
return result
|
||||
end
|
||||
if visitedSet == nil then
|
||||
visitedSet = {}
|
||||
end
|
||||
if infos == nil then
|
||||
infos = { Name = "root", Parent = nil }
|
||||
end
|
||||
for k, v in pairs(base) do
|
||||
if v ~= _G._G then
|
||||
if type(v) == "table" then
|
||||
local newInfos = { Name = tostring(k), Parent = infos }
|
||||
if visitedSet[v] then
|
||||
debugInfo(fullName(visitedSet[v]) .. "is referenced by " .. fullName(newInfos))
|
||||
else
|
||||
visitedSet[v] = newInfos -- mark as visited
|
||||
dumpCycles(v, visitedSet, newInfos)
|
||||
visitedSet[v] = nil -- only intersted in cycles
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- display time taken to execute a function
|
||||
function profileFunction(func, name)
|
||||
assert(type(func) == "function")
|
||||
if name == nil then
|
||||
name = debug.getinfo(func).name
|
||||
end
|
||||
local startTime = nltime.getPreciseLocalTime()
|
||||
func()
|
||||
local endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for %s is %d", tostring(name), endTime - startTime))
|
||||
end
|
||||
|
||||
-- display time taken to execute a function
|
||||
function profileMethod(table, funcName, name)
|
||||
assert(table)
|
||||
assert(type(funcName) == "string")
|
||||
assert(type(table[funcName]) == "function")
|
||||
if name == nil then
|
||||
name = select(debug.getinfo(table[funcName]).name, funcName)
|
||||
end
|
||||
local startTime = nltime.getLocalTime()
|
||||
table[funcName](table)
|
||||
local endTime = nltime.getLocalTime()
|
||||
debugInfo(string.format("time for %s is %f", tostring(name), (endTime - startTime) / 1000))
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- add a break that is triggered when a value in a table has been changed
|
||||
function addBreakOnChange(table, watchedKey)
|
||||
assert(type(table) == "table")
|
||||
local value = table[watchedKey]
|
||||
assert(value ~= nil)
|
||||
table[watchedKey] = nil
|
||||
debugInfo("Adding break on change of key " .. tostring(watchedKey))
|
||||
local mt = getmetatable(table)
|
||||
local oldNewIndex
|
||||
if mt then
|
||||
oldNewIndex = mt.__newindex
|
||||
end
|
||||
local newMT
|
||||
if mt then newMT = clone(mt) else newMT = {} end
|
||||
-- WRITE
|
||||
newMT.__newindex = function(table, key, newValue)
|
||||
debugInfo('write')
|
||||
if key == watchedKey then
|
||||
value = newValue
|
||||
debugInfo(debug.traceback())
|
||||
debugWarning("<addBreakOnChange> Key " .. tostring(watchedKey) .. " changed to " .. tostring(value))
|
||||
assert(nil)
|
||||
elseif mt and mt.__newindex then
|
||||
mt.__newindex(table, key, newValue)
|
||||
else
|
||||
rawset(table, key, newValue)
|
||||
end
|
||||
end
|
||||
-- READ
|
||||
newMT.__index = function(table, key)
|
||||
debugInfo('read')
|
||||
if key == watchedKey then
|
||||
return value
|
||||
elseif mt and mt.__index then
|
||||
return mt.__index(table, key, value)
|
||||
else
|
||||
return rawget(table, key)
|
||||
end
|
||||
end
|
||||
--
|
||||
setmetatable(table, newMT)
|
||||
end
|
||||
|
||||
----------
|
||||
-- INIT --
|
||||
----------
|
||||
|
||||
|
||||
-- replace the assert function with a more verbose one
|
||||
if oldAssert == nil then
|
||||
oldAssert = assert
|
||||
end
|
||||
|
||||
function assert(cond)
|
||||
if not cond then
|
||||
-- rawDebugInfo(colorTag(255, 0, 255) .. "ASSERTION FAILED !! ")
|
||||
rawDebugInfo("@{FOFF}ASSERTION FAILED !! ")
|
||||
dumpCallStack(2);
|
||||
error("")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local gcStartTime
|
||||
|
||||
-- special nico stuff : modified lua version calls "__notify_debug" when a garbage collection cycle occurs
|
||||
function __notify_gc()
|
||||
gcStartTime = nltime.getLocalTime()
|
||||
end
|
||||
function __notify_post_gc()
|
||||
local deltaTime = nltime.getLocalTime() - gcStartTime
|
||||
local used, threshold = gcinfo()
|
||||
debugInfo(colorTag(255, 0, 0) .. string.format("** GC ** (%d ms) (used = %d kb, threshold = %d kb", deltaTime, used, threshold))
|
||||
end
|
||||
|
||||
|
||||
--testTable = { tata = 1, toto = 2 }
|
||||
|
||||
--addBreakOnChange(testTable, "tata")
|
||||
|
||||
--testTable.tutu = 2
|
||||
--testTable.tata = testTable.tata + 20
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,203 +0,0 @@
|
||||
-- main tables of environement & general editor functions
|
||||
|
||||
---------------
|
||||
-- FUNCTIONS --
|
||||
---------------
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- Helper : eval a property in an instance of a class :
|
||||
-- if the property is a value, then that value is returned
|
||||
-- if the property is a function, then the 'this' parameter is passed to the function and the result is returned
|
||||
-- if the property is nil, then the defualt value is returned
|
||||
function r2:evalProp(prop, this, defaultValue)
|
||||
if type(prop) == "function" then return prop(this) -- could have been this:prop(), too...
|
||||
elseif prop ~= nil then return prop
|
||||
else return defaultValue
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------
|
||||
-- get translation id for a property, followed by a boolean (false if not found)
|
||||
function r2:getPropertyTranslationId(prop)
|
||||
local translationId
|
||||
local found = true
|
||||
if prop.Translation ~= nil then
|
||||
translationId = prop.Translation
|
||||
elseif i18n.hasTranslation('uiR2EDProp_' .. prop.Name) then
|
||||
translationId = 'uiR2EDProp_' .. prop.Name
|
||||
elseif i18n.hasTranslation('uiR2ED' .. prop.Name) then
|
||||
translationId = 'uiR2ED' .. prop.Name
|
||||
else
|
||||
translationId = prop.Name
|
||||
found = false
|
||||
end
|
||||
return translationId, found
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------
|
||||
-- get translation id for a property, as an ucstring
|
||||
function r2:getPropertyTranslation(prop)
|
||||
local translationId = r2:getPropertyTranslationId(prop)
|
||||
if (i18n.hasTranslation(translationId)) then
|
||||
return i18n.get(translationId)
|
||||
else
|
||||
return ucstring(translationId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- return the left quota for the current scenario (called by C++)
|
||||
function r2:getLeftQuota()
|
||||
return r2.ScenarioWindow:getLeftQuota()
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- retrieve class description of an instance (in the r2.Classes table)
|
||||
function r2:getClass(instance)
|
||||
if instance == nil or instance.isNil then
|
||||
debugInfo("Calling r2:getClass on nil instance")
|
||||
debugInfo(debug.traceback())
|
||||
return
|
||||
end
|
||||
if instance.Class == nil then
|
||||
debugInfo("Calling r2:getClass on class with no 'Class' field")
|
||||
debugInfo(debug.traceback())
|
||||
return
|
||||
end
|
||||
return r2.Classes[instance.Class]
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- get parent instance of an object in the editor (that is an object with an InstanceId)
|
||||
function r2:getParentInstance(object)
|
||||
debugInfo(debug.traceback())
|
||||
assert(nil) -- deprecated : use special member 'ParentInstance' instead
|
||||
--if object == nil then return nil end
|
||||
--local parent = object.Parent
|
||||
--while parent ~= nil do
|
||||
-- if parent.InstanceId ~= nil then
|
||||
-- return parent
|
||||
-- end
|
||||
-- parent = parent.Parent
|
||||
--end
|
||||
--return nil
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- get max number of acts in a scenario
|
||||
function r2:getMaxNumberOfAdditionnalActs()
|
||||
return getDefine("r2ed_max_num_additionnal_acts")
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- Explore a tree of instance, each instance that has a sheet id is append to the list
|
||||
function r2:exploreInstanceTree(obj, destTable)
|
||||
if obj.InstanceId ~= nil then
|
||||
table.insert(destTable, obj)
|
||||
end
|
||||
for k, v in specPairs(obj) do
|
||||
if type(v) == "userdata" and v.Size ~= nil then
|
||||
-- this is a sub array
|
||||
r2:exploreInstanceTree(v, destTable)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- test from a sheet id if an object is a bot object
|
||||
function r2:isBotObject(sheetClient)
|
||||
return getCharacterSheetSkel(sheetClient, false) == ""
|
||||
or string.match(sheetClient, "object_[%w_]*%.creature") -- patch for bot objects (with skeletons -> wind turbine)
|
||||
end
|
||||
|
||||
-- helper function for pasting : relocate the 'Position' field of 'dest' for proper pasting
|
||||
function r2:relocatePos(dest)
|
||||
local x, y, z = r2:findEmptyPlace(dest.Position.x, dest.Position.y)
|
||||
if x ~= nil then
|
||||
dest.Position.x = x
|
||||
dest.Position.y = y
|
||||
dest.Position.z = z
|
||||
end
|
||||
end
|
||||
|
||||
-- Get a new position were to paste an object
|
||||
function r2:getPastePosition()
|
||||
local x, y, z = r2:getUserEntityPosition()
|
||||
local fx, fy = r2:getUserEntityFront()
|
||||
x = x + fx * 4
|
||||
y = y + fy * 4
|
||||
x = x + 3 * math.random(-100, 100) / 100
|
||||
y = y + 3 * math.random(-100, 100) / 100
|
||||
local nx, ny = r2:findEmptyPlace(x, y)
|
||||
if nx ~= nil then
|
||||
return nx, ny, z
|
||||
else
|
||||
return r2:getUserEntityPosition() -- no empty place found, paste on user
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
--------------------
|
||||
-- INIT / GLOBALS --
|
||||
--------------------
|
||||
|
||||
--debugInfo("Initializing main tables")
|
||||
if r2 == nil then
|
||||
r2 = {} -- for vianney's tests (is initialized by the caller otherwise)
|
||||
end
|
||||
|
||||
------------------
|
||||
-- MISC GLOBALS --
|
||||
------------------
|
||||
|
||||
r2.ScratchUCStr = ucstring() -- scratch ucstring, useful to do call from utf8 without to create a new object
|
||||
|
||||
---------------------
|
||||
-- EDITION GLOBALS --
|
||||
---------------------
|
||||
|
||||
r2.maxId = {}
|
||||
|
||||
-- define in r2_features.lua
|
||||
r2.Features={}
|
||||
|
||||
-- define in r2_basic_bricks.lua
|
||||
r2.BasicBricks = {}
|
||||
|
||||
-- define in r2_palette.lua
|
||||
r2.Palette = {}
|
||||
|
||||
-- definition of all R2 classes (contains both basic components and components of features)
|
||||
r2.Classes = {}
|
||||
|
||||
-- current content of the clipboard after the selection has been copied
|
||||
r2.ClipBoard = nil
|
||||
r2.ClipBoardSrcInstanceId = nil
|
||||
r2.ClipBoardDisplayName = nil
|
||||
|
||||
|
||||
-----------------------
|
||||
-- ANIMATION GLOBALS --
|
||||
-----------------------
|
||||
|
||||
-- contains var related to animation
|
||||
r2.AnimGlobals =
|
||||
{
|
||||
Acts = nil, -- set to nil until received by server, contains
|
||||
-- the list of acts accessible at runtime by the animator
|
||||
UserTriggers = nil, -- set to nil until received by server, contains
|
||||
-- the list of triggers that an animator can fire at runtime
|
||||
|
||||
-------------------------------------------------------------------------------------
|
||||
reset = function(this)
|
||||
this.Acts = nil
|
||||
this.UserTriggers = nil
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,142 +0,0 @@
|
||||
-- obsolete ?
|
||||
local registerFeature = function()
|
||||
local feature={}
|
||||
feature.Name = "EventHandler"
|
||||
|
||||
feature.Components =
|
||||
{
|
||||
{
|
||||
Name = "EventHandlerEntry",
|
||||
Prop=
|
||||
{
|
||||
{Name="InstanceId", Type="String"},
|
||||
{Name="Who", Type="String"},
|
||||
{Name="States", Type="String"},
|
||||
{Name="Event", Type="String"},
|
||||
{Name="Actions", Type="String"}
|
||||
}
|
||||
},
|
||||
{
|
||||
Name = "EventHandler",
|
||||
Prop=
|
||||
{
|
||||
{Name="InstanceId",Type="String"},
|
||||
{Name="Name",Type="String", MaxNumChar="32"},
|
||||
{Name="Entries", Type="Table"}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
feature.createEvent = function(event,who,states)
|
||||
event = r2.split(event)
|
||||
--debugInfo("event: "..event[1])
|
||||
local toRet = Actions.createEvent(event[1],states)
|
||||
assert(toRet)
|
||||
toRet.GroupsByName=who
|
||||
return toRet
|
||||
end
|
||||
|
||||
feature.createAction = function(action)
|
||||
if type (action) == "table"
|
||||
then
|
||||
local multi_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
multi_action.Name = "multi_actions"
|
||||
multi_action.Action="multi_actions"
|
||||
local k,v = next(action, nil)
|
||||
while k ~= nil
|
||||
do if (k ~= "Keys")
|
||||
then
|
||||
local actionTxt = r2.split(v, "#")
|
||||
local tmpAction = Actions.createAction(actionTxt[1], actionTxt[2])
|
||||
table.insert(multi_action.Children, tmpAction)
|
||||
end
|
||||
k,v = next(action, k)
|
||||
end
|
||||
return multi_action
|
||||
end
|
||||
|
||||
if action=="multi_action1"
|
||||
then
|
||||
local multi_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
multi_action.Name = "multi_actions"
|
||||
multi_action.Action="multi_actions"
|
||||
|
||||
local action
|
||||
|
||||
action = Actions.createAction("set_timer_t0",100)
|
||||
action.Name="set end of day timer"
|
||||
table.insert(multi_action.Children,action)
|
||||
|
||||
action = Actions.createAction("stand_up")
|
||||
action.Name="stand up"
|
||||
table.insert(multi_action.Children,action)
|
||||
return multi_action
|
||||
end
|
||||
|
||||
if action=="multi_action2"
|
||||
then
|
||||
local multi_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
multi_action.Name = "multi_actions"
|
||||
multi_action.Action="multi_actions"
|
||||
|
||||
local action=Actions.createAction("set_timer_t0",100)
|
||||
action.Name="set end of night timer"
|
||||
table.insert(multi_action.Children,action)
|
||||
|
||||
action = Actions.createAction("sit_down")
|
||||
action.Name="sit down"
|
||||
table.insert(multi_action.Children,action)
|
||||
return multi_action
|
||||
end
|
||||
action = r2.split(action, "#")
|
||||
toRet = Actions.createAction(action[1],action[2])
|
||||
return toRet
|
||||
end
|
||||
|
||||
|
||||
|
||||
feature.Translator = function(context)
|
||||
local eventHandler = context.Feature
|
||||
local max = table.getn(eventHandler.Entries)
|
||||
for i=1, max do
|
||||
context.Feature = eventHandler.Entries[i]
|
||||
feature.EntryTranslator(context)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature.EntryTranslator = function(context)
|
||||
local entry = context.Feature
|
||||
local states
|
||||
local eventType
|
||||
local who = context.Components[entry.Who].InstanceId
|
||||
--debugInfo("Who: "..who)
|
||||
if entry.States == "ALL"
|
||||
then
|
||||
states = ""
|
||||
else
|
||||
states = entry.States
|
||||
end
|
||||
--debugInfo("States: "..states)
|
||||
if entry.Event == "INIT"
|
||||
then
|
||||
--add the actions in the group's initial state,
|
||||
--in the event "start of state"
|
||||
else
|
||||
eventType = entry.Event
|
||||
end
|
||||
|
||||
local event = feature.createEvent(eventType,who,states)
|
||||
table.insert(context.RtAct.Events,event)
|
||||
|
||||
local action = feature.createAction(entry.Actions)
|
||||
assert(action)
|
||||
table.insert(context.RtAct.Actions,action)
|
||||
table.insert(event.ActionsId,action.Id)
|
||||
end
|
||||
return feature
|
||||
end
|
||||
|
||||
r2.Features["EventHandler"] = registerFeature()
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,470 +0,0 @@
|
||||
|
||||
r2.Features.Ambush = {}
|
||||
|
||||
local feature = r2.Features.Ambush
|
||||
|
||||
feature.Name="Ambush"
|
||||
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
local classAmbushVersion = 1
|
||||
|
||||
feature.Components.Ambush =
|
||||
{
|
||||
--PropertySheetHeader = r2.getDisplayButtonHeader("r2.events:openEditor()", "uiR2EdEditEventsButton"),
|
||||
BaseClass="LogicEntity",
|
||||
Name="Ambush",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
Version=classAmbushVersion ,
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "ambushDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
ApplicableActions = {"activate", "deactivate", "trigger"},
|
||||
Events = {"activation", "deactivation", "trigger"},
|
||||
Conditions = {"is active", "is inactive"},
|
||||
TextContexts = {},
|
||||
TextParameters = {},
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="MobNumber", Type="Number", Category="uiR2EDRollout_Mobs", WidgetStyle="EnumDropDown", Enum={"1", "2", "3", "4", "5"},
|
||||
},
|
||||
{Name="Mob1Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Mob2Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Mob3Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Mob4Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Visible= function(this) return this:displayRefId(4) end},
|
||||
{Name="Mob5Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Visible= function(this) return this:displayRefId(5) end},
|
||||
{Name="TriggerOn", Type="Number", WidgetStyle="EnumDropDown",
|
||||
Enum={"Leaves the zone", "Enters the zone"},
|
||||
},
|
||||
{Name="Components", Type="Table"},
|
||||
|
||||
},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end,
|
||||
|
||||
updateVersion = function(this, scenarioValue, currentValue )
|
||||
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
local component = feature.Components.Ambush
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbMobs = self.MobNumber + 1
|
||||
if index <= nbMobs then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
local ambushDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
--
|
||||
-- If the message is received by a client that didn't request the modification, we must make sure this client
|
||||
-- doesn't modify the data because it has already been performed by the initial client.
|
||||
--
|
||||
local function checkPickedEntity(this, instanceId, attributeName)
|
||||
if instanceId == "" then
|
||||
return false
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
assert(tmpInstance)
|
||||
local i = 1
|
||||
while i < 6 do
|
||||
local attrName = "Mob" ..i.. "Id"
|
||||
if attrName ~= attributeName and this[attrName] == tmpInstance.InstanceId then
|
||||
return false
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
function ambushDisplayerTable:onAttrModified(instance, attributeName)
|
||||
|
||||
if attributeName == "MobNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbMobs = instance.MobNumber + 1
|
||||
local i = 1
|
||||
while i <= 5 do
|
||||
if i > nbMobs then
|
||||
local name = "Mob"..tostring(i).."Id"
|
||||
local refId = propertySheet:find(name)
|
||||
local refIdName = refId:find("name")
|
||||
refIdName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, name, "")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
if string.find(attributeName, "Id") == nil or attributeName == "InstanceId" then return end
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local refId = propertySheet:find(attributeName)
|
||||
if refId == nil then return end
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
refIdName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
local inserted = checkPickedEntity(instance, instanceId, attributeName)
|
||||
if inserted == true then
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
refIdName.hardtext = tmpInstance.Name
|
||||
else
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, "")
|
||||
end
|
||||
instance.User.onHrcMove = false
|
||||
end
|
||||
|
||||
function ambushDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function reattributeIdOnHrcMove(ambush, group, targetAttr)
|
||||
local propertySheet = r2:getPropertySheet(ambush)
|
||||
local refId = propertySheet:find(targetAttr)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
r2.requestSetNode(ambush.InstanceId, targetAttr, group.InstanceId)
|
||||
refIdName.hardtext = group.Name
|
||||
ambush.User.onHrcMove = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
local group = tmpInstance.ParentInstance
|
||||
if group:isKindOf("NpcGrpFeature") then
|
||||
reattributeIdOnHrcMove(self, group, targetAttr)
|
||||
end
|
||||
tmpInstance.User.SelfModified = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function r2:ambushDisplayer()
|
||||
return ambushDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if (action.Action.Type == "trigger") then
|
||||
local i = 1
|
||||
local spawnActions = {}
|
||||
while i <= 5 do
|
||||
local attrName = "Mob"..i.."Id"
|
||||
if component[attrName] ~= "" then
|
||||
local rtMobGrp = r2.Translator.getRtGroup(context, component[attrName])
|
||||
local actionSpawn = r2.Translator.createAction("spawn", rtMobGrp.Id)
|
||||
table.insert(spawnActions, actionSpawn)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
if table.getn(spawnActions) ~= 0 then
|
||||
local actionTrigger = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6)
|
||||
table.insert(spawnActions, actionTrigger)
|
||||
local retAction = r2.Translator.createAction("condition_if", r2:getNamespace()..rtNpcGrp.Id..".Active == 1",
|
||||
r2.Translator.createAction("multi_actions", spawnActions)
|
||||
)
|
||||
return retAction, retAction
|
||||
end
|
||||
return nil, nil
|
||||
end
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if tostring(event.Event.Type) == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createGhostComponents= function(this, act)
|
||||
|
||||
local comp = this
|
||||
local nbMob = 0
|
||||
|
||||
for id = 1, 5 do
|
||||
local propertyName = "Mob"..id.."Id"
|
||||
if comp[propertyName] ~= nil and comp[propertyName] ~= "" then
|
||||
local mob = r2:getInstanceFromId(comp[propertyName])
|
||||
if mob then
|
||||
nbMob = nbMob + 1
|
||||
if mob:isKindOf("NpcGrpFeature") then
|
||||
local instanceId = mob.Components[0].InstanceId
|
||||
r2.requestSetGhostNode(instanceId, "AutoSpawn", 0)
|
||||
else
|
||||
r2.requestSetGhostNode(mob.InstanceId, "AutoSpawn", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nbMob == 0 then
|
||||
return
|
||||
end
|
||||
local zoneTrigger = r2:getInstanceFromId(comp._ZoneId)
|
||||
assert(zoneTrigger)
|
||||
|
||||
do
|
||||
local type = "On Player Left"
|
||||
if comp.TriggerOn == 1 then
|
||||
type = "On Player Arrived"
|
||||
end
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = type
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = type
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(comp.InstanceId)
|
||||
action.Action.Type = "trigger"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = zoneTrigger.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
|
||||
end
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "activation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "activation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(zoneTrigger.InstanceId)
|
||||
action.Action.Type = "activate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = this.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "deactivation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "deactivation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(zoneTrigger.InstanceId)
|
||||
action.Action.Type = "deactivate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = this.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("Ambush")
|
||||
assert(comp)
|
||||
assert(comp.Position)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdAmbush")):toUtf8()
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
local zoneTrigger = r2.Features["ZoneTrigger"].Components.ZoneTrigger.createComponent(x + 3, y + 3)
|
||||
zoneTrigger.Name = comp.Name.." "..i18n.get("uiR2EDZoneTrigger"):toUtf8()--r2:genInstanceName(i18n.get("uiR2EdZoneTrigger")):toUtf8()
|
||||
zoneTrigger.InheritPos = 0
|
||||
zoneTrigger.Deletable = false
|
||||
table.insert(comp.Components, zoneTrigger)
|
||||
comp._ZoneId = zoneTrigger.InstanceId
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function posOk(x, y, z)
|
||||
debugInfo("Validate creation of an Ambush.")
|
||||
if r2.mustDisplayInfo("Ambush") == 1 then
|
||||
r2.displayFeatureHelp("Ambush")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewAmbushFeatureAction"))
|
||||
local component = feature.Components.Ambush.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function posCancel() end
|
||||
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureAmbush")
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
--- register the curent Feature to menu
|
||||
|
||||
function component:getLogicTranslations()
|
||||
-- register trad
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2AA0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()}
|
||||
}
|
||||
}
|
||||
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["Ambush"] = feature
|
||||
|
||||
|
@ -1,900 +0,0 @@
|
||||
|
||||
r2.Features.BanditCampFeature = {}
|
||||
|
||||
local feature = r2.Features.BanditCampFeature
|
||||
|
||||
feature.Name = "BanditCampFeature"
|
||||
|
||||
feature.BanditCount = 0
|
||||
|
||||
feature.Description = "A bandits camp feature"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
local BanditZoneRadius = 5
|
||||
local BanditZoneNumCorners = 6
|
||||
|
||||
local BanditCampVersion = 2
|
||||
feature.Components.BanditCamp =
|
||||
{
|
||||
BaseClass = "LogicEntity",
|
||||
Name = "BanditCamp",
|
||||
InEventUI = true,
|
||||
Menu = "ui:interface:r2ed_feature_menu",
|
||||
Version = BanditCampVersion,
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {
|
||||
},
|
||||
ApplicableActions = {
|
||||
"activate",
|
||||
"deactivate", "Wander", "Sit Down",
|
||||
"Kill"
|
||||
},
|
||||
Events = {
|
||||
"activation",
|
||||
"deactivation",
|
||||
"member death", "group death",
|
||||
"head to wander zone", "arrive at wander zone", "head to camp",
|
||||
"arrive at camp"
|
||||
},
|
||||
Conditions = {
|
||||
"is active", "is inactive",--"is dead",
|
||||
"is wandering", "is sitting",
|
||||
"is heading to wander zone", "is heading to camp"
|
||||
},
|
||||
TextContexts = {
|
||||
},
|
||||
TextParameters = {
|
||||
"max bandits number", "still alive bandits number"
|
||||
},
|
||||
LiveParameters = {
|
||||
"is active", "alive bandits number",
|
||||
"max bandits number", state = {"sitting", "heading to wander", "wandering or heading home"}
|
||||
},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--Category = "uiR2EDRollout_BanditsCamp",
|
||||
Prop =
|
||||
{
|
||||
{Name = "InstanceId", Type = "String", WidgetStyle = "StaticText", Visible = false},
|
||||
{Name = "Components", Type = "Table"},
|
||||
{Name = "Name", Type="String", MaxNumChar="32"},
|
||||
{Name = "BanditsCount", Type = "String", WidgetStyle = "StaticText"},
|
||||
{Name = "Race", Type = "String", WidgetStyle = "StaticText"},
|
||||
{Name = "BanditsLevel", Type = "String", WidgetStyle = "StaticText"},
|
||||
--{Name = "Cycle", Type = "Number", Min = "10", Max = "999999", DefaultValue = "30"},
|
||||
{Name = "SitDuration", Type = "Number", Min = "10", Max = "999999", DefaultValue = "20"},
|
||||
{Name = "WanderDuration", Type = "Number", Min = "10", Max = "999999", DefaultValue = "20"},
|
||||
--{Name = "Behavior", Type = "Table"},
|
||||
{Name = "Cost", Type = "Number", Visible = false },
|
||||
{Name = "Ghosts", Type = "Table", Visible = false },
|
||||
{Name = "Active", Type = "Number", WidgetStyle="Boolean", DefaultValue="1" },
|
||||
{Name = "NoRespawn", Type ="Number", WidgetStyle = "Boolean", DefaultValue="0"},
|
||||
|
||||
},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
updateVersion = function(this, scenarioValue, currentValue )
|
||||
local patchValue = scenarioValue
|
||||
if patchValue < 1 then
|
||||
r2.requestEraseNode(this.InstanceId, "Cost", -1)
|
||||
patchValue = 1
|
||||
end
|
||||
if patchValue < 2 then
|
||||
local invalidEvents = {}
|
||||
invalidEvents["desactivation"] = "deactivation"
|
||||
r2.updateLogicEvents(this, invalidEvents)
|
||||
r2.requestSetNode(this.InstanceId, "BanditsLevel", "22")
|
||||
patchValue = 2
|
||||
end
|
||||
|
||||
if patchValue == currentValue then return true end
|
||||
return false
|
||||
end,
|
||||
|
||||
}
|
||||
local component = feature.Components.BanditCamp
|
||||
|
||||
|
||||
function component.onPostCreate(this)
|
||||
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
|
||||
this:setLocalCost(_BanditCount)
|
||||
local comp = this
|
||||
if comp._Seed then math.randomseed(comp._Seed) end
|
||||
do
|
||||
local x = comp.Position.x
|
||||
local y = comp.Position.y
|
||||
local n = comp._BanditsCount
|
||||
local pas = (2 * math.pi)/n
|
||||
local r = (n/(2*math.pi))+2
|
||||
for i = 1, n do
|
||||
local npc = r2:randomNPC( component.getBanditPaletteId(comp), component.Races[comp._Race + 1])
|
||||
npc.Position.x = (r-1) * math.cos((i-1)*pas) -- make position relative to the feature positio
|
||||
npc.Position.y = (r-1) * math.sin((i-1)*pas)
|
||||
npc.Position.z = 0
|
||||
npc.Angle = (i-1)*pas + math.pi
|
||||
|
||||
r2.requestInsertGhostNode(this.InstanceId, "Ghosts", -1, "", npc)
|
||||
local comp = r2:getInstanceFromId(npc.InstanceId)
|
||||
comp.Selectable = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function component.onPostHrcMove(this)
|
||||
|
||||
for i=0, this.Ghosts.Size-1 do
|
||||
local entity = this.Ghosts[i]
|
||||
entity.DisplayerVisual:updateName()
|
||||
entity:updatePermanentStatutIcon()
|
||||
end
|
||||
r2.events:updateElementsUI()
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Spawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Spawn" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Despawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Despawn" ):toUtf8()},
|
||||
["Wander"] = { menu=i18n.get( "uiR2AA0BanditWander" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1BanditWander" ):toUtf8()},
|
||||
["Sit Down"] = { menu=i18n.get( "uiR2AA0BanditSitDown" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1BanditSitDown" ):toUtf8()},
|
||||
["Kill"] = { menu=i18n.get( "uiR2AA0BanditKill" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1BanditKill" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Spawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Spawn" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Despawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Despawn" ):toUtf8()},
|
||||
["member death"] = { menu=i18n.get( "uiR2Event0MemberDeath" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MemberDeath" ):toUtf8()},
|
||||
["group death"] = { menu=i18n.get( "uiR2Event0GroupDeath" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1GroupDeath" ):toUtf8()},
|
||||
["head to wander zone"] = { menu=i18n.get( "uiR2Event0BanditHeadWander" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1BanditHeadWander" ):toUtf8()},
|
||||
["arrive at wander zone"] = { menu=i18n.get( "uiR2Event0BanditArriveWander" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1BanditArriveWander" ):toUtf8()},
|
||||
["head to camp"] = { menu=i18n.get( "uiR2Event0BanditHeadCamp" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1BanditHeadCamp" ):toUtf8()},
|
||||
["arrive at camp"] = { menu=i18n.get( "uiR2Event0BanditArriveCamp" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1BanditArriveCamp" ):toUtf8()},
|
||||
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Spawned" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Spawned" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Despawned" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Despawned" ):toUtf8()},
|
||||
["is dead"] = { menu=i18n.get( "uiR2Test0BanditDead" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1BanditDead" ):toUtf8()},
|
||||
["is wandering"] = { menu=i18n.get( "uiR2Test0BanditPatrolZone" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1BanditPatrolZone" ):toUtf8()},
|
||||
["is sitting"] = { menu=i18n.get( "uiR2Test0BanditAtCamp" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1BanditAtCamp" ):toUtf8()},
|
||||
["is heading to wander zone"]= {menu=i18n.get( "uiR2Test0BanditHeadPatrolZone" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1BanditHeadPatrolZone" ):toUtf8()},
|
||||
["is heading to camp"] = { menu=i18n.get( "uiR2Test0BanditHeadCamp" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1BanditHeadCamp" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local banditEntity = r2:getInstanceFromId(component.User._BanditGroup)
|
||||
BOMB_IF(banditEntity, "In feature '".. component.Name .. "' associated bandit camp not found.")
|
||||
local banditRtNpcGrp = r2.Translator.getRtGroup( context, banditEntity.InstanceId)
|
||||
BOMB_IF(banditEntity, "In feature '" .. component.Name .. "' associated bandit camp rtGroup not found.")
|
||||
|
||||
if action.Action.Type == "deactivate" then
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 0)
|
||||
local action2 = r2.Translator.getNpcLogicActionDeactivate(banditEntity, context, action, banditRtNpcGrp)
|
||||
local action3 = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 5)
|
||||
local multiaction = r2.Translator.createAction("multi_actions", {action1, action2, action3})
|
||||
return multiaction, multiaction
|
||||
elseif action.Action.Type == "activate" then
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 1)
|
||||
local action2 = r2.Translator.getNpcLogicActionActivate(banditEntity, context, action, banditRtNpcGrp)
|
||||
local action3 = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 4)
|
||||
local multiaction = r2.Translator.createAction("multi_actions", {action1, action2, action3})
|
||||
return multiaction, multiaction
|
||||
elseif action.Action.Type == "Kill" then
|
||||
return r2.Translator.getNpcLogicActionKill(banditEntity, context, action, banditRtNpcGrp)
|
||||
elseif action.Action.Type == "Sit Down" then
|
||||
return r2.Translator.getGenericLogicActionBeginActivitySequence(entity.User._SequenceHeadToFire, banditRtNpcGrp)
|
||||
elseif action.Action.Type == "Wander" then
|
||||
return r2.Translator.getGenericLogicActionBeginActivitySequence(entity.User._SequenceHeadToWander, banditRtNpcGrp)
|
||||
end
|
||||
|
||||
local firstAction, lastAction = nil,nil
|
||||
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local banditEntity = r2:getInstanceFromId(component.User._BanditGroup)
|
||||
BOMB_IF(banditEntity, "In feature '".. component.Name .. "' associated bandit camp not found.")
|
||||
local banditRtNpcGrp = r2.Translator.getRtGroup( context, banditEntity.InstanceId)
|
||||
BOMB_IF(banditEntity, "In feature '" .. component.Name .. "' associated bandit camp rtGroup not found.")
|
||||
|
||||
local conditionType = condition.Condition.Type
|
||||
if conditionType == "is wandering" then
|
||||
return r2.Translator.getGenericLogicConditionIsInActivitySequence(banditEntity, component.User._SequenceWander, banditRtNpcGrp)
|
||||
elseif conditionType == "is sitting" then
|
||||
return r2.Translator.getGenericLogicConditionIsInActivitySequence(banditEntity, component.User._SequenceStayNearFire, banditRtNpcGrp)
|
||||
elseif conditionType == "is heading to wander zone" then
|
||||
return r2.Translator.getGenericLogicConditionIsInActivitySequence(banditEntity, component.User._SequenceHeadToWander, banditRtNpcGrp)
|
||||
elseif conditionType == "is heading to camp" then
|
||||
return r2.Translator.getGenericLogicConditionIsInActivitySequence(banditEntity, component.User._SequenceHeadToFire, banditRtNpcGrp)
|
||||
end
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local banditEntity = r2:getInstanceFromId(component.User._BanditGroup)
|
||||
BOMB_IF(banditEntity, "In feature '".. component.Name .. "' associated bandit camp not found.")
|
||||
local banditRtNpcGrp = r2.Translator.getRtGroup( context, banditEntity.InstanceId)
|
||||
BOMB_IF(banditEntity, "In feature '" .. component.Name .. "' associated bandit camp rtGroup not found.")
|
||||
|
||||
local eventType = event.Event.Type
|
||||
if eventType == "activation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 4)
|
||||
elseif eventType == "deactivation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 5)
|
||||
elseif eventType == "member death" or eventType == "group death" then
|
||||
return r2.Translator.getNpcLogicEvent(banditEntity, context, event)
|
||||
elseif eventType == "head to wander zone" then
|
||||
return r2.Translator.getNpcLogicEventBeginOfActivityStepImpl(this.User._StepHeadToWander, banditRtNpcGrp)
|
||||
elseif eventType == "arrive at wander zone" then
|
||||
return r2.Translator.getNpcLogicEventEndOfActivityStepImpl(this.User._StepHeadToWander, banditRtNpcGrp)
|
||||
elseif eventType == "head to camp" then
|
||||
return r2.Translator.getNpcLogicEventBeginOfActivityStepImpl(this.User._StepHeadToFire, banditRtNpcGrp)
|
||||
elseif eventType == "arrive at camp" then
|
||||
return r2.Translator.getNpcLogicEventEndOfActivityStepImpl(this.User._StepHeadToFire, banditRtNpcGrp)
|
||||
end
|
||||
|
||||
local eventHandler, firsCondition, lastCondition = nil, nil, nil
|
||||
return eventHandler, firsCondition, lastCondition
|
||||
end
|
||||
|
||||
component.Races = { [1] = "Fyros", [2] = "Matis", [3] = "Tryker", [4] = "Zorai"}
|
||||
|
||||
component.RacesId = { [1] = "f", [2] = "m", [3] = "t", [4] = "z"}
|
||||
|
||||
component.LevelsId = { [1] = "20", [2] = "70", [3] = "120", [4] = "170", [5] = "220"}
|
||||
|
||||
component.RolesId = {
|
||||
[1] = "melee_dd", [2] = "melee_tank", [3] = "light_melee", [4] = "mage_damage_dealer",
|
||||
[5] = "mage_aoe", [6] = "mage_atysian_curser", [7] = "mage_celestial_curser"
|
||||
}
|
||||
|
||||
--component.createComponent = function(x, y, banditsCount, race, banditsLevel, cycle, ZoneSize)
|
||||
component.createComponent = function(x, y, banditsCount, race, banditsLevel, ZoneSize)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDCreateBanditCampAction"))
|
||||
local comp = r2.newComponent("BanditCamp")
|
||||
assert(comp)
|
||||
|
||||
-- base is the camp fire, to display the bandit camp as a camp fire
|
||||
comp.Base = "palette.entities.botobjects.campfire"
|
||||
|
||||
--feature.BanditCount = feature.BanditCount + 1
|
||||
--comp.Name = "BanditCampFeature[".. feature.BanditCount .."]"
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDNameBanditCampFeature")):toUtf8()
|
||||
|
||||
local fire = comp.Fire
|
||||
|
||||
--do
|
||||
-- fire.Base = "palette.entities.botobjects.campfire"
|
||||
-- fire.Name = "Camp Fire"
|
||||
-- local tmpPosition = fire.Position
|
||||
-- tmpPosition.x = x
|
||||
-- tmpPosition.y = y
|
||||
-- tmpPosition.z = r2:snapZToGround(x, y)
|
||||
--end
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._BanditsCount = banditsCount
|
||||
comp._Race = race
|
||||
comp._BanditsLevel = banditsLevel
|
||||
comp.BanditsCount = tostring(banditsCount)
|
||||
comp.Race = component.Races[race+1]
|
||||
comp.BanditsLevel = component.LevelsId[banditsLevel + 1]
|
||||
--comp.Cycle = cycle
|
||||
comp.WanderDuration = 20
|
||||
comp.SitDuration = 20
|
||||
comp.ZoneSize = tostring(ZoneSize)
|
||||
|
||||
local zone = r2.newComponent("Region")
|
||||
r2.Utils.createNonDeleteableRegion(zone, 0, 0, BanditZoneRadius, BanditZoneNumCorners) -- the region doesn't inherit the feature position, so must give its pos
|
||||
zone.Deletable = 0
|
||||
zone.Position.x = comp.Position.x
|
||||
zone.Position.y = comp.Position.y
|
||||
zone.Position.z = comp.Position.z
|
||||
zone.InheritPos = 0 -- don't inherit position of parents
|
||||
zone.Name = r2:genInstanceName(i18n.get("uiR2EDNameWanderRegion")):toUtf8()
|
||||
comp._Zone = zone.InstanceId
|
||||
table.insert(comp.Components, zone)
|
||||
comp._Seed = os.time()
|
||||
|
||||
-- r2.registerText("Pas faché que cette journée se termine !")
|
||||
-- r2.registerText("On rentre a la maison!")
|
||||
-- r2.registerText("Asseyez vous mes frères!")
|
||||
-- r2.registerText("Allons detrousser les honnetes gens!")
|
||||
-- r2.registerText("Allez, au boulot!")
|
||||
-- r2.registerText("A l'attaque!!")
|
||||
|
||||
return comp
|
||||
end
|
||||
-- Global function are bad
|
||||
function updateBanditCampEnum()
|
||||
local currentForm = r2.CurrentForm
|
||||
if (currentForm == nil) then
|
||||
return
|
||||
end
|
||||
|
||||
local formRace = currentForm:find("Race")
|
||||
if not formRace then
|
||||
return
|
||||
end
|
||||
local formLevel = currentForm:find("BanditsLevel")
|
||||
if not formLevel then
|
||||
return
|
||||
end
|
||||
local previousLevel = formLevel.selection
|
||||
formLevel:resetTexts()
|
||||
local k, v = next(component.LevelsId, nil)
|
||||
while k do
|
||||
local race = component.RacesId[formRace.selection + 1]
|
||||
local level = v
|
||||
local elementName = "palette.entities.npcs.bandits."..race.."_melee_dd_"..tostring(level)
|
||||
local ok = false
|
||||
if r2.isInPalette(elementName) then
|
||||
|
||||
local paletteElt = r2.getPaletteElement(elementName)
|
||||
if paletteElt and paletteElt.RingAccess and r2.RingAccess.testAccess(paletteElt.RingAccess) then
|
||||
formLevel:addText(ucstring(tostring(level)))
|
||||
ok = true
|
||||
-- local levelEnum = currentForm:find(creature.."Level")
|
||||
|
||||
end
|
||||
end
|
||||
if k == previousLevel and not ok then
|
||||
formLevel.selection = 0
|
||||
end
|
||||
k, v = next(component.LevelsId, k)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
local function initValue()
|
||||
|
||||
local toRet = {}
|
||||
|
||||
local k, v = next(component.LevelsId, nil)
|
||||
while k do
|
||||
local race = component.RacesId[0+ 1]
|
||||
local level = v
|
||||
local elementName = "palette.entities.npcs.bandits."..race.."_melee_dd_"..tostring(level)
|
||||
|
||||
if r2.isInPalette(elementName) then
|
||||
local paletteElt = r2.getPaletteElement(elementName)
|
||||
if paletteElt and paletteElt.RingAccess and r2.RingAccess.testAccess(paletteElt.RingAccess) then
|
||||
table.insert(toRet, level)
|
||||
|
||||
end
|
||||
end
|
||||
k, v = next(component.LevelsId, k)
|
||||
end
|
||||
return toRet
|
||||
end
|
||||
|
||||
|
||||
function feature.registerForms()
|
||||
r2.Forms.BanditCamp_Form =
|
||||
{
|
||||
Caption = "uiR2EDBanditCamp",
|
||||
Prop =
|
||||
{
|
||||
-- following field are tmp for property sheet building testing
|
||||
{Name = "BanditsCount", Type = "Number", Category = "uiR2EDRollout_BanditsCamp", Min = "1", Max = "12", Default = "6"},
|
||||
|
||||
{Name = "Race", Type = "Number", WidgetStyle = "EnumDropDown", Category = "uiR2EDRollout_BanditsCamp",
|
||||
Enum = component.Races,
|
||||
onChange = updateBanditCampEnum
|
||||
},
|
||||
|
||||
{Name = "BanditsLevel", Type = "Number", WidgetStyle = "EnumDropDown", Category = "uiR2EDRollout_BanditsCamp",
|
||||
Enum = initValue(),
|
||||
onChange = updateBanditCampEnum
|
||||
},
|
||||
|
||||
--{Name = "Cycle", Type = "Number", Category = "uiR2EDRollout_BanditsCamp", Min = "0", Max = "999999", Default = "30"},
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- read values from a BanditsComp and get Sheet Id
|
||||
component.getBanditPaletteId = function(comp)
|
||||
-- local tmpId = "palette.entities.npcs.cuthroats.cuthroat_b_melee_a_z_f"
|
||||
-- return tmpId
|
||||
local id = "palette.entities.npcs.bandits." ..
|
||||
component.RacesId[comp._Race + 1] .."_" ..
|
||||
component.RolesId[math.random(0,5) + 1] .."_" ..
|
||||
component.LevelsId[comp._BanditsLevel + 1]
|
||||
|
||||
return id
|
||||
end
|
||||
|
||||
component.init = function()
|
||||
math.randomseed( os.time() ) -- To remove
|
||||
end
|
||||
|
||||
component.createGhostComponents = function(comp, act)
|
||||
local bandits
|
||||
local npcGroup = r2.newComponent("NpcGrpFeature")
|
||||
assert(npcGroup)
|
||||
|
||||
|
||||
local leader = nil
|
||||
local sequences = {}
|
||||
local stepSitDown = nil
|
||||
local stepStandUp = nil
|
||||
|
||||
|
||||
do
|
||||
|
||||
local fire = r2.newComponent("Npc")
|
||||
fire.Name = "Fire"
|
||||
fire.Base = "palette.entities.botobjects.campfire"
|
||||
fire.Position.x = comp.Position.x
|
||||
fire.Position.y = comp.Position.y
|
||||
fire.Position.z = 0
|
||||
fire.Angle = 0
|
||||
r2.requestInsertGhostNode(act.Features[0].InstanceId, "Components", -1, "", fire)
|
||||
end
|
||||
|
||||
if comp._Seed then math.randomseed(comp._Seed) end
|
||||
do
|
||||
local x = comp.Position.x
|
||||
local y = comp.Position.y
|
||||
local n = comp._BanditsCount
|
||||
|
||||
local pas = (2 * math.pi)/n
|
||||
local r = (n/(2*math.pi))+2
|
||||
for i = 1, n do
|
||||
local npc = r2:randomNPC( component.getBanditPaletteId(comp), component.Races[comp._Race + 1])
|
||||
npc.Position.x = (r-1) * math.cos((i-1)*pas) -- make position relative to the feature positio
|
||||
npc.Position.y = (r-1) * math.sin((i-1)*pas)
|
||||
npc.Position.z = 0
|
||||
npc.Angle = (i-1)*pas + math.pi
|
||||
|
||||
if comp.Active == 1 then npc.AutoSpawn = 1 else npc.AutoSpawn = 0 end
|
||||
if i == 1 then leader = npc end
|
||||
|
||||
if comp.NoRespawn then
|
||||
-- debugInfo("setting no respawn for a bandit -- value : " ..comp.NoRespawn)
|
||||
npc.NoRespawn = comp.NoRespawn
|
||||
end
|
||||
|
||||
table.insert(npcGroup.Components, npc)
|
||||
end
|
||||
npcGroup.Name = r2:genInstanceName(i18n.get("uiR2EDNameBanditCamp")):toUtf8()
|
||||
bandits = npcGroup
|
||||
bandits.Position.x = x
|
||||
bandits.Position.y = y
|
||||
bandits.InheritPos = 0
|
||||
end
|
||||
|
||||
-- Sequence1 standUp -> Wander
|
||||
do
|
||||
local sequence = r2.newComponent("ActivitySequence")
|
||||
|
||||
|
||||
table.insert(leader.Behavior.Activities, sequence)
|
||||
table.insert(bandits.ActivitiesId, sequence.InstanceId)
|
||||
sequences[1] = sequence
|
||||
|
||||
sequence.Name = "Head to Wander"
|
||||
sequence.Repeating = 0
|
||||
|
||||
-- Initial wait
|
||||
do
|
||||
|
||||
local step = r2.newComponent("ActivityStep")
|
||||
table.insert(sequence.Components, step)
|
||||
step.Type = "None"
|
||||
step.Name = "Stand Up"
|
||||
|
||||
step.Activity = "Stand Up"
|
||||
step.ActivityZoneId = r2.RefId("")
|
||||
|
||||
step.TimeLimit = "Few Sec"
|
||||
step.TimeLimitValue = "5"
|
||||
end
|
||||
|
||||
|
||||
-- head to Wander
|
||||
do
|
||||
local step = r2.newComponent("ActivityStep")
|
||||
comp.User._StepHeadToWander = step.InstanceId
|
||||
table.insert(sequence.Components, step)
|
||||
step.Type = "None"
|
||||
|
||||
|
||||
step.Activity = "Go To Zone"
|
||||
step.ActivityZoneId = r2.RefId(comp._Zone)
|
||||
|
||||
step.TimeLimit = "No Limit"
|
||||
-- step.TimeLimitValue = ""
|
||||
-- step.Chat = r2.RefId("")
|
||||
end
|
||||
|
||||
-- Go to zone until arrived
|
||||
end
|
||||
|
||||
-- Sequence2 Wander
|
||||
do
|
||||
local sequence = r2.newComponent("ActivitySequence")
|
||||
|
||||
|
||||
table.insert(leader.Behavior.Activities, sequence)
|
||||
table.insert(bandits.ActivitiesId, sequence.InstanceId)
|
||||
sequences[2] = sequence
|
||||
|
||||
sequence.Name = "Wander"
|
||||
sequence.Repeating = 0
|
||||
-- Stand up
|
||||
do
|
||||
local step = r2.newComponent("ActivityStep")
|
||||
table.insert(sequence.Components, step)
|
||||
step.Type = "None"
|
||||
step.Name = "Wander"
|
||||
|
||||
step.Activity = "Wander"
|
||||
step.ActivityZoneId = r2.RefId(comp._Zone)
|
||||
|
||||
--if comp.Cycle ~= 0 then
|
||||
if comp.WanderDuration ~= 0 then
|
||||
step.TimeLimit = "Few Sec"
|
||||
step.TimeLimitValue = tostring( math.ceil(comp.WanderDuration) )
|
||||
else
|
||||
step.TimeLimit = "No Limit"
|
||||
end
|
||||
-- step.TimeLimitValue = ""
|
||||
-- step.Chat = r2.RefId("")
|
||||
|
||||
end
|
||||
-- Go to zone until arrived
|
||||
end
|
||||
|
||||
|
||||
-- Sequence3 wander - >sit
|
||||
do
|
||||
local sequence = r2.newComponent("ActivitySequence")
|
||||
sequence.Name = "Head to Fire"
|
||||
sequence.Repeating = 0
|
||||
table.insert(leader.Behavior.Activities, sequence)
|
||||
table.insert(bandits.ActivitiesId, sequence.InstanceId)
|
||||
|
||||
sequences[3] = sequence
|
||||
|
||||
|
||||
|
||||
-- to fire
|
||||
do
|
||||
local step = r2.newComponent("ActivityStep")
|
||||
comp.User._StepHeadToFire = step.InstanceId
|
||||
table.insert(sequence.Components, step)
|
||||
step.Type = "None"
|
||||
step.Name = "head to fire"
|
||||
|
||||
step.Activity = "Go To Start Point"
|
||||
step.ActivityZoneId = r2.RefId("")
|
||||
|
||||
step.TimeLimit = "No Limit"
|
||||
stepSitDown = step
|
||||
-- step.TimeLimitValue = ""
|
||||
-- step.Chat = r2.RefId("")
|
||||
end
|
||||
|
||||
do
|
||||
local step = r2.newComponent("ActivityStep")
|
||||
table.insert(sequence.Components, step)
|
||||
step.Type = "None"
|
||||
step.Name = "Sit Down"
|
||||
|
||||
step.Activity = "Sit Down"
|
||||
step.ActivityZoneId = r2.RefId("")
|
||||
|
||||
step.TimeLimit = "Few Sec"
|
||||
step.TimeLimitValue = "5"
|
||||
end
|
||||
|
||||
end
|
||||
-- Sequence3 wander - >sit
|
||||
do
|
||||
local sequence = r2.newComponent("ActivitySequence")
|
||||
sequence.Name = "Head to Fire"
|
||||
sequence.Repeating = 0
|
||||
table.insert(leader.Behavior.Activities, sequence)
|
||||
table.insert(bandits.ActivitiesId, sequence.InstanceId)
|
||||
|
||||
sequences[4] = sequence
|
||||
-- stand up : go to start point
|
||||
do
|
||||
local step = r2.newComponent("ActivityStep")
|
||||
|
||||
table.insert(sequence.Components, step)
|
||||
step.Type = "None"
|
||||
step.Name = "Initial Wait"
|
||||
|
||||
step.Activity = "Stand On Start Point"
|
||||
step.ActivityZoneId = r2.RefId("")
|
||||
|
||||
--if comp.Cycle ~= 0 then
|
||||
if comp.SitDuration ~= 0 then
|
||||
step.TimeLimit = "Few Sec"
|
||||
step.TimeLimitValue = tostring( math.ceil(comp.SitDuration) )
|
||||
else
|
||||
step.TimeLimit = "No Limit"
|
||||
end
|
||||
-- step.Chat = r2.RefId("")
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- activitySequence1 -> activitySequence2
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Name = "Heading to wander"
|
||||
table.insert(leader.Behavior.Actions, eventHandler)
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
table.insert(eventHandler.Actions, action)
|
||||
action.Entity = r2.RefId(leader.InstanceId)
|
||||
action.Action.Type = "begin activity sequence"
|
||||
action.Action.Value = r2.RefId(sequences[2].InstanceId)
|
||||
|
||||
|
||||
eventHandler.Event.Type = "end of activity sequence"
|
||||
eventHandler.Event.Value = r2.RefId(sequences[1].InstanceId)
|
||||
end
|
||||
|
||||
-- activitySequence3 -> activitySequence4
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Name = "Wander"
|
||||
table.insert(leader.Behavior.Actions, eventHandler)
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
table.insert(eventHandler.Actions, action)
|
||||
action.Entity = r2.RefId(leader.InstanceId)
|
||||
action.Action.Type = "begin activity sequence"
|
||||
action.Action.Value = r2.RefId(sequences[4].InstanceId)
|
||||
eventHandler.Event.Type = "end of activity sequence"
|
||||
eventHandler.Event.Value = r2.RefId(sequences[3].InstanceId)
|
||||
end
|
||||
|
||||
--if comp.Cycle ~= 0 then
|
||||
if comp.WanderDuration ~= 0 then
|
||||
-- activitySequence2 -> activitySequence3
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Name = "Heading to Fire"
|
||||
table.insert(leader.Behavior.Actions, eventHandler)
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
table.insert(eventHandler.Actions, action)
|
||||
action.Entity = r2.RefId(leader.InstanceId)
|
||||
action.Action.Type = "begin activity sequence"
|
||||
action.Action.Value = r2.RefId(sequences[3].InstanceId)
|
||||
|
||||
|
||||
eventHandler.Event.Type = "end of activity sequence"
|
||||
eventHandler.Event.Value = r2.RefId(sequences[2].InstanceId)
|
||||
end
|
||||
end
|
||||
|
||||
-- activitySequence4 -> activitySequence1
|
||||
if comp.SitDuration ~= 0 then
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Name = "Stay around fire"
|
||||
table.insert(leader.Behavior.Actions, eventHandler)
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
table.insert(eventHandler.Actions, action)
|
||||
action.Entity = r2.RefId(leader.InstanceId)
|
||||
action.Action.Type = "begin activity sequence"
|
||||
action.Action.Value = r2.RefId(sequences[1].InstanceId)
|
||||
eventHandler.Event.Type = "end of activity sequence"
|
||||
eventHandler.Event.Value = r2.RefId(sequences[4].InstanceId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
r2.requestInsertGhostNode(act.InstanceId, "Features", -1, "", bandits)
|
||||
-- r2.requestInsertGhostNode(this.InstanceId, "Ghost", -1, "", ghostNpc)
|
||||
-- r2.requestInsertGhostNode(r2:getCurrentAct().InstanceId, "Features", -1, "", bandits)
|
||||
--
|
||||
local k, sequence = next(sequences, nil)
|
||||
while k do
|
||||
r2.requestInsertGhostNode(act.InstanceId, "ActivitiesIds", -1, "", sequence.InstanceId)
|
||||
k, sequence = next(sequences, k)
|
||||
end
|
||||
|
||||
local k, bandit = next(npcGroup.Components, nil)
|
||||
while k do
|
||||
r2:getInstanceFromId(bandit.InstanceId).Selectable = true -- for debug
|
||||
k, bandit = next(npcGroup.Components, k)
|
||||
end
|
||||
|
||||
comp.User._BanditGroup = npcGroup.InstanceId
|
||||
comp.User._SequenceHeadToWander = sequences[1].InstanceId
|
||||
comp.User._SequenceWander = sequences[2].InstanceId
|
||||
comp.User._SequenceHeadToFire = sequences[3].InstanceId
|
||||
comp.User._SequenceStayNearFire = sequences[4].InstanceId
|
||||
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
local banditsCount = tonumber( resultTable["BanditsCount"] )
|
||||
if not r2:checkAiQuota(banditsCount) then return end
|
||||
|
||||
local race = tonumber( resultTable["Race"] )
|
||||
local banditsLevel = tonumber( resultTable["BanditsLevel"] )
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
--local cycle = tonumber( resultTable["Cycle"] )
|
||||
--local sitDuration = tonumber( resultTable["SitDuration"] )
|
||||
--local wanderDuration= tonumber( resultTable["WanderDuration"] )
|
||||
local ZoneSize = tonumber(resultTable["ZoneSize"])
|
||||
if banditsCount == nil or race == nil or banditsLevel == nil
|
||||
then
|
||||
debugInfo("Can't create Feature")
|
||||
return
|
||||
end
|
||||
|
||||
--local component = feature.Components.BanditCamp.createComponent( x, y, banditsCount, race, banditsLevel, cycle,ZoneSize)
|
||||
local component = feature.Components.BanditCamp.createComponent( x, y, banditsCount, race, banditsLevel, ZoneSize)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
|
||||
-- feature.createContent(component)
|
||||
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for bandit camp creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of bandit camp at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("BanditCamp") == 1 then
|
||||
r2.displayFeatureHelp("BanditCamp")
|
||||
end
|
||||
r2:doForm("BanditCamp_Form", {X = x, Y = y}, paramsOk, paramsCancel)
|
||||
updateBanditCampEnum()
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice of bandit camp position")
|
||||
end
|
||||
local poly = {}
|
||||
local step = 2 * math.pi / BanditZoneNumCorners
|
||||
for k = 0, BanditZoneNumCorners - 1 do
|
||||
table.insert(poly, CVector2f(BanditZoneRadius * math.cos(k * step), BanditZoneRadius * math.sin(k * step)))
|
||||
end
|
||||
r2:choosePos("object_campfire.creature", posOk, posCancel, "createFeatureBanditCamp",
|
||||
"curs_create.tga",
|
||||
"curs_stop.tga",
|
||||
{ poly }, r2.PrimRender.ComponentRegionLook, r2.PrimRender.ComponentRegionInvalidLook)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function feature.hasScenarioCost(this)
|
||||
return true
|
||||
end
|
||||
|
||||
component.init()
|
||||
r2.Features["BanditCampFeature"] = feature
|
||||
|
||||
|
@ -1,557 +0,0 @@
|
||||
|
||||
r2.Features.BossSpawnerFeature = {}
|
||||
|
||||
local feature = r2.Features.BossSpawnerFeature
|
||||
|
||||
feature.Name="BossSpawnerFeature"
|
||||
|
||||
feature.Description="Spawns a boss after the death of a chosen number of kitin workers"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.BossSpawner =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="BossSpawner",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "bossSpawnerDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = { "activation", "deactivation", "trigger"},
|
||||
|
||||
Conditions = { "is active", "is inactive"},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--Category="uiR2EDRollout_Guards"
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table", Visible= false},
|
||||
{Name= "Ghosts", Type = "Table", Visible = false },
|
||||
{Name= "Name", Type="String", MaxNumChar="32"},
|
||||
{Name= "Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="TriggerValue", Type="Number", Min="0", DefaultValue="0", Translation="uiR2EDProp_TriggerValue"},
|
||||
{Name="BossId", Type="RefId", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_BossId"},
|
||||
{Name="GuardNumber", Type="Number", Category="uiR2EDRollout_Guards", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3", "4", "5"}, DefaultValue="5"},
|
||||
{Name="Guard1Id", Type="RefId", Category="uiR2EDRollout_Guards", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Guard1Id", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Guard2Id", Type="RefId", Category="uiR2EDRollout_Guards", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Guard2Id", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Guard3Id", Type="RefId", Category="uiR2EDRollout_Guards", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Guard3Id", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Guard4Id", Type="RefId", Category="uiR2EDRollout_Guards", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Guard4Id", Visible= function(this) return this:displayRefId(4) end},
|
||||
{Name="Guard5Id", Type="RefId", Category="uiR2EDRollout_Guards", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Guard5Id", Visible= function(this) return this:displayRefId(5) end},
|
||||
|
||||
},
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
--r2.Translator.pretranslateDefaultFeature(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
--r2.Translator.translateDefaultFeature(this, context)
|
||||
end
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
local component = feature.Components.BossSpawner
|
||||
|
||||
function component:getMaxTriggerValue()
|
||||
return tostring(this.GuardNumber)
|
||||
end
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbGuards = self.GuardNumber + 1
|
||||
if index <= nbGuards then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local rtBossGrp = r2.Translator.getRtGroup(context, component.BossId)
|
||||
|
||||
if (action.Action.Type == "spawnEntity") then
|
||||
if rtBossGrp then
|
||||
local actionTrigger = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6)
|
||||
local actionSpawn = r2.Translator.createAction("spawn", rtBossGrp.Id)
|
||||
local retAction = r2.Translator.createAction("condition_if", r2:getNamespace()..rtNpcGrp.Id..".Active == 1",
|
||||
r2.Translator.createAction("multi_actions", {actionTrigger, actionSpawn})
|
||||
)
|
||||
return retAction, retAction
|
||||
end
|
||||
return nil, nil
|
||||
end
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if tostring(event.Event.Type) == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
local bossSpawnerDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
--
|
||||
-- If the message is received by a client that didn't request the modification, we must make sure this client
|
||||
-- doesn't modify the data because it has already been performed by the initial client.
|
||||
--
|
||||
local function checkPickedEntity(this, instanceId, attributeName)
|
||||
if instanceId == "" then
|
||||
return false
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
assert(tmpInstance)
|
||||
local i = 1
|
||||
while i < 6 do
|
||||
local attrName = "Guard" ..i.. "Id"
|
||||
if attrName ~= attributeName and this[attrName] == tmpInstance.InstanceId then
|
||||
return false
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
if attributeName ~= "BossId" and tmpInstance.InstanceId == this.BossId then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local oldOnAttrModified = bossSpawnerDisplayerTable.onAttrModified
|
||||
function bossSpawnerDisplayerTable:onAttrModified(instance, attributeName)
|
||||
-- call base version
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
|
||||
if attributeName == "GuardNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbGuards = instance.GuardNumber + 1
|
||||
local i = 1
|
||||
while i <= 5 do
|
||||
if i > nbGuards then
|
||||
local name = "Guard"..tostring(i).."Id"
|
||||
local refId = propertySheet:find(name)
|
||||
local refIdName = refId:find("name")
|
||||
refIdName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, name, "")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
if instance.TriggerValue >= nbGuards then
|
||||
messageBox("Trigger value was exceeding the number of picked guards and was reset to 0")
|
||||
displaySystemInfo(i18n.get("uiR2EdInvalidTriggerValue"), "BC")
|
||||
r2.requestSetNode(instance.InstanceId, "TriggerValue", 0)
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--check if the trigger value doesn't exceed the number of picked guards (or groups)
|
||||
--if it does, reset the value to 0
|
||||
if attributeName == "TriggerValue" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local i = 1
|
||||
local nbPickedGuards = 0
|
||||
|
||||
while i <= 5 do
|
||||
local guardId = "Guard"..tostring(i).."Id"
|
||||
local refId = instance[guardId]
|
||||
r2.print("refId = " ..tostring(refId))
|
||||
if refId ~= "" then
|
||||
nbPickedGuards = nbPickedGuards + 1
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
if instance.TriggerValue ~= 0 and tonumber(instance.TriggerValue) >= nbPickedGuards then
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, 0)
|
||||
displaySystemInfo(i18n.get("uiR2EdInvalidTriggerValue"), "BC")
|
||||
messageBox("The trigger value shouldn't exceed the number of picked guards (or picked groups)")
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if string.find(attributeName, "Id") == nil or attributeName == "InstanceId" then return end
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local refId = propertySheet:find(attributeName)
|
||||
if refId == nil then return end
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
|
||||
local i = 1
|
||||
local nbPickedGuards = 0
|
||||
|
||||
--when clearing a refId, check if the trigger value is still valid
|
||||
while i <= 5 do
|
||||
local guardId = "Guard"..tostring(i).."Id"
|
||||
local refId = instance[guardId]
|
||||
|
||||
if refId ~= "" then
|
||||
nbPickedGuards = nbPickedGuards + 1
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
if instance.TriggerValue ~= 0 and tonumber(instance.TriggerValue) >= nbPickedGuards then
|
||||
r2.requestSetNode(instance.InstanceId, "TriggerValue", 0)
|
||||
displaySystemInfo(i18n.get("uiR2EdInvalidTriggerValue"), "BC")
|
||||
messageBox("The trigger value shouldn't exceed the number of picked guards (or picked groups)")
|
||||
end
|
||||
|
||||
|
||||
refIdName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
local inserted = checkPickedEntity(instance, instanceId, attributeName)
|
||||
if inserted == true then
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
refIdName.hardtext = tmpInstance.Name
|
||||
else
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, "")
|
||||
end
|
||||
instance.User.onHrcMove = false
|
||||
end
|
||||
|
||||
|
||||
function bossSpawnerDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function reattributeIdOnHrcMove(bSpawner, group, targetAttr)
|
||||
local propertySheet = r2:getPropertySheet(bSpawner)
|
||||
local refId = propertySheet:find(targetAttr)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
r2.requestSetNode(bSpawner.InstanceId, targetAttr, group.InstanceId)
|
||||
refIdName.hardtext = group.Name
|
||||
bSpawner.User.onHrcMove = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
local group = tmpInstance.ParentInstance
|
||||
if group:isKindOf("NpcGrpFeature") then
|
||||
reattributeIdOnHrcMove(self, group, targetAttr)
|
||||
end
|
||||
tmpInstance.User.SelfModified = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function r2:bossSpawnerDisplayer()
|
||||
return bossSpawnerDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
component.createGhostComponents= function(this, act)
|
||||
|
||||
local comp = this
|
||||
local boss = r2:getInstanceFromId(comp.BossId)
|
||||
|
||||
if boss == nil then
|
||||
debugInfo("BossSpawner: Can't spawn a nil boss. You have to pick one.")
|
||||
--assert(boss)
|
||||
return
|
||||
end
|
||||
|
||||
local counter = r2.newComponent("Counter")
|
||||
assert(counter)
|
||||
|
||||
counter.Base = "palette.entities.botobjects.milestone"
|
||||
counter.Name = "Guards Counter"
|
||||
counter.Position.x = comp.Position.x
|
||||
counter.Position.y = comp.Position.y
|
||||
counter.Position.z = 0
|
||||
|
||||
|
||||
|
||||
local nbGuard = 0
|
||||
local eventType = "" --depends on the instance type (groupe or npc)
|
||||
local eventName = ""
|
||||
|
||||
-- Add to each guard a 'OnDeath EventHandler' which decrements the counter
|
||||
for id = 1, 5 do
|
||||
local propertyName = "Guard"..tonumber(id).."Id"
|
||||
if comp[propertyName] ~= nil and comp[propertyName] ~= "" then
|
||||
local guardInstance = r2:getInstanceFromId(comp[propertyName])
|
||||
if guardInstance then
|
||||
|
||||
if guardInstance:isKindOf("Npc") then
|
||||
eventType = "death"
|
||||
eventName = "On Death"
|
||||
elseif guardInstance:isKindOf("NpcGrpFeature") then
|
||||
eventType = "group death"
|
||||
eventName = "On Group Death"
|
||||
end
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
--eventHandler.Event.Type = "death"
|
||||
eventHandler.Event.Type = eventType
|
||||
eventHandler.Event.Value = ""
|
||||
--eventHandler.Name = "On Death"
|
||||
eventHandler.Event.Name = eventName
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
table.insert(eventHandler.Actions, action)
|
||||
action.Entity = r2.RefId(counter.InstanceId)
|
||||
action.Action.Type = "Decrement"
|
||||
action.Action.Value = ""
|
||||
|
||||
if guardInstance:isKindOf("Npc") then
|
||||
r2.requestInsertGhostNode(guardInstance.Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
elseif guardInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestInsertGhostNode(guardInstance.Components[0].Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
--r2.requestInsertGhostNode(guardInstance.Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
|
||||
nbGuard = nbGuard + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nbGuard == 0 then
|
||||
r2.print("BossSpawner: No guard has been picked.")
|
||||
return
|
||||
end
|
||||
|
||||
counter.Value = tonumber(nbGuard)
|
||||
counter.TriggerValue = comp.TriggerValue
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "On Trigger"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "On Trigger"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(comp.InstanceId) --r2.RefId(boss.InstanceId)
|
||||
action.Action.Type = "spawnEntity"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
table.insert(counter.Behavior.Actions, eventHandler)
|
||||
|
||||
end
|
||||
|
||||
r2.requestInsertGhostNode(comp.InstanceId, "Components", -1, "", counter)
|
||||
--r2.requestInsertGhostNode(r2:getCurrentAct().InstanceId, "Features", -1, "", counter)
|
||||
|
||||
if boss:isKindOf("NpcGrpFeature") then
|
||||
local instanceId = boss.Components[0].InstanceId
|
||||
--debugInfo("setting autospawn for: " ..instanceId)
|
||||
r2.requestSetGhostNode(instanceId, "AutoSpawn", 0)
|
||||
else
|
||||
r2.requestSetGhostNode(boss.InstanceId, "AutoSpawn", 0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("BossSpawner")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdBossSpawner")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
comp.TriggerValue = 0
|
||||
|
||||
comp.GuardNumber = 0
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
comp.Guard1Id = r2.RefId("")
|
||||
comp.Guard2Id = r2.RefId("")
|
||||
comp.Guard3Id = r2.RefId("")
|
||||
comp.Guard4Id = r2.RefId("")
|
||||
comp.Guard5Id = r2.RefId("")
|
||||
comp.BossId = r2.RefId("")
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
--debugInfo("Show again: "..tostring(showAgain))
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("BossSpawnerForm", 0)
|
||||
else r2.setDisplayInfo("BossSpawnerForm", 1) end
|
||||
|
||||
local component = feature.Components.BossSpawner.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'BossSpawnerFeature' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'BossSpawnerFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("BossSpawner") == 1 then
|
||||
r2.displayFeatureHelp("BossSpawner")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewBossSpawnerAction"))
|
||||
local component = feature.Components.BossSpawner.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'BossSpawnerFeature' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureBossSpawner")
|
||||
end
|
||||
|
||||
--
|
||||
-- Registers the feature creation form used as a creation menu in the editor
|
||||
--
|
||||
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdBossSpawner")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "BossSpawner")
|
||||
end
|
||||
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {}
|
||||
r2.Translator.addActivationToTranslations(logicTranslations)
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["BossSpawnerFeature"] = feature
|
||||
|
@ -1,291 +0,0 @@
|
||||
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdCounter --
|
||||
-- CreationFrom : uiR2EdCounterParameters
|
||||
|
||||
|
||||
r2.Features.CounterFeature = {}
|
||||
|
||||
local feature = r2.Features.CounterFeature
|
||||
|
||||
feature.Name="Counter"
|
||||
|
||||
feature.Description="A Counter"
|
||||
|
||||
|
||||
function feature.registerForms()
|
||||
r2.Forms.CounterFeatureForm =
|
||||
{
|
||||
Caption = "uiR2EdCounterParameters",
|
||||
Prop =
|
||||
{
|
||||
-- following field are tmp for property sheet building testing
|
||||
{Name="TriggerValue", Type="Number", Category="uiR2EDRollout_CounterFeature", Min="0", Default="0"},
|
||||
{Name="Value", Type="Number", Category="uiR2EDRollout_CounterFeature", Min="1", Default="1"}
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.Counter =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="Counter",
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "Activate", "Deactivate", "Increment", "Decrement", "Trigger"},
|
||||
|
||||
Events = { "On Trigger", "On Activation", "On Deactivation"},
|
||||
|
||||
Conditions = { "is active"},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Value", Type="Number"},
|
||||
{Name="TriggerValue", Type="Number", Min="0", Default="0"}
|
||||
},
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--feature.createFeatureLocally(this)
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
local initValue = this.Value
|
||||
local trigValue = this.TriggerValue
|
||||
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
|
||||
local action1 = r2.Translator.createAction("counter_init", rtNpcGrp.Id, initValue, trigValue)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 0)
|
||||
local action = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
|
||||
r2.Translator.translateAiGroupInitialState(this, context, action)
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
}
|
||||
|
||||
local component = feature.Components.Counter
|
||||
|
||||
|
||||
function component.getLogicActionTrigger(entity, context, action, rtNpcGrp)
|
||||
local retAction = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 3)
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if (action.Action.Type == "Activate") then
|
||||
local action1 = r2.Translator.createAction("counter_enable", rtNpcGrp.Id, 0)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 0)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
return retAction, retAction
|
||||
elseif (action.Action.Type == "Deactivate") then
|
||||
local action1 = r2.Translator.createAction("counter_disable", rtNpcGrp.Id, 0)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 1)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
return retAction, retAction
|
||||
elseif (action.Action.Type == "Increment") then
|
||||
local action1 = r2.Translator.createAction("counter_inc", rtNpcGrp.Id, 0)
|
||||
return action1, action1
|
||||
elseif (action.Action.Type == "Decrement") then
|
||||
local action1 = r2.Translator.createAction("counter_dec", rtNpcGrp.Id, 0)
|
||||
return action1, action1
|
||||
elseif (action.Action.Type == "Trigger") then
|
||||
local retAction = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 3)
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
local firstAction, lastAction = nil, nil
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("counter_is_enable", rtNpcGrp.Id, 0);
|
||||
return action1, action1
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "On Trigger" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 3)
|
||||
elseif eventType == "On Activation" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 0)
|
||||
elseif eventType == "On Deactivation" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 1)
|
||||
end
|
||||
|
||||
return eventHandler, firstCondition, lastCondition
|
||||
end
|
||||
|
||||
|
||||
-- feature part
|
||||
|
||||
component.createComponent = function(x, y, value, tvalue)
|
||||
|
||||
local comp = r2.newComponent("Counter")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = "palette.entities.botobjects.milestone"
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDRollout_CounterFeature")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
comp.TriggerValue = tvalue
|
||||
comp.Value = value
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
r2.requestNewAction(i18n.get("uiR2EDCreateCounterFeatureAction"))
|
||||
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local tvalue = tonumber( resultTable["TriggerValue"] )
|
||||
local value = tonumber( resultTable["Value"] )
|
||||
|
||||
if not x or not y or not tvalue or not value
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.CounterFeature.createComponent( x, y, value, tvalue)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
--component.TriggerValue = tvalue
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'CounterFeature' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'CounterFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
r2:doForm("CounterFeatureForm", {X=x, Y=y}, paramsOk, paramsCancel)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'CounterFeature' position")
|
||||
end
|
||||
r2:choosePos("object_milestone.creature", posOk, posCancel, "createFeatureBanditCamp")
|
||||
end
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EDRollout_CounterFeature")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "CounterFeature")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["Activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["Desactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["Increment"] = { menu=i18n.get( "uiR2AA0CounterIncrement" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1CounterIncrement" ):toUtf8()},
|
||||
["Decrement"] = { menu=i18n.get( "uiR2AA0CounterDecrement" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1CounterDecrement" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["desactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()}
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["CounterFeature"] = feature
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,625 +0,0 @@
|
||||
|
||||
r2.Features.DeliveryTask = {}
|
||||
|
||||
local feature = r2.Features.DeliveryTask
|
||||
|
||||
feature.Name="DeliveryTask"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.DeliveryTask =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="DeliveryTask",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "deliveryTaskDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = { "activation", "deactivation", "mission asked", "succeeded", "delivered"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is succeeded" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
{Name="MissionTarget", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
{Name="ItemNumber", Type="Number", Category="uiR2EDRollout_ItemsToDeliver", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3"}, },
|
||||
{Name="Item1Qty", Type="Number", Category="uiR2EDRollout_ItemsToDeliver", Min="0", DefaultValue="1", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item1Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToDeliver", Visible= function(this) return this:displayRefId(1) end},
|
||||
|
||||
{Name="Item2Qty", Type="Number", Category="uiR2EDRollout_ItemsToDeliver", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item2Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToDeliver", Visible= function(this) return this:displayRefId(2) end},
|
||||
|
||||
{Name="Item3Qty", Type="Number", Category="uiR2EDRollout_ItemsToDeliver", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Item3Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToDeliver", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="ValidationNeeded", Category="uiR2EDRollout_TextToSay", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100"},
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay", Visible= function(this)
|
||||
return this:IsValidationNeeded() end },
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
{Name="WaitValidationText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"},
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.DeliveryTask
|
||||
|
||||
function component:IsValidationNeeded()
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
if validationNeeded == 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbItems = self.ItemNumber + 1
|
||||
if index <= nbItems then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function component:getItems()
|
||||
local str = ""
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
local plotItemSheetId = plotItem.SheetId
|
||||
if str ~= "" then str = str ..";" end
|
||||
local name = r2.getSheetIdName(plotItemSheetId)
|
||||
str = str .. tostring(name)..":"..qt
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function component:textAdapter(text)
|
||||
local str = ""
|
||||
local items = {}
|
||||
local qts = {}
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
qts[id] = qt
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
items[id] = plotItem.Name
|
||||
else
|
||||
items[id] = ""
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
local str = text
|
||||
str=string.gsub (str, "<qt1>", tostring(qts[1]))
|
||||
str=string.gsub (str, "<qt2>", tostring(qts[2]))
|
||||
str=string.gsub (str, "<qt3>", tostring(qts[3]))
|
||||
str=string.gsub (str, "<item1>", tostring(items[1]))
|
||||
str=string.gsub (str, "<item2>", tostring(items[2]))
|
||||
str=string.gsub (str, "<item3>", tostring(items[3]))
|
||||
|
||||
local mission_giver = ""
|
||||
if self.MissionGiver == nil then return end
|
||||
local npc = r2:getInstanceFromId(self.MissionGiver)
|
||||
if npc then
|
||||
mission_giver = npc.Name
|
||||
end
|
||||
str=string.gsub(str, "<mission_giver>", tostring(mission_giver))
|
||||
|
||||
local mission_target = ""
|
||||
if self.MissionTarget == nil then return end
|
||||
local npc = r2:getInstanceFromId(self.MissionTarget)
|
||||
if npc then
|
||||
mission_target = npc.Name
|
||||
end
|
||||
str=string.gsub(str, "<mission_target>", tostring(mission_target))
|
||||
|
||||
return str
|
||||
end
|
||||
|
||||
local deliveryTaskDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = deliveryTaskDisplayerTable.onAttrModified
|
||||
function deliveryTaskDisplayerTable:onAttrModified(instance, attributeName)
|
||||
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
|
||||
if attributeName == "ItemNumber" then
|
||||
local nbRefId = instance.ItemNumber + 1
|
||||
local i = 1
|
||||
while i <= 3 do
|
||||
if i > nbRefId then
|
||||
local name = "Item"..tostring(i).."Id"
|
||||
local qty = "Item"..tostring(i).."Qty"
|
||||
r2.requestSetNode(instance.InstanceId, name, r2.RefId(""))
|
||||
r2.requestSetNode(instance.InstanceId, qty, 0)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
if attributeName == "ValidationNeeded" then
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
local targetRefId = propertySheet:find("MissionTarget")
|
||||
local targetName = targetRefId:find("name")
|
||||
|
||||
local giverRefId = propertySheet:find("MissionGiver")
|
||||
local giverName = propertySheet:find("MissionGiver"):find("name")
|
||||
|
||||
if attributeName == "MissionGiver" then
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
giverName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if instance["MissionTarget"] == instance[attributeName] then
|
||||
giverName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, "MissionGiver", "")
|
||||
else
|
||||
giverName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if attributeName == "MissionTarget" then
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
targetName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if instance["MissionGiver"] == instance[attributeName] then
|
||||
targetName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, "MissionTarget", "")
|
||||
else
|
||||
targetName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
return
|
||||
end
|
||||
|
||||
function deliveryTaskDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:deliveryTaskDisplayer()
|
||||
return deliveryTaskDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
-- EVENTS-----------------------------------------------------------------------
|
||||
-- we don't use events 1 to 3 anymore because they were bypassed by the events
|
||||
-- emitted by "request_item" and "give_item" actions
|
||||
-- 4 : activation
|
||||
-- 5 : deactivation
|
||||
-- 6 : mission given
|
||||
-- 8 : items delivered
|
||||
-- 9 : mission completed
|
||||
---------------------------------------------------------------------------------
|
||||
function component:translate(context)
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
debugInfo("VALIDATION VALUE : " ..self.ValidationNeeded)
|
||||
|
||||
if self.MissionGiver == nil then return end
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if not giver then return end
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
assert(rtGiverGrp)
|
||||
|
||||
if self.MissionTarget == nil then return end
|
||||
local target = r2:getInstanceFromId(self.MissionTarget)
|
||||
if not target then return end
|
||||
local rtTargetGrp = r2.Translator.getRtGroup(context, target.InstanceId)
|
||||
assert(rtTargetGrp)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
local items = self:getItems()
|
||||
|
||||
-- Start of state
|
||||
do
|
||||
local action = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 7)
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0)
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0)
|
||||
local rtAction5 = r2.Translator.createAction("set_value", rtGrp.Id, "Validation", self.ValidationNeeded)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, rtAction4, rtAction5 } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_7", self, context, rtAction)
|
||||
end
|
||||
|
||||
-- (re)activation
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_4", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
-- giver propose la mission
|
||||
do
|
||||
local actionSuccessText = r2.Translator.createAction("npc_say", self:textAdapter(self.MissionSucceedText), rtGiverGrp.Id ..":"..giver.Name)
|
||||
local actionEvent = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 9)
|
||||
|
||||
local multiActions = r2.Translator.createAction("multi_actions", {actionSuccessText, actionEvent})
|
||||
local action = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Validation", 1,
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 3, multiActions))
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0,
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.MissionText), rtGiverGrp.Id ..":"..giver.Name),
|
||||
r2.Translator.createAction("give_item", rtGrp.Id, items, self:textAdapter(self.ContextualText)),
|
||||
})
|
||||
))
|
||||
|
||||
local fullAction = r2.Translator.createAction("multi_actions", {rtAction, action})
|
||||
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, fullAction)
|
||||
end
|
||||
|
||||
--when player takes item from giver
|
||||
do
|
||||
local actionItemGiven = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0, --and if the scenery object has been selected once by the player
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 6),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 )}))
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,actionItemGiven)
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_1", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
-- When player talks to target
|
||||
do
|
||||
local actionSay = r2.Translator.createAction("npc_say", self:textAdapter(self.WaitValidationText), rtTargetGrp.Id ..":"..target.Name)
|
||||
local actionRequest = r2.Translator.createAction("request_item", rtGrp.Id, items, self:textAdapter(self.ContextualText))
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, -- if items have been taken from giver
|
||||
r2.Translator.createAction("multi_actions", {actionSay, actionRequest})
|
||||
))
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", target, context, rtAction)
|
||||
end
|
||||
|
||||
--when player gives item to target
|
||||
do
|
||||
local actionItemTaken = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1,
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 8),
|
||||
})
|
||||
)
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, actionItemTaken)
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_3", self, context, rtAction)
|
||||
end
|
||||
|
||||
--when receiving ItemsDelivered event
|
||||
do
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) )
|
||||
local actionSet = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 3)
|
||||
|
||||
local actionEventSuccess = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Validation", 0,
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 9))
|
||||
|
||||
local multiaction = r2.Translator.createAction("multi_actions", {actionBroadcast, actionSet, actionEventSuccess})
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_8", self, context, multiaction)
|
||||
|
||||
end
|
||||
|
||||
-- when receiving user_event_9, which means success, reset mission values.
|
||||
do
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, --if Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
})
|
||||
);
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- if not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 3 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5),
|
||||
})
|
||||
);
|
||||
local actions = r2.Translator.createAction("multi_actions", { action2, action3, })
|
||||
|
||||
|
||||
local action = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 3, actions)
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_9", self, context, action)
|
||||
end
|
||||
|
||||
--r2.Translator.translateFeatureActivation(self, context)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "mission asked" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
elseif eventType == "delivered" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 8)
|
||||
elseif eventType == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 9)
|
||||
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("DeliveryTask")
|
||||
assert(comp)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdDeliveryTask_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdDeliveryTask_MissionText"):toUtf8()
|
||||
local missionSucceedText = i18n.get("uiR2EdDeliveryTask_MissionSucceededText"):toUtf8()
|
||||
local waitValidationText = i18n.get("uiR2EdDeliveryTask_WaitValidationText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdDeliveryTask_BroadcastText"):toUtf8()
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_request_item")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDDeliveryTask")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.MissionSucceedText = missionSucceedText
|
||||
comp.WaitValidationText = waitValidationText
|
||||
comp.BroadcastText = broadcastText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'DeliveryTask' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("DeliveryTask") == 1 then
|
||||
r2.displayFeatureHelp("DeliveryTask")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewDeliveryTaskFeature"))
|
||||
local component = feature.Components.DeliveryTask.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'DeliveryTask' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_request_item.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureDeliveryTask")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdDeliveryTask")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "DeliveryTask")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()}
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["mission asked"] = { menu=i18n.get( "uiR2Event0MissionGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MissionGiven" ):toUtf8()},
|
||||
-- ["wait validation"] = { menu=i18n.get( "uiR2Event0TaskWaitValidation" ):toUtf8(),
|
||||
-- text=i18n.get( "uiR2Event1TaskWaitValidation" ):toUtf8()},
|
||||
["delivered"] = { menu=i18n.get( "uiR2Event0Delivered" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Delivered" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["DeliveryTask"] = feature
|
||||
|
@ -1,489 +0,0 @@
|
||||
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdEasterEgg --
|
||||
-- CreationFrom : uiR2EdEasterEggParameters
|
||||
|
||||
|
||||
r2.Features.EasterEggFeature = {}
|
||||
|
||||
local feature = r2.Features.EasterEggFeature
|
||||
|
||||
feature.Name="EasterEggFeature"
|
||||
|
||||
feature.Description="A feature that allows a NPC to take some item(s) from easter eggs"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
|
||||
|
||||
feature.Components.EasterEgg =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="EasterEgg",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "itemChestDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- Supposed to be the specific attributes of the feature (ex: for a banditcamp, number of bandits,
|
||||
-- race, etc.) but apparently not used..
|
||||
--
|
||||
Parameters = {},
|
||||
--
|
||||
-- The different actions that can be performed by the feature (activate, wander, spawn etc.)
|
||||
--
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
--
|
||||
-- Events are what happen to the feature and may trigger actions on the feature. (ex: "on activation",
|
||||
-- "on arrive at camp" etc.)
|
||||
--
|
||||
Events = { "activation", "deactivation", "opened"},
|
||||
--
|
||||
-- Conditions are what can be tested on the feature, giving information about its state (ex: "is wandering", "is active" etc.)
|
||||
--
|
||||
Conditions = { "is active", "is inactive" },
|
||||
--
|
||||
-- TextContexts is what the feature might say upon events (2 different kinds: spontaneous & interrogation texts)
|
||||
--
|
||||
TextContexts = {},
|
||||
--
|
||||
-- Not quite clear..
|
||||
--
|
||||
TextParameters = {},
|
||||
--
|
||||
-- Feature's parameters which can be modified by the GM at runtime.
|
||||
--
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- Properties define the feature's parameters like this:
|
||||
-- {Name="Parameter_Name", Type="Param_Type", Category="??", WidgetStyle="UI_WidgetStyle", Min="min_value", Max="max_value", Default="defalut_value"
|
||||
-- Categories can be found in data_common/r2/r2.uxt??
|
||||
--
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table", Visible = false},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Angle", Type="Number",
|
||||
WidgetStyle="Slider", Min="0", Max="360",
|
||||
--------------------
|
||||
convertToWidgetValue =
|
||||
function(value)
|
||||
local angle = value
|
||||
if angle == nil then angle = 0 end
|
||||
local result = math.fmod(math.floor(180 * angle / math.pi), 360)
|
||||
if result < 0 then result = 360 + result end
|
||||
return result
|
||||
end,
|
||||
--------------------
|
||||
convertFromWidgetValue =
|
||||
function(value)
|
||||
local angle = value
|
||||
if angle == nil then angle = 0 end
|
||||
return math.pi * math.min(359, angle) / 180
|
||||
end,
|
||||
},
|
||||
{Name="ItemNumber", Type="Number", Category="uiR2EDRollout_Items", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3"}, DefaultValue="3"},
|
||||
{Name="Item1Qty", Type="Number", Category="uiR2EDRollout_Items", Min="1", Max="50", DefaultValue="1", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item1Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_Items", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item2Qty", Type="Number", Category="uiR2EDRollout_Items", Min="0",Max="50", DefaultValue="0", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item2Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_Items", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item3Qty", Type="Number", Category="uiR2EDRollout_Items", Min="0",Max="50", DefaultValue="0", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Item3Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_Items", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", Min="0", DefaultValue="1"},
|
||||
-- {Name="Look", Type="String", DefaultValue="object_bones.creature"}, TODO use an enem / tree to select an object
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
--
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
--
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
--
|
||||
-- Called when running EditMode to create locally the feature without sending anything into the act (speed purpose).
|
||||
--
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
local eggId = this:getEggId(context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
local entity = this
|
||||
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
|
||||
if (this.Active == 1)
|
||||
then
|
||||
local eggId = this:getEggId(context)
|
||||
local intialAction = this:createActionActivateEasterEgg(context)
|
||||
r2.Translator.translateAiGroupInitialState(this, context, intialAction)
|
||||
end
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end
|
||||
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local component = feature.Components.EasterEgg
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbItems = self.ItemNumber + 1
|
||||
if index <= nbItems then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local itemChestDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
function itemChestDisplayerTable:onAttrModified(instance, attributeName)
|
||||
if attributeName == "ItemNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbRefId = instance.ItemNumber + 1
|
||||
local i = 1
|
||||
while i <= 3 do
|
||||
if i > nbRefId then
|
||||
local name = "Item"..tostring(i).."Id"
|
||||
local qty = "Item"..tostring(i).."Qty"
|
||||
r2.requestSetNode(instance.InstanceId, name, r2.RefId(""))
|
||||
r2.requestSetNode(instance.InstanceId, qty, 0)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
end
|
||||
|
||||
function itemChestDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function r2:itemChestDisplayer()
|
||||
return itemChestDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
--
|
||||
-- Create the logic actions relative to the feature via the translator.
|
||||
--
|
||||
|
||||
function getPlotItemIdByInstance(missionItem)
|
||||
local container = r2.Scenario.PlotItems
|
||||
local k, v = next(container)
|
||||
local id = 0
|
||||
while k do
|
||||
if tostring(v.InstanceId) == tostring(missionItem.InstanceId) then return id end
|
||||
id = id + 1
|
||||
k, v = next(container, k)
|
||||
end
|
||||
assert(nil)
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
function component:getItems()
|
||||
local str = ""
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
local plotItemId = getPlotItemIdByInstance(plotItem)
|
||||
if str ~= "" then str = str ..";" end
|
||||
|
||||
str = str .. tostring(plotItemId)..":"..qt
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function component:createActionActivateEasterEgg(context)
|
||||
local eggId = self:getEggId(context)
|
||||
|
||||
local str = self:getItems()
|
||||
|
||||
local pos = r2.getWorldPos(self)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = r2:snapZToGround(x, y)
|
||||
local heading = 0
|
||||
if self.Angle then
|
||||
heading = self.Angle
|
||||
end
|
||||
|
||||
local name = self.Name
|
||||
local clientSheet = self.Look
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
local multiActions = r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("easter_egg_activate", rtGrp.Id, eggId, r2:getActId(context.Act), str, x, y, z, heading, name, clientSheet),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)})
|
||||
return multiActions, multiActions
|
||||
end
|
||||
|
||||
function component:createActionDeactivateEasterEgg(context)
|
||||
local eggId = self:getEggId(context)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
local multiActions = r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("easter_egg_deactivate", rtGrp.Id, eggId, r2:getActId(context.Act)),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0)})
|
||||
return multiActions, multiActions
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if (action.Action.Type == "activate") then
|
||||
local retAction = component:createActionActivateEasterEgg(context)
|
||||
return retAction, retAction
|
||||
elseif (action.Action.Type == "deactivate") then
|
||||
local retAction = component:createActionDeactivateEasterEgg(context)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
local firstAction, lastAction = nil, nil
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
--
|
||||
-- Checks the conditions defined for this feature
|
||||
--
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "opened" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "activation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 4)
|
||||
elseif eventType == "deactivation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 5)
|
||||
end
|
||||
return eventHandler, firstCondition, lastCondition
|
||||
end
|
||||
|
||||
|
||||
-- feature part
|
||||
|
||||
|
||||
--
|
||||
-- Creates an instance of the feature with attributes retrieved from the creation form
|
||||
--
|
||||
function component.createComponent(x, y)
|
||||
|
||||
local comp = r2.newComponent("EasterEgg")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = "palette.entities.botobjects.chest_wisdom_std_sel"
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdEasterEgg")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp.ItemNumber = 0
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
function component:getEggId(context)
|
||||
assert(context)
|
||||
local n = 0
|
||||
|
||||
if context.EasterEggUniqId == nil then
|
||||
context.EasterEggUniqId = {}
|
||||
context.EasterEggMaxId = 0
|
||||
end
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
if context.EasterEggUniqId[rtNpcGrp.Id] == nil then
|
||||
local n = context.EasterEggMaxId + 1
|
||||
context.EasterEggUniqId[rtNpcGrp.Id] = n
|
||||
context.EasterEggMaxId = n
|
||||
end
|
||||
|
||||
return context.EasterEggUniqId[rtNpcGrp.Id]
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- from ihm
|
||||
-- Displays the creation form of the feature and calls CreateComponent with the user input values
|
||||
--
|
||||
function component.create()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("EasterEggForm", 0)
|
||||
else r2.setDisplayInfo("EasterEggForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local comp = component.createComponent( x, y)
|
||||
r2:setCookie(comp.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", comp)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'EasterEggFeature' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'EasterEggFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("EasterEgg") == 1 then
|
||||
r2.displayFeatureHelp("EasterEgg")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewEasterEggAction"))
|
||||
local comp = component.createComponent( x, y)
|
||||
r2:setCookie(comp.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", comp)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'EasterEggFeature' position")
|
||||
end
|
||||
r2:choosePos("object_chest_wisdom_std_sel.creature", posOk, posCancel, "createFeatureEasterEgg")
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
--- register the current Feature to menu
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- add a line to the event menu
|
||||
function component:getLogicTranslations()
|
||||
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Spawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Spawn" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Despawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Despawn" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Spawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Spawn" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Despawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Despawn" ):toUtf8()},
|
||||
["opened"] = { menu=i18n.get( "uiR2Event0ChestOpened" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1ChestOpened" ):toUtf8()},
|
||||
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Spawned" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Spawned" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Despawned" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Despawned" ):toUtf8()}
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["EasterEggFeature"] = feature
|
||||
|
||||
|
||||
|
@ -1,268 +0,0 @@
|
||||
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdEmptyFeature --
|
||||
-- CreationFrom : uiR2EdEmptyParameters
|
||||
|
||||
|
||||
r2.Features.EmptyFeature = {}
|
||||
|
||||
local feature = r2.Features.EmptyFeature
|
||||
|
||||
feature.Name="EmptyFeature"
|
||||
|
||||
feature.Description="An empty feature"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
|
||||
-- #########################
|
||||
-- # FEATURE FUNCTIONS #
|
||||
-- #########################
|
||||
|
||||
--
|
||||
-- Registers the feature creation form used as a creation menu in the editor
|
||||
--
|
||||
function feature.registerForms()
|
||||
r2.Forms.EmptyFeatureForm =
|
||||
{
|
||||
Caption = "uiR2EdEmptyParameters",
|
||||
Prop =
|
||||
{
|
||||
-- The creation form's fields are defined here
|
||||
{Name="Property1", Type="String", Category="UI Subsection"}
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
feature.Components.EmptyFeature =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="EmptyFeature",
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
--
|
||||
-- The different actions that can be performed by the feature ("activate", "wander", "spawn" etc.)
|
||||
--
|
||||
ApplicableActions = {},
|
||||
|
||||
--
|
||||
-- Events are the feature's states that may trigger actions on the feature. (ex: "on activation",
|
||||
-- "on arrive at camp" etc.)
|
||||
--
|
||||
Events = {},
|
||||
|
||||
--
|
||||
-- Conditions can be tested on the feature, giving information about its state (ex: "is wandering", "is active" etc.)
|
||||
--
|
||||
Conditions = {},
|
||||
|
||||
--
|
||||
-- TextContexts is what the feature might say upon events (2 different kinds: spontaneous & interrogation texts)
|
||||
--
|
||||
TextContexts = {},
|
||||
|
||||
--
|
||||
-- Not quite clear..
|
||||
--
|
||||
TextParameters = {},
|
||||
|
||||
--
|
||||
-- Feature's parameters which can be modified by the GM at runtime.
|
||||
--
|
||||
LiveParameters = {},
|
||||
|
||||
--
|
||||
-- Properties define the attributes of the feature.
|
||||
-- They're all displayed in the properties window of the feature.
|
||||
--
|
||||
-- -Name: define the name of the property
|
||||
--
|
||||
-- -Type: define the type of the property and can be "String", "Number", "Table", "RefId" etc.
|
||||
--
|
||||
-- -Category: Define a subsection of the property window displayed within the editor, so that different properties
|
||||
-- refering to the same feature's aspect can be grouped, and not added randomly in the window
|
||||
--
|
||||
-- WidgetStyle: define the type of UI widget that will be used to display the property. If not specified,
|
||||
-- the property is displayed in a textBox.
|
||||
--
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", Category="uiR2EDRollout_UISubsection", WidgetStyle="StaticText"}
|
||||
},
|
||||
|
||||
--
|
||||
-- from base class
|
||||
--
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
--
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
--
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
--
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
--
|
||||
-- Called when running EditMode to create the feature locally without sending anything into the act (speed purpose).
|
||||
--
|
||||
onPostCreate = function(this)
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
}
|
||||
|
||||
-- ###########################
|
||||
-- # COMPONENT FUNCTIONS #
|
||||
-- ###########################
|
||||
|
||||
local component = feature.Components.EmptyFeature
|
||||
|
||||
--
|
||||
-- Called when running test mode to create the feature and insert it into the current act.
|
||||
--
|
||||
component.createGhostComponents = function(act, comp)
|
||||
end
|
||||
|
||||
--
|
||||
-- Creates an instance of the feature with attributes retrieved from the creation form
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("EmptyFeature")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = "palette.entities.botobjects.milestone"
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdEmptyFeature")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
--
|
||||
-- Displays the creation form of the feature and calls CreateComponent with the user input values
|
||||
--
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewEmptyFeatureAction"))
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.EmptyFeature.createComponent( x, y)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'EmptyFeature' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'EmptyFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
r2:doForm("EmptyFeatureForm", {X=x, Y=y}, paramsOk, paramsCancel)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'EmptyFeature' position")
|
||||
end
|
||||
r2:choosePos("object_milestone.creature", posOk, posCancel, "createFeatureBanditCamp")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
function feature.registerForms()
|
||||
r2.Forms.EmptyFeatureForm =
|
||||
{
|
||||
Caption = "uiR2EdEmptyParameters",
|
||||
Prop =
|
||||
{
|
||||
-- The creation form's fields are defined here
|
||||
{Name="Property1", Type="String", Category="uiR2EDRollout_UISubsection"}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
--
|
||||
-- The following functions are specific to the Feature
|
||||
--
|
||||
local component = feature.Components.EmptyFeature
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
local firstAction, lastAction = nil,nil
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
local eventHandler, firsCondition, lastCondition = nil, nil, nil
|
||||
return eventHandler, firsCondition, lastCondition
|
||||
|
||||
end
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdEmptyFeature")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "EmptyFeature")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {},
|
||||
["Events"] = {},
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["EmptyFeature"] = feature
|
||||
|
@ -1,840 +0,0 @@
|
||||
--
|
||||
-- *****************
|
||||
-- * FAUNA FEATURE *
|
||||
-- *****************
|
||||
--
|
||||
-- The fauna feature contains 2 herds of creatures (herbivores and carnivores) that wander between 2 life zones (sleep zone and
|
||||
-- food zone).There are 2 differents kinds of components in this feature: fauna system and creature.
|
||||
-- The fauna system component is some kind of manager for the feature. It creates the creatures and their life zones, and then
|
||||
-- store them in its components table, so that their createChostComponents call and translation are automatically done by
|
||||
-- the translator.
|
||||
-- The created life zones are affected to each of the creature components. But the properties panel of the creature components allows
|
||||
-- the DM to choose other zones in the scenario through RefId picking.
|
||||
|
||||
|
||||
r2.Features.FaunaFeature = {}
|
||||
|
||||
local feature = r2.Features.FaunaFeature
|
||||
|
||||
feature.Name="FaunaFeature"
|
||||
|
||||
feature.Description="Generates a pack of carnivores and a herd of herbivores that will wander between two life zones (sleep zone, food zone) each."
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
|
||||
-- *********************
|
||||
-- * FEATURE FUNCTIONS *
|
||||
-- *********************
|
||||
|
||||
|
||||
--Form functions
|
||||
|
||||
-- Reinit makes sure the enums are reinitialized, ie contain all creatures (respectively herbivores or carnivores) from
|
||||
-- the desert ecosystem and with a level between 1 and 50.
|
||||
local function reinit(form, creature)
|
||||
if form == nil then
|
||||
debugInfo("Reinit impossible: nil form")
|
||||
return
|
||||
end
|
||||
|
||||
local creatureEnum = form:find(creature.."Race")
|
||||
if creatureEnum == nil then
|
||||
debugInfo("Reinit impossible: can't find "..creature.."Race enum")
|
||||
return
|
||||
end
|
||||
creatureEnum:resetTexts()
|
||||
|
||||
local creaturePalette = {}
|
||||
if creature == "Carnivore" then
|
||||
creaturePalette = r2.Palette.Entries.creature.creatures_predators.instances
|
||||
else
|
||||
creaturePalette = r2.Palette.Entries.creature.creatures_passive.instances
|
||||
end
|
||||
|
||||
local k, v = next(creaturePalette, nil)
|
||||
while k do
|
||||
if r2.isInPalette(v.Id) then
|
||||
local paletteElt = r2.getPaletteElement(v.Id)
|
||||
if paletteElt and paletteElt.RingAccess and
|
||||
r2.RingAccess.testAccess(paletteElt.RingAccess) then
|
||||
|
||||
if paletteElt.Ecosystem == "Desert" and paletteElt.Level >= 1 and paletteElt.Level <= 50 then
|
||||
creatureEnum:addText(ucstring(i18n.get(v.Translation)))
|
||||
end
|
||||
end
|
||||
end
|
||||
k, v = next(creaturePalette, k)
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns the chosen bases from the form before creating the components.
|
||||
local function getBase(creature, form)
|
||||
if (form == nil) then
|
||||
debugInfo("getBase: form is nil")
|
||||
return
|
||||
end
|
||||
|
||||
local creaturePalette = {}
|
||||
if creature == "Carnivore" then
|
||||
creaturePalette = r2.Palette.Entries.creature.creatures_predators.instances
|
||||
else
|
||||
creaturePalette = r2.Palette.Entries.creature.creatures_passive.instances
|
||||
end
|
||||
|
||||
local creatureEnum = form:find(creature.."Race")
|
||||
local race = creatureEnum.selection_text
|
||||
|
||||
local k, v = next(creaturePalette, nil)
|
||||
while k do
|
||||
local name = i18n.get(v.Translation):toUtf8()
|
||||
if name == race then
|
||||
return v.Id, name
|
||||
end
|
||||
k, v = next(creaturePalette, k)
|
||||
end
|
||||
end
|
||||
|
||||
-- When the selected ecosystem or level changes, the corresponding creature combobox is updated.
|
||||
local function updateEnum(creature)
|
||||
local currentForm = r2.CurrentForm
|
||||
if (currentForm == nil) then
|
||||
debugInfo("UpdatePredators: r2.CurrentForm is nil")
|
||||
return
|
||||
end
|
||||
|
||||
local creatureEnum = currentForm:find(creature.."Race")
|
||||
local ecoEnum = currentForm:find(creature.."Ecosystem")
|
||||
local currentEco = ecoEnum.selection_text
|
||||
if currentEco == "Lakes" then
|
||||
currentEco = "Lacustre"
|
||||
end
|
||||
|
||||
local levelEnum = currentForm:find(creature.."Level")
|
||||
local levelRange = levelEnum.selection + 1
|
||||
local levelMin
|
||||
local levelMax
|
||||
if levelRange == 0 then
|
||||
levelMin = 1
|
||||
levelMax = 250
|
||||
else
|
||||
levelMin = (levelRange - 1) * 50 + 1
|
||||
levelMax = levelMin + 49
|
||||
end
|
||||
|
||||
creatureEnum:resetTexts()
|
||||
|
||||
local creaturePalette = {}
|
||||
if creature == "Carnivore" then
|
||||
creaturePalette = r2.Palette.Entries.creature.creatures_predators.instances
|
||||
else
|
||||
creaturePalette = r2.Palette.Entries.creature.creatures_passive.instances
|
||||
end
|
||||
|
||||
local k, v = next(creaturePalette, nil)
|
||||
while k do
|
||||
if r2.isInPalette(v.Id) then
|
||||
local paletteElt = r2.getPaletteElement(v.Id)
|
||||
if paletteElt and paletteElt.RingAccess and
|
||||
r2.RingAccess.testAccess(paletteElt.RingAccess) then
|
||||
if paletteElt.Ecosystem == currentEco and paletteElt.Level >= levelMin and paletteElt.Level <= levelMax then
|
||||
creatureEnum:addText(ucstring(i18n.get(v.Translation)))
|
||||
end
|
||||
end
|
||||
end
|
||||
k, v = next(creaturePalette, k)
|
||||
end
|
||||
end
|
||||
|
||||
-- Calls update function for the carnivores combobox.
|
||||
local function updateCarnivores(form)
|
||||
updateEnum("Carnivore")
|
||||
end
|
||||
|
||||
-- Calls update function for the herbivores combobox.
|
||||
local function updateHerbivores(form)
|
||||
updateEnum("Herbivore")
|
||||
end
|
||||
|
||||
local function resetForm()
|
||||
|
||||
local currentForm = r2:getForm("Fauna_Form")
|
||||
assert(currentForm)
|
||||
|
||||
do
|
||||
local creature = "Carnivore"
|
||||
local ecoEnum = currentForm:find(creature.."Ecosystem")
|
||||
ecoEnum.selection_text= "Desert"
|
||||
local levelEnum = currentForm:find(creature.."Level")
|
||||
levelEnum.selection = 0
|
||||
updateCarnivores(form)
|
||||
end
|
||||
do
|
||||
local creature = "Herbivore"
|
||||
local ecoEnum = currentForm:find(creature.."Ecosystem")
|
||||
ecoEnum.selection_text= "Desert"
|
||||
local levelEnum = currentForm:find(creature.."Level")
|
||||
levelEnum.selection = 0
|
||||
updateHerbivores(form)
|
||||
end
|
||||
|
||||
end
|
||||
--
|
||||
-- The creation form lets the DM choose the type of creatures and their number.
|
||||
-- Like the palette tree, the available creatures are filtered by their ecosystems and level.
|
||||
-- Each life cycle duration is defined in the properties panel of the creature component.
|
||||
-- The creation form will return the chosen creature base when ok button is pressed.
|
||||
-- The form is reinitialized each time the ok or cancel button is pressed.
|
||||
--
|
||||
feature.registerForms = function()
|
||||
|
||||
-- Initializes the creature comboboxes. Default ecosystem is desert and default level range is 1-50.
|
||||
local function init(creature)
|
||||
local initEnum = {}
|
||||
|
||||
local creaturePalette = {}
|
||||
if not r2.Palette.Entries.creature then
|
||||
return -- special case for the 'light' palette
|
||||
end
|
||||
if creature == "Carnivore" then
|
||||
creaturePalette = r2.Palette.Entries.creature.creatures_predators.instances
|
||||
else
|
||||
creaturePalette = r2.Palette.Entries.creature.creatures_passive.instances
|
||||
end
|
||||
local k, v = next(creaturePalette, nil)
|
||||
while k do
|
||||
if r2.isInPalette(v.Id) then
|
||||
local paletteElt = r2.getPaletteElement(v.Id)
|
||||
if paletteElt then
|
||||
if paletteElt.Ecosystem == "Desert" and paletteElt.Level >= 1 and paletteElt.Level <= 50 then
|
||||
table.insert(initEnum, i18n.get(v.Translation))
|
||||
end
|
||||
end
|
||||
end
|
||||
k, v = next(creaturePalette, k)
|
||||
end
|
||||
|
||||
return initEnum
|
||||
end
|
||||
|
||||
r2.Forms.Fauna_Form =
|
||||
{
|
||||
Caption = "uiR2EdFauna",
|
||||
Prop =
|
||||
{
|
||||
{Name="CarnivoresCount", Type="Number", Category="uiR2EDRollout_Carnivores", Min="1", Max="12", Default="3", Translation="uiR2EDProp_Count"},
|
||||
{Name="CarnivoreRace", Type="Number", Category="uiR2EDRollout_Carnivores", WidgetStyle="EnumDropDown", Translation="uiR2EDProp_Race",
|
||||
Enum= init("Carnivore")
|
||||
},
|
||||
{Name="CarnivoreEcosystem", Type="Number", Category="uiR2EDRollout_Carnivores", WidgetStyle="EnumDropDown", Translation="uiR2EDProp_Ecosystem",
|
||||
Enum={"Desert", "Forest", "Jungle", "Lakes", "PrimeRoots", "Goo"},
|
||||
onChange = updateCarnivores
|
||||
},
|
||||
{Name="CarnivoreLevel", Type="Number", Category="uiR2EDRollout_Carnivores", WidgetStyle="EnumDropDown", Translation="uiR2EDProp_Level",
|
||||
Enum={"1-50", "51-100", "101-150", "151-200", "201-250"},
|
||||
onChange = updateCarnivores
|
||||
},
|
||||
{Name="HerbivoresCount", Type="Number", Category="uiR2EDRollout_Herbivores", Min="1", Max="12", Default="7", Translation="uiR2EDProp_Count"},
|
||||
{Name="HerbivoreRace", Type="Number", Category="uiR2EDRollout_Herbivores", WidgetStyle="EnumDropDown", Translation="uiR2EDProp_Race",
|
||||
Enum= init("Herbivore")
|
||||
},
|
||||
{Name="HerbivoreEcosystem", Type="Number", Category="uiR2EDRollout_Herbivores", WidgetStyle="EnumDropDown", Translation="uiR2EDProp_Ecosystem",
|
||||
Enum={"Desert", "Forest", "Jungle", "Lakes", "PrimeRoots", "Goo"},
|
||||
onChange = updateHerbivores
|
||||
},
|
||||
{Name="HerbivoreLevel", Type="Number", Category="uiR2EDRollout_Herbivores", WidgetStyle="EnumDropDown", Translation="uiR2EDProp_Level",
|
||||
Enum={"1-50", "51-100", "101-150", "151-200", "201-250"},
|
||||
onChange = updateHerbivores
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
-- **************
|
||||
-- * COMPONENTS *
|
||||
-- **************
|
||||
|
||||
local FaunaRegionRadius = 5
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- CREATURE COMPONENT
|
||||
|
||||
feature.Components.Creature =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="Creature",
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = {},
|
||||
|
||||
Events = {},
|
||||
|
||||
Conditions = {},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table", Visible= false},
|
||||
{Name="Ghosts", Type = "Table", Visible = false },
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="CrittersCount", Type="String", WidgetStyle="StaticText", Translation="uiR2EDProp_CrittersCount"},
|
||||
{Name="RaceBase", Type="String", WidgetStyle="StaticText", Visible=false},
|
||||
{Name="RaceName", Type="String", WidgetStyle="StaticText", Translation="uiR2EDProp_Race"},
|
||||
{Name="SleepZone", Type="RefId", PickFuntion = "r2:canPickZone", SetRefIdFunction = "r2:setZoneRefIdTarget", Translation="uiR2EDProp_SleepZone"},
|
||||
{Name="FoodZone", Type="RefId", PickFuntion = "r2:canPickZone", SetRefIdFunction = "r2:setZoneRefIdTarget", Translation="uiR2EDProp_FoodZone"},
|
||||
{Name="FoodDuration", Type="Number", Category="uiR2EDRollout_LifeCyclesInSeconds", Min="1", Max="40000", Default="30", Translation="uiR2EDProp_FoodDuration"},
|
||||
{Name="SleepDuration", Type="Number", Category="uiR2EDRollout_LifeCyclesInSeconds", Min="1", Max="40000", Default="30", Translation="uiR2EDProp_SleepDuration"},
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
this:createGhostComponents()
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
--local rtNpcGrp = r2.Translator.getRtGroup(context, context.Feature.InstanceId)
|
||||
--local aiState = r2.newComponent("RtAiState")
|
||||
--aiState.AiActivity = "normal"
|
||||
--table.insert(context.RtAct.AiStates, aiState)
|
||||
--table.insert(aiState.Children, rtNpcGrp.Id)
|
||||
--local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
--r2.Translator.translateEventHandlers( context, this, this.Behavior.Actions, rtNpcGrp)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
--local instance = r2:getInstanceFromId(context.Feature.InstanceId);
|
||||
--r2.Translator.registerManager(context, context.Feature)
|
||||
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end
|
||||
}
|
||||
|
||||
local component = feature.Components.Creature
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
return nil, nil, nil
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {},
|
||||
["Events"] = {}
|
||||
}
|
||||
return nil--logicTranslations
|
||||
end
|
||||
|
||||
component.createGhostComponents= function(this, act)
|
||||
local comp = this
|
||||
local leader = nil
|
||||
local herd = nil
|
||||
local isHerbivore
|
||||
|
||||
if act then
|
||||
herd = r2.newComponent("NpcGrpFeature")
|
||||
end
|
||||
|
||||
if comp._Seed then math.randomseed(comp._Seed) end
|
||||
|
||||
do
|
||||
local x = comp.Position.x
|
||||
local y = comp.Position.y
|
||||
local n = comp._CrittersCount
|
||||
local pas = (2 * math.pi)/n
|
||||
local r = (n/(2*math.pi))+2
|
||||
for i = 1, n do
|
||||
local npc = r2.newComponent("Npc")
|
||||
npc.Name = comp.RaceName
|
||||
npc.Base = comp.RaceBase --"palette.entities.creatures.cbadc1"
|
||||
|
||||
|
||||
local rr = FaunaRegionRadius - 1--r + math.random() * 5
|
||||
npc.Position.x = (rr-1) * math.cos((i-1)*pas)
|
||||
npc.Position.y = (rr-1) * math.sin((i-1)*pas)
|
||||
npc.Position.z = 0
|
||||
npc.Angle = 2 * math.pi * math.random(0, 100)/100.0
|
||||
|
||||
if i == 1 then
|
||||
local manager = r2:getInstanceFromId(comp.ManagerId)
|
||||
assert(manager)
|
||||
if manager.Active == 1 then npc.AutoSpawn = 1 else npc.AutoSpawn = 0 end
|
||||
leader = npc
|
||||
r2.requestSetGhostNode(comp.InstanceId, "_LeaderId",npc.InstanceId)
|
||||
isHerbivore = r2.getPropertyValue(npc, "IsHerbivore")
|
||||
end
|
||||
|
||||
if act then -- TestMode --
|
||||
table.insert(herd.Components, npc)
|
||||
else
|
||||
r2.requestInsertGhostNode(this.InstanceId, "Ghosts", -1, "", npc)
|
||||
r2:getInstanceFromId(npc.InstanceId).Selectable = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 2 wander sequences corresponding to the activities in both life zones attached to the herd
|
||||
do
|
||||
local sequence = r2.newComponent("ActivitySequence")
|
||||
|
||||
|
||||
table.insert(leader.Behavior.Activities, sequence)
|
||||
|
||||
sequence.Name = "Life Cycle"
|
||||
sequence.Repeating = 1
|
||||
|
||||
-- Wander in sleep zone
|
||||
local step = r2.newComponent("ActivityStep")
|
||||
table.insert(sequence.Components, step)
|
||||
step.Type = "None"
|
||||
step.Name = "Rest In Zone"
|
||||
step.Activity = "Rest In Zone"
|
||||
step.ActivityZoneId = r2.RefId(comp.SleepZone)
|
||||
|
||||
step.TimeLimit = "Few Sec"
|
||||
step.TimeLimitValue = tostring(comp.SleepDuration)
|
||||
|
||||
-- Wander in food zone
|
||||
local step = r2.newComponent("ActivityStep")
|
||||
table.insert(sequence.Components, step)
|
||||
step.Type = "None"
|
||||
|
||||
if isHerbivore == 1 then
|
||||
step.Name = "Feed In Zone"
|
||||
step.Activity = "Feed In Zone"
|
||||
else
|
||||
step.Name = "Hunt In Zone"
|
||||
step.Activity = "Hunt In Zone"
|
||||
end
|
||||
step.ActivityZoneId = r2.RefId(comp.FoodZone)
|
||||
|
||||
step.TimeLimit = "Few Sec"
|
||||
step.TimeLimitValue = tostring(comp.FoodDuration)
|
||||
|
||||
end
|
||||
|
||||
if act then
|
||||
comp.User._Herd = herd.InstanceId
|
||||
--herd.Name = r2:genInstanceName(i18n.get("uiR2EdFaunaFeature")):toUtf8()
|
||||
herd.InheritPos = 0
|
||||
herd.Position.x = comp.Position.x
|
||||
herd.Position.y = comp.Position.y
|
||||
r2.requestInsertGhostNode(act.InstanceId, "Features", -1, "", herd)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
component.createComponent = function(x, y, nbcritters, raceBase, raceName,
|
||||
sleepZoneId, foodZoneId)
|
||||
|
||||
|
||||
local comp = r2.newComponent("Creature")
|
||||
assert(comp)
|
||||
|
||||
--comp.Base = "palette.entities.botobjects.user_event"
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdCreatureComponent")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._CrittersCount= nbcritters
|
||||
comp.CrittersCount = tostring(nbcritters)
|
||||
comp.RaceBase = raceBase
|
||||
comp.RaceName = raceName
|
||||
|
||||
comp.SleepDuration = 30
|
||||
comp.FoodDuration = 30
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
comp.SleepZone = sleepZoneId
|
||||
comp.FoodZone = foodZoneId
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- FAUNA SYSTEM COMPONENT
|
||||
-- Fauna system containing 2 Creature components (herbivores & carnivores) and 3 life zones.
|
||||
feature.Components.Fauna =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="Fauna",
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
InEventUI = true,
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = {"activate", "deactivate"},
|
||||
|
||||
Events = {"deactivation", "activation"},
|
||||
|
||||
Conditions = {"is active", "is inactive"},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table", Visible = false},
|
||||
{Name="Ghosts", Type = "Table", Visible = false },
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Active", Type = "Number", WidgetStyle="Boolean", DefaultValue="1" },
|
||||
{Name="CarnivoresCount", Type="String", Category="uiR2EDRollout_Carnivores", WidgetStyle="StaticText", Translation="uiR2EDProp_Count"},
|
||||
{Name="CarnivoreBase", Type="String", Category="uiR2EDRollout_Carnivores", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="CarnivoreRace", Type="String", Category="uiR2EDRollout_Carnivores", WidgetStyle="StaticText", Translation="uiR2EDProp_Race"},
|
||||
{Name="HerbivoresCount", Type="String", Category="uiR2EDRollout_Herbivores", WidgetStyle="StaticText",Translation="uiR2EDProp_Count"},
|
||||
{Name="HerbivoreBase", Type="String", Category="uiR2EDRollout_Herbivores", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="HerbivoreRace", Type="String", Category="uiR2EDRollout_Herbivores", WidgetStyle="StaticText", Translation="uiR2EDProp_Race"},
|
||||
},
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end
|
||||
}
|
||||
|
||||
component = feature.Components.Fauna
|
||||
|
||||
|
||||
local FaunaRegionNumCorners = 6
|
||||
--local FaunaRegionRadius = 5
|
||||
local FaunaRegionOffsets = { { x = 10, y = 0 }, { x = -7, y = -7}, { x = 0, y = 10} }
|
||||
|
||||
|
||||
component.create = function()
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function paramsOk(resultTable, form)
|
||||
|
||||
|
||||
local carnivoreBase, carnivoreName = getBase("Carnivore", form)
|
||||
local herbivoreBase, herbivoreName = getBase("Herbivore", form)
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
|
||||
local carnCount = tonumber(resultTable["CarnivoresCount"])
|
||||
local herbCount = tonumber(resultTable["HerbivoresCount"])
|
||||
|
||||
|
||||
if not r2:checkAiQuota(carnCount + herbCount + 1) then return end
|
||||
|
||||
|
||||
if not x or not y or not carnivoreBase or not carnivoreName or not carnCount or not herbivoreBase
|
||||
or not herbivoreName or not herbCount
|
||||
then
|
||||
r2:doForm("Fauna_Form", resultTable , paramsOk, paramsCancel)
|
||||
resetForm()
|
||||
|
||||
printMsg("FaunaSystem: Failed to create component either because your scenario is full or because you don't yet have access to creatures of the level and ecosystem that you have selected")
|
||||
|
||||
return
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewFaunaFeatureAction"))
|
||||
local component = feature.Components.Fauna.createComponent(x, y, carnCount, carnivoreBase, carnivoreName,
|
||||
herbCount, herbivoreBase, herbivoreName)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
resetForm()
|
||||
end
|
||||
|
||||
local function paramsCancel(data, form)
|
||||
resetForm()
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'FaunaFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("Fauna") == 1 then
|
||||
r2.displayFeatureHelp("Fauna")
|
||||
end
|
||||
r2:doForm("Fauna_Form", {X=x, Y=y}, paramsOk, paramsCancel)
|
||||
resetForm()
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'FaunaFeature' position")
|
||||
end
|
||||
--r2:choosePos("object_component_user_event.creature", posOk, posCancel, "createFeatureFauna")
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
--r2:choosePos(creature, posOk, posCancel, "createFeatureFauna")
|
||||
|
||||
local polys = {}
|
||||
for p = 1, table.getn(FaunaRegionOffsets) do
|
||||
local poly = {}
|
||||
local step = 2 * math.pi / FaunaRegionNumCorners
|
||||
for k = 0, FaunaRegionNumCorners - 1 do
|
||||
table.insert(poly, CVector2f(FaunaRegionOffsets[p].x + FaunaRegionRadius * math.cos(k * step),
|
||||
FaunaRegionOffsets[p].y + FaunaRegionRadius * math.sin(k * step)))
|
||||
end
|
||||
table.insert(polys, poly)
|
||||
end
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureFauna",
|
||||
"curs_create.tga",
|
||||
"curs_stop.tga",
|
||||
polys, r2.PrimRender.ComponentRegionLook, r2.PrimRender.ComponentRegionInvalidLook)
|
||||
end
|
||||
|
||||
function component.getAiCost(this)
|
||||
if this.User.GhostDuplicate then return 0 end
|
||||
return r2.getAiCost(this) - 2
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- create the fauna system component by creating and inserting zones and creature component into its own components table.
|
||||
-- Generates a sleep zone and a food zone for the herbivores, and a sleep zone for the carnivores. The carnivore hunt zone is
|
||||
-- one of the herbivore zones (default is herbivore sleep zone).
|
||||
--
|
||||
component.createComponent = function(x, y, carnCount, carnivoreBase, carnivoresName,
|
||||
herbCount, herbivoreBase, herbivoresName)
|
||||
|
||||
local comp = r2.newComponent("Fauna")
|
||||
assert(comp)
|
||||
|
||||
--TODO: replace this milestone base by some default feature base
|
||||
comp.Base = "palette.entities.botobjects.user_event"
|
||||
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdFaunaFeature")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._CarnCount= carnCount
|
||||
comp.CarnivoresCount = tostring(carnCount)
|
||||
comp.CarnivoreBase = carnivoreBase
|
||||
comp.CarnivoreRace = tostring(carnivoresName)
|
||||
|
||||
comp._HerbCount= herbCount
|
||||
comp.HerbivoresCount = tostring(herbCount)
|
||||
comp.HerbivoreBase = herbivoreBase
|
||||
comp.HerbivoresName = herbivoresName
|
||||
comp.HerbivoreRace = tostring(herbivoresName)
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
-- Herbivore sleep zone
|
||||
local zoneSleep1 = r2.newComponent("Region")
|
||||
r2.Utils.createRegion(zoneSleep1, 0, 0, FaunaRegionRadius, FaunaRegionNumCorners)
|
||||
zoneSleep1.Deletable = 1
|
||||
zoneSleep1.Position.x = comp.Position.x + FaunaRegionOffsets[1].x
|
||||
zoneSleep1.Position.y = comp.Position.y + FaunaRegionOffsets[1].y
|
||||
zoneSleep1.Position.z = comp.Position.z
|
||||
zoneSleep1.InheritPos = 0
|
||||
zoneSleep1.Name = r2:genInstanceName(i18n.get("uiR2EDNameSleepRegion")):toUtf8()
|
||||
table.insert(comp.Components, zoneSleep1)
|
||||
|
||||
-- Carnivore sleep zone
|
||||
local zoneSleep2 = r2.newComponent("Region")
|
||||
r2.Utils.createRegion(zoneSleep2, 0, 0, FaunaRegionRadius, FaunaRegionNumCorners)
|
||||
zoneSleep2.Deletable = 1
|
||||
zoneSleep2.Position.x = comp.Position.x + FaunaRegionOffsets[2].x
|
||||
zoneSleep2.Position.y = comp.Position.y + FaunaRegionOffsets[2].y
|
||||
zoneSleep2.Position.z = comp.Position.z
|
||||
zoneSleep2.InheritPos = 0
|
||||
zoneSleep2.Name = r2:genInstanceName(i18n.get("uiR2EDNameSleepRegion")):toUtf8()
|
||||
table.insert(comp.Components, zoneSleep2)
|
||||
|
||||
--Herbivore sleep zone
|
||||
local zoneFood = r2.newComponent("Region")
|
||||
r2.Utils.createRegion(zoneFood, 0, 0, FaunaRegionRadius, FaunaRegionNumCorners)
|
||||
zoneFood.Deletable = 1
|
||||
zoneFood.Position.x = comp.Position.x + FaunaRegionOffsets[3].x
|
||||
zoneFood.Position.y = comp.Position.y + FaunaRegionOffsets[3].y
|
||||
zoneFood.Position.z = comp.Position.z
|
||||
zoneFood.InheritPos = 0
|
||||
zoneFood.Name = r2:genInstanceName(i18n.get("uiR2EDNameFoodRegion")):toUtf8()
|
||||
table.insert(comp.Components, zoneFood)
|
||||
|
||||
-- Herd of herbivores
|
||||
local herbivores = feature.Components.Creature.createComponent(zoneSleep1.Position.x, zoneSleep1.Position.y, herbCount, herbivoreBase,
|
||||
herbivoresName, zoneSleep1.InstanceId, zoneFood.InstanceId)
|
||||
herbivores.Name = i18n.get("uiR2EdHerbivores"):toUtf8()
|
||||
--herbivores.Position.x = zoneSleep1.Position.x--comp.Position.x + 10
|
||||
--herbivores.Position.y = zoneSleep1.Position.y--comp.Position.y + 10
|
||||
herbivores.InheritPos = 0
|
||||
--herbivores.Active = comp.Active
|
||||
herbivores.ManagerId = comp.InstanceId
|
||||
table.insert(comp.Components, herbivores)
|
||||
comp._HerbId = herbivores.InstanceId
|
||||
|
||||
-- Pack of carnivores
|
||||
local carnivores = feature.Components.Creature.createComponent(zoneSleep2.Position.x, zoneSleep2.Position.y, carnCount, carnivoreBase,
|
||||
carnivoresName, zoneSleep2.InstanceId, zoneSleep1.InstanceId)
|
||||
carnivores.Name = i18n.get("uiR2EdCarnivores"):toUtf8()
|
||||
carnivores.InheritPos = 0
|
||||
carnivores.ManagerId = comp.InstanceId
|
||||
table.insert(comp.Components, carnivores)
|
||||
comp._CarnId = carnivores.InstanceId
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local herbi = r2:getInstanceFromId(component._HerbId)
|
||||
assert(herbi)
|
||||
local herbivores = r2:getInstanceFromId(herbi.User._Herd)
|
||||
assert(herbivores)
|
||||
local rtHerbiGrp = r2.Translator.getRtGroup(context, herbivores.InstanceId)
|
||||
assert(rtHerbiGrp)
|
||||
|
||||
local carni = r2:getInstanceFromId(component._CarnId)
|
||||
assert(carni)
|
||||
local carnivores = r2:getInstanceFromId(carni.User._Herd)
|
||||
assert(carnivores)
|
||||
local rtCarniGrp = r2.Translator.getRtGroup(context, carnivores.InstanceId)
|
||||
assert(rtCarniGrp)
|
||||
|
||||
|
||||
if action.Action.Type == "deactivate" then
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 0)
|
||||
local action2 = r2.Translator.getNpcLogicActionDeactivate(herbivores, context, action, rtHerbiGrp)
|
||||
local action3 = r2.Translator.getNpcLogicActionDeactivate(carnivores, context, action, rtCarniGrp)
|
||||
local action4 = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 5)
|
||||
local multiaction = r2.Translator.createAction("multi_actions", {action1, action2, action3, action4})
|
||||
return multiaction, multiaction
|
||||
elseif (action.Action.Type == "activate") then
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 1)
|
||||
local action2 = r2.Translator.getNpcLogicActionActivate(herbivores, context, action, rtHerbiGrp)
|
||||
local action3 = r2.Translator.getNpcLogicActionActivate(carnivores, context, action, rtCarniGrp)
|
||||
local action4 = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 4)
|
||||
local multiaction = r2.Translator.createAction("multi_actions", {action1, action2, action3, action4})
|
||||
return multiaction, multiaction
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
local component = this
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {}
|
||||
r2.Translator.addActivationToTranslations(logicTranslations)
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdFaunaFeature")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "FaunaFeature")
|
||||
end
|
||||
|
||||
r2.Features["FaunaFeature"] = feature
|
||||
|
@ -1,487 +0,0 @@
|
||||
|
||||
r2.Features.GetItemFromSceneryObjectFeature = {}
|
||||
|
||||
local feature = r2.Features.GetItemFromSceneryObjectFeature
|
||||
|
||||
feature.Name="GetItemFromSceneryObjectFeature"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.GetItemFromSceneryObject =
|
||||
{
|
||||
--PropertySheetHeader = r2.getHelpButtonHeader("GetItemFromSceneryObject") ,
|
||||
BaseClass="LogicEntity",
|
||||
Name="GetItemFromSceneryObject",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "getItemFromSceneryObjectDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "trigger"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "has triggered", "has not triggered" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="SceneryObject", Type="RefId", PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget"},
|
||||
|
||||
{Name="ItemNumber", Type="Number", Category="uiR2EDRollout_ItemsToGive", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3"}, DefaultValue="3" },
|
||||
{Name="Item1Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="1", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item1Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(1) end},
|
||||
|
||||
|
||||
{Name="Item2Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item2Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(2) end},
|
||||
|
||||
{Name="Item3Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Item3Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(3) end},
|
||||
|
||||
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"}
|
||||
|
||||
},
|
||||
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
--pretranslate = function(this, context)
|
||||
-- r2.Translator.createAiGroup(this, context)
|
||||
--end,
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.GetItemFromSceneryObject
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbItems = self.ItemNumber + 1
|
||||
if index <= nbItems then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function component:pretranslate(context)
|
||||
if context.InteractingSceneryObjects then
|
||||
if self.SceneryObject and self.SceneryObject ~= "" then
|
||||
local scObj = r2:getInstanceFromId(self.SceneryObject)
|
||||
if scObj then
|
||||
--assert(scObj)
|
||||
table.insert(context.InteractingSceneryObjects, scObj.InstanceId)
|
||||
end
|
||||
end
|
||||
end
|
||||
r2.Translator.createAiGroup(self, context)
|
||||
end
|
||||
|
||||
|
||||
local getItemFromSceneryObjectDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = getItemFromSceneryObjectDisplayerTable.onAttrModified
|
||||
|
||||
function getItemFromSceneryObjectDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
if attributeName == "ItemNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbRefId = instance.ItemNumber + 1
|
||||
local i = 1
|
||||
while i <= 3 do
|
||||
if i > nbRefId then
|
||||
local name = "Item"..tostring(i).."Id"
|
||||
local qty = "Item"..tostring(i).."Qty"
|
||||
r2.requestSetNode(instance.InstanceId, name, r2.RefId(""))
|
||||
r2.requestSetNode(instance.InstanceId, qty, 0)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function getItemFromSceneryObjectDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function r2:getItemFromSceneryObjectDisplayer()
|
||||
return getItemFromSceneryObjectDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:getItems()
|
||||
local str = ""
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
local plotItemSheetId = plotItem.SheetId
|
||||
if str ~= "" then str = str ..";" end
|
||||
local name = r2.getSheetIdName(plotItemSheetId)
|
||||
str = str .. tostring(name)..":"..qt
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function component:textAdapter(text)
|
||||
local str = ""
|
||||
local items = {}
|
||||
local qts = {}
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
qts[id] = qt
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
items[id] = plotItem.Name
|
||||
else
|
||||
items[id] = ""
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
local str = text
|
||||
str=string.gsub (str, "<qt1>", tostring(qts[1]))
|
||||
str=string.gsub (str, "<qt2>", tostring(qts[2]))
|
||||
str=string.gsub (str, "<qt3>", tostring(qts[3]))
|
||||
str=string.gsub (str, "<item1>", tostring(items[1]))
|
||||
str=string.gsub (str, "<item2>", tostring(items[2]))
|
||||
str=string.gsub (str, "<item3>", tostring(items[3]))
|
||||
|
||||
local sceneryObjectName = ""
|
||||
if self.SceneryObject == nil then return end
|
||||
local sceneryObject = r2:getInstanceFromId(self.SceneryObject)
|
||||
if sceneryObject then
|
||||
sceneryObjectName = sceneryObject.Name
|
||||
end
|
||||
str=string.gsub(str, "<object_name>", tostring(sceneryObjectName))
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
if self.SceneryObject == nil then return end
|
||||
local sceneryObject = r2:getInstanceFromId(self.SceneryObject)
|
||||
if not sceneryObject then return end
|
||||
|
||||
local sceneryObjectGrp = r2.Translator.getRtGroup(context, sceneryObject.InstanceId)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
local items = self:getItems()
|
||||
|
||||
-----------------
|
||||
--Contextual text
|
||||
do
|
||||
if sceneryObject then
|
||||
local actionContextual = r2.Translator.createAction("give_item", rtGrp.Id, items, self:textAdapter(self.ContextualText))
|
||||
--local actionSetSelectStatus = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1)
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0, -- giver has been spoken to
|
||||
--r2.Translator.createAction("multi_actions", {actionContextual, actionSetSelectStatus}) )
|
||||
actionContextual))
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", sceneryObject, context, rtAction)
|
||||
end
|
||||
end
|
||||
|
||||
-------------------
|
||||
--Trigger
|
||||
if sceneryObject then
|
||||
--local rtSceneryObjectGrp = r2.Translator.getRtGroup(context, sceneryObject.InstanceId)
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, --if active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0, --and if the scenery object has been selected once by the player
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 6),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ) })
|
||||
))
|
||||
|
||||
--r2.Translator.translateAiGroupEvent("player_target_npc", sceneryObject, context, rtAction)
|
||||
r2.Translator.translateAiGroupEvent("user_event_1", self, context, rtAction)
|
||||
end
|
||||
|
||||
-------------------
|
||||
--Start of state
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- the scenery object hasn't been selected yet
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0 )
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3,rtAction4 } )
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
})
|
||||
);
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- Not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {action2, action3})
|
||||
--Autodeactivate after having triggered?
|
||||
r2.Translator.translateAiGroupEvent("user_event_6", self, context, rtAction)
|
||||
end
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
local prefix = ""
|
||||
|
||||
if rtNpcGrp.Id and rtNpcGrp.Id ~= "" then
|
||||
prefix = r2:getNamespace() .. rtNpcGrp.Id.."."
|
||||
end
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "has triggered" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1 );
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "has not triggered" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 0 );
|
||||
return action1, action1
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if event.Event.Type == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("GetItemFromSceneryObject")
|
||||
assert(comp)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdGetItemFromSceneryObject_ContextualText"):toUtf8()
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_request_item")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDGetItemFromSceneryObject")):toUtf8()
|
||||
comp.ItemNumber = 0
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
-- comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewGetItemFromSceneryObjectFeature"))
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("GetItemFromSceneryObject", 0)
|
||||
else r2.setDisplayInfo("GetItemFromSceneryObject", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.GetItemFromSceneryObject.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'GetItemFromSceneryObject' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'GetItemFromSceneryObject' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("GetItemFromSceneryObject") == 1 then
|
||||
r2.displayFeatureHelp("GetItemFromSceneryObject")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewGetItemFromSceneryObjectFeature"))
|
||||
local component = feature.Components.GetItemFromSceneryObject.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'GetItemFromSceneryObject' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_request_item.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureGetItemFromSceneryObject")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdGetItemFromSceneryObject")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "GetItemFromSceneryObject")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["has triggered"] = { menu=i18n.get( "uiR2Test0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Trigger" ):toUtf8()},
|
||||
["has not triggered"] = { menu=i18n.get( "uiR2Test0NotTrigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1NotTrigger" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["GetItemFromSceneryObject"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,543 +0,0 @@
|
||||
|
||||
r2.Features.GetItemFromSceneryObjectTaskStep = {}
|
||||
|
||||
local feature = r2.Features.GetItemFromSceneryObjectTaskStep
|
||||
|
||||
feature.Name="GetItemFromSceneryObjectTaskStep"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.GetItemFromSceneryObjectTaskStep =
|
||||
{
|
||||
--PropertySheetHeader = r2.getHelpButtonHeader("getItemFromSceneryObjectTaskStep") ,
|
||||
BaseClass="LogicEntity",
|
||||
Name="GetItemFromSceneryObjectTaskStep",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "getItemFromSceneryObjectDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "success"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is succeeded", "in progress" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="SceneryObject", Type="RefId", PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
|
||||
{Name="ItemNumber", Type="Number", Category="uiR2EDRollout_ItemsToGive", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3"}, DefaultValue="3" },
|
||||
{Name="Item1Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="1", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item1Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(1) end},
|
||||
|
||||
|
||||
{Name="Item2Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item2Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(2) end},
|
||||
|
||||
{Name="Item3Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Item3Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(3) end},
|
||||
|
||||
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="NotValidatedText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"}
|
||||
|
||||
},
|
||||
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
--pretranslate = function(this, context)
|
||||
-- r2.Translator.createAiGroup(this, context)
|
||||
--end,
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.GetItemFromSceneryObjectTaskStep
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbItems = self.ItemNumber + 1
|
||||
if index <= nbItems then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function component:pretranslate(context)
|
||||
if context.InteractingSceneryObjects then
|
||||
if self.SceneryObject and self.SceneryObject ~= "" then
|
||||
local scObj = r2:getInstanceFromId(self.SceneryObject)
|
||||
if scObj then
|
||||
table.insert(context.InteractingSceneryObjects, scObj.InstanceId)
|
||||
end
|
||||
end
|
||||
end
|
||||
r2.Translator.createAiGroup(self, context)
|
||||
end
|
||||
|
||||
|
||||
local getItemFromSceneryObjectDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = getItemFromSceneryObjectDisplayerTable.onAttrModified
|
||||
|
||||
function getItemFromSceneryObjectDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
if attributeName == "ItemNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbRefId = instance.ItemNumber + 1
|
||||
local i = 1
|
||||
while i <= 3 do
|
||||
if i > nbRefId then
|
||||
local name = "Item"..tostring(i).."Id"
|
||||
local qty = "Item"..tostring(i).."Qty"
|
||||
r2.requestSetNode(instance.InstanceId, name, r2.RefId(""))
|
||||
r2.requestSetNode(instance.InstanceId, qty, 0)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function getItemFromSceneryObjectDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function r2:getItemFromSceneryObjectDisplayer()
|
||||
return getItemFromSceneryObjectDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:getItems()
|
||||
local str = ""
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
local plotItemSheetId = plotItem.SheetId
|
||||
if str ~= "" then str = str ..";" end
|
||||
local name = r2.getSheetIdName(plotItemSheetId)
|
||||
str = str .. tostring(name)..":"..qt
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function component:textAdapter(text)
|
||||
local str = ""
|
||||
local items = {}
|
||||
local qts = {}
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
qts[id] = qt
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
items[id] = plotItem.Name
|
||||
else
|
||||
items[id] = ""
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
local str = text
|
||||
str=string.gsub (str, "<qt1>", tostring(qts[1]))
|
||||
str=string.gsub (str, "<qt2>", tostring(qts[2]))
|
||||
str=string.gsub (str, "<qt3>", tostring(qts[3]))
|
||||
str=string.gsub (str, "<item1>", tostring(items[1]))
|
||||
str=string.gsub (str, "<item2>", tostring(items[2]))
|
||||
str=string.gsub (str, "<item3>", tostring(items[3]))
|
||||
|
||||
local sceneryObjectName = ""
|
||||
if self.SceneryObject == nil then return end
|
||||
local sceneryObject = r2:getInstanceFromId(self.SceneryObject)
|
||||
if sceneryObject then
|
||||
sceneryObjectName = sceneryObject.Name
|
||||
end
|
||||
str=string.gsub(str, "<object_name>", tostring(sceneryObjectName))
|
||||
|
||||
local giverName = ""
|
||||
if self.MissionGiver == nil then return end
|
||||
local missionGiver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if missionGiver then
|
||||
giverName = missionGiver.Name
|
||||
end
|
||||
str=string.gsub(str, "<mission_giver>", tostring(giverName))
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
if not self.SceneryObject or self.SceneryObject == "" then return end
|
||||
if not self.MissionGiver or self.MissionGiver == "" then return end
|
||||
|
||||
local sceneryObject = r2:getInstanceFromId(self.SceneryObject)
|
||||
if not sceneryObject then return end
|
||||
|
||||
local sceneryObjectGrp = r2.Translator.getRtGroup(context, sceneryObject.InstanceId)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
local items = self:getItems()
|
||||
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
|
||||
-----------------
|
||||
--Contextual text
|
||||
do
|
||||
if sceneryObject then
|
||||
local actionContextual = r2.Translator.createAction("give_item", rtGrp.Id, items, self:textAdapter(self.ContextualText))
|
||||
--local actionSetSelectStatus = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2)
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, -- giver has been spoken to
|
||||
actionContextual))--r2.Translator.createAction("multi_actions", {actionContextual, actionSetSelectStatus}) )
|
||||
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", sceneryObject, context, rtAction)
|
||||
end
|
||||
end
|
||||
|
||||
-------------------
|
||||
--Mission text
|
||||
if giver then
|
||||
local actionValidation = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, --giver already said mission text
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.NotValidatedText), rtGiverGrp.Id ..":"..giver.Name))
|
||||
|
||||
local actionMission = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0, --giver didn't say mission text yet
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.MissionText), rtGiverGrp.Id ..":"..giver.Name),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ), }))
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("multi_actions", {actionValidation, actionMission}))
|
||||
|
||||
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, rtAction)
|
||||
end
|
||||
|
||||
-------------------
|
||||
--Succcess
|
||||
if sceneryObject then
|
||||
local rtSceneryObjectGrp = r2.Translator.getRtGroup(context, sceneryObject.InstanceId)
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, --if active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, --and if the scenery object has been selected once by the player
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2 ),
|
||||
r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 6),
|
||||
})
|
||||
))
|
||||
|
||||
|
||||
|
||||
--r2.Translator.translateAiGroupEvent("player_target_npc", sceneryObject, context, rtAction)
|
||||
r2.Translator.translateAiGroupEvent("user_event_1", self, context, rtAction)
|
||||
end
|
||||
|
||||
-------------------
|
||||
--Start of state
|
||||
do
|
||||
local action = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 7)
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- the scenery object hasn't been selected yet
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0 )
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3,rtAction4 } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_7", self, context, rtAction)
|
||||
end
|
||||
|
||||
--activation
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- the scenery object hasn't been selected yet
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0 )
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3,rtAction4 } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_4", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
--trigger (if not repeatable, deactivation)
|
||||
do
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
})
|
||||
);
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- Not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {action2, action3})
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_6", self, context, rtAction)
|
||||
end
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
local prefix = ""
|
||||
|
||||
if rtNpcGrp.Id and rtNpcGrp.Id ~= "" then
|
||||
prefix = r2:getNamespace() .. rtNpcGrp.Id.."."
|
||||
end
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "in progress" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v2", 1 );
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("dynamic_if", prefix.."v3 == 1");
|
||||
return action1, action1
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if event.Event.Type == "success" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("GetItemFromSceneryObjectTaskStep")
|
||||
assert(comp)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdGetItemFromSceneryObjectTaskStep_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdGetItemFromSceneryObjectTaskStep_MissionText"):toUtf8()
|
||||
local notValidatedText = i18n.get("uiR2EdGetItemFromSceneryObjectTaskStep_NotValidatedText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdGetItemFromSceneryObjectTaskStep_BroadcastText"):toUtf8()
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_request_item")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDGetItemFromSceneryObjectTaskStep")):toUtf8()
|
||||
comp.ItemNumber = 0
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.NotValidatedText = notValidatedText
|
||||
comp.BroadcastText = broadcastText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
comp.ItemNumber = 0
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'getItemFromSceneryObjectTaskStep' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("GetItemFromSceneryObjectTaskStep") == 1 then
|
||||
r2.displayFeatureHelp("GetItemFromSceneryObjectTaskStep")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewGetItemFromSceneryObjectTaskStep"))
|
||||
local component = feature.Components.GetItemFromSceneryObjectTaskStep.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'getItemFromSceneryObjectTaskStep' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_request_item.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureGetItemFromSceneryObject")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdGetItemFromSceneryObjectTaskStep")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "GetItemFromSceneryObjectTaskStep")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["success"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
["in progress"] = { menu=i18n.get( "uiR2Test0InProgress" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1InProgress" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["GetItemFromSceneryObjectTaskStep"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,516 +0,0 @@
|
||||
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdGiveItem --
|
||||
-- CreationFrom : uiR2EdGiveItemParameters
|
||||
|
||||
|
||||
r2.Features.GiveItemFeature = {}
|
||||
|
||||
local feature = r2.Features.GiveItemFeature
|
||||
|
||||
feature.Name="GiveItemFeature"
|
||||
|
||||
feature.Description="A feature that allows a NPC to give some item(s) to the player"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.GiveItem =
|
||||
{
|
||||
--PropertySheetHeader = r2.getHelpButtonHeader("GiveItem") ,
|
||||
BaseClass="LogicEntity",
|
||||
Name="GiveItem",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "giveItemDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = { "activation", "deactivation", "mission asked", "succeeded"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is succeeded" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
|
||||
{Name="ItemNumber", Type="Number", Category="uiR2EDRollout_ItemsToGive", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3"}, DefaultValue="3" },
|
||||
{Name="Item1Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="1", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item1Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(1) end},
|
||||
|
||||
|
||||
{Name="Item2Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item2Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(2) end},
|
||||
|
||||
{Name="Item3Qty", Type="Number", Category="uiR2EDRollout_ItemsToGive", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Item3Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToGive", Visible= function(this) return this:displayRefId(3) end},
|
||||
|
||||
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100"},
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"}
|
||||
|
||||
},
|
||||
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.GiveItem
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbItems = self.ItemNumber + 1
|
||||
if index <= nbItems then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local giveItemDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = giveItemDisplayerTable.onAttrModified
|
||||
|
||||
function giveItemDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
if attributeName == "ItemNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbRefId = instance.ItemNumber + 1
|
||||
local i = 1
|
||||
while i <= 3 do
|
||||
if i > nbRefId then
|
||||
local name = "Item"..tostring(i).."Id"
|
||||
local qty = "Item"..tostring(i).."Qty"
|
||||
r2.requestSetNode(instance.InstanceId, name, r2.RefId(""))
|
||||
r2.requestSetNode(instance.InstanceId, qty, 0)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function giveItemDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function r2:giveItemDisplayer()
|
||||
return giveItemDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:getItems()
|
||||
local str = ""
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
local plotItemSheetId = plotItem.SheetId
|
||||
if str ~= "" then str = str ..";" end
|
||||
local name = r2.getSheetIdName(plotItemSheetId)
|
||||
str = str .. tostring(name)..":"..qt
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function component:textAdapter(text)
|
||||
local str = ""
|
||||
local items = {}
|
||||
local qts = {}
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
qts[id] = qt
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
items[id] = plotItem.Name
|
||||
else
|
||||
items[id] = ""
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
local str = text
|
||||
str=string.gsub (str, "<qt1>", tostring(qts[1]))
|
||||
str=string.gsub (str, "<qt2>", tostring(qts[2]))
|
||||
str=string.gsub (str, "<qt3>", tostring(qts[3]))
|
||||
str=string.gsub (str, "<item1>", tostring(items[1]))
|
||||
str=string.gsub (str, "<item2>", tostring(items[2]))
|
||||
str=string.gsub (str, "<item3>", tostring(items[3]))
|
||||
|
||||
local mission_giver = ""
|
||||
if self.MissionGiver == nil then return end
|
||||
local npc = r2:getInstanceFromId(self.MissionGiver)
|
||||
if npc then
|
||||
mission_giver = npc.Name
|
||||
end
|
||||
str=string.gsub(str, "<mission_giver>", tostring(mission_giver))
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
if self.MissionGiver == nil then return end
|
||||
local npc = r2:getInstanceFromId(self.MissionGiver)
|
||||
if not npc then return end
|
||||
|
||||
local npcGrp = r2.Translator.getRtGroup(context, npc.InstanceId)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
local items = self:getItems()
|
||||
|
||||
do
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.MissionText), npcGrp.Id ..":"..npc.Name);
|
||||
r2.Translator.createAction("give_item", rtGrp.Id, items, self:textAdapter(self.ContextualText)),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 2)
|
||||
})
|
||||
)
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", npc, context, rtAction)
|
||||
end
|
||||
|
||||
do
|
||||
local action = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 7)
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- Success
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_7", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- Success
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_4", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
local action1 = r2.Translator.createAction("npc_say", self:textAdapter(self.MissionSucceedText), npcGrp.Id ..":"..npc.Name);
|
||||
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 )
|
||||
})
|
||||
);
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- Not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) )
|
||||
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {action1, action2, action3, actionBroadcast})
|
||||
r2.Translator.translateAiGroupEvent("user_event_1", self, context, rtAction)
|
||||
|
||||
end
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
|
||||
|
||||
|
||||
|
||||
-- ()receiveMissionItems("system_mp.sitem:2;system_mp_choice.sitem:1;system_mp_supreme.sitem:3", "Give some stuff hé!", @groupToNotify);
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v2", 1);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "mission asked" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 1)
|
||||
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("GiveItem")
|
||||
assert(comp)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdGiveItem_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdGiveItem_MissionText"):toUtf8()
|
||||
local missionSucceedText = i18n.get("uiR2EdGiveItem_MissionSucceededText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdGiveItem_BroadcastText"):toUtf8()
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_request_item")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDGiveItem")):toUtf8()
|
||||
|
||||
comp.ItemNumber = 0
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.MissionSucceedText = missionSucceedText
|
||||
comp.BroadcastText = broadcastText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
-- comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewGiveItemFeature"))
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("GiveItemForm", 0)
|
||||
else r2.setDisplayInfo("GiveItemForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.GiveItem.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'GiveItem' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'GiveItem' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("GiveItem") == 1 then
|
||||
r2.displayFeatureHelp("GiveItem")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewGiveItemFeature"))
|
||||
local component = feature.Components.GiveItem.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'GiveItem' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_request_item.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureGiveItem")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdGiveItem")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "GiveItem")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()}
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["mission asked"] = { menu=i18n.get( "uiR2Event0MissionGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MissionGiven" ):toUtf8()},
|
||||
["wait validation"] = { menu=i18n.get( "uiR2Event0TaskWaitValidation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskWaitValidation" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["GiveItem"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,290 +0,0 @@
|
||||
|
||||
r2.Features.HiddenChest = {}
|
||||
|
||||
local feature = r2.Features.HiddenChest
|
||||
|
||||
feature.Name="HiddenChest"
|
||||
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
local classHiddenChestVersion = 1
|
||||
|
||||
feature.Components.HiddenChest =
|
||||
{
|
||||
--PropertySheetHeader = r2.getDisplayButtonHeader("r2.events:openEditor()", "uiR2EdEditEventsButton"),
|
||||
BaseClass="EasterEgg",
|
||||
Name="HiddenChest",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
Version=classHiddenChestVersion ,
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
ApplicableActions = {"activate", "deactivate", "trigger"},
|
||||
Events = {"activation", "deactivation", "trigger"},
|
||||
Conditions = {"is active", "is inactive"},
|
||||
TextContexts = {},
|
||||
TextParameters = {},
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="TriggerOn", Type="Number", WidgetStyle="EnumDropDown", Translation="uiR2EdProp_TriggerOn",
|
||||
Enum={"Leaves the zone", "Enters the zone"},
|
||||
},
|
||||
},
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
local eggId = this:getEggId(context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
local eggId = this:getEggId(context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end,
|
||||
|
||||
updateVersion = function(this, scenarioValue, currentValue )
|
||||
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
local component = feature.Components.HiddenChest
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if action.Action.Type == "trigger" then
|
||||
local actionTrigger = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6)
|
||||
local actionSpawn = component:createActionActivateEasterEgg(context)
|
||||
local retAction = r2.Translator.createAction("condition_if", r2:getNamespace()..rtNpcGrp.Id..".Active == 1",
|
||||
r2.Translator.createAction("multi_actions", {actionTrigger, actionSpawn})
|
||||
)
|
||||
return retAction, retAction
|
||||
elseif (action.Action.Type == "activate") then
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 1)
|
||||
local action2 = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 4)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
elseif (action.Action.Type == "deactivate") then
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 0)
|
||||
local action2 = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 5)
|
||||
--local action3 = component:createActionDeactivateEasterEgg(context)
|
||||
--local retAction = r2.Translator.createAction("multi_actions", {action1, action2, action3})
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
end
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if tostring(event.Event.Type) == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createGhostComponents= function(this, act)
|
||||
|
||||
local comp = this
|
||||
|
||||
local zoneTrigger = r2:getInstanceFromId(comp._ZoneId)
|
||||
assert(zoneTrigger)
|
||||
|
||||
do
|
||||
local type = "On Player Left"
|
||||
if comp.TriggerOn == 1 then
|
||||
type = "On Player Arrived"
|
||||
end
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = type
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = type
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(comp.InstanceId)
|
||||
action.Action.Type = "trigger"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = zoneTrigger.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
|
||||
end
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "activation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "activation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(zoneTrigger.InstanceId)
|
||||
action.Action.Type = "activate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = this.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "deactivation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "deactivation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(zoneTrigger.InstanceId)
|
||||
action.Action.Type = "deactivate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = this.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("HiddenChest")
|
||||
assert(comp)
|
||||
assert(comp.Position)
|
||||
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdHiddenChest")):toUtf8()
|
||||
comp.Base = "palette.entities.botobjects.chest_wisdom_std_sel"
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp.CompareClass = true
|
||||
|
||||
comp.ItemNumber = 0
|
||||
|
||||
local zoneTrigger = r2.Features["ZoneTrigger"].Components.ZoneTrigger.createComponent(x + 3, y + 3)
|
||||
zoneTrigger.Name = comp.Name.." "..i18n.get("uiR2EdZoneTrigger"):toUtf8()--r2:genInstanceName(i18n.get("uiR2EdZoneTrigger")):toUtf8()
|
||||
zoneTrigger.InheritPos = 0
|
||||
zoneTrigger.Deletable = false
|
||||
table.insert(comp.Components, zoneTrigger)
|
||||
comp._ZoneId = zoneTrigger.InstanceId
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function posOk(x, y, z)
|
||||
debugInfo("Validate creation of an HiddenChest.")
|
||||
if r2.mustDisplayInfo("HiddenChest") == 1 then
|
||||
r2.displayFeatureHelp("HiddenChest")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewHiddenChestFeatureAction"))
|
||||
local component = feature.Components.HiddenChest.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function posCancel() end
|
||||
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureHiddenChest")
|
||||
end
|
||||
|
||||
|
||||
component.initLogicEntitiesInstancesMenu = function(this, subMenu, calledFunction)
|
||||
|
||||
local entitiesTable = r2.Scenario:getAllInstancesByType(this.Name)
|
||||
for key, entity in pairs(entitiesTable) do
|
||||
local uc_name = ucstring()
|
||||
uc_name:fromUtf8(entity.Name)
|
||||
subMenu:addLine(uc_name, "lua", calledFunction.."('".. entity.InstanceId .."')", entity.InstanceId)
|
||||
end
|
||||
|
||||
if table.getn(entitiesTable)==0 then
|
||||
subMenu:addLine(i18n.get("uiR2EdNoSelelection"), "", "", "")
|
||||
end
|
||||
end
|
||||
-----------------------------------------
|
||||
--- register the curent Feature to menu
|
||||
|
||||
function component:getLogicTranslations()
|
||||
-- register trad
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2AA0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()}
|
||||
}
|
||||
}
|
||||
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["HiddenChest"] = feature
|
||||
|
||||
|
@ -1,708 +0,0 @@
|
||||
|
||||
r2.Features.HuntTask = {}
|
||||
|
||||
local feature = r2.Features.HuntTask
|
||||
|
||||
feature.Name="HuntTask"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.HuntTask =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="HuntTask",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "huntTaskDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate", "succeed", "succeedStep"},
|
||||
|
||||
Events = {"activation", "deactivation", "wait validation", "mission asked", "succeeded"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is succeeded" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
{Name="TargetNumber", Type="Number", Min="1", Default="1"},
|
||||
{Name="IdNumber", Type="Number", Category="uiR2EDRollout_Targets", WidgetStyle="EnumDropDown", Enum={"1", "2", "3", "4"},},
|
||||
{Name="Target1Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Target2Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Target3Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Target4Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",Visible= function(this) return this:displayRefId(4) end},
|
||||
{Name="ValidationNeeded", Category="uiR2EDRollout_TextToSay", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100" },
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="WaitValidationText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay", Visible= function(this)
|
||||
return this:IsValidationNeeded() end },
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"},
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.HuntTask
|
||||
|
||||
function component:IsValidationNeeded()
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
if validationNeeded == 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbRefId = self.IdNumber + 1
|
||||
if index <= nbRefId then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
---------------------------------------------------------------------------------------
|
||||
---------------------------------------------------------------------------------------
|
||||
function component:textAdapter(text)
|
||||
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local mission_giver = ""
|
||||
local nbTargets = ""
|
||||
|
||||
if tostring(self.MissionGiver) ~= "" then
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if giver then mission_giver = giver.Name end
|
||||
end
|
||||
|
||||
if tostring(self.TargetNumber) ~= "" then
|
||||
nbTargets = tostring(self.TargetNumber)
|
||||
end
|
||||
|
||||
str=string.gsub(str, "<mission_giver>", mission_giver)
|
||||
str=string.gsub(str, "<target_number>", nbTargets)
|
||||
return str
|
||||
end
|
||||
|
||||
local huntTaskDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
--
|
||||
-- If the message is received by a client that didn't request the modification, we must make sure this client
|
||||
-- doesn't modify the data because it has already been done by the initial client.
|
||||
--
|
||||
local function checkPickedEntity(this, instanceId, attributeName)
|
||||
if instanceId == "" then
|
||||
return false
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
assert(tmpInstance)
|
||||
local i = 1
|
||||
while i < 5 do
|
||||
local attrName = "Target" ..i.. "Id"
|
||||
if attrName ~= attributeName and this[attrName] == tmpInstance.InstanceId then
|
||||
return false
|
||||
end
|
||||
if attributeName ~= "MissionGiver" and this["MissionGiver"] == tmpInstance.InstanceId then
|
||||
return false
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local oldOnAttrModified = huntTaskDisplayerTable.onAttrModified
|
||||
function huntTaskDisplayerTable:onAttrModified(instance, attributeName)
|
||||
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
if attributeName == "ValidationNeeded" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
if attributeName == "IdNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbRefId = instance.IdNumber + 1
|
||||
local i = 1
|
||||
while i <= 4 do
|
||||
if i > nbRefId then
|
||||
local name = "Target"..tostring(i).."Id"
|
||||
local refId = propertySheet:find(name)
|
||||
local refIdName = refId:find("name")
|
||||
refIdName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, name, "")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
if (string.find(attributeName, "Id") == nil or attributeName == "InstanceId") and not attributeName == "MissionGiver" then return end
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local refId = propertySheet:find(attributeName)
|
||||
if refId == nil then return end
|
||||
local refIdName = refId:find("name")
|
||||
local instanceId = instance[attributeName]
|
||||
if not instanceId then
|
||||
return
|
||||
end
|
||||
|
||||
if instanceId == "" then
|
||||
refIdName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
local inserted = checkPickedEntity(instance, instanceId, attributeName)
|
||||
if inserted == true then
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
refIdName.hardtext = tmpInstance.Name
|
||||
else
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, "")
|
||||
end
|
||||
instance.User.onHrcMove = false
|
||||
end
|
||||
|
||||
function huntTaskDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function reattributeIdOnHrcMove(hunt, group, targetAttr)
|
||||
local propertySheet = r2:getPropertySheet(hunt)
|
||||
local refId = propertySheet:find(targetAttr)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
r2.requestSetNode(hunt.InstanceId, targetAttr, group.InstanceId)
|
||||
refIdName.hardtext = group.Name
|
||||
hunt.User.onHrcMove = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
if targetAttr == "MissionGiver" then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, "")
|
||||
return
|
||||
end
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
local group = tmpInstance.ParentInstance
|
||||
if group:isKindOf("NpcGrpFeature") then
|
||||
reattributeIdOnHrcMove(self, group, targetAttr)
|
||||
end
|
||||
tmpInstance.User.SelfModified = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function r2:huntTaskDisplayer()
|
||||
return huntTaskDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
function component:createGhostComponents(act)
|
||||
local comp = self
|
||||
|
||||
local counter = r2.newComponent("Counter")
|
||||
assert(counter)
|
||||
|
||||
counter.Base = "palette.entities.botobjects.milestone"
|
||||
counter.Name = "TargetCounter"
|
||||
counter.Position.x = comp.Position.x
|
||||
counter.Position.y = comp.Position.y
|
||||
counter.Position.z = 0
|
||||
|
||||
local counterId = counter.InstanceId
|
||||
assert(counterId)
|
||||
r2.requestSetGhostNode(comp.InstanceId, "_CounterId", counterId)
|
||||
local nbTarget = 0
|
||||
local eventType = "" --depends on the instance type (groupe or npc)
|
||||
local eventName = ""
|
||||
|
||||
-- Add to each guard a 'OnDeath EventHandler' which decrements the counter
|
||||
for id = 1, 4 do
|
||||
local propertyName = "Target"..tonumber(id).."Id"
|
||||
if comp[propertyName] ~= nil and comp[propertyName] ~= "" then
|
||||
local targetInstance = r2:getInstanceFromId(comp[propertyName])
|
||||
if targetInstance then
|
||||
|
||||
if targetInstance:isKindOf("Npc") then
|
||||
eventType = "death"
|
||||
eventName = "On Death"
|
||||
elseif targetInstance:isKindOf("NpcGrpFeature") then
|
||||
eventType = "member death"
|
||||
eventName = "On Member Death"
|
||||
end
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
--eventHandler.Event.Type = "death"
|
||||
eventHandler.Event.Type = eventType
|
||||
eventHandler.Event.Value = ""
|
||||
--eventHandler.Name = "On Death"
|
||||
eventHandler.Event.Name = eventName
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
table.insert(eventHandler.Actions, action)
|
||||
action.Entity = r2.RefId(comp.InstanceId)
|
||||
action.Action.Type = "succeedStep"
|
||||
action.Action.Value = ""
|
||||
|
||||
if targetInstance:isKindOf("Npc") then
|
||||
r2.requestInsertGhostNode(targetInstance.Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
elseif targetInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestInsertGhostNode(targetInstance.Components[0].Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
--r2.requestInsertGhostNode(guardInstance.Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
|
||||
nbTarget = nbTarget + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nbTarget == 0 then
|
||||
debugInfo("hunt task: No target has been picked.")
|
||||
return
|
||||
end
|
||||
|
||||
counter.Value = tonumber(comp.TargetNumber)
|
||||
counter.TriggerValue = 0
|
||||
|
||||
do
|
||||
local validationNeeded = tonumber(comp.ValidationNeeded)
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "On Trigger"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "On Trigger"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
action.Entity = r2.RefId(comp.InstanceId)
|
||||
|
||||
if validationNeeded == 1 then
|
||||
action.Action.Type = "validateTask"
|
||||
else
|
||||
action.Action.Type = "succeed"
|
||||
end
|
||||
|
||||
action.Action.Value = ""
|
||||
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
table.insert(counter.Behavior.Actions, eventHandler)
|
||||
|
||||
end
|
||||
|
||||
r2.requestInsertGhostNode(comp.InstanceId, "Components", -1, "", counter)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if not giver then return end
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
|
||||
-- Start of state
|
||||
do
|
||||
local action = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 7)
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- Success
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3,rtAction4 } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_7", self, context, rtAction)
|
||||
end
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- Success
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_4", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- when player targets mission giver
|
||||
do
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, -- giver has been spoken to
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 2),
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.WaitValidationText), rtGiverGrp.Id ..":"..giver.Name)}) )
|
||||
)
|
||||
|
||||
local multiActions = r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ),
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.MissionText), rtGiverGrp.Id ..":"..giver.Name),
|
||||
r2.Translator.createAction("talk_to", rtGrp.Id, self:textAdapter(self.ContextualText)),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 1)})
|
||||
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0, multiActions))
|
||||
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, rtAction)
|
||||
end
|
||||
|
||||
if validationNeeded == 1 then
|
||||
do
|
||||
local actionEvent = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 9)
|
||||
local actionSuccessTxt = r2.Translator.createAction("npc_say", self:textAdapter(self.MissionSucceedText), rtGiverGrp.Id ..":"..giver.Name)
|
||||
|
||||
local action = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 2,
|
||||
r2.Translator.createAction("condition_if", r2:getNamespace()..rtGrp.Id..".Active == 1",
|
||||
r2.Translator.createAction("multi_actions", {actionEvent, actionSuccessTxt})))
|
||||
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) )
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_8", self, context, actionBroadcast)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, --if Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
})
|
||||
);
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- if not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
|
||||
local actions = {}
|
||||
if validationNeeded == 1 then
|
||||
actions = {action2, action3}
|
||||
else
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) )
|
||||
|
||||
actions = {action2, action3, actionBroadcast}
|
||||
end
|
||||
local multiActions = r2.Translator.createAction("multi_actions", actions)
|
||||
|
||||
local action = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 2,
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, multiActions))
|
||||
r2.Translator.translateAiGroupEvent("user_event_9", self, context, action)
|
||||
end
|
||||
|
||||
--deactivate
|
||||
do
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
})
|
||||
r2.Translator.translateAiGroupEvent("user_event_5", self, context, rtAction)
|
||||
end
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtGrp)
|
||||
local rtGrpCounter = r2.Translator.getRtGroup(context, component._CounterId)
|
||||
assert(rtGrpCounter)
|
||||
|
||||
if action.Action.Type == "validateTask" then
|
||||
local action = r2.Translator.createAction("validate_task", rtGrp.Id)
|
||||
return action, action
|
||||
elseif action.Action.Type == "succeed" then
|
||||
local action = r2.Translator.createAction("complete_mission", rtGrp.Id)
|
||||
return action, action
|
||||
elseif action.Action.Type == "succeedStep" then
|
||||
local actionDec = r2.Translator.createAction("counter_dec", rtGrpCounter.Id)
|
||||
local actionIf = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1,
|
||||
r2.Translator.createAction("condition_if", r2:getNamespace()..rtGrp.Id..".Active == 1",actionDec))
|
||||
return actionIf, actionIf
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "mission asked" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 1)
|
||||
elseif eventType == "wait validation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 9)
|
||||
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdHuntTask_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdHuntTask_MissionText"):toUtf8()
|
||||
local waitValidationText = i18n.get("uiR2EdHuntTask_WaitValidationText"):toUtf8()
|
||||
local missionSucceededText = i18n.get("uiR2EdHuntTask_MissionSucceededText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdHuntTask_BroadcastText"):toUtf8()
|
||||
|
||||
|
||||
local comp = r2.newComponent("HuntTask")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdHuntTask")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.WaitValidationText = waitValidationText
|
||||
comp.MissionSucceedText = missionSucceededText
|
||||
comp.BroadcastText= broadcastText
|
||||
comp.TargetNumber = 1
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("HuntTask", 0)
|
||||
else r2.setDisplayInfo("HuntTask", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.HuntTask.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'HuntTask' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'HuntTask' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("HuntTask") == 1 then
|
||||
r2.displayFeatureHelp("HuntTask")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewHuntTaskFeatureAction"))
|
||||
local component = feature.Components.HuntTask.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'HuntTask' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureHuntTask")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdHuntTask")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "HuntTask")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["succeed"] = { menu=i18n.get( "uiR2AA0SucceedTask" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1SucceedTask" ):toUtf8()},
|
||||
["succeedStep"] = { menu=i18n.get( "uiR2AA0SucceedStep" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1SucceedStep" ):toUtf8()}
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["mission asked"] = { menu=i18n.get( "uiR2Event0MissionGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MissionGiven" ):toUtf8()},
|
||||
["wait validation"] = { menu=i18n.get( "uiR2Event0TaskWaitValidation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskWaitValidation" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["HuntTask"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,479 +0,0 @@
|
||||
|
||||
r2.Features.KillNpc = {}
|
||||
|
||||
local feature = r2.Features.KillNpc
|
||||
|
||||
feature.Name="KillNpc"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.KillNpc =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="KillNpc",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "killNpcDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "wait validation", "mission asked", "succeeded"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is completed" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
{Name="MissionTarget", Type="RefId", PickFunction="r2:canPickNotGroupedNpc", SetRefIdFunction="r2:setNotGroupedNpcRefIdTarget"},
|
||||
{Name="ValidationNeeded", Category="uiR2EDRollout_TextToSay", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100" },
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="WaitValidationText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay", Visible= function(this)
|
||||
return this:IsValidationNeeded() end },
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.KillNpc
|
||||
|
||||
function component:IsValidationNeeded()
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
if validationNeeded == 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local killNpcDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
local oldOnAttrModified = killNpcDisplayerTable.onAttrModified
|
||||
|
||||
function killNpcDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
|
||||
if attributeName == "ValidationNeeded" then
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
local targetRefId = propertySheet:find("MissionTarget")
|
||||
local targetName = targetRefId:find("name")
|
||||
|
||||
local giverRefId = propertySheet:find("MissionGiver")
|
||||
local giverName = propertySheet:find("MissionGiver"):find("name")
|
||||
|
||||
if attributeName == "MissionGiver" then
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
giverName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if instance["MissionTarget"] == instance[attributeName] then
|
||||
giverName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, "MissionGiver", "")
|
||||
else
|
||||
giverName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if attributeName == "MissionTarget" then
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
targetName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if instance["MissionGiver"] == instance[attributeName] then
|
||||
targetName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, "MissionTarget", "")
|
||||
else
|
||||
targetName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
function killNpcDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:killNpcDisplayer()
|
||||
return killNpcDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
|
||||
function component:textAdapter(text)
|
||||
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local mission_giver = ""
|
||||
local mission_target = ""
|
||||
|
||||
if tostring(self.MissionGiver) ~= "" then
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if giver then mission_giver = giver.Name end
|
||||
end
|
||||
|
||||
if tostring(self.MissionTarget) ~= "" then
|
||||
local target = r2:getInstanceFromId(self.MissionTarget)
|
||||
if target then mission_target = target.Name end
|
||||
end
|
||||
|
||||
str=string.gsub(str, "<mission_giver>", mission_giver)
|
||||
str=string.gsub(str, "<mission_target>", mission_target)
|
||||
return str
|
||||
end
|
||||
|
||||
-- EVENTS-----------------------------------------------------------------------
|
||||
-- 4 : activation
|
||||
-- 5 : deactivation
|
||||
-- 3 : mission given
|
||||
-- 2 : wait validation
|
||||
-- 9 : mission completed
|
||||
---------------------------------------------------------------------------------
|
||||
function component:translate(context)
|
||||
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
local validationNeeded = tonumber(self.ValidationNeeded)
|
||||
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if not giver then return end
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
|
||||
local target = r2:getInstanceFromId(self.MissionTarget)
|
||||
if not target then return end
|
||||
local rtTargetGrp = r2.Translator.getRtGroup(context, target.InstanceId)
|
||||
|
||||
if tostring(self.MissionTarget) == "" or self.MissionTarget == nil then return end
|
||||
|
||||
-- Start of state
|
||||
r2.Translator.Tasks.startOfStateLogic(self, context, rtGrp)
|
||||
|
||||
-- Activation
|
||||
r2.Translator.Tasks.activationLogic(self, context, rtGrp)
|
||||
|
||||
--Deactivation
|
||||
r2.Translator.Tasks.deactivationLogic(self, context, rtGrp)
|
||||
|
||||
|
||||
-- when player targets mission giver
|
||||
r2.Translator.Tasks.giverLogic(self, giver, context, rtGrp)
|
||||
|
||||
--Set mission status to 1 when mission is taken
|
||||
r2.Translator.Tasks.setStatusLogic(self, context, rtGrp)
|
||||
|
||||
-- Qd player target le targetNpc : si validation sur giver = event 2 (waitValidation)
|
||||
-- si validation sur target = event 3 (success)
|
||||
do
|
||||
local actionEvent = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 9)
|
||||
|
||||
local actionSet = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2)
|
||||
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) )
|
||||
|
||||
local actions = {actionSet, actionBroadcast}
|
||||
if validationNeeded == 0 then
|
||||
table.insert(actions, actionEvent)
|
||||
end
|
||||
|
||||
local multiactions = r2.Translator.createAction("multi_actions", actions)
|
||||
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, multiactions))
|
||||
r2.Translator.translateAiGroupEvent("group_eliminated", target, context, rtAction)
|
||||
end
|
||||
|
||||
r2.Translator.Tasks.validationByMissionGiver(self, giver, context, rtGrp)
|
||||
|
||||
r2.Translator.Tasks.successNoBroadcastLogic(self, context, rtGrp)
|
||||
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is completed" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "mission asked" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 3)
|
||||
elseif eventType == "wait validation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 9)
|
||||
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdKillNpc_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdKillNpc_MissionText"):toUtf8()
|
||||
local waitValidationText = i18n.get("uiR2EdKillNpc_WaitValidationText"):toUtf8()
|
||||
local missionSucceededText = i18n.get("uiR2EdKillNpc_MissionSucceededText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdKillNpc_BroadcastText"):toUtf8()
|
||||
|
||||
local comp = r2.newComponent("KillNpc")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdKillNpc")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.WaitValidationText = waitValidationText
|
||||
comp.MissionSucceedText = missionSucceededText
|
||||
comp.BroadcastText= broadcastText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
-- comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("KillNpc", 0)
|
||||
else r2.setDisplayInfo("KillNpc", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.KillNpc.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'KillNpc' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'KillNpc' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("KillNpc") == 1 then
|
||||
r2.displayFeatureHelp("KillNpc")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewKillNpcFeatureAction"))
|
||||
local component = feature.Components.KillNpc.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'KillNpc' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureKillNpc")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdKillNpc")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "KillNpc")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()}
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["mission asked"] = { menu=i18n.get( "uiR2Event0MissionGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MissionGiven" ):toUtf8()},
|
||||
["wait validation"] = { menu=i18n.get( "uiR2Event0TaskWaitValidation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskWaitValidation" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is completed"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["KillNpc"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
function r2.getCategories()
|
||||
local categories = {
|
||||
{"uiR2EdMobSpawnersCategory", "r2ed_icon_creatures.tga", "root"},
|
||||
|
||||
{"uiR2EdChestsCategory", "r2ed_icon_components_chest.tga.tga", "root"},
|
||||
|
||||
-- {"uiR2EdTasksSubTasksCategory", "r2ed_icon_components_tasks.tga", "root"},
|
||||
-- {"uiR2EdTasksCategory", "r2ed_icon_macro_components.tga", "uiR2EdTasksSubTasksCategory"},
|
||||
-- {"uiR2EdTaskStepCategory", "", "uiR2EdTasksSubTasksCategory"},
|
||||
{"uiR2EdTasksCategory", "r2ed_icon_macro_components.tga", "root"},
|
||||
{"uiR2EdTaskStepCategory", "", "root"},
|
||||
|
||||
{"uiR2EdTriggersCategory", "r2ed_icon_components_trigger.tga", "root"},
|
||||
|
||||
{"uiR2EdDialogsCategory", "r2_mini_activity_chat.tga", "root"},
|
||||
|
||||
{"uiR2EdMacroComponentsCategory", "r2ed_icon_macro_components.tga", "root"},
|
||||
|
||||
{"uiR2EdDevCategory", "r2ed_icon_macro_components.tga", "root"},
|
||||
--{Category_Id, Category_Icon, Parent_Node}
|
||||
}
|
||||
return categories
|
||||
end
|
||||
|
||||
function r2.getLoadedFeaturesDynamic()
|
||||
local loadedFeatures =
|
||||
{
|
||||
--Dev
|
||||
--{"r2_features_teleport_near.lua", "TeleportNearFeature", "uiR2EdDevCategory"},
|
||||
{"r2_features_quest.lua", "Quest", "uiR2EdDevCategory"},
|
||||
{"r2_features_npc_interaction.lua", "NpcInteraction", "uiR2EdDevCategory"},
|
||||
|
||||
--{filename, feature_name, category}
|
||||
}
|
||||
return loadedFeatures
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -1,499 +0,0 @@
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdLootSpawner --
|
||||
-- CreationFrom : uiR2EdLootSpawnerParameters
|
||||
|
||||
|
||||
r2.Features.LootSpawnerFeature = {}
|
||||
|
||||
local feature = r2.Features.LootSpawnerFeature
|
||||
|
||||
feature.Name="LootSpawnerFeature"
|
||||
|
||||
feature.Description="Spawns an easterEgg containing several user items after the death of a chosen number of npc"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.LootSpawner =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="LootSpawner",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "lootSpawnerDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = { "activation", "deactivation", "trigger"},
|
||||
|
||||
Conditions = { "is active", "is inactive"},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--Category="uiR2EDRollout_Npc",
|
||||
--Category="uiR2EDRollout_SpawningEgg",
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible= false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name= "Ghosts", Type = "Table", Visible = false },
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name= "Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="TriggerValue", Type="Number", Min="0", Default="0", Translation="uiR2EDProp_TriggerValue"},
|
||||
{Name="NpcNumber", Type="Number", Category="uiR2EDRollout_Npcs", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3", "4", "5"}, DefaultValue="5"},
|
||||
{Name="Npc1Id", Type="RefId", Category="uiR2EDRollout_Npcs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Npc1Id", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Npc2Id", Type="RefId", Category="uiR2EDRollout_Npcs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Npc2Id", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Npc3Id", Type="RefId", Category="uiR2EDRollout_Npcs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Npc3Id", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Npc4Id", Type="RefId", Category="uiR2EDRollout_Npcs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Npc4Id", Visible= function(this) return this:displayRefId(4) end},
|
||||
{Name="Npc5Id", Type="RefId", Category="uiR2EDRollout_Npcs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget", Translation="uiR2EDProp_Npc5Id", Visible= function(this) return this:displayRefId(5) end},
|
||||
{Name="EasterEggId", Type="RefId", PickFunction="r2:canPickEasterEgg", SetRefIdFunction="r2:setEasterEggRefIdTarget", Translation="uiR2EDProp_EasterEgg"}
|
||||
},
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
local component = feature.Components.LootSpawner
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbNPCs = self.NpcNumber + 1
|
||||
if index <= nbNPCs then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
--local rtEggGrp = r2.Translator.getRtGroup(context, component.EasterEggId)
|
||||
local eggInstance = r2:getInstanceFromId(component.EasterEggId)
|
||||
assert(eggInstance)
|
||||
|
||||
if (action.Action.Type == "spawnEntity") then
|
||||
if eggInstance then
|
||||
local actionTrigger = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6)
|
||||
local actionSpawn = eggInstance:createActionActivateEasterEgg(context)
|
||||
local retAction = r2.Translator.createAction("condition_if", r2:getNamespace()..rtNpcGrp.Id..".Active == 1",
|
||||
r2.Translator.createAction("multi_actions", {actionTrigger, actionSpawn})
|
||||
)
|
||||
return retAction, retAction
|
||||
end
|
||||
return nil, nil
|
||||
end
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if tostring(event.Event.Type) == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
local lootSpawnerDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
--
|
||||
-- If the message is received by a client that didn't request the modification, we must make sure this client
|
||||
-- doesn't modify the data because it has already been performed by the initial client.
|
||||
--
|
||||
local function checkPickedEntity(this, instanceId, attributeName)
|
||||
|
||||
if instanceId == "" then
|
||||
return false
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
assert(tmpInstance)
|
||||
|
||||
local i = 1
|
||||
while i < 6 do
|
||||
local attrName = "Npc" ..i.. "Id"
|
||||
if attrName ~= attributeName and this[attrName] == tmpInstance.InstanceId then
|
||||
--if not tmpInstance.User.SelfModified or tmpInstance.User.SelfModified == false then
|
||||
-- messageBox("'"..tmpInstance.Name.."' has already been picked.")
|
||||
--else
|
||||
-- tmpInstance.User.SelfModified = false
|
||||
--end
|
||||
return false
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
local oldOnAttrModified = lootSpawnerDisplayerTable.onAttrModified
|
||||
|
||||
function lootSpawnerDisplayerTable:onAttrModified(instance, attributeName)
|
||||
--if not instance.User.SelfModified then return end
|
||||
-- call base version
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
|
||||
if attributeName == "NpcNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbNPCs = instance.NpcNumber + 1
|
||||
local i = 1
|
||||
while i <= 5 do
|
||||
if i > nbNPCs then
|
||||
local name = "Npc"..tostring(i).."Id"
|
||||
local refId = propertySheet:find(name)
|
||||
local refIdName = refId:find("name")
|
||||
refIdName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, name, "")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
if string.find(attributeName, "Id") == nil or attributeName == "InstanceId" then return end
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local refId = propertySheet:find(attributeName)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
refIdName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if checkPickedEntity(instance, instanceId, attributeName) then
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
refIdName.hardtext = tmpInstance.Name
|
||||
else
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, "")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function lootSpawnerDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function reattributeIdOnHrcMove(lootSpawner, group, targetAttr)
|
||||
local propertySheet = r2:getPropertySheet(lootSpawner)
|
||||
local refId = propertySheet:find(targetAttr)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
r2.requestSetNode(lootSpawner.InstanceId, targetAttr, group.InstanceId)
|
||||
refIdName.hardtext = group.Name
|
||||
|
||||
end
|
||||
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
local group = tmpInstance.ParentInstance
|
||||
if group:isKindOf("NpcGrpFeature") then
|
||||
reattributeIdOnHrcMove(self, group, targetAttr)
|
||||
end
|
||||
tmpInstance.User.SelfModified = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function r2:lootSpawnerDisplayer()
|
||||
return lootSpawnerDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
component.createGhostComponents= function(this, act)
|
||||
|
||||
local comp = this
|
||||
local easterEgg= r2:getInstanceFromId(comp.EasterEggId)
|
||||
|
||||
if easterEgg == nil then
|
||||
debugInfo("LootSpawner: Can't spawn a nil easteregg. You have to pick one.")
|
||||
--assert(easterEgg)
|
||||
return
|
||||
end
|
||||
|
||||
local counter = r2.newComponent("Counter")
|
||||
assert(counter)
|
||||
counter.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
counter.Name = "Npc Counter"
|
||||
counter.Position.x = comp.Position.x
|
||||
counter.Position.y = comp.Position.y
|
||||
counter.Position.z = 0
|
||||
|
||||
|
||||
|
||||
local nbNpc = 0
|
||||
|
||||
for id = 1, 5 do
|
||||
local propertyName = "Npc"..tonumber(id).."Id"
|
||||
if comp[propertyName] ~= nil and comp[propertyName] ~= "" then
|
||||
local npcInstance = r2:getInstanceFromId(comp[propertyName])
|
||||
if npcInstance then
|
||||
|
||||
if npcInstance:isKindOf("Npc") then
|
||||
eventType = "death"
|
||||
eventName = "On Death"
|
||||
elseif npcInstance:isKindOf("NpcGrpFeature") then
|
||||
eventType = "group death"
|
||||
eventName = "On Group Death"
|
||||
end
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
--eventHandler.Event.Type = "death"
|
||||
eventHandler.Event.Type = eventType
|
||||
eventHandler.Event.Value = ""
|
||||
--eventHandler.Name = "On Death"
|
||||
eventHandler.Event.Name = eventName
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
table.insert(eventHandler.Actions, action)
|
||||
action.Entity = r2.RefId(counter.InstanceId)
|
||||
action.Action.Type = "Decrement"
|
||||
action.Action.Value = ""
|
||||
|
||||
if npcInstance:isKindOf("Npc") then
|
||||
r2.requestInsertGhostNode(npcInstance.Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
elseif npcInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestInsertGhostNode(npcInstance.Components[0].Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
--r2.requestInsertGhostNode(guardInstance.Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
|
||||
nbNpc = nbNpc + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nbNpc == 0 then
|
||||
debugInfo("LootSpawner: No npc has been picked.")
|
||||
return
|
||||
end
|
||||
|
||||
counter.Value = tonumber(nbNpc)
|
||||
--counter.TriggerValue = comp._TriggerValue
|
||||
counter.TriggerValue = comp.TriggerValue
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "On Trigger"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "On Trigger"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(comp.InstanceId) --r2.RefId(boss.InstanceId)
|
||||
action.Action.Type = "spawnEntity"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
table.insert(counter.Behavior.Actions, eventHandler)
|
||||
|
||||
end
|
||||
|
||||
r2.requestInsertGhostNode(comp.InstanceId, "Components", -1, "", counter)
|
||||
--r2.requestInsertGhostNode(r2:getCurrentAct().InstanceId, "Features", -1, "", counter)
|
||||
|
||||
r2.requestSetGhostNode(easterEgg.InstanceId, "Active", 0)
|
||||
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y, tvalue)
|
||||
|
||||
local comp = r2.newComponent("LootSpawner")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDRollout_LootSpawner")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
comp.TriggerValue = 0
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
comp.Npc1Id = r2.RefId("")
|
||||
comp.Npc2Id = r2.RefId("")
|
||||
comp.Npc3Id = r2.RefId("")
|
||||
comp.Npc4Id = r2.RefId("")
|
||||
comp.Npc5Id = r2.RefId("")
|
||||
|
||||
comp.NpcNumber = 0
|
||||
|
||||
|
||||
local easterEgg = r2.Features["EasterEggFeature"].Components.EasterEgg.createComponent(comp.Position.x + 1, comp.Position.y + 1)
|
||||
easterEgg.Position.x, easterEgg.Position.y = r2:findEmptyPlace(comp.Position.x + 1, comp.Position.y + 1)
|
||||
--easterEgg.Position.y = comp.Position.y + 1
|
||||
easterEgg.InheritPos = 0
|
||||
comp.EasterEggId = easterEgg.InstanceId
|
||||
table.insert(comp.Components, easterEgg)
|
||||
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
component.create = function()
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("LootSpawnerForm", 0)
|
||||
else r2.setDisplayInfo("LootSpawnerForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.LootSpawner.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'LootSpawnerFeature' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'LootSpawnerFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("LootSpawner") == 1 then
|
||||
r2.displayFeatureHelp("LootSpawner")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewLootSpawnerFeatureAction"))
|
||||
local component = feature.Components.LootSpawner.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'LootSpawnerFeature' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureLootSpawner")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EDRollout_RewardChest")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "RewardChest")
|
||||
end
|
||||
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {}
|
||||
r2.Translator.addActivationToTranslations(logicTranslations)
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["LootSpawnerFeature"] = feature
|
@ -1,442 +0,0 @@
|
||||
|
||||
r2.Features.ManHuntFeature = {}
|
||||
|
||||
local feature = r2.Features.ManHuntFeature
|
||||
|
||||
feature.Name="ManHuntFeature"
|
||||
|
||||
feature.Description="Triggers when all selected NPCs die."
|
||||
|
||||
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.ManHunt =
|
||||
{
|
||||
PropertySheetHeader = r2.getDisplayButtonHeader("r2.events:openEditor()", "uiR2EdEditEventsButton"),
|
||||
BaseClass="LogicEntity",
|
||||
Name="ManHunt",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "manHuntDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = { "activation", "deactivation", "trigger"},
|
||||
|
||||
Conditions = { "is active", "is inactive"},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--Category="uiR2EDRollout_Guards"
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table", Visible= false},
|
||||
{Name= "Ghosts", Type = "Table", Visible = false },
|
||||
{Name= "Name", Type="String"},
|
||||
{Name= "Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="TriggerValue", Type="Number", Min="0", Default="0", Translation="uiR2EDProp_TriggerValue"},
|
||||
{Name="MobNumber", Type="Number", Category="uiR2EDRollout_Mobs", WidgetStyle="EnumDropDown", Enum={"1", "2", "3", "4", "5"},
|
||||
},
|
||||
{Name="Mob1Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob1Id", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Mob2Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob2Id", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Mob3Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob3Id", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Mob4Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob4Id", Visible= function(this) return this:displayRefId(4) end},
|
||||
{Name="Mob5Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob5Id", Visible= function(this) return this:displayRefId(5) end},
|
||||
},
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
--r2.Translator.pretranslateDefaultFeature(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
local component = feature.Components.ManHunt
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbMobs = self.MobNumber + 1
|
||||
if index <= nbMobs then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if (action.Action.Type == "trigger") then
|
||||
local retAction = r2.Translator.createAction("condition_if", r2:getNamespace()..rtNpcGrp.Id..".Active == 1",
|
||||
r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6)
|
||||
)
|
||||
return retAction, retAction
|
||||
end
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if tostring(event.Event.Type) == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
local manHuntDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
--
|
||||
-- If the message is received by a client that didn't request the modification, we must make sure this client
|
||||
-- doesn't modify the data because it has already been performed by the initial client.
|
||||
--
|
||||
local function checkPickedEntity(this, instanceId, attributeName)
|
||||
if instanceId == "" then
|
||||
return false
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
assert(tmpInstance)
|
||||
local i = 1
|
||||
while i < 6 do
|
||||
local attrName = "Mob" ..i.. "Id"
|
||||
if attrName ~= attributeName and this[attrName] == tmpInstance.InstanceId then
|
||||
return false
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local oldOnAttrModified = manHuntDisplayerTable.onAttrModified
|
||||
function manHuntDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
|
||||
if attributeName == "MobNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbMobs = instance.MobNumber + 1
|
||||
local i = 1
|
||||
while i <= 5 do
|
||||
if i > nbMobs then
|
||||
local name = "Mob"..tostring(i).."Id"
|
||||
local refId = propertySheet:find(name)
|
||||
local refIdName = refId:find("name")
|
||||
refIdName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, name, "")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
if string.find(attributeName, "Id") == nil or attributeName == "InstanceId" then return end
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local refId = propertySheet:find(attributeName)
|
||||
if refId == nil then return end
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
refIdName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
local inserted = checkPickedEntity(instance, instanceId, attributeName)
|
||||
if inserted == true then
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
refIdName.hardtext = tmpInstance.Name
|
||||
else
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, "")
|
||||
end
|
||||
instance.User.onHrcMove = false
|
||||
end
|
||||
|
||||
function manHuntDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function reattributeIdOnHrcMove(mHunt, group, targetAttr)
|
||||
local propertySheet = r2:getPropertySheet(mHunt)
|
||||
local refId = propertySheet:find(targetAttr)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
r2.requestSetNode(bSpawner.InstanceId, targetAttr, group.InstanceId)
|
||||
refIdName.hardtext = group.Name
|
||||
mHunt.User.onHrcMove = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
local group = tmpInstance.ParentInstance
|
||||
if group:isKindOf("NpcGrpFeature") then
|
||||
reattributeIdOnHrcMove(self, group, targetAttr)
|
||||
end
|
||||
tmpInstance.User.SelfModified = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function r2:manHuntDisplayer()
|
||||
return manHuntDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
component.createGhostComponents= function(this, act)
|
||||
|
||||
local comp = this
|
||||
|
||||
local counter = r2.newComponent("Counter")
|
||||
assert(counter)
|
||||
|
||||
counter.Base = "palette.entities.botobjects.milestone"
|
||||
counter.Name = "Mob Counter"
|
||||
counter.Position.x = comp.Position.x
|
||||
counter.Position.y = comp.Position.y
|
||||
counter.Position.z = 0
|
||||
|
||||
|
||||
|
||||
local nbGuard = 0
|
||||
local eventType = "" --depends on the instance type (groupe or npc)
|
||||
local eventName = ""
|
||||
|
||||
-- Add to each guard a 'OnDeath EventHandler' which decrements the counter
|
||||
for id = 1, 5 do
|
||||
local propertyName = "Mob"..tonumber(id).."Id"
|
||||
if comp[propertyName] ~= nil and comp[propertyName] ~= "" then
|
||||
local guardInstance = r2:getInstanceFromId(comp[propertyName])
|
||||
if guardInstance then
|
||||
|
||||
if guardInstance:isKindOf("Npc") then
|
||||
eventType = "death"
|
||||
eventName = "On Death"
|
||||
elseif guardInstance:isKindOf("NpcGrpFeature") then
|
||||
eventType = "group death"
|
||||
eventName = "On Group Death"
|
||||
end
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = eventType
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Event.Name = eventName
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
table.insert(eventHandler.Actions, action)
|
||||
action.Entity = r2.RefId(counter.InstanceId)
|
||||
action.Action.Type = "Decrement"
|
||||
action.Action.Value = ""
|
||||
|
||||
if guardInstance:isKindOf("Npc") then
|
||||
r2.requestInsertGhostNode(guardInstance.Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
elseif guardInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestInsertGhostNode(guardInstance.Components[0].Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
--r2.requestInsertGhostNode(guardInstance.Behavior.InstanceId, "Actions", -1, "", eventHandler)
|
||||
|
||||
nbGuard = nbGuard + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nbGuard == 0 then
|
||||
debugInfo("Man Hunt: No mob has been picked.")
|
||||
return
|
||||
end
|
||||
|
||||
counter.Value = tonumber(nbGuard)
|
||||
counter.TriggerValue = comp.TriggerValue
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "On Trigger"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "On Trigger"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(comp.InstanceId)
|
||||
action.Action.Type = "trigger"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
table.insert(counter.Behavior.Actions, eventHandler)
|
||||
|
||||
end
|
||||
|
||||
r2.requestInsertGhostNode(comp.InstanceId, "Components", -1, "", counter)
|
||||
|
||||
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("ManHunt")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdManHunt")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
comp.TriggerValue = 0
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
comp.Guard1Id = r2.RefId("")
|
||||
comp.Guard2Id = r2.RefId("")
|
||||
comp.Guard3Id = r2.RefId("")
|
||||
comp.Guard4Id = r2.RefId("")
|
||||
comp.Guard5Id = r2.RefId("")
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
component.create = function()
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'ManHuntFeature' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'ManHuntFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("ManHunt") == 1 then
|
||||
r2.displayFeatureHelp("ManHunt")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewManHuntAction"))
|
||||
local component = feature.Components.ManHunt.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'ManHuntFeature' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureManHunt")
|
||||
end
|
||||
|
||||
--
|
||||
-- Registers the feature creation form used as a creation menu in the editor
|
||||
--
|
||||
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdManHunt")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "ManHunt")
|
||||
end
|
||||
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {}
|
||||
r2.Translator.addActivationToTranslations(logicTranslations)
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["ManHuntFeature"] = feature
|
||||
|
@ -1,591 +0,0 @@
|
||||
|
||||
local registerFeature = function ()
|
||||
local feature={}
|
||||
|
||||
feature.Name="NpcGrpFeature"
|
||||
|
||||
feature.Description="The default feature"
|
||||
|
||||
local NpcGrpFeatureVersion = 1
|
||||
feature.Components=
|
||||
{
|
||||
NpcGrpFeature = {
|
||||
BaseClass="ActiveLogicEntity",
|
||||
Name="NpcGrpFeature",
|
||||
Version = NpcGrpFeatureVersion,
|
||||
InEventUI = true,
|
||||
--Menu="ui:interface:r2ed_base_menu",
|
||||
--Menu="ui:interface:r2ed_entity_menu",
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "groupUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualGroup",
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "npcGroupPropertySheetDisplayer",
|
||||
DisplayerVisualParams =
|
||||
{
|
||||
Look = r2.PrimRender.GroupLook,
|
||||
ArrayName = "Components"
|
||||
},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {
|
||||
},
|
||||
ApplicableActions = {
|
||||
"Activate",
|
||||
"Deactivate", "Kill", "begin activity sequence",
|
||||
"Sit Down", "Stand Up",
|
||||
"Fight with player", "Fight with Npcs",
|
||||
"Dont fight with player", "Dont fight with Npcs",
|
||||
"Run", "Dont run",
|
||||
--"begin chat sequence"
|
||||
},
|
||||
Events = {
|
||||
"activation",
|
||||
"desactivation", "member death", "group death",
|
||||
"end of activity step", "end of activity sequence",
|
||||
"begin of activity step", "begin of activity sequence",
|
||||
"targeted by player",
|
||||
|
||||
--"end of chat step", "end of chat sequence"
|
||||
},
|
||||
Conditions = {
|
||||
|
||||
--"is active", "is inactive",
|
||||
"is in activity sequence",
|
||||
"is in activity step", --"is in chat sequence", "is in chat step"
|
||||
"is dead", "is alive",
|
||||
},
|
||||
TextContexts = {
|
||||
"a member is dead", "a member is dead", "a member is alive",
|
||||
"group is dead", "group is alive"
|
||||
},
|
||||
TextParameters = {
|
||||
"members number"
|
||||
},
|
||||
LiveParameters = {
|
||||
"is active", "current activity sequence and activity step",
|
||||
"current chat sequence and chat step"
|
||||
},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Components", Type="Table"},
|
||||
},
|
||||
|
||||
TreeIcon= function(this)
|
||||
|
||||
if this.Components.Size>0 and (this.Components[0]:isKindOf("NpcCreature") or this.Components[0]:isKindOf("NpcPlant")) then
|
||||
return "r2ed_icon_group_creatures.tga"
|
||||
else
|
||||
return "r2ed_icon_group.tga"
|
||||
end
|
||||
|
||||
return ""
|
||||
end,
|
||||
|
||||
PermanentTreeIcon= function(this)
|
||||
if this.Components.Size>0 and (this.Components[0]:isKindOf("NpcCreature") or this.Components[0]:isKindOf("NpcPlant")) then
|
||||
return "r2ed_icon_permanent_group_creatures.tga"
|
||||
else
|
||||
return "r2ed_icon_permanent_group.tga"
|
||||
end
|
||||
|
||||
return ""
|
||||
end,
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get select bar type
|
||||
SelectBarType = function(this)
|
||||
return i18n.get("uiR2EDScene"):toUtf8()
|
||||
end,
|
||||
|
||||
updateVersion = function(this, scenarioValue, currentValue )
|
||||
local patchValue = scenarioValue
|
||||
-- version 1 : Remove the "Cost" field -> hold locally now
|
||||
if patchValue < 1 then
|
||||
r2.requestEraseNode(this.InstanceId, "Cost", -1)
|
||||
patchValue = 1
|
||||
end
|
||||
|
||||
if patchValue == currentValue then return true end
|
||||
return false
|
||||
end,
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
isCopyable = function(this)
|
||||
return true
|
||||
end,
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- from WorldObject
|
||||
canChangeDisplayMode = function(this)
|
||||
return true
|
||||
end,
|
||||
-- from WorldObject
|
||||
isDisplayModeToggleSupported = function(this, displayMode)
|
||||
return this.Components[0]:isDisplayModeToggleSupported(displayMode)
|
||||
end,
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.ActiveLogicEntity.getAvailableCommands(this, dest)
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
-- additionnal parameter 'srcOptions' gives the options inherited
|
||||
paste = function(src, newPlace, srcInstanceId, srcOptions)
|
||||
local options
|
||||
if not srcOptions then
|
||||
options =
|
||||
{
|
||||
CopyEvents = 0,
|
||||
CopyActivities = 0,
|
||||
-- CopyChatSequences = 0
|
||||
DuplicateGroup = -1 -- option available when duplicating leader only
|
||||
}
|
||||
end
|
||||
local function paramsOk(options)
|
||||
if not r2:checkAiQuota(table.getn(src.Components)) then return end
|
||||
if options.CopyActivities == 0 then
|
||||
src.ActivitiesId = {}
|
||||
src.Components[1].Behavior.Activities = {}
|
||||
end
|
||||
if options.CopyEvents == 0 then
|
||||
src.Components[1].Behavior.Actions = {}
|
||||
end
|
||||
--if options.CopyChatSequences == 0 then
|
||||
-- src.Behavior.ChatSequences = {}
|
||||
-- end
|
||||
if newPlace then
|
||||
-- compute min position and use as group ref pos
|
||||
local mx = 0
|
||||
local my = 0
|
||||
local mz = 0
|
||||
-- compute center
|
||||
for k, v in pairs(src.Components) do
|
||||
v.Position.x = v.Position.x + src.Position.x
|
||||
v.Position.y = v.Position.y + src.Position.y
|
||||
v.Position.z = v.Position.z + src.Position.z
|
||||
mx = mx + v.Position.x
|
||||
my = my + v.Position.y
|
||||
mz = mz + v.Position.z
|
||||
end
|
||||
mx = mx / table.getn(src.Components)
|
||||
my = my / table.getn(src.Components)
|
||||
mz = mz / table.getn(src.Components)
|
||||
-- make relative to center
|
||||
for k, v in pairs(src.Components) do
|
||||
v.Position.x = v.Position.x - mx
|
||||
v.Position.y = v.Position.y - my
|
||||
v.Position.z = v.Position.z - mz
|
||||
end
|
||||
-- compute new center
|
||||
if type(newPlace) == "table" then
|
||||
src.Position.x, src.Position.y, src.Position.z = newPlace.x, newPlace.y, newPlace.z
|
||||
else
|
||||
src.Position.x, src.Position.y, src.Position.z = r2:getPastePosition()
|
||||
end
|
||||
end
|
||||
r2:setCookie(src.InstanceId, "Select", true)
|
||||
-- insert in current act
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1,"", src)
|
||||
|
||||
end
|
||||
if srcOptions then
|
||||
-- if options were given, do not ask the user
|
||||
paramsOk(srcOptions)
|
||||
return
|
||||
end
|
||||
local function paramsCancel()
|
||||
debugInfo('paste was cancelled')
|
||||
end
|
||||
if table.getn(src.Components[1].Behavior.Activities) == 0 then
|
||||
options.CopyActivities = -1
|
||||
end
|
||||
if table.getn(src.Components[1].Behavior.Actions) == 0 then
|
||||
options.CopyEvents = -1
|
||||
end
|
||||
--if table.getn(src.Behavior.ChatSequences) == 0 then
|
||||
-- options.CopyChatSequences = -1
|
||||
-- end
|
||||
if options.CopyActivities >= 0 or
|
||||
options.CopyEvents >= 0
|
||||
--or options.CopyChatSequences >= 0
|
||||
then
|
||||
r2:doForm("SpecialPaste", options, paramsOk, paramsCancel)
|
||||
else
|
||||
-- nothing specific to copy, do direct paste
|
||||
paramsOk(options)
|
||||
end
|
||||
end,
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
pasteGhost = function(src)
|
||||
if not r2:checkAiQuota(table.getn(src.Components)) then return end
|
||||
local target = r2:getCurrentAct():getDefaultFeature()
|
||||
-- create the 'Ghosts' entry locally if it doesn't already exists
|
||||
if target.Ghosts == nil then
|
||||
r2.requestInsertGhostNode(target.InstanceId, "", -1, "Ghosts", {})
|
||||
end
|
||||
--
|
||||
r2.requestInsertGhostNode(target.InstanceId, "Ghosts",-1,"", src)
|
||||
-- insertion should have been done right now
|
||||
return r2:getInstanceFromId(src.InstanceId)
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- create a new copy with renaming
|
||||
newCopy = function(this)
|
||||
local result = r2.Classes.BaseClass.newCopy(this)
|
||||
|
||||
local counterNames = {}
|
||||
|
||||
for k, v in pairs(result.Components) do
|
||||
local category = r2.getPropertyValue(v, "Category")
|
||||
local subCategory = r2.getPropertyValue(v, "SubCategory")
|
||||
if category == "Npc" then
|
||||
|
||||
if subCategory=="Kami" or subCategory=="Karavan" then
|
||||
|
||||
local baseName = r2.PaletteIdToTranslation[this.Components[k-1].Base]
|
||||
if counterNames[baseName]==nil then
|
||||
local uc_name = ucstring()
|
||||
uc_name:fromUtf8(baseName)
|
||||
local name = r2:genInstanceName(uc_name):toUtf8()
|
||||
counterName = string.gsub(name, tostring(uc_name), "")
|
||||
counterNames[baseName] = tonumber(counterName)
|
||||
else
|
||||
counterNames[baseName] = counterNames[baseName]+1
|
||||
end
|
||||
|
||||
v.Name = baseName .. " " .. counterNames[baseName]
|
||||
else
|
||||
local sex
|
||||
local sheetClient = r2.getPropertyValue(v, "SheetClient")
|
||||
if isR2PlayerMale(sheetClient) then
|
||||
sex = r2.male
|
||||
else
|
||||
sex = r2.female
|
||||
end
|
||||
local race = getR2PlayerRace(sheetClient)
|
||||
v.Name = r2:randomNPCName2(race, sex)
|
||||
end
|
||||
end
|
||||
end
|
||||
return result
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- From logic entity
|
||||
getCategory = function(this)
|
||||
return this.Components[0]:getCategory()
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- From logic entity
|
||||
getSubCategory = function(this)
|
||||
return this.Components[0]:getSubCategory()
|
||||
end,
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- cut / paste
|
||||
accept = function(this, targetInstance)
|
||||
return r2:testCanGroup(targetInstance, this)
|
||||
end,
|
||||
--
|
||||
insert = function(this, instanceToInsert)
|
||||
assert(r2:testCanGroup(instanceToInsert, this))
|
||||
r2:group(instanceToInsert, this)
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
getFirstSelectableSon = function(this)
|
||||
for k = 0, this.Components.Size - 1 do
|
||||
if this.Components[k].Selectable then
|
||||
return this.Components[k]
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
isNextSelectable = function(this)
|
||||
return true
|
||||
end,
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
-- if not this.ParentInstance:isKindOf("Act") then
|
||||
-- return r2.Classes.BaseClass.getParentTreeNode(this)
|
||||
-- end
|
||||
-- return this:getParentAct():getContentTreeNodes("people")
|
||||
|
||||
if this.Components.Size>0 and (this.Components[0]:isKindOf("NpcCreature") or this.Components[0]:isKindOf("NpcPlant")) then
|
||||
return this:getParentAct():getContentTreeNodes("creatures")
|
||||
else
|
||||
return this:getParentAct():getContentTreeNodes("people")
|
||||
end
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.BaseClass.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
hasScenarioCost = function(this)
|
||||
return true
|
||||
end,
|
||||
|
||||
pretranslate = function (this, context)
|
||||
debugInfo("##pretranslate npcgrp##")
|
||||
local feature = this
|
||||
local components = this.Components
|
||||
-- create one RtNpcGrp by group
|
||||
|
||||
local rtNpcGrp = r2.newComponent("RtNpcGrp")
|
||||
table.insert(context.RtAct.NpcGrps, rtNpcGrp)
|
||||
-- register the groupe
|
||||
context.RtGroups[feature.InstanceId] = rtNpcGrp
|
||||
context.RtGroups[feature.InstanceId].Name = rtNpcGrp.Id
|
||||
|
||||
-- register all group components
|
||||
local key, comp = next(components, nil)
|
||||
while (key ~= nil) do
|
||||
context.RtGroups[comp.InstanceId] = rtNpcGrp
|
||||
context.RtGroups[comp.InstanceId].Name = rtNpcGrp.Id
|
||||
key, comp = next(components, key)
|
||||
end
|
||||
end,
|
||||
pretranslate2 = function(this, context)
|
||||
--
|
||||
context.Feature = this
|
||||
--
|
||||
local scenario = context.Scenario
|
||||
|
||||
local components = context.Feature.Components
|
||||
local leader = components[0]
|
||||
local hlComponent = context.Feature
|
||||
|
||||
|
||||
assert(components.Size >= 1)
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, context.Feature.InstanceId)
|
||||
|
||||
-- translate actionHandlers
|
||||
local aiActivity = r2.Translator.getAiActivity(leader)
|
||||
r2.Translator.translateActivities(context, hlComponent, hlComponent:getBehavior(), rtNpcGrp, aiActivity)
|
||||
|
||||
end,
|
||||
translate = function (this, context)
|
||||
--
|
||||
context.Feature = this
|
||||
--
|
||||
local scenario = context.Scenario
|
||||
|
||||
local components = context.Feature.Components
|
||||
local leader = components[0]
|
||||
local hlComponent = context.Feature
|
||||
|
||||
|
||||
assert(components.Size >= 1)
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, context.Feature.InstanceId)
|
||||
--if there's no sequence for the group,
|
||||
--create a state with no movement, and put the group in it.
|
||||
local key, comp = next(components, nil)
|
||||
while key do
|
||||
if (comp.isKindOf and comp:isKindOf( "Npc") ) then
|
||||
context.Component = comp
|
||||
|
||||
-- insert Npc
|
||||
local rtNpc = r2.Translator.translateNpc(comp, context)
|
||||
table.insert(context.RtAct.Npcs, rtNpc)
|
||||
table.insert(rtNpcGrp.Children, rtNpc.Id)
|
||||
|
||||
end
|
||||
key, comp = next(components, key)
|
||||
end
|
||||
|
||||
-- dump every action of the ai
|
||||
-- r2.dumpAi(rpcGrp)
|
||||
r2.Translator.setGroupParameters (leader, rtNpcGrp)
|
||||
-- translate actionHandlers
|
||||
-- local aiActivity = r2.Translator.getAiActivity(leader)
|
||||
-- r2.Translator.translateActivities(context, hlComponent, hlComponent:getBehavior(), rtNpcGrp, aiActivity)
|
||||
|
||||
-- set eventHandlers
|
||||
r2.Translator.translateEventHandlers(context, hlComponent, hlComponent:getBehavior().Actions, rtNpcGrp)
|
||||
--> events = leader or npc
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
-- same for group and for npc
|
||||
local component = feature.Components.NpcGrpFeature
|
||||
component.getLogicCondition = r2.Translator.getNpcLogicCondition
|
||||
component.getLogicAction = r2.Translator.getNpcLogicAction
|
||||
component.getLogicEvent = r2.Translator.getNpcLogicEvent
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- add a line to the event menu
|
||||
function component:getLogicTranslations()
|
||||
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["Activate"] = { menu=i18n.get( "uiR2AA0Spawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Spawn" ):toUtf8()},
|
||||
["Deactivate"] = { menu=i18n.get( "uiR2AA0Despawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Despawn" ):toUtf8()},
|
||||
["Sit Down"] = { menu=i18n.get( "uiR2AA0NpcSit" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1NpcSit" ):toUtf8(),
|
||||
groupIndependant=true},
|
||||
["Stand Up"] = { menu=i18n.get( "uiR2AA0NpcStand" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1NpcStand" ):toUtf8(),
|
||||
groupIndependant=true},
|
||||
["Kill"] = { menu=i18n.get( "uiR2AA0Kill" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Kill" ):toUtf8()},
|
||||
["begin activity sequence"] = { menu=i18n.get( "uiR2AA0BeginSeq" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1BeginSeq" ):toUtf8()},
|
||||
["Fight with player"] = { menu=i18n.get( "uiR2AA0FlagFightPlayersOn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1FlagFightPlayersOn" ):toUtf8()},
|
||||
["Dont fight with player"] = { menu=i18n.get( "uiR2AA0FlagFightPlayersOff" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1FlagFightPlayersOff" ):toUtf8()},
|
||||
["Fight with Npcs"] = { menu=i18n.get( "uiR2AA0FlagFightNpcsOn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1FlagFightNpcsOn" ):toUtf8()},
|
||||
["Dont fight with Npcs"] = { menu=i18n.get( "uiR2AA0FlagFightNpcsOff" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1FlagFightNpcsOff" ):toUtf8()},
|
||||
["Run"] = { menu=i18n.get( "uiR2AA0FlagRunOn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1FlagRunOn" ):toUtf8()},
|
||||
["Dont run"] = { menu=i18n.get( "uiR2AA0FlagRunOff" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1FlagRunOff" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Spawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Spawn" ):toUtf8()},
|
||||
["desactivation"] = { menu=i18n.get( "uiR2Event0Despawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Despawn" ):toUtf8()},
|
||||
["member death"] = { menu=i18n.get( "uiR2Event0MemberDeath" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MemberDeath" ):toUtf8()},
|
||||
["group death"] = { menu=i18n.get( "uiR2Event0GroupDeath" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1GroupDeath" ):toUtf8()},
|
||||
["end of activity step"] = { menu=i18n.get( "uiR2Event0EndActivityStep" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1EndActivityStep" ):toUtf8()},
|
||||
["end of activity sequence"] = { menu=i18n.get( "uiR2Event0EndActivitySeq" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1EndActivitySeq" ):toUtf8()},
|
||||
["begin of activity step"] = { menu=i18n.get( "uiR2Event0BeginActivityStep" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1BeginActivityStep" ):toUtf8()},
|
||||
["begin of activity sequence"] = { menu=i18n.get( "uiR2Event0BeginOfActivitySeq" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1BeginOfActivitySeq" ):toUtf8()},
|
||||
["targeted by player"] = { menu=i18n.get( "uiR2Event0TargetedByPlayer" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TargetedByPlayer" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Spawned" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Spawned" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Despawned" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Despawned" ):toUtf8()},
|
||||
["is dead"] = { menu=i18n.get( "uiR2Test0Dead" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Dead" ):toUtf8()},
|
||||
["is alive"] = { menu=i18n.get( "uiR2Test0Alive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Alive" ):toUtf8()},
|
||||
["is in activity sequence"] = { menu=i18n.get( "uiR2Test0Seq" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Seq" ):toUtf8()},
|
||||
["is in activity step"] = { menu=i18n.get( "uiR2Test0Step" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Step" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
|
||||
function component.getActivitiesIds(this)
|
||||
local activitiesIds = {}
|
||||
|
||||
local behavior = this:getBehavior()
|
||||
local k, v = next(behavior.Activities, nil)
|
||||
while k do
|
||||
table.insert(activitiesIds, v.InstanceId)
|
||||
k, v = next(behavior.Activities, k)
|
||||
end
|
||||
|
||||
return activitiesIds
|
||||
end
|
||||
|
||||
function component.getAiCost(this)
|
||||
if this.User.GhostDuplicate then return 0 end
|
||||
return r2.getAiCost(this) - 1
|
||||
end
|
||||
|
||||
|
||||
-- obsolete
|
||||
feature.getCost = function (featureInstance)
|
||||
local cost = 0
|
||||
local components = featureInstance.Components
|
||||
local key, comp = next(components, nil)
|
||||
while(key ~= nil)
|
||||
do
|
||||
|
||||
if (comp.Class == "Npc" or comp.Class == "NpcCustom")
|
||||
then
|
||||
cost = cost +1
|
||||
end
|
||||
key, comp = next(components, key)
|
||||
end
|
||||
return cost
|
||||
|
||||
end
|
||||
return feature
|
||||
end
|
||||
|
||||
|
||||
r2.Features["NpcGrpFeature"] = registerFeature()
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------------------------
|
||||
-------------------------- NPC GROUP DisplayerProperties -----------------------------------------
|
||||
--------------------------------------------------------------------------------------------------
|
||||
|
||||
local npcGroupPropertySheetDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
------------------------------------------------
|
||||
function npcGroupPropertySheetDisplayerTable:onPostCreate(instance)
|
||||
end
|
||||
------------------------------------------------
|
||||
function npcGroupPropertySheetDisplayerTable:onErase(instance)
|
||||
end
|
||||
------------------------------------------------
|
||||
function npcGroupPropertySheetDisplayerTable:onPreHrcMove(instance)
|
||||
end
|
||||
------------------------------------------------
|
||||
function npcGroupPropertySheetDisplayerTable:onPostHrcMove(instance)
|
||||
|
||||
for i=0, instance.Components.Size-1 do
|
||||
local entity = instance.Components[i]
|
||||
entity.DisplayerVisual:updateName()
|
||||
entity:updatePermanentStatutIcon()
|
||||
end
|
||||
r2.events:updateElementsUI()
|
||||
end
|
||||
------------------------------------------------
|
||||
function npcGroupPropertySheetDisplayerTable:onFocus(instance, hasFocus)
|
||||
end
|
||||
|
||||
------------------------------------------------
|
||||
function npcGroupPropertySheetDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:activeLogicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
------------------------------------------------
|
||||
function npcGroupPropertySheetDisplayerTable:onAttrModified(instance, attributeName)
|
||||
r2:activeLogicEntityPropertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
end
|
||||
|
||||
------------------------------------------------
|
||||
function r2:npcGroupPropertySheetDisplayer()
|
||||
return npcGroupPropertySheetDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -1,411 +0,0 @@
|
||||
|
||||
|
||||
r2.Features.NpcInteraction = {}
|
||||
|
||||
local feature = r2.Features.NpcInteraction
|
||||
|
||||
feature.Name="NpcInteraction"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.NpcInteraction =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="NpcInteraction",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "npcInteractionDisplayer",
|
||||
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "trigger"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "has triggered" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="InteractionTarget", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100" },
|
||||
{Name="PreInteractionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="PostInteractionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"}
|
||||
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
|
||||
local component = feature.Components.NpcInteraction
|
||||
|
||||
function component.pretranslate(this, context)
|
||||
local prop = component.Prop
|
||||
r2.Translator.CheckPickedEntity(this, prop)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local npcInteractionDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = npcInteractionDisplayerTable.onAttrModified
|
||||
|
||||
function npcInteractionDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(instance, attributeName)
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
|
||||
local targetRefId = propertySheet:find("InteractionTarget")
|
||||
local targetName = targetRefId:find("name")
|
||||
|
||||
if attributeName == "InteractionTarget" then
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
targetName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
targetName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function npcInteractionDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:npcInteractionDisplayer()
|
||||
return npcInteractionDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:textAdapter(text)
|
||||
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local mission_giver = ""
|
||||
local mission_target = ""
|
||||
|
||||
if tostring(self.InteractionTarget) ~= "" then
|
||||
local target = r2:getInstanceFromId(self.InteractionTarget)
|
||||
if target then mission_target = target.Name end
|
||||
end
|
||||
|
||||
str=string.gsub(str, "<mission_target>", mission_target)
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local target = r2:getInstanceFromId(self.InteractionTarget)
|
||||
|
||||
local rtTargetGrp = nil
|
||||
if target then
|
||||
rtTargetGrp = r2.Translator.getRtGroup(context, target.InstanceId)
|
||||
end
|
||||
|
||||
-----------------
|
||||
--Contextual text
|
||||
do
|
||||
if target then
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("talk_to", rtGrp.Id, self:textAdapter(self.ContextualText)))
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", target, context, rtAction)
|
||||
end
|
||||
end
|
||||
|
||||
-------------------
|
||||
--Start of state
|
||||
|
||||
do
|
||||
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3,})
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, -- Repeatable
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ))
|
||||
|
||||
local action4 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
local action5 = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 6)
|
||||
local action1 = r2.Translator.createAction("npc_say", self:textAdapter(self.PostInteractionText), rtTargetGrp.Id ..":"..target.Name);
|
||||
local action2 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {action1, action2, action3, action4, action5})
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_3", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
if rtTargetGrp then
|
||||
local rtAction = r2.Translator.createAction("npc_say", self:textAdapter(self.PreInteractionText), rtTargetGrp.Id ..":"..target.Name);
|
||||
r2.Translator.translateAiGroupEvent("user_event_1", self, context, rtAction)
|
||||
end
|
||||
end
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "has triggered" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
else
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdNpcInteraction_ContextualText"):toUtf8()
|
||||
local preInteractionText = i18n.get("uiR2EdNpcInteraction_PreInteractionText"):toUtf8()
|
||||
local postInteractionText = i18n.get("uiR2EdNpcInteraction_PostInteractionText"):toUtf8()
|
||||
|
||||
local comp = r2.newComponent("NpcInteraction")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdNpcInteraction")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.PreInteractionText = preInteractionText
|
||||
comp.PostInteractionText = postInteractionText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
r2:checkAiQuota()
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("NpcInteractionForm", 0)
|
||||
else r2.setDisplayInfo("NpcInteractionForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.NpcInteraction.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'NpcInteraction' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'NpcInteraction' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("NpcInteraction") == 1 then
|
||||
r2.displayFeatureHelp("NpcInteraction")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewNpcInteractionFeatureAction"))
|
||||
local component = feature.Components.NpcInteraction.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'NpcInteraction' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureNpcInteraction")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdNpcInteraction")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "NpcInteraction")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["has triggered"] = { menu=i18n.get( "uiR2Test0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Trigger" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["NpcInteraction"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,304 +0,0 @@
|
||||
|
||||
r2.Features.ProximityDialog = {}
|
||||
|
||||
local feature = r2.Features.ProximityDialog
|
||||
|
||||
feature.Name="ProximityDialog"
|
||||
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
local classProximityDialogVersion = 1
|
||||
|
||||
feature.Components.ProximityDialog =
|
||||
{
|
||||
PropertySheetHeader = r2.getDisplayButtonHeader("r2.dialogs:openEditor()", "uiR2EdEditDialogButton"),
|
||||
BaseClass="ChatSequence",
|
||||
Name="ProximityDialog",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
Version=classProximityDialogVersion ,
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
ApplicableActions = {"activate", "deactivate", "trigger", "starts dialog", "stops dialog", "starts chat"},
|
||||
Events = {"activation", "deactivation", "trigger", "end of chat", "end of dialog", "start of chat", "start of dialog"},
|
||||
Conditions = {"is active", "is inactive", "is in dialog", "is not in dialog", "is in chat"},
|
||||
TextContexts = {},
|
||||
TextParameters = {},
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="TriggerOn", Type="Number", WidgetStyle="EnumDropDown", Translation="uiR2EdProp_TriggerOn",
|
||||
Enum={"Leaves the zone", "Enters the zone"},
|
||||
},
|
||||
},
|
||||
|
||||
updateVersion = function(this, scenarioValue, currentValue )
|
||||
|
||||
end,
|
||||
}
|
||||
|
||||
local component = feature.Components.ProximityDialog
|
||||
|
||||
function component:translate(context)
|
||||
r2.Classes["ChatSequence"].translate(self, context)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
--start of state
|
||||
do
|
||||
--use zone trigger prop Cyclic as Repeatable for this component
|
||||
local zTrigger = r2:getInstanceFromId(self._zoneTriggerId)
|
||||
assert(zTrigger)
|
||||
local cyclic = tonumber(zTrigger.Cyclic)
|
||||
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "Repeatable", cyclic)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3,} )
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, rtAction)
|
||||
end
|
||||
|
||||
--trigger
|
||||
do
|
||||
local actionStartDialog = r2.Translator.createAction("dialog_starts", rtGrp.Id)
|
||||
local actionDeactivate = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Repeatable", 0,
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 8))
|
||||
local actionSetV3 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1)
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("multi_actions", {actionStartDialog, actionDeactivate, actionSetV3}))
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_6", self, context, rtAction)
|
||||
end
|
||||
|
||||
--deactivation
|
||||
do
|
||||
local rtAction = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 )
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_8", self, context, rtAction)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function component.createGhostComponents(this, act)
|
||||
local zoneTrigger = r2:getInstanceFromId(this._zoneTriggerId)
|
||||
assert(zoneTrigger)
|
||||
do
|
||||
local type = "On Player Left"
|
||||
if this.TriggerOn == 1 then
|
||||
type = "On Player Arrived"
|
||||
end
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = type
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = type
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(this.InstanceId)
|
||||
action.Action.Type = "trigger"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = zoneTrigger.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "activation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "activation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(zoneTrigger.InstanceId)
|
||||
action.Action.Type = "activate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = this.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "deactivation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "deactivation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(zoneTrigger.InstanceId)
|
||||
action.Action.Type = "deactivate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = this.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function onComponentCreated(this)
|
||||
local x = this.Position.x + 3
|
||||
local y = this.Position.y + 3
|
||||
local zoneTrigger = r2.Features["ZoneTrigger"].Components.ZoneTrigger.createComponent(x, y)
|
||||
assert(zoneTrigger)
|
||||
zoneTrigger.Name = this.Name.." "..i18n.get("uiR2EdZoneTrigger"):toUtf8()
|
||||
zoneTrigger.InheritPos = 0
|
||||
zoneTrigger.Deletable = false
|
||||
table.insert(this.SubComponents, zoneTrigger)
|
||||
this._zoneTriggerId = zoneTrigger.InstanceId
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
|
||||
local function createComponent(x, y)
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewProximityDialogAction"))
|
||||
local proxDialog = r2.newComponent("ProximityDialog")
|
||||
assert(proxDialog)
|
||||
proxDialog.Name = r2:genInstanceName(i18n.get("uiR2EDProximityDialog")):toUtf8()
|
||||
proxDialog.Base = r2.Translator.getDebugBase("palette.entities.botobjects.dialog")
|
||||
proxDialog.Position.x = x
|
||||
proxDialog.Position.y = y
|
||||
proxDialog.Position.z = r2:snapZToGround(x, y)
|
||||
proxDialog.AutoStart = 0
|
||||
onComponentCreated(proxDialog)
|
||||
r2:setCookie(proxDialog.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", proxDialog)
|
||||
end
|
||||
|
||||
local function posOk(x, y, z)
|
||||
if r2.mustDisplayInfo("ProximityDialog") == 1 then
|
||||
r2.displayFeatureHelp("ProximityDialog")
|
||||
end
|
||||
createComponent(x, y)
|
||||
end
|
||||
|
||||
local function posCancel() end
|
||||
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureProximityDialog")
|
||||
end
|
||||
|
||||
component.getLogicAction = function(this, context, action)
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
local rtZoneTrigger = r2.Translator.getRtGroup(context, component._zoneTriggerId)
|
||||
assert(rtZoneTrigger)
|
||||
|
||||
if action.Action.Type == "trigger" then
|
||||
local actionEvent = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6))
|
||||
return actionEvent, actionEvent
|
||||
end
|
||||
|
||||
return r2.Translator.getDialogLogicAction(this, context, action)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
if eventType == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getDialogLogicEvent(this, context, event)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, condition.Entity)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local firstCondition = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1)
|
||||
return firstCondition, firstCondition
|
||||
end
|
||||
|
||||
if condition.Condition.Type == "is inactive" then
|
||||
local firstCondition = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0)
|
||||
return firstCondition, firstCondition
|
||||
end
|
||||
|
||||
return r2.Translator.getDialogLogicCondition(this, context, condition)
|
||||
end
|
||||
|
||||
function component.initLogicEntitiesInstancesMenu(this, subMenu, calledFunction)
|
||||
local entitiesTable = r2.Scenario:getAllInstancesByType(this.Name)
|
||||
for key, entity in pairs(entitiesTable) do
|
||||
local uc_name = ucstring()
|
||||
uc_name:fromUtf8(entity.Name)
|
||||
subMenu:addLine(uc_name, "lua", calledFunction.."('".. entity.InstanceId .."')", entity.InstanceId)
|
||||
end
|
||||
|
||||
if table.getn(entitiesTable)==0 then
|
||||
subMenu:addLine(i18n.get("uiR2EdNoSelelection"), "", "", "")
|
||||
end
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["starts dialog"] = { menu=i18n.get( "uiR2AA0ChatSeqStart" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1ChatSeqStart" ):toUtf8()},
|
||||
["stops dialog"] = { menu=i18n.get( "uiR2AA0ChatSeqStop" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1ChatSeqStop" ):toUtf8()},
|
||||
["starts chat"] = { menu=i18n.get( "uiR2AA0ChatStepStart" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1ChatStepStart" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2AA0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["start of dialog"] = { menu=i18n.get( "uiR2Event0ChatSeqStart" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1ChatSeqStart" ):toUtf8()},
|
||||
["end of dialog"] = { menu=i18n.get( "uiR2Event0ChatSeqEnd" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1ChatSeqEnd" ):toUtf8()},
|
||||
["start of chat"] = { menu=i18n.get( "uiR2Event0ChatStepStart" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1ChatStepStart" ):toUtf8()},
|
||||
["end of chat"] = { menu=i18n.get( "uiR2Event0ChatStepEnd" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1ChatStepEnd" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is in dialog"] = { menu=i18n.get( "uiR2Test0ChatSeq" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1ChatSeq" ):toUtf8()},
|
||||
["is not in dialog"] = { menu=i18n.get( "uiR2Test0ChatNotSeq" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1ChatNotSeq" ):toUtf8()},
|
||||
["is in chat"] = { menu=i18n.get( "uiR2Test0ChatStep" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1ChatStep" ):toUtf8()},
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["ProximityDialog"] = feature
|
||||
|
||||
|
@ -1,589 +0,0 @@
|
||||
|
||||
r2.Features.Quest = {}
|
||||
|
||||
local feature = r2.Features.Quest
|
||||
|
||||
feature.Name="Quest"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.Quest =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="Quest",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "questDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate", "validate current task", "complete"},
|
||||
|
||||
Events = {"activation", "deactivation", "success"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is finished" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
|
||||
{Name="TaskNumber", Type="Number", Category="uiR2EDRollout_Targets", WidgetStyle="EnumDropDown", Enum={"1", "2", "3", "4", "5"},},
|
||||
{Name="TaskStep1Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickTaskComponent", SetRefIdFunction="r2:setTaskComponentTarget",Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="TaskStep2Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickTaskComponent", SetRefIdFunction="r2:setTaskComponentTarget",Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="TaskStep3Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickTaskComponent", SetRefIdFunction="r2:setTaskComponentTarget",Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="TaskStep4Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickTaskComponent", SetRefIdFunction="r2:setTaskComponentTarget",Visible= function(this) return this:displayRefId(4) end},
|
||||
{Name="TaskStep5Id", Type="RefId", Category="uiR2EDRollout_Targets", PickFunction="r2:canPickTaskComponent", SetRefIdFunction="r2:setTaskComponentTarget",Visible= function(this) return this:displayRefId(5) end},
|
||||
|
||||
{Name="QuestCompletedText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"},
|
||||
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.Quest
|
||||
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbRefId = self.TaskNumber + 1
|
||||
if index <= nbRefId then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function component:textAdapter(text)
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
|
||||
str=string.gsub(str, "<quest_name>", self.Name)
|
||||
return str
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
-----------------------------------------------------------------------------------------------------------
|
||||
local questDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
--
|
||||
-- If the message is received by a client that didn't request the modification, we must make sure this client
|
||||
-- doesn't modify the data because it has already been done by the initial client.
|
||||
--
|
||||
local function checkPickedEntity(this, instanceId, attributeName)
|
||||
if instanceId == "" then
|
||||
return false
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
assert(tmpInstance)
|
||||
local i = 1
|
||||
while i < 5 do
|
||||
local attrName = "Task" ..i.. "Id"
|
||||
if attrName ~= attributeName and this[attrName] == tmpInstance.InstanceId then
|
||||
return false
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local oldOnAttrModified = questDisplayerTable.onAttrModified
|
||||
function questDisplayerTable:onAttrModified(instance, attributeName)
|
||||
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
|
||||
if attributeName == "TaskNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbRefId = instance.TaskNumber + 1
|
||||
local i = 1
|
||||
while i <= 5 do
|
||||
if i > nbRefId then
|
||||
local name = "TaskStep"..tostring(i).."Id"
|
||||
local refId = propertySheet:find(name)
|
||||
local refIdName = refId:find("name")
|
||||
refIdName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, name, "")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
if (string.find(attributeName, "Id") == nil or attributeName == "InstanceId") then return end
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local refId = propertySheet:find(attributeName)
|
||||
if refId == nil then return end
|
||||
local refIdName = refId:find("name")
|
||||
local instanceId = instance[attributeName]
|
||||
if not instanceId then
|
||||
return
|
||||
end
|
||||
|
||||
if instanceId == "" then
|
||||
refIdName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
local inserted = checkPickedEntity(instance, instanceId, attributeName)
|
||||
if inserted == true then
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
refIdName.hardtext = tmpInstance.Name
|
||||
else
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, "")
|
||||
end
|
||||
instance.User.onHrcMove = false
|
||||
end
|
||||
|
||||
function questDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function r2:questDisplayer()
|
||||
return questDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------
|
||||
---------------------------------------------------------------------------------------
|
||||
function component:createGhostComponents(act)
|
||||
local comp = self
|
||||
|
||||
local nbTask = 0
|
||||
local firstId = true
|
||||
|
||||
for id = 1, 5 do
|
||||
local propertyName = "TaskStep"..tonumber(id).."Id"
|
||||
if comp[propertyName] ~= nil and comp[propertyName] ~= "" then
|
||||
local taskInstance = r2:getInstanceFromId(comp[propertyName])
|
||||
if taskInstance then
|
||||
if firstId == true then
|
||||
if comp.Active == 1 then
|
||||
r2.requestSetGhostNode(taskInstance.InstanceId, "Active", 1)
|
||||
else
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "activation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "activation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(taskInstance.InstanceId)
|
||||
action.Action.Type = "activate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = comp.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
firstId = false
|
||||
else
|
||||
r2.requestSetGhostNode(taskInstance.InstanceId, "Active", 0)
|
||||
end
|
||||
r2.requestSetGhostNode(taskInstance.InstanceId, "Repeatable", 0)
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "deactivation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "deactivation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(taskInstance.InstanceId)
|
||||
action.Action.Type = "deactivate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = comp.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end --!FOR
|
||||
end
|
||||
|
||||
function component:getTaskRtIds(context)
|
||||
local rtGroups = {}
|
||||
for id = 1, 5 do
|
||||
local taskId = self["TaskStep"..id.."Id"]
|
||||
if taskId and taskId ~= "" then
|
||||
local rtGroup = r2.Translator.getRtGroup(context, taskId)
|
||||
local prefix = ""
|
||||
if rtGroup.Id and rtGroup.Id ~= "" then
|
||||
prefix = r2:getNamespace()..rtGroup.Id.."."
|
||||
end
|
||||
table.insert(rtGroups, prefix)
|
||||
end
|
||||
end
|
||||
return rtGroups
|
||||
end
|
||||
|
||||
function component:getTaskInstances(context)
|
||||
local instances = {}
|
||||
for id = 1, 5 do
|
||||
local taskId = self["TaskStep"..id.."Id"]
|
||||
if taskId and taskId ~= "" then
|
||||
local instance = r2:getInstanceFromId(taskId)
|
||||
if instance then
|
||||
table.insert(instances, instance)
|
||||
end
|
||||
end
|
||||
end
|
||||
return instances
|
||||
end
|
||||
|
||||
function component:translate(context)
|
||||
--EVENTS :
|
||||
-- 4: activate
|
||||
-- 5 : deactivate
|
||||
-- 4 (for steps) : init (activate reinit default values on mission steps)
|
||||
-- 8 : quest completed
|
||||
-- 9 : validate task step
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
local taskInstances = self:getTaskInstances(context)
|
||||
if table.getn(taskInstances) == 0 then return end
|
||||
local taskRtGrps = self:getTaskRtIds(context)
|
||||
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
|
||||
-- Start of state
|
||||
do
|
||||
-- v1 = repeatable
|
||||
-- v2 = current step index
|
||||
-- v3 = completed (at least once)
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1)
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, } )
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
local k, v = next(taskInstances, nil)
|
||||
while k do
|
||||
local taskIndex = k
|
||||
local taskInstance = v
|
||||
|
||||
local rtActionIncrement = r2.Translator.createAction("increment_quest_step_index", rtGrp.Id, taskIndex)
|
||||
local event = r2.Translator.getEventFromType(taskInstance, context, "succeeded") --get the right event for "succeeded"
|
||||
r2.Translator.translateAiGroupEvent(event.Event, taskInstance, context, rtActionIncrement)
|
||||
|
||||
k, v = next(taskInstances, k)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local actionValidateTask = r2.Translator.createAction("validate_quest_step", rtGrp.Id, taskRtGrps)
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_9", self, context, actionValidateTask)
|
||||
end
|
||||
|
||||
|
||||
--Deactivation (event 5)
|
||||
do
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
})
|
||||
r2.Translator.translateAiGroupEvent("user_event_5", self, context, rtAction)
|
||||
end
|
||||
|
||||
--Mission completed (event 8)
|
||||
do
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg", baseActRtGrp.Id, self:textAdapter(self.QuestCompletedText))
|
||||
|
||||
local actionRepeatable = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, --if Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
})
|
||||
);
|
||||
local actionNotRepeatable = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- if not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
})
|
||||
)
|
||||
|
||||
local actionCompleted = r2.Translator.createAction("multi_actions", {
|
||||
actionRepeatable, actionNotRepeatable, actionBroadcast,
|
||||
})
|
||||
r2.Translator.translateAiGroupEvent("user_event_8", self, context, actionCompleted)
|
||||
end
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtGrp)
|
||||
|
||||
local prefix = ""
|
||||
if rtGrp.Id and rtGrp.Id ~= "" then
|
||||
prefix = r2:getNamespace() .. rtGrp.Id.."."
|
||||
end
|
||||
|
||||
local taskRtGrps = component:getTaskRtIds(context)
|
||||
|
||||
if action.Action.Type == "validate current task" then
|
||||
local actionSet = r2.Translator.createAction("set_value", rtGrp.Id, "v2", prefix.."v2 + 1")
|
||||
local actionEvent = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 9)
|
||||
--local actionValidateStep = r2.Translator.createAction("validate_task_step", rtGrp.Id, taskRtGrps)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {actionSet, actionEvent})
|
||||
local ifActive = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, rtAction)
|
||||
return ifActive, ifActive
|
||||
|
||||
elseif action.Action.Type == "complete" then
|
||||
|
||||
local actionEventComplete = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 8)
|
||||
local ifActive = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, actionEventComplete)
|
||||
|
||||
return ifActive, ifActive
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is finished" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1);
|
||||
return action1, action1
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "success" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 8)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local questCompletedText = i18n.get("uiR2EdQuest_QuestCompletedText"):toUtf8()
|
||||
|
||||
local comp = r2.newComponent("Quest")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdQuest")):toUtf8()
|
||||
|
||||
comp.QuestCompletedText = questCompletedText
|
||||
comp.TaskNumber = 0
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("Quest", 0)
|
||||
else r2.setDisplayInfo("Quest", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.Quest.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'Quest' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'Quest' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("Quest") == 1 then
|
||||
r2.displayFeatureHelp("Quest")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewQuestAction"))
|
||||
local component = feature.Components.Quest.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'Quest' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureQuest")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdQuest")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "Quest")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["validate current task"] = { menu=i18n.get( "uiR2AA0ValidateCurrentTask" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1ValidateCurrentTask" ):toUtf8()},
|
||||
["complete"] = { menu=i18n.get( "uiR2AA0CompleteQuest" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1CompleteQuest" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["success"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is finished"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["Quest"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,472 +0,0 @@
|
||||
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdEasterEgg --
|
||||
-- CreationFrom : uiR2EdEasterEggParameters
|
||||
|
||||
|
||||
r2.Features.RandomChest = {}
|
||||
|
||||
local feature = r2.Features.RandomChest
|
||||
|
||||
feature.Name="RandomChest"
|
||||
|
||||
feature.Description="A feature that allows a NPC to take some item(s) from easter eggs"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
|
||||
|
||||
feature.Components.RandomChest =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="RandomChest",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "randomChestDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = { "activation", "deactivation", "opened"},
|
||||
|
||||
Conditions = { "is active", "is inactive" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table", Visible = false},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="ItemNumber", Type="Number", Category="uiR2EDRollout_Items", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3"}, },
|
||||
{Name="Item1Qty", Type="Number", Category="uiR2EDRollout_Items", Min="1", Max="50",DefaultValue="1", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item1Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_Items", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item1Weight", Type="Number", Category="uiR2EDRollout_Items", Min="1", Max="100", DefaultValue="33", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item2Qty", Type="Number", Category="uiR2EDRollout_Items", Min="0", Max="50",DefaultValue="0", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item2Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_Items", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item2Weight", Type="Number", Category="uiR2EDRollout_Items", Min="1", Max="100", DefaultValue="33", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item3Qty", Type="Number", Category="uiR2EDRollout_Items", Min="0",Max="50", DefaultValue="0", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Item3Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_Items", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Item3Weight", Type="Number", Category="uiR2EDRollout_Items", Min="1", Max="100", DefaultValue="33", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", Min="0", DefaultValue="1"},
|
||||
},
|
||||
|
||||
--
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
--
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
--
|
||||
-- Called when running EditMode to create locally the feature without sending anything into the act (speed purpose).
|
||||
--
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
local eggId = this:getEggId(context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
local entity = this
|
||||
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
|
||||
if (this.Active == 1)
|
||||
then
|
||||
local eggId = this:getEggId(context)
|
||||
local initialAction = this:createActionActivateRandomChest(context)
|
||||
r2.Translator.translateAiGroupInitialState(this, context, initialAction)
|
||||
end
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end
|
||||
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local component = feature.Components.RandomChest
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbItems = self.ItemNumber + 1
|
||||
if index <= nbItems then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local randomChestDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
function randomChestDisplayerTable:onAttrModified(instance, attributeName)
|
||||
if attributeName == "ItemNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbRefId = instance.ItemNumber + 1
|
||||
local i = 1
|
||||
while i <= 3 do
|
||||
if i > nbRefId then
|
||||
local name = "Item"..tostring(i).."Id"
|
||||
local qty = "Item"..tostring(i).."Qty"
|
||||
local weight = "Item"..tostring(i).."Weight"
|
||||
r2.requestSetNode(instance.InstanceId, name, r2.RefId(""))
|
||||
r2.requestSetNode(instance.InstanceId, qty, 0)
|
||||
r2.requestSetNode(instance.InstanceId, weight, 0)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
end
|
||||
|
||||
function randomChestDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function r2:randomChestDisplayer()
|
||||
return randomChestDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
--
|
||||
-- Create the logic actions relative to the feature via the translator.
|
||||
--
|
||||
|
||||
function getPlotItemIdByInstance(missionItem)
|
||||
if not missionItem then return "" end
|
||||
local container = r2.Scenario.PlotItems
|
||||
local k, v = next(container)
|
||||
local id = 0
|
||||
while k do
|
||||
if tostring(v.InstanceId) == tostring(missionItem.InstanceId) then return id end
|
||||
id = id + 1
|
||||
k, v = next(container, k)
|
||||
end
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
|
||||
function component:getItems()
|
||||
|
||||
local str = ""
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
--r2.print("ITEM= '" ..item.."'")
|
||||
if item and item ~= "" then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
local plotItemId = getPlotItemIdByInstance(plotItem)
|
||||
if str ~= "" then str = str ..";" end
|
||||
|
||||
str = str .. tostring(plotItemId)..":"..qt
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function component:computeItemWeight(index)
|
||||
local total = tonumber(self.Item1Weight) + tonumber(self.Item2Weight) + tonumber(self.Item3Weight)
|
||||
if total == 0 then return -1 end
|
||||
local coeff = 100.0 / total
|
||||
|
||||
local weight = tonumber(self["Item"..tostring(index).."Weight"]) * coeff
|
||||
return weight
|
||||
end
|
||||
|
||||
function component:createActionActivateRandomChest(context)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
local eggId = self:getEggId(context)
|
||||
local pos = r2.getWorldPos(self)
|
||||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = r2:snapZToGround(x, y)
|
||||
|
||||
local item1Weight = self:computeItemWeight(1)
|
||||
local item1Id = tostring(getPlotItemIdByInstance(r2:getInstanceFromId(self.Item1Id)))
|
||||
local item1Qty = tonumber(self.Item1Qty)
|
||||
|
||||
local item2Weight = self:computeItemWeight(2)
|
||||
local item2Id = tostring(getPlotItemIdByInstance(r2:getInstanceFromId(self.Item2Id)))
|
||||
local item2Qty = tonumber(self.Item2Qty)
|
||||
|
||||
local item3Weight = self:computeItemWeight(3)
|
||||
local item3Id = tostring(getPlotItemIdByInstance(r2:getInstanceFromId(self.Item3Id)))
|
||||
local item3Qty = tonumber(self.Item3Qty)
|
||||
|
||||
if item1Weight == -1 or item2Weight == -1 or item3Weight == -1 then
|
||||
debugInfo("Random chest: cannot divide by 0!")
|
||||
return
|
||||
end
|
||||
|
||||
local randomChestActivation = r2.Translator.createAction("random_chest_activate", rtGrp.Id, eggId, r2:getActId(context.Act), x, y, z,
|
||||
item1Weight, item1Id, item1Qty,
|
||||
item2Weight, item2Id, item2Qty,
|
||||
item3Weight, item3Id, item3Qty,
|
||||
self.Name)
|
||||
local setValue = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)
|
||||
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {randomChestActivation, setValue})
|
||||
return rtAction
|
||||
end
|
||||
|
||||
function component:createActionDeactivateEasterEgg(context)
|
||||
local eggId = self:getEggId(context)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
local actionDeactivate = r2.Translator.createAction("easter_egg_deactivate", rtGrp.Id, eggId, r2:getActId(context.Act))
|
||||
local actionSetValue = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0)
|
||||
|
||||
return r2.Translator.createAction("multi_actions", {actionDeactivate, actionSetValue})
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
|
||||
if (action.Action.Type == "activate") then
|
||||
|
||||
local retAction = component:createActionActivateRandomChest(context)
|
||||
return retAction, retAction
|
||||
elseif (action.Action.Type == "deactivate") then
|
||||
local retAction = component:createActionDeactivateEasterEgg(context)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
local firstAction, lastAction = nil, nil
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
--
|
||||
-- Checks the conditions defined for this feature
|
||||
--
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "opened" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "activation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 4)
|
||||
elseif eventType == "deactivation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 5)
|
||||
end
|
||||
return eventHandler, firstCondition, lastCondition
|
||||
end
|
||||
|
||||
|
||||
-- feature part
|
||||
|
||||
|
||||
--
|
||||
-- Creates an instance of the feature with attributes retrieved from the creation form
|
||||
--
|
||||
function component.createComponent(x, y)
|
||||
|
||||
local comp = r2.newComponent("RandomChest")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = "palette.entities.botobjects.chest_wisdom_std_sel"
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdRandomChest")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
function component:getEggId(context)
|
||||
assert(context)
|
||||
local n = 0
|
||||
|
||||
if context.EasterEggUniqId == nil then
|
||||
context.EasterEggUniqId = {}
|
||||
context.EasterEggMaxId = 0
|
||||
end
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
if context.EasterEggUniqId[rtNpcGrp.Id] == nil then
|
||||
local n = context.EasterEggMaxId + 1
|
||||
context.EasterEggUniqId[rtNpcGrp.Id] = n
|
||||
context.EasterEggMaxId = n
|
||||
end
|
||||
|
||||
return context.EasterEggUniqId[rtNpcGrp.Id]
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- from ihm
|
||||
-- Displays the creation form of the feature and calls CreateComponent with the user input values
|
||||
--
|
||||
function component.create()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("EasterEggForm", 0)
|
||||
else r2.setDisplayInfo("EasterEggForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local comp = component.createComponent( x, y)
|
||||
r2:setCookie(comp.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", comp)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'RandomChest' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'RandomChest' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("RandomChest") == 1 then
|
||||
r2.displayFeatureHelp("RandomChest")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewRandomChestAction"))
|
||||
local comp = component.createComponent( x, y)
|
||||
r2:setCookie(comp.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", comp)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'RandomChest' position")
|
||||
end
|
||||
r2:choosePos("object_chest_wisdom_std_sel.creature", posOk, posCancel, "createFeatureEasterEgg")
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
--- register the current Feature to menu
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- add a line to the event menu
|
||||
function component:getLogicTranslations()
|
||||
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Spawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Spawn" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Despawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Despawn" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Spawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Spawn" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Despawn" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Despawn" ):toUtf8()},
|
||||
["opened"] = { menu=i18n.get( "uiR2Event0ChestOpened" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1ChestOpened" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Spawned" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Spawned" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Despawned" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Despawned" ):toUtf8()}
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["RandomChest"] = feature
|
||||
|
||||
|
||||
|
@ -1,562 +0,0 @@
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdRequestItem --
|
||||
-- CreationFrom : uiR2EdRequestItemParameters
|
||||
|
||||
|
||||
r2.Features.RequestItemFeature = {}
|
||||
|
||||
local feature = r2.Features.RequestItemFeature
|
||||
|
||||
feature.Name="RequestItemFeature"
|
||||
|
||||
feature.Description="A feature that makes a NPC request some item(s) from the player"
|
||||
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.RequestItem =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="RequestItem",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "requestItemDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = { "activation", "deactivation", "wait validation", "mission asked", "succeeded"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is succeeded" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
{Name="ItemNumber", Type="Number", Category="uiR2EDRollout_ItemsToRequest", WidgetStyle="EnumDropDown", DefaultValue="3",
|
||||
Enum={"1", "2", "3"}, },
|
||||
{Name="Item1Qty", Type="Number", Category="uiR2EDRollout_ItemsToRequest", Min="0", DefaultValue="1", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Item1Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToRequest", Visible= function(this) return this:displayRefId(1) end},
|
||||
|
||||
|
||||
{Name="Item2Qty", Type="Number", Category="uiR2EDRollout_ItemsToRequest", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Item2Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToRequest", Visible= function(this) return this:displayRefId(2) end},
|
||||
|
||||
{Name="Item3Qty", Type="Number", Category="uiR2EDRollout_ItemsToRequest", Min="0", DefaultValue="0", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Item3Id", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_ItemsToRequest", Visible= function(this) return this:displayRefId(3) end},
|
||||
|
||||
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100"},
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="WaitValidationText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"}
|
||||
|
||||
},
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.RequestItem
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbItems = self.ItemNumber + 1
|
||||
if index <= nbItems then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local requestItemDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
function requestItemDisplayerTable:onAttrModified(instance, attributeName)
|
||||
if attributeName == "ItemNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbRefId = instance.ItemNumber + 1
|
||||
local i = 1
|
||||
while i <= 3 do
|
||||
if i > nbRefId then
|
||||
local name = "Item"..tostring(i).."Id"
|
||||
local qty = "Item"..tostring(i).."Qty"
|
||||
r2.requestSetNode(instance.InstanceId, name, r2.RefId(""))
|
||||
r2.requestSetNode(instance.InstanceId, qty, 0)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
end
|
||||
|
||||
function requestItemDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:requestItemDisplayer()
|
||||
return requestItemDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:getItems()
|
||||
local str = ""
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
local plotItemSheetId = plotItem.SheetId
|
||||
if str ~= "" then str = str ..";" end
|
||||
local name = ""
|
||||
if plotItemSheetId ~= nil then
|
||||
name = r2.getSheetIdName(plotItemSheetId)
|
||||
end
|
||||
str = str .. tostring(name)..":"..qt
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function component:textAdapter(text)
|
||||
assert(text)
|
||||
if type(text) ~= "string" then
|
||||
debugInfo("Wrong type "..type(text))
|
||||
assert(nil)
|
||||
end
|
||||
local str = ""
|
||||
local items = {}
|
||||
local qts = {}
|
||||
|
||||
local id = 1
|
||||
while id <= 3 do
|
||||
local item = self["Item"..tostring(id).."Id"]
|
||||
local item2 = self.Item1Id
|
||||
if (item) then
|
||||
|
||||
local qt = tonumber(self["Item"..tostring(id).."Qty"])
|
||||
qts[id] = qt
|
||||
|
||||
local plotItem = r2:getInstanceFromId(item)
|
||||
if plotItem then
|
||||
items[id] = plotItem.Name
|
||||
else
|
||||
items[id] = ""
|
||||
end
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
local str = text
|
||||
str=string.gsub (str, "<qt1>", tostring(qts[1]))
|
||||
str=string.gsub (str, "<qt2>", tostring(qts[2]))
|
||||
str=string.gsub (str, "<qt3>", tostring(qts[3]))
|
||||
str=string.gsub (str, "<item1>", tostring(items[1]))
|
||||
str=string.gsub (str, "<item2>", tostring(items[2]))
|
||||
str=string.gsub (str, "<item3>", tostring(items[3]))
|
||||
|
||||
local mission_giver = ""
|
||||
if self.MissionGiver == nil then return end
|
||||
local npc = r2:getInstanceFromId(self.MissionGiver)
|
||||
if npc then
|
||||
mission_giver = npc.Name
|
||||
end
|
||||
str=string.gsub(str, "<mission_giver>", tostring(mission_giver))
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
if self.MissionGiver == nil or self.MissionGiver == "" then return end
|
||||
local npc = r2:getInstanceFromId(self.MissionGiver)
|
||||
if not npc then return end
|
||||
|
||||
local npcGrp = r2.Translator.getRtGroup(context, npc.InstanceId)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
local items = self:getItems()
|
||||
|
||||
|
||||
--START OF STATE
|
||||
do
|
||||
local action = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 7)
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- Success
|
||||
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {rtAction1, rtAction2, rtAction3})
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_7", self, context, rtAction)
|
||||
end
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_4", self, context, rtAction)
|
||||
end
|
||||
|
||||
--CONTEXTUAL TEXT
|
||||
do
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("request_item", rtGrp.Id, items, self:textAdapter(self.ContextualText))
|
||||
)
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", npc, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--MISSION SUCCEEDED TEXT
|
||||
do
|
||||
|
||||
local actionSaySucceedText = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1,
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2),
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.MissionSucceedText), npcGrp.Id ..":"..npc.Name),
|
||||
}));
|
||||
|
||||
local actionRepeatable = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 )
|
||||
})
|
||||
);
|
||||
local actionNotRepeatable = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- Not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) )
|
||||
|
||||
|
||||
--reset all features var after success (depending on "repeatable")
|
||||
local actionReset = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 2,
|
||||
r2.Translator.createAction("multi_actions", {actionRepeatable, actionNotRepeatable}))
|
||||
|
||||
local rtActionSucceed = r2.Translator.createAction("multi_actions", {actionSaySucceedText, actionReset, actionBroadcast})
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_3", self, context, rtActionSucceed)
|
||||
end
|
||||
|
||||
|
||||
--MISSION TEXT
|
||||
do
|
||||
local actionSayMissionText = r2.Translator.createAction("npc_say", self:textAdapter(self.MissionText), npcGrp.Id ..":"..npc.Name);
|
||||
local actionSetStatus = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1)
|
||||
|
||||
--local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0,actionSayMissionText)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {actionSayMissionText, actionSetStatus})
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_2", self, context, rtAction)
|
||||
end
|
||||
|
||||
--WAIT VALIDATION TEXT
|
||||
do
|
||||
|
||||
|
||||
-- if the player carries the requested items when talking to the giver for the first time
|
||||
local actionMission = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0,
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.MissionText), npcGrp.Id ..":"..npc.Name),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1)
|
||||
}))
|
||||
|
||||
|
||||
-- if the player has already talked to the giver and brings the requested item
|
||||
|
||||
|
||||
local actionValidation = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1,
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.WaitValidationText), npcGrp.Id ..":"..npc.Name)
|
||||
)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {actionValidation, actionMission})
|
||||
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_1", self, context, rtAction)
|
||||
end
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v2", 2);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this--r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "mission asked" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "wait validation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 1)
|
||||
elseif eventType == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 3)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("RequestItem")
|
||||
assert(comp)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdRequestItem_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdRequestItem_MissionText"):toUtf8()
|
||||
local waitValidationText = i18n.get("uiR2EdRequestItem_WaitValidationText"):toUtf8()
|
||||
local missionSucceededText = i18n.get("uiR2EdRequestItem_MissionSucceededText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdRequestItem_BroadcastText"):toUtf8()
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_request_item")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDRequestItem")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.WaitValidationText = waitValidationText
|
||||
comp.MissionSucceedText = missionSucceededText
|
||||
comp.BroadcastText = broadcastText
|
||||
|
||||
comp.ItemNumber = 0
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
-- comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("RequestItemForm", 0)
|
||||
else r2.setDisplayInfo("RequestItemForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.RequestItem.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'RequestItem' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'RequestItem' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("RequestItem") == 1 then
|
||||
r2.displayFeatureHelp("RequestItem")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewRequestItemFeatureAction"))
|
||||
local component = feature.Components.RequestItem.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'RequestItem' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_request_item.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureRequestItem")
|
||||
end
|
||||
|
||||
|
||||
--function component:registerMenu(logicEntityMenu)
|
||||
-- local name = i18n.get("uiR2EDRequestItem")
|
||||
-- logicEntityMenu:addLine(ucstring(name), "lua", "", "RequestItem")
|
||||
--end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["mission asked"] = { menu=i18n.get( "uiR2Event0MissionGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MissionGiven" ):toUtf8()},
|
||||
["wait validation"] = { menu=i18n.get( "uiR2Event0TaskWaitValidation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskWaitValidation" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["RequestItem"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,426 +0,0 @@
|
||||
--------------------------------
|
||||
-- Events for reward provider:
|
||||
-- #4 : activation
|
||||
-- #5 : deactivation
|
||||
-- #6 : reward generated
|
||||
|
||||
|
||||
r2.Features.RewardProviderFeature = {}
|
||||
|
||||
local feature = r2.Features.RewardProviderFeature
|
||||
|
||||
feature.Name="RewardProviderFeature"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
|
||||
feature.Components.RewardProvider =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="RewardProvider",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "rewardProviderDisplayer",
|
||||
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "reward given"},
|
||||
|
||||
Conditions = { "is active", "is inactive"},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="RewardGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="OnTargetText", Type="String", Category="uiR2EDRollout_TextToSay" },
|
||||
{Name="RewardText", Type="String", Category="uiR2EDRollout_TextToSay" },
|
||||
{Name="RareRewardText", Type="String", Category="uiR2EDRollout_TextToSay" },
|
||||
{Name="InventoryFullText", Type="String", Category="uiR2EDRollout_TextToSay" },
|
||||
{Name="NotEnoughPointsText", Type="String", Category="uiR2EDRollout_TextToSay" },
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
if component.appendInstancesByType then
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
|
||||
local component = feature.Components.RewardProvider
|
||||
|
||||
function component.pretranslate(this, context)
|
||||
local prop = component.Prop
|
||||
r2.Translator.CheckPickedEntity(this, prop)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local rewardProviderTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = rewardProviderTable.onAttrModified
|
||||
|
||||
function rewardProviderTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(instance, attributeName)
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
|
||||
local giverRefId = propertySheet:find("RewardGiver")
|
||||
local giverName = propertySheet:find("RewardGiver"):find("name")
|
||||
|
||||
if attributeName == "RewardGiver" then
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
giverName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
giverName.hardtext = tmpInstance.Name
|
||||
end
|
||||
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function rewardProviderTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:rewardProviderDisplayer()
|
||||
return rewardProviderTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:textAdapter(text)
|
||||
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local reward_giver = ""
|
||||
|
||||
if tostring(self.RewardGiver) ~= "" then
|
||||
local giver = r2:getInstanceFromId(self.RewardGiver)
|
||||
if giver then reward_giver = giver.Name end
|
||||
end
|
||||
|
||||
str=string.gsub(str, "<reward_giver>", reward_giver)
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
function component:getTextTable()
|
||||
local texts = {}
|
||||
texts["rewardText"] = self:textAdapter(self.RewardText)
|
||||
texts["rareRewardText"] = self:textAdapter(self.RareRewardText)
|
||||
texts["inventoryFullText"] = self:textAdapter(self.InventoryFullText)
|
||||
texts["notEnoughPointsText"] = self:textAdapter(self.NotEnoughPointsText)
|
||||
|
||||
return texts
|
||||
end
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local giver = r2:getInstanceFromId(self.RewardGiver)
|
||||
if not giver then return end
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
|
||||
-----------------
|
||||
--Contextual & onTarget text
|
||||
do
|
||||
if giver then
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("talk_to", rtGrp.Id, self:textAdapter(self.ContextualText)))
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, rtAction)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
if giver then
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.OnTargetText), rtGiverGrp.Id ..":"..giver.Name))
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, rtAction)
|
||||
end
|
||||
end
|
||||
-------------------
|
||||
--give reward action
|
||||
do
|
||||
if giver then
|
||||
local texts = self:getTextTable()
|
||||
|
||||
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("give_reward", rtGiverGrp.Id, giver.Name, texts),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 6) }))
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_3", self, context, rtAction)
|
||||
end
|
||||
end
|
||||
-------------------
|
||||
--Start of state
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2} )
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, rtAction)
|
||||
end
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "reward given" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdRewardProvider_ContextualText"):toUtf8()
|
||||
local onTargetText = i18n.get("uiR2EdRewardProvider_OnTargetText"):toUtf8()
|
||||
local rewardText = i18n.get("uiR2EdRewardProvider_RewardText"):toUtf8()
|
||||
local rareRewardText = i18n.get("uiR2EdRewardProvider_RareRewardText"):toUtf8()
|
||||
local inventoryFullText = i18n.get("uiR2EdRewardProvider_InventoryFullText"):toUtf8()
|
||||
local notEnoughPointsText = i18n.get("uiR2EdRewardProvider_NotEnoughPointsText"):toUtf8()
|
||||
|
||||
local comp = r2.newComponent("RewardProvider")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDRewardProvider")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.OnTargetText = onTargetText
|
||||
comp.RewardText = rewardText
|
||||
comp.RareRewardText = rareRewardText
|
||||
comp.InventoryFullText = inventoryFullText
|
||||
comp.NotEnoughPointsText = notEnoughPointsText
|
||||
|
||||
comp.Repeatable = true
|
||||
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
r2:checkAiQuota()
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("RewardProvider", 0)
|
||||
else r2.setDisplayInfo("RewardProvider", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.RewardProvider.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'RewardProvider' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'RewardProvider' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("RewardProvider") == 1 then
|
||||
r2.displayFeatureHelp("RewardProvider")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewRewardProviderFeatureAction"))
|
||||
local component = feature.Components.RewardProvider.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'RewardProvider' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureRewardProvider")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EDRollout_RewardProvider")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "RewardProvider")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["reward given"] = { menu=i18n.get( "uiR2Event0RewardGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1RewardGiven" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["RewardProvider"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,438 +0,0 @@
|
||||
|
||||
r2.Features.SceneryObjectInteractionFeature = {}
|
||||
|
||||
local feature = r2.Features.SceneryObjectInteractionFeature
|
||||
|
||||
feature.Name="SceneryObjectInteractionFeature"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.SceneryObjectInteraction =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="SceneryObjectInteraction",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "sceneryObjectInteractionDisplayer",
|
||||
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "trigger"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "has triggered", "has not triggered" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="SceneryObject", Type="RefId", PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget"},
|
||||
|
||||
--{Name="ContextualText", Type="String", ValidationFun="r2.refuseEmptyString", Category="uiR2EDRollout_TextToSay" },
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100" },
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"}
|
||||
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
|
||||
local component = feature.Components.SceneryObjectInteraction
|
||||
|
||||
function component.pretranslate(this, context)
|
||||
local prop = component.Prop
|
||||
r2.Translator.CheckPickedEntity(this, prop)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local sceneryObjectInteractionDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = sceneryObjectInteractionDisplayerTable.onAttrModified
|
||||
|
||||
function sceneryObjectInteractionDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(instance, attributeName)
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
|
||||
local scObjRefId = propertySheet:find("SceneryObject")
|
||||
local scObjName = scObjRefId:find("name")
|
||||
|
||||
|
||||
|
||||
if attributeName == "SceneryObject" then
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
scObjName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
scObjName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
return
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function sceneryObjectInteractionDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
debugInfo("postHrcMove!")
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:sceneryObjectInteractionDisplayer()
|
||||
return sceneryObjectInteractionDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:textAdapter(text)
|
||||
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local object = ""
|
||||
|
||||
|
||||
if tostring(self.SceneryObject) ~= "" then
|
||||
local scObject = r2:getInstanceFromId(self.SceneryObject)
|
||||
if scObject then object = scObject.Name end
|
||||
end
|
||||
|
||||
|
||||
str=string.gsub(str, "<object_name>", object)
|
||||
return str
|
||||
end
|
||||
|
||||
function component:pretranslate(context)
|
||||
if context.InteractingSceneryObjects then
|
||||
if self.SceneryObject and self.SceneryObject ~= "" then
|
||||
local scObj = r2:getInstanceFromId(self.SceneryObject)
|
||||
--assert(scObj)
|
||||
table.insert(context.InteractingSceneryObjects, scObj.InstanceId)
|
||||
end
|
||||
end
|
||||
--inspect(context.InteractingSceneryObjects)
|
||||
r2.Translator.createAiGroup(self, context)
|
||||
end
|
||||
|
||||
function component:translate(context)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local sceneryObject = r2:getInstanceFromId(self.SceneryObject)
|
||||
|
||||
-----------------
|
||||
--Contextual text
|
||||
do
|
||||
if sceneryObject then
|
||||
local actionContextual = r2.Translator.createAction("talk_to", rtGrp.Id, self:textAdapter(tostring(self.ContextualText)))
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0, actionContextual))
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", sceneryObject, context, rtAction)
|
||||
end
|
||||
end
|
||||
|
||||
r2.Translator.Tasks.setStatusLogic(self, context, rtGrp)
|
||||
-------------------
|
||||
--Trigger
|
||||
if sceneryObject then
|
||||
local rtSceneryObjectGrp = r2.Translator.getRtGroup(context, sceneryObject.InstanceId)
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, --if active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, --and if the scenery object has been selected once by the player
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 6) })
|
||||
))
|
||||
|
||||
--r2.Translator.translateAiGroupEvent("player_target_npc", sceneryObject, context, rtAction)
|
||||
r2.Translator.translateAiGroupEvent("user_event_3", self, context, rtAction)
|
||||
end
|
||||
|
||||
-------------------
|
||||
--Start of state
|
||||
|
||||
do
|
||||
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- the scenery object hasn't been selected yet
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 0)
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, rtAction4} )
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
})
|
||||
);
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- Not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
|
||||
local rtAction = r2.Translator.createAction("multi_actions", {action2, action3})
|
||||
--Autodeactivate after having triggered
|
||||
r2.Translator.translateAiGroupEvent("user_event_6", self, context, rtAction)
|
||||
end
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
local prefix = ""
|
||||
|
||||
if rtNpcGrp.Id and rtNpcGrp.Id ~= "" then
|
||||
prefix = r2:getNamespace() .. rtNpcGrp.Id.."."
|
||||
end
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "has triggered" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1 );
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "has not triggered" then
|
||||
local action1 = r2.Translator.createAction("dynamic_if", prefix.."v3 == 0");
|
||||
return action1, action1
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if event.Event.Type == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdSceneryObjectInteraction_ContextualText"):toUtf8()
|
||||
|
||||
local comp = r2.newComponent("SceneryObjectInteraction")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdSceneryObjectInteraction")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
-- comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
r2:checkAiQuota()
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("SceneryObjectInteraction", 0)
|
||||
else r2.setDisplayInfo("SceneryObjectInteraction", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.SceneryObjectInteraction.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'SceneryObjectInteraction' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'SceneryObjectInteraction' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("SceneryObjectInteraction") == 1 then
|
||||
r2.displayFeatureHelp("SceneryObjectInteraction")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewSceneryObjectInteractionFeatureAction"))
|
||||
local component = feature.Components.SceneryObjectInteraction.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'SceneryObjectInteraction' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureSceneryObjectInteraction")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdSceneryObjectInteraction")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "SceneryObjectInteraction")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["has triggered"] = { menu=i18n.get( "uiR2Test0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Trigger" ):toUtf8()},
|
||||
["has not triggered"] = { menu=i18n.get( "uiR2Test0NotTrigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1NotTrigger" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["SceneryObjectInteractionFeature"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,549 +0,0 @@
|
||||
|
||||
r2.Features.SceneryObjectInteractionTaskStepTaskStep = {}
|
||||
|
||||
local feature = r2.Features.SceneryObjectInteractionTaskStepTaskStep
|
||||
|
||||
feature.Name="SceneryObjectInteractionTaskStepTaskStep"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.SceneryObjectInteractionTaskStep =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="SceneryObjectInteractionTaskStep",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "sceneryObjectInteractionTaskStepDisplayer",
|
||||
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "succeeded"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "in progress", "is succeeded" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"},
|
||||
{Name="ValidationNeeded", Category="uiR2EDRollout_TextToSay", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="SceneryObject", Type="RefId", PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="NotValidatedText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay", Visible= function(this)
|
||||
return this:IsValidationNeeded() end, DefaultInBase = 1},
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
|
||||
local component = feature.Components.SceneryObjectInteractionTaskStep
|
||||
|
||||
function component:IsValidationNeeded()
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
if validationNeeded == 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function component.pretranslate(this, context)
|
||||
local prop = component.Prop
|
||||
r2.Translator.CheckPickedEntity(this, prop)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local sceneryObjectInteractionTaskStepDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = sceneryObjectInteractionTaskStepDisplayerTable.onAttrModified
|
||||
|
||||
function sceneryObjectInteractionTaskStepDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(instance, attributeName)
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
|
||||
local scObjRefId = propertySheet:find("SceneryObject")
|
||||
local scObjName = scObjRefId:find("name")
|
||||
|
||||
if attributeName == "ValidationNeeded" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
if attributeName == "SceneryObject" then
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
scObjName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
scObjName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
return
|
||||
end
|
||||
|
||||
local giverRefId = propertySheet:find("MissionGiver")
|
||||
local giverName = propertySheet:find("MissionGiver"):find("name")
|
||||
|
||||
if attributeName == "MissionGiver" then
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
giverName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if instance["MissionTarget"] == instance[attributeName] then
|
||||
giverName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, "MissionGiver", "")
|
||||
else
|
||||
giverName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function sceneryObjectInteractionTaskStepDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:sceneryObjectInteractionTaskStepDisplayer()
|
||||
return sceneryObjectInteractionTaskStepDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:textAdapter(text)
|
||||
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local object = ""
|
||||
local mission_giver = ""
|
||||
|
||||
if tostring(self.SceneryObject) ~= "" then
|
||||
local scObject = r2:getInstanceFromId(self.SceneryObject)
|
||||
if scObject then object = scObject.Name end
|
||||
end
|
||||
|
||||
if tostring(self.MissionGiver) ~= "" then
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if giver then mission_giver = giver.Name end
|
||||
end
|
||||
|
||||
str=string.gsub(str, "<object_name>", object)
|
||||
str=string.gsub(str, "<mission_giver>", mission_giver)
|
||||
|
||||
return str
|
||||
end
|
||||
|
||||
function component:pretranslate(context)
|
||||
if context.InteractingSceneryObjects then
|
||||
if self.SceneryObject and self.SceneryObject ~= "" then
|
||||
local scObj = r2:getInstanceFromId(self.SceneryObject)
|
||||
if scObj then
|
||||
table.insert(context.InteractingSceneryObjects, scObj.InstanceId)
|
||||
end
|
||||
end
|
||||
end
|
||||
--inspect(context.InteractingSceneryObjects)
|
||||
r2.Translator.createAiGroup(self, context)
|
||||
end
|
||||
|
||||
function component:translate(context)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
if not self.SceneryObject or self.SceneryObject == "" then return end
|
||||
if not self.MissionGiver or self.MissionGiver == "" then return end
|
||||
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
|
||||
local sceneryObject = r2:getInstanceFromId(self.SceneryObject)
|
||||
if not sceneryObject then return end
|
||||
|
||||
local rtSceneryObjectGrp = r2.Translator.getRtGroup(context, sceneryObject.InstanceId)
|
||||
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if not giver then return end
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
|
||||
-------------------
|
||||
--Start of state
|
||||
do
|
||||
local action = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 7)
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- the scenery object hasn't been selected yet
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_7", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
--Activation
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- the scenery object hasn't been selected yet
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_4", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
-------------------
|
||||
--Mission text
|
||||
if giver then
|
||||
local actionValidation = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, --giver already said mission text
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.NotValidatedText), rtGiverGrp.Id ..":"..giver.Name))
|
||||
|
||||
local actionMission = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 0, --giver didn't say mission text yet
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.MissionText), rtGiverGrp.Id ..":"..giver.Name),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ), }))
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("multi_actions", {actionValidation, actionMission}))
|
||||
|
||||
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--Contextual text
|
||||
do
|
||||
if sceneryObject then
|
||||
local actionContextual = r2.Translator.createAction("talk_to", rtGrp.Id, self:textAdapter(tostring(self.ContextualText)))
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, actionContextual))
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", sceneryObject, context, rtAction)
|
||||
end
|
||||
end
|
||||
|
||||
--when the player did interact with the scenery obj : trigger
|
||||
if sceneryObject then
|
||||
local eventId = 9
|
||||
if validationNeeded == 1 then
|
||||
eventId = 8
|
||||
end
|
||||
local actionEvent = r2.Translator.createAction("user_event_trigger", rtGrp.Id, eventId)
|
||||
|
||||
local actionSet = r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1)
|
||||
|
||||
local actionSetStatus = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2)
|
||||
|
||||
local actions = r2.Translator.createAction("multi_actions", {actionSetStatus, actionEvent, actionSet})
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, --if active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, actions))--and if the scenery object has been selected once by the player
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_3", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
--depending on validationNeeded prop
|
||||
if validationNeeded == 1 then
|
||||
do
|
||||
local actionEvent = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 9)
|
||||
local actionSaySuccessText = r2.Translator.createAction("npc_say", self:textAdapter(self.MissionSucceedText), rtGiverGrp.Id ..":"..giver.Name);
|
||||
|
||||
local action = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 2,
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("multi_actions", {actionEvent, actionSaySuccessText})))
|
||||
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg", baseActRtGrp.Id, self:textAdapter(self.BroadcastText))
|
||||
r2.Translator.translateAiGroupEvent("user_event_8", self, context, actionBroadcast)
|
||||
end
|
||||
end
|
||||
|
||||
--user event 9 : success
|
||||
do
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
})
|
||||
);
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- Not Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
|
||||
local actions = {}
|
||||
if validationNeeded == 1 then
|
||||
actions = {action2, action3}
|
||||
else
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg", baseActRtGrp.Id, self:textAdapter(self.BroadcastText))
|
||||
|
||||
actions = {action2, action3, actionBroadcast}
|
||||
end
|
||||
|
||||
local rtAction = r2.Translator.createAction("multi_actions", actions)
|
||||
|
||||
|
||||
--Autodeactivate after having triggered?
|
||||
r2.Translator.translateAiGroupEvent("user_event_9", self, context, rtAction)
|
||||
end
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
local prefix = ""
|
||||
|
||||
if rtNpcGrp.Id and rtNpcGrp.Id ~= "" then
|
||||
prefix = r2:getNamespace() .. rtNpcGrp.Id.."."
|
||||
end
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "in progress" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v2", 1 );
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1 );
|
||||
return action1, action1
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if event.Event.Type == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 9)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdSceneryObjectInteractionTaskStep_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdSceneryObjectInteractionTaskStep_MissionText"):toUtf8()
|
||||
local notValidatedText = i18n.get("uiR2EdSceneryObjectInteractionTaskStep_NotValidatedText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdSceneryObjectInteractionTaskStep_BroadcastText"):toUtf8()
|
||||
local missionSucceedText = i18n.get("uiR2EdSceneryObjectInteractionTaskStep_MissionSucceedTextText"):toUtf8()
|
||||
|
||||
|
||||
local comp = r2.newComponent("SceneryObjectInteractionTaskStep")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdSceneryObjectInteractionTaskStep")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.NotValidatedText = notValidatedText
|
||||
comp.BroadcastText = broadcastText
|
||||
comp.MissionSucceedText = missionSucceedText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
-- comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
r2:checkAiQuota()
|
||||
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'SceneryObjectInteractionTaskStep' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("SceneryObjectInteractionTaskStep") == 1 then
|
||||
r2.displayFeatureHelp("SceneryObjectInteractionTaskStep")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewSceneryObjectInteractionTaskStepAction"))
|
||||
local component = feature.Components.SceneryObjectInteractionTaskStep.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'SceneryObjectInteractionTaskStep' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureSceneryObjectInteractionTaskStep")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdSceneryObjectInteractionTaskStep")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "SceneryObjectInteractionTaskStep")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
["in progress"] = { menu=i18n.get( "uiR2Test0InProgress" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1InProgress" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["SceneryObjectInteractionTaskStep"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,448 +0,0 @@
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdSceneryObjectRemover --
|
||||
-- CreationFrom : uiR2EdSceneryObjectRemoverParameters
|
||||
|
||||
|
||||
r2.Features.SceneryObjectRemoverFeature = {}
|
||||
|
||||
local feature = r2.Features.SceneryObjectRemoverFeature
|
||||
|
||||
feature.Name="SceneryObjectRemoverFeature"
|
||||
|
||||
feature.Description="Removes scenery objects at runtime"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.SceneryObjectRemover =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="SceneryObjectRemover",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "sceneryObjectRemoverDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate", "remove objects"},
|
||||
|
||||
Events = {"removed objects"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "has removed objects", "has not removed objects"},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible= false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name= "Ghosts", Type = "Table", Visible = false },
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name= "Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="SceneryObjectNumber", Type="Number", Category="uiR2EDRollout_Scenery_Objects", WidgetStyle="EnumDropDown",
|
||||
Enum={"1", "2", "3", "4", "5"}, DefaultValue="0"},
|
||||
{Name="SceneryObject1Id", Type="RefId", Category="uiR2EDRollout_Scenery_Objects",PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget", Translation="uiR2EDProp_SceneryObject1Id", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="SceneryObject2Id", Type="RefId", Category="uiR2EDRollout_Scenery_Objects",PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget", Translation="uiR2EDProp_SceneryObject2Id", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="SceneryObject3Id", Type="RefId", Category="uiR2EDRollout_Scenery_Objects",PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget", Translation="uiR2EDProp_SceneryObject3Id", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="SceneryObject4Id", Type="RefId", Category="uiR2EDRollout_Scenery_Objects",PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget", Translation="uiR2EDProp_SceneryObject4Id", Visible= function(this) return this:displayRefId(4) end},
|
||||
{Name="SceneryObject5Id", Type="RefId", Category="uiR2EDRollout_Scenery_Objects",PickFunction="r2:canPickSceneryObject", SetRefIdFunction="r2:setSceneryObjectTarget", Translation="uiR2EDProp_SceneryObject5Id", Visible= function(this) return this:displayRefId(5) end},
|
||||
},
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
--r2.Translator.translateFeatureActivation(this, context)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
if this.Active and this.Active == 1 then
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 1)
|
||||
local action2 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "v1", 0)
|
||||
local action3 = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 4)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2, action3})
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , this, context, retAction)
|
||||
else
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 0)
|
||||
local action2 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "v1", 0)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , this, context, retAction)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
local component = feature.Components.SceneryObjectRemover
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbScObj = self.SceneryObjectNumber + 1
|
||||
if index <= nbScObj then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
|
||||
if (action.Action.Type == "remove objects") then
|
||||
local actionTrigger = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6)
|
||||
local actionSetValue = r2.Translator.createAction("set_value", rtNpcGrp.Id, "v1", 1)
|
||||
local despawnActions = {}
|
||||
local i = 1
|
||||
while i <= component.SceneryObjectNumber + 1 do
|
||||
local rtScenObj = r2.Translator.getRtGroup(context, component["SceneryObject"..i.."Id"])
|
||||
if rtScenObj then
|
||||
local actionDespawn = r2.Translator.createAction("despawn", rtScenObj.Id)
|
||||
table.insert(despawnActions, actionDespawn)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
local removedEvent = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6)
|
||||
|
||||
table.insert(despawnActions, actionTrigger)
|
||||
table.insert(despawnActions, actionSetValue)
|
||||
table.insert(despawnActions, removedEvent)
|
||||
|
||||
local retAction = r2.Translator.createAction("condition_if", r2:getNamespace()..rtNpcGrp.Id..".Active == 1",
|
||||
r2.Translator.createAction("condition_if", r2:getNamespace()..rtNpcGrp.Id..".v1 == 0",
|
||||
r2.Translator.createAction("multi_actions", despawnActions))
|
||||
)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "has removed objects" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v1", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "has not removed objects" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v1", 0);
|
||||
return action1, action1
|
||||
end
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
if eventType == "removed objects" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return nil, nil
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
local sceneryObjectRemoverDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
--
|
||||
-- If the message is received by a client that didn't request the modification, we must make sure this client
|
||||
-- doesn't modify the data because it has already been performed by the initial client.
|
||||
--
|
||||
local function checkPickedEntity(this, instanceId, attributeName)
|
||||
|
||||
if instanceId == "" then
|
||||
return false
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
assert(tmpInstance)
|
||||
|
||||
local i = 1
|
||||
while i < 6 do
|
||||
local attrName = "Npc" ..i.. "Id"
|
||||
if attrName ~= attributeName and this[attrName] == tmpInstance.InstanceId then
|
||||
--if not tmpInstance.User.SelfModified or tmpInstance.User.SelfModified == false then
|
||||
-- messageBox("'"..tmpInstance.Name.."' has already been picked.")
|
||||
--else
|
||||
-- tmpInstance.User.SelfModified = false
|
||||
--end
|
||||
return false
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
local oldOnAttrModified = sceneryObjectRemoverDisplayerTable.onAttrModified
|
||||
|
||||
function sceneryObjectRemoverDisplayerTable:onAttrModified(instance, attributeName)
|
||||
--if not instance.User.SelfModified then return end
|
||||
-- call base version
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
|
||||
if attributeName == "NpcNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbScObjs = instance.SceneryObjectNumber + 1
|
||||
local i = 1
|
||||
while i <= 5 do
|
||||
if i > nbScObjs then
|
||||
local name = "SceneryObject"..tostring(i).."Id"
|
||||
local refId = propertySheet:find(name)
|
||||
local refIdName = refId:find("name")
|
||||
refIdName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, name, "")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
if string.find(attributeName, "Id") == nil or attributeName == "InstanceId" then return end
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local refId = propertySheet:find(attributeName)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
refIdName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if checkPickedEntity(instance, instanceId, attributeName) then
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
refIdName.hardtext = tmpInstance.Name
|
||||
else
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, "")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function sceneryObjectRemoverDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function reattributeIdOnHrcMove(scObjRemover, group, targetAttr)
|
||||
local propertySheet = r2:getPropertySheet(scObjRemover)
|
||||
local refId = propertySheet:find(targetAttr)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
r2.requestSetNode(scObjRemover.InstanceId, targetAttr, group.InstanceId)
|
||||
refIdName.hardtext = group.Name
|
||||
|
||||
end
|
||||
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
local group = tmpInstance.ParentInstance
|
||||
if group:isKindOf("NpcGrpFeature") then
|
||||
reattributeIdOnHrcMove(self, group, targetAttr)
|
||||
end
|
||||
tmpInstance.User.SelfModified = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function r2:sceneryObjectRemoverDisplayer()
|
||||
return sceneryObjectRemoverDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
component.createGhostComponents= function(this, act)
|
||||
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y, tvalue)
|
||||
|
||||
local comp = r2.newComponent("SceneryObjectRemover")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDRollout_SceneryObjectRemover")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
comp.SceneryObjectId = r2.RefId("")
|
||||
comp.SceneryObject2Id = r2.RefId("")
|
||||
comp.SceneryObject3Id = r2.RefId("")
|
||||
comp.SceneryObject4Id = r2.RefId("")
|
||||
comp.SceneryObject5Id = r2.RefId("")
|
||||
comp.SceneryObjectNumber = 0
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
component.create = function()
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("SceneryObjectRemover", 0)
|
||||
else r2.setDisplayInfo("SceneryObjectRemover", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.SceneryObjectRemover.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'SceneryObjectRemoverFeature' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'SceneryObjectRemoverFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("SceneryObjectRemover") == 1 then
|
||||
r2.displayFeatureHelp("SceneryObjectRemover")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewSceneryObjectRemoverFeatureAction"))
|
||||
local component = feature.Components.SceneryObjectRemover.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'SceneryObjectRemoverFeature' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureSceneryObjectRemover")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EDRollout_SceneryObjectRemover")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "SceneryObject")
|
||||
end
|
||||
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["remove objects"] = { menu=i18n.get( "uiR2AA0RemoveObject" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1RemoveObject" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["removed objects"] = { menu=i18n.get( "uiR2Event0RemovedObjects" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1RemovedObjects" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["has removed objects"] = { menu=i18n.get( "uiR2Test0HasRemoved" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1HasRemoved" ):toUtf8()},
|
||||
["has not removed objects"] = { menu=i18n.get( "uiR2Test0HasNotRemoved" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1HasNotRemoved" ):toUtf8()}
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["SceneryObjectRemoverFeature"] = feature
|
@ -1,529 +0,0 @@
|
||||
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdTalkTo --
|
||||
-- CreationFrom : uiR2EdTalkToParameters
|
||||
|
||||
|
||||
r2.Features.TalkToFeature = {}
|
||||
|
||||
local feature = r2.Features.TalkToFeature
|
||||
|
||||
feature.Name="TalkToFeature"
|
||||
|
||||
feature.Description="A feature that makes a NPC request the player to talk to an other player"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.TalkTo =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="TalkTo",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "talkToDisplayer",
|
||||
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "wait validation", "mission asked", "succeeded"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is succeeded" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
{Name="MissionTarget", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
|
||||
--{Name="ContextualText", Type="String", ValidationFun="r2.refuseEmptyString", Category="uiR2EDRollout_TextToSay" },
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100" },
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="WaitValidationText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"}
|
||||
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
|
||||
local component = feature.Components.TalkTo
|
||||
|
||||
function component.pretranslate(this, context)
|
||||
local prop = component.Prop
|
||||
r2.Translator.CheckPickedEntity(this, prop)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local talkToDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = talkToDisplayerTable.onAttrModified
|
||||
|
||||
function talkToDisplayerTable:onAttrModified(instance, attributeName)
|
||||
oldOnAttrModified(instance, attributeName)
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
|
||||
local targetRefId = propertySheet:find("MissionTarget")
|
||||
local targetName = targetRefId:find("name")
|
||||
|
||||
local giverRefId = propertySheet:find("MissionGiver")
|
||||
local giverName = propertySheet:find("MissionGiver"):find("name")
|
||||
|
||||
|
||||
|
||||
if attributeName == "MissionGiver" then
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
giverName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if instance["MissionTarget"] == instance[attributeName] then
|
||||
giverName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, "MissionGiver", "")
|
||||
else
|
||||
giverName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if attributeName == "MissionTarget" then
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
targetName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
if instance["MissionGiver"] == instance[attributeName] then
|
||||
targetName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, "MissionTarget", "")
|
||||
else
|
||||
targetName.hardtext = r2:getInstanceFromId(instance[attributeName]).Name
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function talkToDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:talkToDisplayer()
|
||||
return talkToDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
|
||||
function component:textAdapter(text)
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local mission_giver = ""
|
||||
local mission_target = ""
|
||||
|
||||
if tostring(self.MissionGiver) ~= "" then
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if giver then mission_giver = giver.Name end
|
||||
end
|
||||
|
||||
if tostring(self.MissionTarget) ~= "" then
|
||||
local target = r2:getInstanceFromId(self.MissionTarget)
|
||||
if target then mission_target = target.Name end
|
||||
end
|
||||
|
||||
str=string.gsub(str, "<mission_giver>", mission_giver)
|
||||
str=string.gsub(str, "<mission_target>", mission_target)
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
|
||||
|
||||
|
||||
local target = r2:getInstanceFromId(self.MissionTarget)
|
||||
|
||||
local rtTargetGrp = nil
|
||||
if target then
|
||||
rtTargetGrp = r2.Translator.getRtGroup(context, target.InstanceId)
|
||||
end
|
||||
|
||||
-----------------
|
||||
--Contextual text
|
||||
do
|
||||
if target then
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v3", 1, -- giver has been spoken to
|
||||
r2.Translator.createAction("talk_to", rtGrp.Id, self:textAdapter(self.ContextualText)) )
|
||||
)
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", target, context, rtAction)
|
||||
end
|
||||
end
|
||||
|
||||
-------------------
|
||||
--Mission text
|
||||
if giver then
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
--local rtAction2 = r2.Translator.createAction("condition_if", r2:getNamespace()..rtGrp.Id..".Active == 1")
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("npc_say", self:textAdapter(self.MissionText), rtGiverGrp.Id ..":"..giver.Name),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", 1 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 2) })
|
||||
)
|
||||
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", giver, context, rtAction)
|
||||
end
|
||||
|
||||
--if there's no giver, target should speak anyway
|
||||
local v3
|
||||
if giver == nil then v3 = 1 else v3 = 0 end
|
||||
-------------------
|
||||
--Start of state
|
||||
|
||||
|
||||
do
|
||||
local action = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 7)
|
||||
r2.Translator.translateAiGroupEvent("start_of_state" , self, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", self.Active)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- Success
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", v3 ) -- Has
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, rtAction4, } )
|
||||
--r2.Translator.translateAiGroupEvent("start_of_state" , self, context, rtAction)
|
||||
r2.Translator.translateAiGroupEvent("user_event_7", self, context, rtAction)
|
||||
end
|
||||
|
||||
do
|
||||
local rtAction1 = r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1)
|
||||
local rtAction2 = r2.Translator.createAction("set_value", rtGrp.Id, "v1", self.Repeatable)
|
||||
local rtAction3 = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0) -- Success
|
||||
local rtAction4 = r2.Translator.createAction("set_value", rtGrp.Id, "v3", v3 ) -- Has
|
||||
local rtAction = r2.Translator.createAction("multi_actions", { rtAction1, rtAction2, rtAction3, rtAction4, } )
|
||||
r2.Translator.translateAiGroupEvent("user_event_4", self, context, rtAction)
|
||||
end
|
||||
|
||||
do
|
||||
local action2 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 1, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 0 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", v3 )
|
||||
})
|
||||
);
|
||||
local action3 = r2.Translator.createAction("if_value_equal", rtGrp.Id, "v1", 0, -- Repeatable
|
||||
r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "Active", 0 ) ,
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v2", 1 ),
|
||||
r2.Translator.createAction("set_value", rtGrp.Id, "v3", v3 ),
|
||||
r2.Translator.createAction("user_event_trigger", rtGrp.Id, 5)
|
||||
})
|
||||
);
|
||||
|
||||
local rtAction
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) )
|
||||
|
||||
if rtTargetGrp then
|
||||
local action1 = r2.Translator.createAction("npc_say", self:textAdapter(self.MissionSucceedText), rtTargetGrp.Id ..":"..target.Name);
|
||||
rtAction = r2.Translator.createAction("multi_actions", {action1, action2, action3, actionBroadcast})
|
||||
else
|
||||
rtAction = r2.Translator.createAction("multi_actions", {action2, action3, actionBroadcast})
|
||||
end
|
||||
|
||||
r2.Translator.translateAiGroupEvent("user_event_3", self, context, rtAction)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
do
|
||||
if rtTargetGrp then
|
||||
local rtAction = r2.Translator.createAction("npc_say", self:textAdapter(self.WaitValidationText), rtTargetGrp.Id ..":"..target.Name);
|
||||
r2.Translator.translateAiGroupEvent("user_event_1", self, context, rtAction)
|
||||
end
|
||||
end
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
|
||||
|
||||
-- ()receiveMissionItems("system_mp.sitem:2;system_mp_choice.sitem:1;system_mp_supreme.sitem:3", "Give some stuff hé!", @groupToNotify);
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v2", 1);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "mission asked" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "wait validation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 1)
|
||||
elseif eventType == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 3)
|
||||
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdTalkTo_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdTalkTo_MissionText"):toUtf8()
|
||||
local waitValidationText = i18n.get("uiR2EdTalkTo_WaitValidationText"):toUtf8()
|
||||
local missionSucceededText = i18n.get("uiR2EdTalkTo_MissionSucceededText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdTalkTo_BroadcastText"):toUtf8()
|
||||
|
||||
local comp = r2.newComponent("TalkTo")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdTalkTo")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.WaitValidationText = waitValidationText
|
||||
comp.MissionSucceedText = missionSucceededText
|
||||
comp.BroadcastText = broadcastText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
-- comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
r2:checkAiQuota()
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("TalkToForm", 0)
|
||||
else r2.setDisplayInfo("TalkToForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.TalkTo.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'TalkTo' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'TalkTo' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("TalkTo") == 1 then
|
||||
r2.displayFeatureHelp("TalkTo")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewTalkToFeatureAction"))
|
||||
local component = feature.Components.TalkTo.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'TalkTo' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureTalkTo")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdTalkTo")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "TalkTo")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["mission asked"] = { menu=i18n.get( "uiR2Event0MissionGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MissionGiven" ):toUtf8()},
|
||||
["wait validation"] = { menu=i18n.get( "uiR2Event0TaskWaitValidation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskWaitValidation" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["TalkTo"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,436 +0,0 @@
|
||||
|
||||
r2.Features.TargetMob = {}
|
||||
|
||||
local feature = r2.Features.TargetMob
|
||||
|
||||
feature.Name="TargetMobFeature"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.TargetMob =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="TargetMob",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "targetMobDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate"},
|
||||
|
||||
Events = {"activation", "deactivation", "wait validation", "mission asked", "succeeded"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is succeeded" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
{Name="MissionTarget", Type="RefId", PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget"},
|
||||
{Name="ValidationNeeded", Category="uiR2EDRollout_TextToSay", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100" },
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="WaitValidationText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay", Visible= function(this)
|
||||
return this:IsValidationNeeded() end },
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"},
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.TargetMob
|
||||
|
||||
function component:IsValidationNeeded()
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
if validationNeeded == 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local targetMobDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = targetMobDisplayerTable.onAttrModified
|
||||
function targetMobDisplayerTable:onAttrModified(instance, attributeName)
|
||||
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
|
||||
if attributeName == "ValidationNeeded" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function targetMobDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:targetMobDisplayer()
|
||||
return targetMobDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
|
||||
function component:textAdapter(text)
|
||||
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local mission_giver = ""
|
||||
local mission_target = ""
|
||||
|
||||
if tostring(self.MissionGiver) ~= "" then
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if giver then mission_giver = giver.Name end
|
||||
end
|
||||
|
||||
if tostring(self.MissionTarget) ~= "" then
|
||||
local target = r2:getInstanceFromId(self.MissionTarget)
|
||||
if target then mission_target = target.Name end
|
||||
end
|
||||
|
||||
str=string.gsub(str, "<mission_giver>", mission_giver)
|
||||
str=string.gsub(str, "<mission_target>", mission_target)
|
||||
return str
|
||||
end
|
||||
|
||||
|
||||
function component:translate(context)
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
|
||||
if self.MissionGiver == nil then return end
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if not giver then return end
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
assert(rtGiverGrp)
|
||||
|
||||
if self.MissionTarget == nil then return end
|
||||
local target = r2:getInstanceFromId(self.MissionTarget)
|
||||
if not target then return end
|
||||
local rtTargetGrp = r2.Translator.getRtGroup(context, target.InstanceId)
|
||||
assert(rtTargetGrp)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
-- Start of state
|
||||
r2.Translator.Tasks.startOfStateLogic(self, context, rtGrp)
|
||||
|
||||
--Activation
|
||||
r2.Translator.Tasks.activationLogic(self, context, rtGrp)
|
||||
|
||||
--Deactivation
|
||||
r2.Translator.Tasks.deactivationLogic(self, context, rtGrp)
|
||||
|
||||
--Mission given on user_event_3
|
||||
r2.Translator.Tasks.setStatusLogic(self, context, rtGrp)
|
||||
|
||||
--Mission successful on user_event_9
|
||||
r2.Translator.Tasks.successNoBroadcastLogic(self, context, rtGrp)
|
||||
|
||||
--If giver validates the task
|
||||
if validationNeeded == 1 then
|
||||
r2.Translator.Tasks.validationByMissionGiver(self, giver, context, rtGrp)
|
||||
end
|
||||
|
||||
|
||||
-- Texte contextuel de mission
|
||||
do
|
||||
local actionSet = r2.Translator.createAction("set_value", rtGrp.Id, "v2", 2 )
|
||||
|
||||
local baseAct = r2.Scenario:getBaseAct()
|
||||
local baseActRtGrp = r2.Translator.getRtGroup(context, baseAct.InstanceId)
|
||||
local actionBroadcast = r2.Translator.createAction("broadcast_msg",baseActRtGrp.Id, self:textAdapter(self.BroadcastText) )
|
||||
|
||||
local actions = {}
|
||||
if validationNeeded == 0 then
|
||||
local actionEvent = r2.Translator.createAction("user_event_trigger", rtGrp.Id, 9)
|
||||
actions = {actionSet, actionEvent, actionBroadcast}
|
||||
else
|
||||
actions = {actionSet, actionBroadcast}
|
||||
end
|
||||
|
||||
local rtAction = r2.Translator.createAction("if_value_equal", rtGrp.Id, "Active", 1, -- Active
|
||||
r2.Translator.createAction("if_value_equal", rtGrp.Id, "v2", 1, -- giver has been spoken to
|
||||
r2.Translator.createAction("multi_actions", actions)
|
||||
))
|
||||
r2.Translator.translateAiGroupEvent("player_target_npc", target, context, rtAction)
|
||||
end
|
||||
|
||||
-- Mission giver must either give the mission (1st time) or say WaitValidationText
|
||||
r2.Translator.Tasks.giverLogic(self, giver, context, rtGrp)
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "mission asked" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 3)
|
||||
elseif eventType == "wait validation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 9)
|
||||
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdTargetMob_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdTargetMob_MissionText"):toUtf8()
|
||||
local waitValidationText = i18n.get("uiR2EdTargetMob_WaitValidationText"):toUtf8()
|
||||
local missionSucceededText = i18n.get("uiR2EdTargetMob_MissionSucceededText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdTargetMob_BroadcastText"):toUtf8()
|
||||
|
||||
local comp = r2.newComponent("TargetMob")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdTargetMob")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.WaitValidationText = waitValidationText
|
||||
comp.MissionSucceedText = missionSucceededText
|
||||
comp.BroadcastText= broadcastText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
-- comp.ItemQty = 1
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("TargetMobForm", 0)
|
||||
else r2.setDisplayInfo("TargetMobForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.TargetMob.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'TargetMob' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'TargetMob' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("TargetMob") == 1 then
|
||||
r2.displayFeatureHelp("TargetMob")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewTargetMobFeatureAction"))
|
||||
local component = feature.Components.TargetMob.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'TargetMob' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureTargetMob")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdTargetMob")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "TargetMob")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["mission asked"] = { menu=i18n.get( "uiR2Event0MissionGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MissionGiven" ):toUtf8()},
|
||||
["wait validation"] = { menu=i18n.get( "uiR2Event0TaskWaitValidation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskWaitValidation" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["TargetMob"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,435 +0,0 @@
|
||||
|
||||
|
||||
-- In Transalation file
|
||||
-- Category : uiR2EdTimeTrigger --
|
||||
-- CreationFrom : uiR2EdTimeTriggerParameters
|
||||
-- uiR2EdtooltipCreateFeatureTimeTrigger -> tooltip
|
||||
|
||||
r2.Features.TimeTriggerFeature = {}
|
||||
|
||||
local feature = r2.Features.TimeTriggerFeature
|
||||
|
||||
feature.Name="TimeTriggerFeature"
|
||||
|
||||
feature.Description="A Time Trigger"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.TimeTriggerFeature =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="TimeTriggerFeature",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
ApplicableActions = {
|
||||
"Activate", "Deactivate", "Trigger",
|
||||
},
|
||||
Events = {
|
||||
"On Trigger",
|
||||
"On Activation",
|
||||
"On Desactivation"
|
||||
},
|
||||
Conditions = {
|
||||
"is active", "is finished"
|
||||
},
|
||||
TextContexts = {},
|
||||
TextParameters = {},
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText"},
|
||||
{Name="Name", Category="uiR2EDRollout_TimeTrigger", Type="String", MaxNumChar="32"},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="AtWhichHour", Type="Number", Category="uiR2EDRollout_TimeTrigger", Min="0", Max="23", Default="0"},
|
||||
{Name="uiR2EDProp_AtWhichMinute", Type="Number", Category="uiR2EDRollout_TimeTrigger", Min="0", Max="59", Default="0"},
|
||||
{Name="Cyclic", Type="Number", Category="uiR2EDRollout_TimeTrigger", WidgetStyle="Boolean", Min="0", Max="1", Default="0"},
|
||||
|
||||
-- {Name="Secondes",Type="Number", Category="uiR2EDRollout_TimeTrigger", Min="0", Max="59", Default="0"}
|
||||
|
||||
|
||||
},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this) end,
|
||||
|
||||
translate = function(this, context)end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
}
|
||||
|
||||
-- Specific to the component TimeTrigger
|
||||
local component = feature.Components.TimeTriggerFeature
|
||||
|
||||
function feature.getLogicActionActivate(entity, context, action, rtNpcGrp)
|
||||
local action1 = r2.Translator.createAction("timer_enable", rtNpcGrp.Id, 0)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 0)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
function feature.getLogicActionDeactivate(entity, context, action, rtNpcGrp)
|
||||
local action1 = r2.Translator.createAction("timer_disable", rtNpcGrp.Id, 0)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 1)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
|
||||
function feature.getLogicActionTrigger(entity, context, action, rtNpcGrp)
|
||||
local retAction = r2.Translator.createAction("timer_trigger", rtNpcGrp.Id, 0)
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
function feature.getLogicActionAdd10Seconds(entity, context, action, rtNpcGrp)
|
||||
local retAction = r2.Translator.createAction("timer_add", rtNpcGrp.Id, 0, 10)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
function feature.getLogicActionAdd1Minute(entity, context, action, rtNpcGrp)
|
||||
local retAction = r2.Translator.createAction("timer_add", rtNpcGrp.Id, 0, 60)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
function feature.getLogicActionSub10Seconds(entity, context, action, rtNpcGrp)
|
||||
local retAction = r2.Translator.createAction("timer_sub", rtNpcGrp.Id, 0, 10)
|
||||
return retAction, retAction
|
||||
|
||||
end
|
||||
|
||||
function feature.getLogicActionSub1Minute(entity, context, action, rtNpcGrp)
|
||||
local retAction = r2.Translator.createAction("timer_sub", rtNpcGrp.Id, 0, 60)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
|
||||
local funs = {
|
||||
["Activate"] = feature.getLogicActionActivate,
|
||||
["Deactivate"] = feature.getLogicActionDeactivate,
|
||||
["Pause"] = feature.getLogicActionPause,
|
||||
["Resume"] = feature.getLogicActionResume,
|
||||
["Trigger"] = feature.getLogicActionTrigger,
|
||||
["Add 10 Seconds"] = feature.getLogicActionAdd10Seconds,
|
||||
["Add 1 minute"] = feature.getLogicActionAdd1Minute,
|
||||
["Sub 10 seconds"] = feature.getLogicActionSub0Seconds,
|
||||
["Sub 1 minute"] = feature.getLogicActionSub1Minute,
|
||||
}
|
||||
|
||||
|
||||
local fun = funs[ action.Action.Type ]
|
||||
if fun then
|
||||
firstAction, lastAction = fun(entity, context, action, rtNpcGrp)
|
||||
end
|
||||
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local action2 = r2.Translator.createAction("condition_if", "is_enable == 1" );
|
||||
local multiactions= r2.Translator.createAction("multi_actions", {action1, action2});
|
||||
return multiactions, action2
|
||||
elseif condition.Condition.Type == "is paused" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local action2 = r2.Translator.createAction("timer_is_suspended", rtNpcGrp.Id, 0);
|
||||
local action31 = r2.Translator.createAction("condition_if", "is_suspended == 1");
|
||||
local action3 = r2.Translator.createAction("condition_if", "is_enable == 1", action31);
|
||||
local multiactions = r2.Translator.createAction("multi_actions", {action1, action2, action3});
|
||||
table.insert(action3.Children, action31)
|
||||
return multiactions, action31
|
||||
elseif condition.Condition.Type == "is running" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local action2 = r2.Translator.createAction("timer_is_suspended", rtNpcGrp.Id, 0);
|
||||
local action31 = r2.Translator.createAction("condition_if", "is_suspended == 0");
|
||||
local action3 = r2.Translator.createAction("condition_if", "is_enable == 1", action31);
|
||||
local multiactions = r2.Translator.createAction("multi_actions", {action1, action2, action3});
|
||||
table.insert(action3.Children, action31)
|
||||
return multiactions, action3
|
||||
elseif condition.Condition.Type == "is finished" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local action2 = r2.Translator.createAction("condition_if", "is_enable == 0" );
|
||||
local multiactions= r2.Translator.createAction("multi_actions", {action1, action2});
|
||||
return multiactions, action2
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "On Trigger" then
|
||||
eventHandler, firstCondition, lastCondition = r2.Translator.createEvent("timer_t0_triggered", "", rtNpcGrp.Id)
|
||||
elseif eventType == "On Activation" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 0)
|
||||
elseif eventType == "On Desactivation" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 1)
|
||||
elseif eventType == "On Pause" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 2)
|
||||
end
|
||||
|
||||
|
||||
return eventHandler, firstCondition, lastCondition
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- feature part
|
||||
|
||||
|
||||
|
||||
feature.createComponent = function(x, y, hours, minutes, cyclic)
|
||||
|
||||
local comp = r2.newComponent("TimeTriggerFeature")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = "palette.entities.botobjects.time_trigger"
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdNameTimeTriggerFeature")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
comp.Hours = hours
|
||||
comp.Minutes = minutes
|
||||
comp.Cyclic = cyclic
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- TODO to up
|
||||
-- Register an RtNpcGrp to a specific instnaceId
|
||||
r2.Translator.registerManager = function(context, comp)
|
||||
local rtNpcGrp = r2.newComponent("RtNpcGrp")
|
||||
table.insert(context.RtAct.NpcGrps, rtNpcGrp)
|
||||
context.RtGroups[tostring(comp.InstanceId)] = rtNpcGrp
|
||||
rtNpcGrp.Name = rtNpcGrp.Id
|
||||
end
|
||||
|
||||
feature.preTranslatFeature = function(context)
|
||||
--debugInfo("Pre")
|
||||
--feature.doLogic(context)
|
||||
local instance = r2:getInstanceFromId(context.Feature.InstanceId);
|
||||
r2.Translator.registerManager(context, context.Feature)
|
||||
|
||||
end
|
||||
|
||||
feature.Translator = function(context)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, context.Feature.InstanceId)
|
||||
|
||||
local aiState = r2.newComponent("RtAiState")
|
||||
aiState.AiActivity = "normal"
|
||||
table.insert(context.RtAct.AiStates, aiState)
|
||||
table.insert(aiState.Children, rtNpcGrp.Id)
|
||||
|
||||
context.Feature:translate(context)
|
||||
|
||||
end
|
||||
-- from ihm
|
||||
feature.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewTimeTriggerFeatureAction"))
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local minutes = tonumber( resultTable["Minutes"] )
|
||||
local hours = tonumber( resultTable["Hours"] )
|
||||
local cyclic = tonumber( resultTable["Cyclic"] )
|
||||
|
||||
if not x or not y or not minutes or not hours or hours <0 or hours >=24 or minutes <0 or minutes > 59
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
|
||||
local component = feature.createComponent( x, y, hours, cyclic)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
component.Minutes = minutes
|
||||
component.Hours = hours
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'TimeTrigger' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'TimeTrigger' at pos (%d, %d, %d)", x, y, z))
|
||||
r2:doForm("TimeTriggerForm", {X=x, Y=y}, paramsOk, paramsCancel)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'TimeTrigger' position")
|
||||
end
|
||||
r2:choosePos("object_component_time_trigger.creature", posOk, posCancel, "createFeatureTimeTrigger")
|
||||
end
|
||||
|
||||
|
||||
function feature.registerForms()
|
||||
r2.Forms.TimeTriggerForm =
|
||||
{
|
||||
Caption = "uiR2EdTimeTriggerParameters",
|
||||
Prop =
|
||||
{
|
||||
-- following field are tmp for property sheet building testing
|
||||
{Name="Hours", Type="Number", Category="uiR2EDRollout_TimeTrigger", Min="0", Max="23", Default="0"},
|
||||
{Name="Minutes", Type="Number", Category="uiR2EDRollout_TimeTrigger", Min="0", Max="59", Default="0"},
|
||||
-- {Name="Secondes", Type="Number", Category="uiR2EDRollout_TimeTrigger", Min="0", Max="59", Default="0"},
|
||||
{Name="Cyclic", Type="Number", Category="uiR2EDRollout_TimeTrigger", WidgetStyle="Boolean", Min="0", Max="1", Default="0"},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
|
||||
feature.preTranslatFeature = function(context)
|
||||
local instance = r2:getInstanceFromId(context.Feature.InstanceId);
|
||||
r2.Translator.registerManager(context, context.Feature)
|
||||
|
||||
end
|
||||
|
||||
feature.Translator = function(context)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, context.Feature.InstanceId)
|
||||
|
||||
local aiState = r2.newComponent("RtAiState")
|
||||
aiState.AiActivity = "normal"
|
||||
table.insert(context.RtAct.AiStates, aiState)
|
||||
table.insert(aiState.Children, rtNpcGrp.Id)
|
||||
|
||||
local instance = context.Feature
|
||||
r2.Translator.translateEventHandlers( context, instance, instance.Behavior.Actions, rtNpcGrp)
|
||||
|
||||
do
|
||||
local eventHandler = r2.Translator.createEvent("start_of_state", aiState.Id, rtNpcGrp.Id)
|
||||
|
||||
local action1 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 0, time)
|
||||
local action2 = r2.Translator.createAction("timer_set_daytime", rtNpcGrp.Id, 0, instance.Hours, instance.Minutes)
|
||||
local action = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
|
||||
table.insert(context.RtAct.Events, eventHandler)
|
||||
-- insert a npc_event_handler_action
|
||||
table.insert(eventHandler.ActionsId, action.Id)
|
||||
table.insert(context.RtAct.Actions, action)
|
||||
end
|
||||
|
||||
if instance.Cyclic == 1 then
|
||||
local eventHandler =r2.Translator.createEvent("timer_t0_triggered", aiState.Id, rtNpcGrp.Id)
|
||||
local action1 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 0, time)
|
||||
local action2 = r2.Translator.createAction("timer_set_daytime", rtNpcGrp.Id, 0, instance.Hours, instance.Minutes)
|
||||
local action = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
|
||||
table.insert(context.RtAct.Events, eventHandler)
|
||||
-- insert a npc_event_handler_action
|
||||
table.insert(eventHandler.ActionsId, action.Id)
|
||||
table.insert(context.RtAct.Actions, action)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
-- register trad
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2AA0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["On Activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["On Desactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["On Trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is finished"] = { menu=i18n.get( "uiR2Test0TimerFinished" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TimerFinished" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["TimeTriggerFeature"] = feature
|
||||
|
@ -1,453 +0,0 @@
|
||||
|
||||
r2.Features.TimedSpawner = {}
|
||||
|
||||
local feature = r2.Features.TimedSpawner
|
||||
|
||||
feature.Name="Timed Spawner"
|
||||
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
local classTimedSpawnerVersion = 1
|
||||
|
||||
feature.Components.TimedSpawner =
|
||||
{
|
||||
--PropertySheetHeader = r2.getDisplayButtonHeader("r2.events:openEditor()", "uiR2EdEditEventsButton"),
|
||||
BaseClass="LogicEntity",
|
||||
Name="TimedSpawner",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
Version=classTimedSpawnerVersion ,
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "timedSpawnerDisplayer",
|
||||
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
ApplicableActions = {"activate", "deactivate", "trigger"},
|
||||
Events = {"activation", "deactivation", "trigger"},
|
||||
Conditions = {"is active", "is inactive"},
|
||||
TextContexts = {},
|
||||
TextParameters = {},
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="MobNumber", Type="Number", Category="uiR2EDRollout_Mobs", WidgetStyle="EnumDropDown", Enum={"1", "2", "3", "4", "5"},
|
||||
},
|
||||
{Name="Mob1Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob1Id", Visible= function(this) return this:displayRefId(1) end},
|
||||
{Name="Mob2Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob2Id", Visible= function(this) return this:displayRefId(2) end},
|
||||
{Name="Mob3Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob3Id", Visible= function(this) return this:displayRefId(3) end},
|
||||
{Name="Mob4Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob4Id", Visible= function(this) return this:displayRefId(4) end},
|
||||
{Name="Mob5Id", Type="RefId", Category="uiR2EDRollout_Mobs",PickFunction="r2:canPickNpcOrGroup", SetRefIdFunction="r2:setNpcOrGroupRefIdTarget",
|
||||
Translation="uiR2EdProp_Mob5Id", Visible= function(this) return this:displayRefId(5) end},
|
||||
{Name="Minutes", Type="Number", Min="0", Max="60", DefaultValue="0"},
|
||||
{Name="Secondes",Type="Number", Min="0", Max="60", DefaultValue="30"},
|
||||
{Name="Components", Type="Table"},
|
||||
|
||||
},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
r2.Translator.translateFeatureActivation(this, context)
|
||||
end,
|
||||
|
||||
updateVersion = function(this, scenarioValue, currentValue )
|
||||
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
local component = feature.Components.TimedSpawner
|
||||
|
||||
function component:displayRefId(index)
|
||||
local nbMobs = self.MobNumber + 1
|
||||
if index <= nbMobs then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
------------------------------------------------------------------------------------------------------------------
|
||||
local timedSpawnerDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
--
|
||||
-- If the message is received by a client that didn't request the modification, we must make sure this client
|
||||
-- doesn't modify the data because it has already been performed by the initial client.
|
||||
--
|
||||
local function checkPickedEntity(this, instanceId, attributeName)
|
||||
if instanceId == "" then
|
||||
return false
|
||||
end
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
assert(tmpInstance)
|
||||
local i = 1
|
||||
while i < 6 do
|
||||
local attrName = "Mob" ..i.. "Id"
|
||||
if attrName ~= attributeName and this[attrName] == tmpInstance.InstanceId then
|
||||
return false
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
function timedSpawnerDisplayerTable:onAttrModified(instance, attributeName)
|
||||
if attributeName == "MobNumber" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local nbMobs = instance.MobNumber + 1
|
||||
local i = 1
|
||||
while i <= 5 do
|
||||
if i > nbMobs then
|
||||
local name = "Mob"..tostring(i).."Id"
|
||||
local refId = propertySheet:find(name)
|
||||
local refIdName = refId:find("name")
|
||||
refIdName.hardtext = "NONE"
|
||||
r2.requestSetNode(instance.InstanceId, name, "")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
|
||||
if string.find(attributeName, "Id") == nil or attributeName == "InstanceId" then return end
|
||||
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
local refId = propertySheet:find(attributeName)
|
||||
if refId == nil then return end
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
local instanceId = instance[attributeName]
|
||||
if instanceId == "" then
|
||||
refIdName.hardtext = "NONE"
|
||||
return
|
||||
end
|
||||
|
||||
local inserted = checkPickedEntity(instance, instanceId, attributeName)
|
||||
if inserted == true then
|
||||
local tmpInstance = r2:getInstanceFromId(instanceId)
|
||||
refIdName.hardtext = tmpInstance.Name
|
||||
else
|
||||
r2.requestSetNode(instance.InstanceId, attributeName, "")
|
||||
end
|
||||
instance.User.onHrcMove = false
|
||||
end
|
||||
|
||||
function timedSpawnerDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
local function reattributeIdOnHrcMove(timedSpawner, group, targetAttr)
|
||||
local propertySheet = r2:getPropertySheet(timedSpawner)
|
||||
local refId = propertySheet:find(targetAttr)
|
||||
local refIdName = refId:find("name")
|
||||
|
||||
r2.requestSetNode(timedSpawner.InstanceId, targetAttr, group.InstanceId)
|
||||
refIdName.hardtext = group.Name
|
||||
timedSpawner.User.onHrcMove = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
local group = tmpInstance.ParentInstance
|
||||
if group:isKindOf("NpcGrpFeature") then
|
||||
reattributeIdOnHrcMove(self, group, targetAttr)
|
||||
end
|
||||
tmpInstance.User.SelfModified = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function r2:timedSpawnerDisplayer()
|
||||
return timedSpawnerDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if (action.Action.Type == "trigger") then
|
||||
local i = 1
|
||||
local spawnActions = {}
|
||||
while i <= 5 do
|
||||
local attrName = "Mob"..i.."Id"
|
||||
if component[attrName] ~= "" then
|
||||
local rtMobGrp = r2.Translator.getRtGroup(context, component[attrName])
|
||||
local actionSpawn = r2.Translator.createAction("spawn", rtMobGrp.Id)
|
||||
table.insert(spawnActions, actionSpawn)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
if table.getn(spawnActions) ~= 0 then
|
||||
local actionTrigger = r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 6)
|
||||
table.insert(spawnActions, actionTrigger)
|
||||
local retAction = r2.Translator.createAction("condition_if", r2:getNamespace()..rtNpcGrp.Id..".Active == 1",
|
||||
r2.Translator.createAction("multi_actions", spawnActions)
|
||||
)
|
||||
return retAction, retAction
|
||||
end
|
||||
return nil, nil
|
||||
end
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtNpcGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if tostring(event.Event.Type) == "trigger" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createGhostComponents= function(this, act)
|
||||
|
||||
local comp = this
|
||||
|
||||
local timer = r2.newComponent("Timer")
|
||||
assert(timer)
|
||||
timer.Name = r2:genInstanceName(i18n.get("uiR2EdTimer")):toUtf8()
|
||||
timer.InheritPos = 0
|
||||
timer.Position.x = comp.Position.x
|
||||
timer.Position.y = comp.Position.y
|
||||
timer.Position.z = comp.Position.z
|
||||
timer.Minutes = comp.Minutes
|
||||
timer.Secondes = comp.Secondes
|
||||
--timer.Cyclic = comp.Cyclic
|
||||
timer.Active = comp.Active
|
||||
r2.requestInsertGhostNode(comp.InstanceId, "Components", -1, "", timer)
|
||||
local nbMob = 0
|
||||
|
||||
for id = 1, 5 do
|
||||
local propertyName = "Mob"..id.."Id"
|
||||
if comp[propertyName] ~= nil and comp[propertyName] ~= "" then
|
||||
local mob = r2:getInstanceFromId(comp[propertyName])
|
||||
if mob then
|
||||
nbMob = nbMob + 1
|
||||
if mob:isKindOf("NpcGrpFeature") then
|
||||
local instanceId = mob.Components[0].InstanceId
|
||||
r2.requestSetGhostNode(instanceId, "AutoSpawn", 0)
|
||||
else
|
||||
r2.requestSetGhostNode(mob.InstanceId, "AutoSpawn", 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nbMob == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
do
|
||||
local type = "On Trigger"
|
||||
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = type
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = type
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(comp.InstanceId)
|
||||
action.Action.Type = "trigger"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = timer.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
|
||||
end
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "activation"
|
||||
eventHandler.Value = ""
|
||||
eventHandler.Name = "activation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
action.Entity = r2.RefId(timer.InstanceId)
|
||||
action.Action.Type = "Activate"
|
||||
action.Action.Value = ""
|
||||
table.insert(eventHandler.Actions, action)
|
||||
local behaviorId = comp.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("TimedSpawner")
|
||||
assert(comp)
|
||||
assert(comp.Position)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdTimedSpawner")):toUtf8()
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
|
||||
local function posOk(x, y, z)
|
||||
debugInfo("Validate creation of a Timed Spawner.")
|
||||
if r2.mustDisplayInfo("TimedSpawner") == 1 then
|
||||
r2.displayFeatureHelp("TimedSpawner")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewTimedSpawnerFeatureAction"))
|
||||
local component = feature.Components.TimedSpawner.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function posCancel() end
|
||||
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureTimedSpawner")
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
--- register the curent Feature to menu
|
||||
|
||||
function component:getLogicTranslations()
|
||||
-- register trad
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2AA0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()}
|
||||
}
|
||||
}
|
||||
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["TimedSpawner"] = feature
|
||||
|
||||
|
@ -1,593 +0,0 @@
|
||||
-- In Transalation file
|
||||
-- Category : uiR2EdTimer --
|
||||
-- CreationFrom : uiR2EdTimerParameters
|
||||
-- uiR2EDtooltipCreateFeatureTimer -> tooltip
|
||||
|
||||
r2.Features.TimerFeature = {}
|
||||
|
||||
local feature = r2.Features.TimerFeature
|
||||
|
||||
feature.Name="TimerFeature"
|
||||
|
||||
feature.BanditCount = 0
|
||||
|
||||
feature.Description="A Timer"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
|
||||
feature.Components.Timer =
|
||||
{
|
||||
PropertySheetHeader = r2.getDisplayButtonHeader("r2.events:openEditor()", "uiR2EdEditEventsButton"),
|
||||
BaseClass="LogicEntity",
|
||||
Name="Timer",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
ApplicableActions = {
|
||||
"Activate", "Deactivate", "Pause", "Resume", "Trigger",
|
||||
"add seconds", "sub seconds",
|
||||
-- "Add 10 Seconds", "Add 1 minute", "Sub 10 seconds", "Sub 1 minute"
|
||||
},
|
||||
Events = {
|
||||
"On Trigger",
|
||||
"On Activation", "On Desactivation",
|
||||
"On Pause", "On Resume"
|
||||
},
|
||||
Conditions = {
|
||||
"is active", "is inactive", "is paused",
|
||||
"is running", "is finished"
|
||||
},
|
||||
TextContexts = {},
|
||||
TextParameters = {},
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- Category="uiR2EDRollout_Timer",
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Minutes", Type="Number", Min="0", Max="120", DefaultValue="0"},
|
||||
{Name="Secondes",Type="Number", Min="0", Max="999", DefaultValue="30"},
|
||||
{Name="Cyclic", Type="Number", WidgetStyle="Boolean", Min="0", Max="1", DefaultValue="0"},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
|
||||
|
||||
local time = this.Secondes + this.Minutes * 60
|
||||
--local time = secs + min * 60
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
|
||||
if this.Active == 1 then
|
||||
local action1 = r2.Translator.createAction("timer_set", rtNpcGrp.Id, 0, time)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 0)
|
||||
local action3 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "v2", 0)
|
||||
local action4 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 1)
|
||||
local action = r2.Translator.createAction("multi_actions", {action1, action2, action3, action4})
|
||||
|
||||
r2.Translator.translateAiGroupInitialState(this, context, action)
|
||||
else
|
||||
local action1 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "v2", 0)
|
||||
local action2 = r2.Translator.createAction("set_value", rtNpcGrp.Id, "Active", 0)
|
||||
local action = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
|
||||
r2.Translator.translateAiGroupInitialState(this, context, action)
|
||||
end
|
||||
|
||||
do
|
||||
local actionTrigger = r2.Translator.createAction("set_value", rtNpcGrp.Id, "v2", 1)
|
||||
r2.Translator.translateAiGroupEvent("timer_t0_triggered", this, context, actionTrigger)
|
||||
end
|
||||
|
||||
--TODO: gestion v2 pour trigger
|
||||
if this.Cyclic == 1 then
|
||||
local states = r2.Translator.getRtStatesNames(context, this.InstanceId)
|
||||
local eventHandler = r2.Translator.createEvent("timer_t0_triggered", states, rtNpcGrp.Id)
|
||||
local action1 = r2.Translator.createAction("timer_set", rtNpcGrp.Id, 0, time)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 0)
|
||||
local action = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
table.insert(context.RtAct.Events, eventHandler)
|
||||
-- insert a npc_event_handler_action
|
||||
table.insert(eventHandler.ActionsId, action.Id)
|
||||
table.insert(context.RtAct.Actions, action)
|
||||
else
|
||||
local states = r2.Translator.getRtStatesNames(context, this.InstanceId)
|
||||
local eventHandler = r2.Translator.createEvent("timer_t0_triggered", states, rtNpcGrp.Id)
|
||||
local actionEmit = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 1)
|
||||
table.insert(context.RtAct.Events, eventHandler)
|
||||
-- insert a npc_event_handler_action
|
||||
table.insert(eventHandler.ActionsId, actionEmit.Id)
|
||||
table.insert(context.RtAct.Actions, actionEmit)
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
-- Specific to the component Timer
|
||||
local component = feature.Components.Timer
|
||||
|
||||
|
||||
function component.getLogicActionActivate(entity, context, action, rtNpcGrp)
|
||||
|
||||
local time = entity.Secondes + entity.Minutes * 60
|
||||
local action1 = r2.Translator.createAction("timer_set", rtNpcGrp.Id, 0, time)
|
||||
-- local action1 = r2.Translator.createAction("timer_enable", rtNpcGrp.Id, 0)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 0)
|
||||
local actionIfInactive = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0,
|
||||
r2.Translator.createAction("multi_actions", {action1, action2}))
|
||||
|
||||
return actionIfInactive, actionIfInactive
|
||||
end
|
||||
|
||||
function component.getLogicActionDeactivate(entity, context, action, rtNpcGrp)
|
||||
local action2 = r2.Translator.createAction("timer_disable", rtNpcGrp.Id, 0)
|
||||
local action1 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 1)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
local actionIfActive = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1, retAction)
|
||||
return actionIfActive, actionIfActive
|
||||
end
|
||||
|
||||
function component.getLogicActionPause(entity, context, action, rtNpcGrp)
|
||||
local action1 = r2.Translator.createAction("timer_suspend", rtNpcGrp.Id, 0)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 2)
|
||||
|
||||
local multiAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
|
||||
local actionIsEnable = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local actionIf = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "is_enable", 1, multiAction)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {actionIsEnable, actionIf})
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
function component.getLogicActionResume(entity, context, action, rtNpcGrp)
|
||||
|
||||
local action1 = r2.Translator.createAction("timer_resume", rtNpcGrp.Id, 0)
|
||||
local action2 = r2.Translator.createAction("generic_event_trigger", rtNpcGrp.Id, 3)
|
||||
|
||||
local multiAction = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
|
||||
local actionIsEnable = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local actionIf = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "is_enable", 1, multiAction)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {actionIsEnable, actionIf})
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
function component.getLogicActionTrigger(entity, context, action, rtNpcGrp)
|
||||
local multiAction = r2.Translator.createAction("multi_actions", {
|
||||
r2.Translator.createAction("set_value", rtNpcGrp.Id, "v2", 1),
|
||||
r2.Translator.createAction("timer_trigger", rtNpcGrp.Id, 0)})
|
||||
local actionIsEnable = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local actionIf = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "is_enable", 1, multiAction)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {actionIsEnable, actionIf})
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
function component.getLogicActionAddSeconds(entity, context, action, rtNpcGrp)
|
||||
local value = 0
|
||||
if action.Action.ValueString then value = tonumber(action.Action.ValueString) end
|
||||
local timerAdd = r2.Translator.createAction("timer_add", rtNpcGrp.Id, 0, value)
|
||||
|
||||
local actionIsEnable = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local actionIf = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "is_enable", 1, timerAdd)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {actionIsEnable, actionIf})
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
function component.getLogicActionSubSeconds(entity, context, action, rtNpcGrp)
|
||||
local value = 0
|
||||
if action.Action.ValueString then value = tonumber(action.Action.ValueString) end
|
||||
local actionSub = r2.Translator.createAction("timer_sub", rtNpcGrp.Id, 0, value)
|
||||
|
||||
local actionIsEnable = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local actionIf = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "is_enable", 1, actionSub)
|
||||
local retAction = r2.Translator.createAction("multi_actions", {actionIsEnable, actionIf})
|
||||
assert(retAction)
|
||||
return retAction, retAction
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
|
||||
local funs = {
|
||||
["Activate"] = component.getLogicActionActivate,
|
||||
["Deactivate"] = component.getLogicActionDeactivate,
|
||||
["Pause"] = component.getLogicActionPause,
|
||||
["Resume"] = component.getLogicActionResume,
|
||||
["Trigger"] = component.getLogicActionTrigger,
|
||||
["Add 10 Seconds"] = component.getLogicActionAdd10Seconds,
|
||||
["Add 1 minute"] = component.getLogicActionAdd1Minute,
|
||||
["Sub 10 seconds"] = component.getLogicActionSub0Seconds,
|
||||
["Sub 1 minute"] = component.getLogicActionSub1Minute,
|
||||
["sub seconds"] = component.getLogicActionSubSeconds,
|
||||
["add seconds"] = component.getLogicActionAddSeconds,
|
||||
|
||||
}
|
||||
|
||||
|
||||
local fun = funs[ action.Action.Type ]
|
||||
if fun then
|
||||
firstAction, lastAction = fun(entity, context, action, rtNpcGrp)
|
||||
|
||||
end
|
||||
|
||||
assert(firstAction)
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
local prefix = ""
|
||||
|
||||
if rtNpcGrp.Id and rtNpcGrp.Id ~= "" then
|
||||
prefix = r2:getNamespace() .. rtNpcGrp.Id.."."
|
||||
end
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local action2 = r2.Translator.createAction("condition_if", prefix.."is_enable == 1" );
|
||||
local multiactions= r2.Translator.createAction("multi_actions", {action1, action2});
|
||||
return multiactions, action2
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0)
|
||||
local action2 = r2.Translator.createAction("condition_if", prefix.."is_enable == 0")
|
||||
local multiActions = r2.Translator.createAction("multi_actions", {action1, action2})
|
||||
return multiActions, action2
|
||||
elseif condition.Condition.Type == "is paused" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local action2 = r2.Translator.createAction("timer_is_suspended", rtNpcGrp.Id, 0);
|
||||
local actionSuspended = r2.Translator.createAction("condition_if", prefix.."is_suspended == 1");
|
||||
local action3 = r2.Translator.createAction("condition_if", prefix.."is_enable == 1", actionSuspended);
|
||||
local multiactions = r2.Translator.createAction("multi_actions", {action1, action2, action3});
|
||||
return multiactions, actionSuspended
|
||||
elseif condition.Condition.Type == "is running" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local action2 = r2.Translator.createAction("timer_is_suspended", rtNpcGrp.Id, 0);
|
||||
local actionSuspended = r2.Translator.createAction("condition_if", prefix.."is_suspended == 0");
|
||||
local action3 = r2.Translator.createAction("condition_if", prefix.."is_enable == 1", actionSuspended);
|
||||
local multiactions = r2.Translator.createAction("multi_actions", {action1, action2, action3});
|
||||
return multiactions, actionSuspended
|
||||
elseif condition.Condition.Type == "is finished" then
|
||||
local action1 = r2.Translator.createAction("timer_is_enable", rtNpcGrp.Id, 0);
|
||||
local action2 = r2.Translator.createAction("condition_if", prefix.."is_enable == 0");
|
||||
local action3 = r2.Translator.createAction("condition_if", prefix.."v2 == 1", action2);
|
||||
|
||||
local multiactions= r2.Translator.createAction("multi_actions", {action1, action3});
|
||||
|
||||
return multiactions, action2
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "On Trigger" then
|
||||
eventHandler, firstCondition, lastCondition = r2.Translator.createEvent("timer_t0_triggered", "", rtNpcGrp.Id)
|
||||
--return r2.Translator.getComponentUserEvent(rtNpcGrp, 6)
|
||||
elseif eventType == "On Activation" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 0)
|
||||
elseif eventType == "On Desactivation" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 1)
|
||||
elseif eventType == "On Pause" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "On Resume" then
|
||||
return r2.Translator.getComponentGenericEvent(rtNpcGrp, 3)
|
||||
end
|
||||
|
||||
|
||||
return eventHandler, firstCondition, lastCondition
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y, secondes, minutes, cyclic)
|
||||
|
||||
local comp = r2.newComponent("Timer")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.timer")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdNameTimerFeature")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
if minutes then comp.Minutes = minutes end
|
||||
if secondes then comp.Secondes = secondes end
|
||||
if cyclic then comp.Cyclic = cyclic end
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local minutes = tonumber( resultTable["Minutes"] )
|
||||
local secondes = tonumber( resultTable["Secondes"] )
|
||||
local cyclic = tonumber( resultTable["Cyclic"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
|
||||
local component = feature.Components.Timer.createComponent( x, y, secondes, minutes, cyclic)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'Timer' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'Timer' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("Timer") == 1 then
|
||||
r2.displayFeatureHelp("Timer")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewTimerFeatureAction"))
|
||||
local component = feature.Components.Timer.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'Timer' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_timer.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureTimer")
|
||||
end
|
||||
|
||||
|
||||
|
||||
function feature.registerForms()
|
||||
r2.Forms.TimerForm =
|
||||
{
|
||||
Caption = "uiR2EdTimerParameters",
|
||||
PropertySheetHeader =
|
||||
[[
|
||||
<view type="text" id="t" multi_line="true" sizeref="w" w="-36" x="4" y="-2" posref="TL TL" global_color="true" fontsize="14" shadow="true" hardtext="uiR2EDTimerDescription"/>
|
||||
]],
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="Display", Type="Number", WidgetStyle="Boolean", DefaultValue="0", Translation="uiR2showMessageAgain", InvertWidget=true, CaptionWidth=5 },
|
||||
-- following field are tmp for property sheet building testing
|
||||
-- {Name="Minutes", Type="Number", Category="uiR2EDRollout_Timer", Min="0", Max="59", Default="0"},
|
||||
-- {Name="Secondes", Type="Number", Category="uiR2EDRollout_Timer", Min="0", Max="59", Default="10"},
|
||||
-- {Name="Cyclic", Type="Number", Category="uiR2EDRollout_Timer", WidgetStyle="Boolean", Min="0", Max="1", Default="0"},
|
||||
-- {Name="Active", Type="Number", WidgetStyle="Boolean", Category="uiR2EDRollout_Default", DefaultValue="1"},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
-- register trad
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["Activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["Deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["Trigger"] = { menu=i18n.get( "uiR2AA0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Trigger" ):toUtf8()},
|
||||
["Pause"] = { menu=i18n.get( "uiR2AA0TimerPause" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1TimerPause" ):toUtf8()},
|
||||
["Resume"] = { menu=i18n.get( "uiR2AA0TimerResume" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1TimerResume" ):toUtf8()},
|
||||
["Add 10 Seconds"] = { menu=i18n.get( "uiR2AA0TimerAdd10s" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1TimerAdds10s" ):toUtf8()},
|
||||
["Add 1 minute"] = { menu=i18n.get( "uiR2AA0TimerAdd1m" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1TimerAdds1m" ):toUtf8()},
|
||||
["Sub 10 seconds"] = { menu=i18n.get( "uiR2AA0TimerSub10s" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1TimerSubs10s" ):toUtf8()},
|
||||
["Sub 1 minute"] = { menu=i18n.get( "uiR2AA0TimerSub1m" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1TimerSubs1m" ):toUtf8()},
|
||||
["add seconds"] = { menu=i18n.get( "uiR2AA0TimerAddNSeconds" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1TimerAddNSeconds" ):toUtf8()},
|
||||
["sub seconds"] = { menu=i18n.get( "uiR2AA0TimerSubNSeconds" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1TimerSubNSeconds" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["On Activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["On Desactivation"]= { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["On Trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
["On Pause"] = { menu=i18n.get( "uiR2Event0TimerPause" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TimerPause" ):toUtf8()},
|
||||
["On Resume"] = { menu=i18n.get( "uiR2Event0TimerResume" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TimerResume" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is paused"] = { menu=i18n.get( "uiR2Test0TimerPaused" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TimerPaused" ):toUtf8()},
|
||||
["is running"] = { menu=i18n.get( "uiR2Test0TimerRunning" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TimerRunning" ):toUtf8()},
|
||||
["is finished"] = { menu=i18n.get( "uiR2Test0TimerFinished" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TimerFinished" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
function component.initEventValuesMenu(this, menu, categoryEvent)
|
||||
--local startTime = nltime.getPreciseLocalTime()
|
||||
for ev=0,menu:getNumLine()-1 do
|
||||
|
||||
local eventType = tostring(menu:getLineId(ev))
|
||||
|
||||
--local endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for 10 is %f", endTime - startTime))
|
||||
--startTime = nltime.getPreciseLocalTime()
|
||||
|
||||
if r2.events.eventTypeWithValue[eventType] == "Number" then
|
||||
menu:addSubMenu(ev)
|
||||
local subMenu = menu:getSubMenu(ev)
|
||||
local func = ""
|
||||
-- for i=0, 9 do
|
||||
-- local uc_name = ucstring()
|
||||
-- uc_name:fromUtf8( tostring(i) )
|
||||
-- func = "r2.events:setEventValue('','" .. categoryEvent .."','".. tostring(i).."')"
|
||||
-- subMenu:addLine(uc_name, "lua", func, tostring(i))
|
||||
-- end
|
||||
|
||||
--endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for 11 is %f", endTime - startTime))
|
||||
--startTime = nltime.getPreciseLocalTime()
|
||||
|
||||
local lineNb = 0
|
||||
for i=0, 50, 10 do
|
||||
local lineStr = tostring(i).."/"..tostring(i+9)
|
||||
subMenu:addLine(ucstring(lineStr), "", "", tostring(i))
|
||||
|
||||
--endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for 12 is %f", endTime - startTime))
|
||||
--startTime = nltime.getPreciseLocalTime()
|
||||
|
||||
subMenu:addSubMenu(lineNb)
|
||||
local subMenu2= subMenu:getSubMenu(lineNb)
|
||||
for s=0,9 do
|
||||
lineStr = tostring(i+s)
|
||||
local func = "r2.events:setEventValue('','" .. categoryEvent .."','".. lineStr.."')"
|
||||
subMenu2:addLine(ucstring(lineStr), "lua", func, lineStr)
|
||||
end
|
||||
lineNb = lineNb+1
|
||||
|
||||
--endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for 13 is %f", endTime - startTime))
|
||||
--startTime = nltime.getPreciseLocalTime()
|
||||
end
|
||||
|
||||
for i=0, 50, 10 do
|
||||
local lineStr = tostring(i).." m /"..tostring(i+9).." m"
|
||||
subMenu:addLine(ucstring(lineStr), "", "", tostring(i))
|
||||
|
||||
subMenu:addSubMenu(lineNb)
|
||||
local subMenu2= subMenu:getSubMenu(lineNb)
|
||||
local index = 0
|
||||
|
||||
--endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for 14 is %f", endTime - startTime))
|
||||
--startTime = nltime.getPreciseLocalTime()
|
||||
|
||||
for m=0,9 do
|
||||
lineStr = tostring( (i+m)*60)
|
||||
-- local func = "r2.events:setEventValue('','" .. categoryEvent .."','".. lineStr.."')"
|
||||
subMenu2:addLine(ucstring(tostring(i+m) .. "m"), "", "", lineStr)
|
||||
subMenu2:addSubMenu(index)
|
||||
local subMenu3= subMenu2:getSubMenu(index)
|
||||
index = index + 1
|
||||
for s=0, 55, 5 do
|
||||
lineStr = tostring( (i+m)*60 + s)
|
||||
local func = "r2.events:setEventValue('','" .. categoryEvent .."','".. lineStr.."')"
|
||||
subMenu3:addLine(ucstring(tostring(i+m) .. "m ".. s .. "s"), "lua", func, lineStr)
|
||||
end
|
||||
end
|
||||
lineNb = lineNb+1
|
||||
|
||||
--endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for 15 is %f", endTime - startTime))
|
||||
--startTime = nltime.getPreciseLocalTime()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
r2.Features["TimerFeature"] = feature
|
||||
|
@ -1,208 +0,0 @@
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdUserItemFeature --
|
||||
-- CreationFrom : uiR2EdUserItemParameters
|
||||
|
||||
|
||||
r2.Features.UserItemFeature = {}
|
||||
|
||||
local feature = r2.Features.UserItemFeature
|
||||
|
||||
feature.Name="UserItemFeature"
|
||||
|
||||
feature.Description="A UserItem feature"
|
||||
|
||||
|
||||
|
||||
-- #########################
|
||||
-- # FEATURE FUNCTIONS #
|
||||
-- #########################
|
||||
|
||||
function feature.registerForms()
|
||||
r2.Forms.UserItemFeatureForm =
|
||||
{
|
||||
Caption = "uiR2EdUserItemParameters",
|
||||
Prop =
|
||||
{
|
||||
-- The creation form's fields are defined here
|
||||
{Name="Property1", Type="String", Category="uiR2EDRollout_UISubsection"}
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.UserItemFeature =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="UserItemFeature",
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = {},
|
||||
|
||||
Events = {},
|
||||
|
||||
Conditions = {},
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", Category="uiR2EDRollout_UISubsection", WidgetStyle="StaticText"}
|
||||
},
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
this:createGhostComponents()
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
-- ###########################
|
||||
-- # COMPONENT FUNCTIONS #
|
||||
-- ###########################
|
||||
--
|
||||
-- The following functions are specific to the Feature
|
||||
--
|
||||
local component = feature.Components.UserItemFeature
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
local firstAction, lastAction = nil,nil
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
local eventHandler, firsCondition, lastCondition = nil, nil, nil
|
||||
return eventHandler, firsCondition, lastCondition
|
||||
|
||||
end
|
||||
|
||||
component.createGhostComponents = function(act, comp)
|
||||
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("UserItemFeature")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = "palette.entities.botobjects.milestone"
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdUserItemFeature")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
--comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewUserItemFeatureAction"))
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.createComponent( x, y)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'UserItemFeature' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'UserItemFeature' at pos (%d, %d, %d)", x, y, z))
|
||||
r2:doForm("UserItemFeatureForm", {X=x, Y=y}, paramsOk, paramsCancel)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'UserItemFeature' position")
|
||||
end
|
||||
r2:choosePos("object_milestone.creature", posOk, posCancel, "createFeatureBanditCamp")
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
--- register the current Feature to menu
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdUserItemFeature")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "UserItemFeature")
|
||||
end
|
||||
|
||||
function component:getLogicEntityAttributes()
|
||||
-- register trad
|
||||
local localLogicEntityAttributes = {
|
||||
["ApplicableActions"] = {},
|
||||
["Events"] = {},
|
||||
["Conditions"] = {}
|
||||
}
|
||||
return localLogicEntityAttributes
|
||||
end
|
||||
|
||||
r2.Features["UserItemFeature"] = feature
|
||||
|
@ -1,330 +0,0 @@
|
||||
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdUserTrigger --
|
||||
-- CreationFrom : uiR2EdUserTriggerParameters
|
||||
|
||||
|
||||
r2.Features.UserTriggerFeature = {}
|
||||
|
||||
local feature = r2.Features.UserTriggerFeature
|
||||
|
||||
feature.Name="UserTriggerFeature"
|
||||
|
||||
feature.Description="A feature that allows a DM to trigger an event"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
|
||||
function feature.registerForms()
|
||||
r2.Forms.UserTriggerForm =
|
||||
{
|
||||
Caption = "uiR2EdUserTriggerParameters",
|
||||
PropertySheetHeader =
|
||||
[[
|
||||
<view type="text" id="t" multi_line="true" sizeref="w" w="-36" x="4" y="-2" posref="TL TL" global_color="true" fontsize="14" shadow="true" hardtext="uiR2EdUserTriggerDescription"/>
|
||||
]],
|
||||
Prop =
|
||||
{
|
||||
{Name="Display", Type="Number", WidgetStyle="Boolean", DefaultValue="0", Translation="uiR2showMessageAgain", InvertWidget=true, CaptionWidth=5 },
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
feature.Components.UserTrigger =
|
||||
{
|
||||
PropertySheetHeader = r2.getDisplayButtonHeader("r2.events:openEditor()", "uiR2EdEditEventsButton"),
|
||||
BaseClass="LogicEntity",
|
||||
Name="UserTrigger",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- Supposed to be the specific attributes of the feature (ex: for a banditcamp, number of bandits,
|
||||
-- race, etc.) but apparently not used..
|
||||
--
|
||||
Parameters = {},
|
||||
--
|
||||
-- The different actions that can be performed by the feature (activate, wander, spawn etc.)
|
||||
--
|
||||
ApplicableActions = { "trigger"},
|
||||
--
|
||||
-- Events are what happen to the feature and may trigger actions on the feature. (ex: "on activation",
|
||||
-- "on arrive at camp" etc.)
|
||||
--
|
||||
Events = { "triggered"},
|
||||
|
||||
-- Conditions are what can be tested on the feature, giving information about its state (ex: "is wandering", "is active" etc.)
|
||||
--
|
||||
Conditions = { },
|
||||
--
|
||||
-- TextContexts is what the feature might say upon events (2 different kinds: spontaneous & interrogation texts)
|
||||
--
|
||||
TextContexts = {},
|
||||
--
|
||||
-- Not quite clear..
|
||||
--
|
||||
TextParameters = {},
|
||||
--
|
||||
-- Feature's parameters which can be modified by the GM at runtime.
|
||||
--
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- Properties define the feature's parameters like this:
|
||||
-- {Name="Parameter_Name", Type="Param_Type", Category="??", WidgetStyle="UI_WidgetStyle", Min="min_value", Max="max_value", Default="defalut_value"
|
||||
-- Categories can be found in data_common/r2/r2.uxt??
|
||||
--
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table", Visible = false},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Description", Type="String", }
|
||||
-- {Name="SheetId", Type="RefId", WidgetStyle="PlotItem", Category="uiR2EDRollout_Description"},
|
||||
},
|
||||
|
||||
--
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
--
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
--
|
||||
-- Called when running EditMode to create locally the feature without sending anything into the act (speed purpose).
|
||||
--
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, this.InstanceId)
|
||||
|
||||
local rt = r2.newComponent("RtUserTrigger")
|
||||
assert(rt)
|
||||
rt.Name = this.Name
|
||||
rt.TriggerId = 1
|
||||
rt.Grp = rtNpcGrp.Id
|
||||
|
||||
table.insert(context.RtAct.UserTriggers, rt)
|
||||
end
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.UserTrigger
|
||||
|
||||
--
|
||||
-- Create the logic actions relative to the feature via the translator.
|
||||
--
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if (action.Action.Type == "Trigger") then
|
||||
local retAction =r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 1)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
local firstAction, lastAction = nil, nil
|
||||
return firstAction, lastAction
|
||||
end
|
||||
|
||||
--
|
||||
-- Checks the conditions defined for this feature
|
||||
--
|
||||
function component.getLogicCondition(this, context, condition)
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
function component.getLogicEvent(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "triggered" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 1)
|
||||
end
|
||||
|
||||
return eventHandler, firstCondition, lastCondition
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- feature part
|
||||
|
||||
|
||||
--
|
||||
-- Creates an instance of the feature with attributes retrieved from ttriggeredd-
|
||||
function component.createComponent(x, y)
|
||||
|
||||
local comp = r2.newComponent("UserTrigger")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.user_event")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2ED" .. component.Name)):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- from ihm
|
||||
-- Displays the creation form of the feature and calls CreateComponent with the user input values
|
||||
--
|
||||
component.create = function(this)
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewUserTriggerFeatureAction"))
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("UserTriggerForm", 0)
|
||||
else r2.setDisplayInfo("UserTriggerForm", 1) end
|
||||
|
||||
local component = component.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'UserTrigger' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("UserTrigger") == 1 then
|
||||
r2.displayFeatureHelp("UserTrigger")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewUserTriggerFeatureAction"))
|
||||
local component = component.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'UserTriggerFeature' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_user_event.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureUserTrigger")
|
||||
end
|
||||
|
||||
|
||||
|
||||
function component.getLogicAction(entity, context, action)
|
||||
assert( action.Class == "ActionStep")
|
||||
|
||||
local firstAction, lastAction = nil, nil
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
|
||||
if action.Action.Type == 'trigger' then
|
||||
local retAction =r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 1)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
printWarning('Action not implemented yet :'.. action.Action.Type)
|
||||
assert(nil)
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- add a line to the event menu
|
||||
function component:getLogicTranslations()
|
||||
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["trigger"] = { menu=i18n.get( "uiR2AA0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["triggered"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["UserTriggerFeature"] = feature
|
||||
|
@ -1,502 +0,0 @@
|
||||
|
||||
-- In Translation file
|
||||
-- Category : uiR2EdVisitZone --
|
||||
-- CreationFrom : uiR2EdVisitZoneParameters
|
||||
|
||||
|
||||
r2.Features.VisitZoneFeature = {}
|
||||
|
||||
local feature = r2.Features.VisitZoneFeature
|
||||
|
||||
feature.Name="VisitZoneFeature"
|
||||
|
||||
feature.Description=""
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
feature.Components.VisitZone =
|
||||
{
|
||||
BaseClass="LogicEntity",
|
||||
Name="VisitZone",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "visitZoneDisplayer",
|
||||
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
|
||||
Parameters = {},
|
||||
|
||||
ApplicableActions = { "activate", "deactivate", "succeed"},
|
||||
|
||||
Events = {"activation", "deactivation", "wait validation", "mission asked", "succeeded"},
|
||||
|
||||
Conditions = { "is active", "is inactive", "is succeeded" },
|
||||
|
||||
TextContexts = {},
|
||||
|
||||
TextParameters = {},
|
||||
|
||||
LiveParameters = {},
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Components", Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="MissionGiver", Type="RefId", PickFunction="r2:canPickTalkingNpc", SetRefIdFunction="r2:setTalkingNpc"},
|
||||
{Name="ValidationNeeded", Category="uiR2EDRollout_TextToSay", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="ContextualText", Type="String", Category="uiR2EDRollout_TextToSay", MaxNumChar="100" },
|
||||
{Name="MissionText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="WaitValidationText", Type="String", Category="uiR2EDRollout_TextToSay"},
|
||||
{Name="MissionSucceedText", Type="String", Category="uiR2EDRollout_TextToSay", Visible= function(this)
|
||||
return this:IsValidationNeeded() end },
|
||||
{Name="BroadcastText", Type="String", Category="uiR2EDRollout_TextToSay", DefaultValue="", DefaultInBase = 1},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Repeatable", Type="Number", WidgetStyle="Boolean", DefaultValue="0"},
|
||||
|
||||
|
||||
},
|
||||
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
pretranslate = function(this, context)
|
||||
r2.Translator.createAiGroup(this, context)
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
local component = feature.Components.VisitZone
|
||||
|
||||
function component:IsValidationNeeded()
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
if validationNeeded == 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
----------------------------------------
|
||||
|
||||
local visitZoneDisplayerTable = clone(r2:propertySheetDisplayer())
|
||||
|
||||
local oldOnAttrModified = visitZoneDisplayerTable.onAttrModified
|
||||
function visitZoneDisplayerTable:onAttrModified(instance, attributeName)
|
||||
|
||||
oldOnAttrModified(self, instance, attributeName)
|
||||
r2:propertySheetDisplayer():onAttrModified(instance, attributeName)
|
||||
if attributeName == "ValidationNeeded" then
|
||||
local propertySheet = r2:getPropertySheet(instance)
|
||||
propertySheet.Env.updatePropVisibility()
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function visitZoneDisplayerTable:onSelect(instance, isSelected)
|
||||
r2:logicEntityPropertySheetDisplayer():onSelect(instance, isSelected)
|
||||
end
|
||||
|
||||
function component:onTargetInstancePreHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
tmpInstance.User.SelfModified = true
|
||||
end
|
||||
|
||||
function component:onTargetInstancePostHrcMove(targetAttr, targetIndexInArray)
|
||||
local targetId = self[targetAttr]
|
||||
|
||||
local tmpInstance = r2:getInstanceFromId(targetId)
|
||||
|
||||
assert(tmpInstance)
|
||||
if tmpInstance.User.SelfModified and tmpInstance.User.SelfModified == true then
|
||||
if tmpInstance.ParentInstance and tmpInstance.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
r2.requestSetNode(self.InstanceId, targetAttr, r2.RefId(""))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function r2:visitZoneDisplayer()
|
||||
return visitZoneDisplayerTable -- returned shared displayer to avoid wasting memory
|
||||
end
|
||||
----------------------------------------
|
||||
----------------------------------------
|
||||
component.createGhostComponents = function(this, act)
|
||||
|
||||
local comp = this
|
||||
|
||||
local giver = r2:getInstanceFromId(comp.MissionGiver)
|
||||
if not giver then return end
|
||||
|
||||
local zoneTrigger = r2:getInstanceFromId(comp._ZoneId)
|
||||
assert(zoneTrigger)
|
||||
|
||||
local validationNeeded = comp.ValidationNeeded
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "On Player Arrived"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "On Player Arrived"
|
||||
|
||||
local actionSuccess = r2.newComponent("ActionStep")
|
||||
actionSuccess.Entity = r2.RefId(comp.InstanceId)
|
||||
if validationNeeded == 1 then
|
||||
actionSuccess.Action.Type = "validateTask"
|
||||
else
|
||||
actionSuccess.Action.Type = "succeed"
|
||||
end
|
||||
actionSuccess.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, actionSuccess)
|
||||
|
||||
local behaviorId = zoneTrigger.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "activation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "activation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(zoneTrigger.InstanceId)
|
||||
action.Action.Type = "activate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = this.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
do
|
||||
local eventHandler = r2.newComponent("LogicEntityAction")
|
||||
eventHandler.Event.Type = "deactivation"
|
||||
eventHandler.Event.Value = ""
|
||||
eventHandler.Name = "deactivation"
|
||||
|
||||
local action = r2.newComponent("ActionStep")
|
||||
|
||||
action.Entity = r2.RefId(zoneTrigger.InstanceId)
|
||||
action.Action.Type = "deactivate"
|
||||
action.Action.Value = ""
|
||||
|
||||
table.insert(eventHandler.Actions, action)
|
||||
|
||||
local behaviorId = this.Behavior.InstanceId
|
||||
assert(behaviorId)
|
||||
r2.requestInsertGhostNode(behaviorId, "Actions", -1, "", eventHandler)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function component:textAdapter(text)
|
||||
|
||||
assert(self)
|
||||
assert(type(text) == "string")
|
||||
local str = text
|
||||
local mission_giver = ""
|
||||
local mission_target = ""
|
||||
|
||||
if tostring(self.MissionGiver) ~= "" then
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if giver then mission_giver = giver.Name end
|
||||
end
|
||||
|
||||
str=string.gsub(str, "<mission_giver>", mission_giver)
|
||||
return str
|
||||
end
|
||||
|
||||
--EVENT
|
||||
-- 1: mission given (plugged on talkto)
|
||||
-- 2: wait validation (plugged on talkto)
|
||||
-- 4: activation (generic)
|
||||
-- 5: deactivation (generic)
|
||||
-- 8: step validated
|
||||
-- 9: mission successful (generic)
|
||||
|
||||
|
||||
--
|
||||
-- v1: repeatable
|
||||
-- v2: mission state 0= the player didn't talk to the mission giver,
|
||||
-- 1= player talked to the mission giver, but didn't visit the zone yet
|
||||
-- 2= player did visit the zone but didn't come back to talk to the mission giver yet
|
||||
-- v3: mission completed (0=never completed, 1=completed at least once)
|
||||
--
|
||||
function component:translate(context)
|
||||
r2.Translator.translateAiGroup(self, context)
|
||||
|
||||
local rtGrp = r2.Translator.getRtGroup(context, self.InstanceId)
|
||||
|
||||
local validationNeeded = self.ValidationNeeded
|
||||
|
||||
local giver = r2:getInstanceFromId(self.MissionGiver)
|
||||
if not giver then return end
|
||||
local rtGiverGrp = r2.Translator.getRtGroup(context, giver.InstanceId)
|
||||
|
||||
-- Start of state
|
||||
r2.Translator.Tasks.startOfStateLogic(self, context, rtGrp)
|
||||
|
||||
-- Activation
|
||||
r2.Translator.Tasks.activationLogic(self, context, rtGrp)
|
||||
|
||||
--Deactivation
|
||||
r2.Translator.Tasks.deactivationLogic(self, context, rtGrp)
|
||||
|
||||
--Set mission status to 1 when mission is taken
|
||||
r2.Translator.Tasks.setStatusLogic(self, context, rtGrp)
|
||||
|
||||
-- Mission giver must either give the mission (1st time) or say WaitValidationText
|
||||
r2.Translator.Tasks.giverLogic(self, giver, context, rtGrp)
|
||||
|
||||
--depending on validationNeeded prop, either set
|
||||
if validationNeeded == 1 then
|
||||
r2.Translator.Tasks.validationByMissionGiver(self, giver, context, rtGrp)
|
||||
|
||||
r2.Translator.Tasks.broadcastOnEvent8(self, context)
|
||||
end
|
||||
|
||||
--success with broadcast
|
||||
r2.Translator.Tasks.successBroadcastLogic(self, context, rtGrp)
|
||||
|
||||
r2.Translator.translateFeatureActivation(self, context)
|
||||
|
||||
end
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtGrp)
|
||||
|
||||
if action.Action.Type == "validateTask" then
|
||||
local action = r2.Translator.createAction("validate_task", rtGrp.Id)
|
||||
return action, action
|
||||
elseif action.Action.Type == "succeed" then
|
||||
local actionComplete = r2.Translator.createAction("complete_mission", rtGrp.Id)
|
||||
return actionComplete, actionComplete
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicAction(rtGrp, action)
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
if condition.Condition.Type == "is active" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is inactive" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0);
|
||||
return action1, action1
|
||||
elseif condition.Condition.Type == "is succeeded" then
|
||||
local action1 = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "v3", 1);
|
||||
return action1, action1
|
||||
|
||||
else
|
||||
assert(nil)
|
||||
end
|
||||
return nil,nil
|
||||
end
|
||||
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "mission asked" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 3)
|
||||
elseif eventType == "wait validation" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 2)
|
||||
elseif eventType == "succeeded" then
|
||||
return r2.Translator.getComponentUserEvent(rtNpcGrp, 9)
|
||||
|
||||
end
|
||||
|
||||
return r2.Translator.getFeatureActivationLogicEvent(rtNpcGrp, event)
|
||||
end
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local contextualText = i18n.get("uiR2EdVisitZone_ContextualText"):toUtf8()
|
||||
local missionText = i18n.get("uiR2EdVisitZone_MissionText"):toUtf8()
|
||||
local waitValidationText = i18n.get("uiR2EdVisitZone_WaitValidationText"):toUtf8()
|
||||
local missionSucceededText = i18n.get("uiR2EdVisitZone_MissionSucceededText"):toUtf8()
|
||||
local broadcastText = i18n.get("uiR2EdVisitZone_BroadcastText"):toUtf8()
|
||||
|
||||
local comp = r2.newComponent("VisitZone")
|
||||
assert(comp)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.bot_chat")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EdVisitZone")):toUtf8()
|
||||
|
||||
comp.ContextualText = contextualText
|
||||
comp.MissionText = missionText
|
||||
comp.WaitValidationText = waitValidationText
|
||||
comp.MissionSucceedText = missionSucceededText
|
||||
comp.BroadcastText = broadcastText
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
local zoneTrigger = r2.Features["ZoneTrigger"].Components.ZoneTrigger.createComponent(x + 3, y + 3)
|
||||
zoneTrigger.Name = comp.Name.." "..i18n.get("uiR2EdZoneTrigger"):toUtf8() --r2:genInstanceName(i18n.get("uiR2EdZoneTrigger")):toUtf8()
|
||||
zoneTrigger.InheritPos = 0
|
||||
zoneTrigger.Deletable = false
|
||||
table.insert(comp.Components, zoneTrigger)
|
||||
comp._ZoneId = zoneTrigger.InstanceId
|
||||
|
||||
comp._Seed = os.time()
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
if r2:getLeftQuota() <= 0 then
|
||||
r2:makeRoomMsg()
|
||||
return
|
||||
end
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("VisitZoneForm", 0)
|
||||
else r2.setDisplayInfo("VisitZoneForm", 1) end
|
||||
|
||||
if not x or not y
|
||||
then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
local component = feature.Components.VisitZone.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function paramsCancel()
|
||||
debugInfo("Cancel form for 'VisitZone' creation")
|
||||
end
|
||||
local function posOk(x, y, z)
|
||||
debugInfo(string.format("Validate creation of 'VisitZone' at pos (%d, %d, %d)", x, y, z))
|
||||
if r2.mustDisplayInfo("VisitZone") == 1 then
|
||||
r2.displayFeatureHelp("VisitZone")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("ui2REDNewVisitZoneFeatureAction"))
|
||||
local component = feature.Components.VisitZone.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
local function posCancel()
|
||||
debugInfo("Cancel choice 'VisitZone' position")
|
||||
end
|
||||
local creature = r2.Translator.getDebugCreature("object_component_bot_chat.creature")
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureVisitZone")
|
||||
end
|
||||
|
||||
|
||||
function component:registerMenu(logicEntityMenu)
|
||||
local name = i18n.get("uiR2EdVisitZone")
|
||||
logicEntityMenu:addLine(ucstring(name), "lua", "", "VisitZone")
|
||||
end
|
||||
|
||||
function component:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["succeed"] = { menu=i18n.get( "uiR2AA0SucceedTask" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1SucceedTask" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["mission asked"] = { menu=i18n.get( "uiR2Event0MissionGiven" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1MissionGiven" ):toUtf8()},
|
||||
["wait validation"] = { menu=i18n.get( "uiR2Event0TaskWaitValidation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskWaitValidation" ):toUtf8()},
|
||||
["succeeded"] = { menu=i18n.get( "uiR2Event0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1TaskSuccess" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is succeeded"] = { menu=i18n.get( "uiR2Test0TaskSuccess" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1TaskSuccess" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
|
||||
r2.Features["VisitZone"] = feature
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,403 +0,0 @@
|
||||
|
||||
r2.Features.ZoneTrigger = {}
|
||||
|
||||
local feature = r2.Features.ZoneTrigger
|
||||
|
||||
feature.Name="ZoneTrigger"
|
||||
|
||||
|
||||
feature.Description="Triggers an event when a player enters or leaves a zone"
|
||||
|
||||
feature.Components = {}
|
||||
|
||||
local classZoneTriggerVersion = 1
|
||||
|
||||
feature.Components.ZoneTrigger =
|
||||
{
|
||||
PropertySheetHeader = r2.getDisplayButtonHeader("r2.events:openEditor()", "uiR2EdEditEventsButton"),
|
||||
BaseClass="LogicEntity",
|
||||
Name="ZoneTrigger",
|
||||
InEventUI = true,
|
||||
Menu="ui:interface:r2ed_feature_menu",
|
||||
Version=classZoneTriggerVersion ,
|
||||
DisplayerUI = "R2::CDisplayerLua",
|
||||
DisplayerUIParams = "defaultUIDisplayer",
|
||||
DisplayerVisual = "R2::CDisplayerVisualEntity",
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Parameters = {},
|
||||
ApplicableActions = {
|
||||
"activate", "deactivate", "simulate on enter", "simulate on leave"
|
||||
},
|
||||
Events = {
|
||||
"On Player Arrived",
|
||||
"On Player Left",
|
||||
"activation", "deactivation"
|
||||
-- "On First Player Arrived",
|
||||
-- "On First Player Left",
|
||||
},
|
||||
Conditions = {"is active", "is inactive", "is empty", "is full"},
|
||||
TextContexts = {},
|
||||
TextParameters = {},
|
||||
LiveParameters = {},
|
||||
-----------------------------------------------------------------------------------------------
|
||||
Prop =
|
||||
{
|
||||
{Name="InstanceId", Type="String", WidgetStyle="StaticText", Visible = false},
|
||||
{Name="Name", Type="String", MaxNumChar="32"},
|
||||
{Name="Cyclic", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Active", Type="Number", WidgetStyle="Boolean", DefaultValue="1"},
|
||||
{Name="Components", Type="Table"}
|
||||
|
||||
},
|
||||
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.LogicEntity.getAvailableCommands(this, dest) -- fill by ancestor
|
||||
this:getAvailableDisplayModeCommands(dest)
|
||||
end,
|
||||
-----------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getParentTreeNode = function(this)
|
||||
return this:getFeatureParentTreeNode()
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
appendInstancesByType = function(this, destTable, kind)
|
||||
assert(type(kind) == "string")
|
||||
--this:delegate():appendInstancesByType(destTable, kind)
|
||||
r2.Classes.LogicEntity.appendInstancesByType(this, destTable, kind)
|
||||
for k, component in specPairs(this.Components) do
|
||||
component:appendInstancesByType(destTable, kind)
|
||||
end
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getSelectBarSons = function(this)
|
||||
return Components
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
canHaveSelectBarSons = function(this)
|
||||
return false;
|
||||
end,
|
||||
|
||||
onPostCreate = function(this)
|
||||
--this:createGhostComponents()
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
pretranslate = function(this, context)
|
||||
local rtNpcGrp, aiState = r2.Translator.createAiGroup(this, context)
|
||||
local zone = r2:getInstanceFromId(this._Zone)
|
||||
Logic.assignZone(aiState, zone)
|
||||
aiState.IsTriggerZone = 1
|
||||
end,
|
||||
|
||||
translate = function(this, context)
|
||||
|
||||
local instance = this
|
||||
local instanceId = this.InstanceId
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, instanceId)
|
||||
local states = r2.Translator.getRtStatesNames(context, instanceId)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
do
|
||||
local eventHandler = r2.Translator.createEvent("on_player_arrived", states, rtNpcGrp.Id)
|
||||
eventHandler.IsTriggerZone = 1
|
||||
local action = r2.Translator.createAction("on_player_arrived_impl", rtNpcGrp.Id)
|
||||
|
||||
table.insert(context.RtAct.Events, eventHandler)
|
||||
-- insert a npc_event_handler_action
|
||||
table.insert(eventHandler.ActionsId, action.Id)
|
||||
table.insert(context.RtAct.Actions, action)
|
||||
end
|
||||
|
||||
do
|
||||
local eventHandler = r2.Translator.createEvent("on_player_left", states, rtNpcGrp.Id)
|
||||
eventHandler.IsTriggerZone = 1
|
||||
local action = r2.Translator.createAction("on_player_left_impl", rtNpcGrp.Id)
|
||||
|
||||
table.insert(context.RtAct.Events, eventHandler)
|
||||
-- insert a npc_event_handler_action
|
||||
table.insert(eventHandler.ActionsId, action.Id)
|
||||
table.insert(context.RtAct.Actions, action)
|
||||
end
|
||||
|
||||
do
|
||||
local eventHandler =r2.Translator.createEvent("start_of_state", states, rtNpcGrp.Id)
|
||||
eventHandler.IsTriggerZone = 1
|
||||
local action = r2.Translator.createAction("trigger_zone_init", rtNpcGrp.Id, instance.Active, instance.Cyclic )
|
||||
|
||||
table.insert(context.RtAct.Events, eventHandler)
|
||||
-- insert a npc_event_handler_action
|
||||
table.insert(eventHandler.ActionsId, action.Id)
|
||||
table.insert(context.RtAct.Actions, action)
|
||||
end
|
||||
|
||||
-- AdD
|
||||
r2.Translator.translateAiGroup(this, context)
|
||||
--r2.Translator.translateEventHandlers( context, instance, instance.Behavior.Actions, rtNpcGrp)
|
||||
|
||||
end,
|
||||
|
||||
updateVersion = function(this, scenarioValue, currentValue )
|
||||
local patchValue = scenarioValue
|
||||
if patchValue < 1 then
|
||||
if not this.Active then r2.requestSetNode(this.InstanceId, "Active", 1) end
|
||||
if not this.Cyclic then r2.requestSetNode(this.InstanceId, "Cyclic", 1) end
|
||||
patchValue = 1
|
||||
end
|
||||
|
||||
if patchValue == currentValue then return true end
|
||||
return false
|
||||
end,
|
||||
|
||||
|
||||
}
|
||||
|
||||
-- Specific to the component Zone
|
||||
local component = feature.Components.ZoneTrigger
|
||||
|
||||
|
||||
component.getLogicAction = function(entity, context, action)
|
||||
|
||||
assert( action.Class == "ActionStep")
|
||||
local component = r2:getInstanceFromId(action.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
|
||||
local theType = action.Action.Type
|
||||
local retAction = nil
|
||||
if theType == "activate" then
|
||||
retAction = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 0,
|
||||
r2.Translator.createAction("trigger_zone_activates", rtNpcGrp.Id))
|
||||
elseif theType == "deactivate" then
|
||||
retAction = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("trigger_zone_deactivates", rtNpcGrp.Id))
|
||||
elseif theType == "simulate on enter" then
|
||||
retAction = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 1))
|
||||
elseif theType == "simulate on leave" then
|
||||
retAction = r2.Translator.createAction("if_value_equal", rtNpcGrp.Id, "Active", 1,
|
||||
r2.Translator.createAction("user_event_trigger", rtNpcGrp.Id, 2))
|
||||
|
||||
end
|
||||
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
component.getLogicCondition = function(this, context, condition)
|
||||
assert( condition.Class == "ConditionStep")
|
||||
local component = r2:getInstanceFromId(condition.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
local states = r2.Translator.getRtStatesNames(context, component.InstanceId)
|
||||
assert(states)
|
||||
|
||||
local theType = condition.Condition.Type
|
||||
if theType == "is empty" then
|
||||
local retAction = r2.Translator.createAction("trigger_zone_min_player", rtNpcGrp.Id, states, 0)
|
||||
return retAction, retAction
|
||||
elseif theType == "is full" then
|
||||
local retAction = r2.Translator.createAction("trigger_zone_min_player", rtNpcGrp.Id, states, 1)
|
||||
return retAction, retAction
|
||||
end
|
||||
|
||||
|
||||
return r2.Translator.getFeatureActivationCondition(condition, rtNpcGrp)
|
||||
end
|
||||
|
||||
component.getLogicEvent = function(this, context, event)
|
||||
assert( event.Class == "LogicEntityAction")
|
||||
|
||||
local component = this -- r2:getInstanceFromId(event.Entity)
|
||||
assert(component)
|
||||
local rtNpcGrp = r2.Translator.getRtGroup(context, component.InstanceId)
|
||||
assert(rtNpcGrp)
|
||||
|
||||
local eventType = tostring(event.Event.Type)
|
||||
|
||||
local eventHandler, lastCondition = nil, nil
|
||||
|
||||
if eventType == "On Player Arrived" then
|
||||
local e, c1, c2 =r2.Translator.getComponentUserEvent(rtNpcGrp, 1);
|
||||
e.IsTriggerZone = 1
|
||||
return e, c1, c2
|
||||
elseif eventType == "On Player Left" then
|
||||
local e, c1, c2 = r2.Translator.getComponentUserEvent(rtNpcGrp, 2);
|
||||
e.IsTriggerZone = 1
|
||||
return e, c1, c2
|
||||
elseif eventType == "activation" then
|
||||
e, c1, c2 = r2.Translator.getComponentUserEvent(rtNpcGrp, 4)
|
||||
e.IsTriggerZone = 1
|
||||
return e, c1, c2
|
||||
elseif eventType == "deactivation" then
|
||||
e, c1, c2 = r2.Translator.getComponentUserEvent(rtNpcGrp, 5)
|
||||
e.IsTriggerZone = 1
|
||||
return e, c1, c2
|
||||
end
|
||||
return eventHandler, firstCondition, lastCondition
|
||||
end
|
||||
|
||||
|
||||
local ZoneTriggerRadius = 5
|
||||
local ZoneTriggerNumCorners = 4
|
||||
|
||||
component.createComponent = function(x, y)
|
||||
|
||||
local comp = r2.newComponent("ZoneTrigger")
|
||||
assert(comp)
|
||||
assert(comp.Position)
|
||||
|
||||
comp.Base = r2.Translator.getDebugBase("palette.entities.botobjects.trigger_zone")
|
||||
comp.Name = r2:genInstanceName(i18n.get("uiR2EDRollout_ZoneTrigger")):toUtf8()
|
||||
|
||||
comp.Position.x = x
|
||||
comp.Position.y = y
|
||||
comp.Position.z = r2:snapZToGround(x, y)
|
||||
|
||||
local zone = r2.newComponent("Region")
|
||||
r2.Utils.createTriggerRegion(zone, 0, 0, ZoneTriggerRadius) -- the region doesn't inherit the feature position, so must give its pos
|
||||
zone.Deletable = 0
|
||||
zone.Position.x = 0 -- comp.Position.x
|
||||
zone.Position.y = 0 -- comp.Position.y
|
||||
zone.Position.z = 0 -- comp.Position.z
|
||||
zone.InheritPos = 1 -- don't inherit position of parents
|
||||
zone.Name = r2:genInstanceName(i18n.get("uiR2EDPlaces")):toUtf8()
|
||||
comp._Zone = zone.InstanceId
|
||||
table.insert(comp.Components, zone)
|
||||
|
||||
|
||||
return comp
|
||||
end
|
||||
|
||||
component.create = function()
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
local function paramsOk(resultTable)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewZoneTriggersFeatureAction"))
|
||||
|
||||
local x = tonumber( resultTable["X"] )
|
||||
local y = tonumber( resultTable["Y"] )
|
||||
local showAgain = tonumber(resultTable["Display"])
|
||||
|
||||
if not x or not y then
|
||||
debugInfo("Can't create Component")
|
||||
return
|
||||
end
|
||||
|
||||
if showAgain == 1 then
|
||||
r2.setDisplayInfo("ZoneForm", 0)
|
||||
else r2.setDisplayInfo("ZoneForm", 1) end
|
||||
|
||||
|
||||
local component = feature.Components.ZoneTrigger.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function posOk(x, y, z)
|
||||
debugInfo("Validate creation of a Zone Trigger.")
|
||||
if r2.mustDisplayInfo("ZoneTrigger") == 1 then
|
||||
r2.displayFeatureHelp("ZoneTrigger")
|
||||
end
|
||||
r2.requestNewAction(i18n.get("uiR2EDNewZoneTriggersFeatureAction"))
|
||||
local component = feature.Components.ZoneTrigger.createComponent( x, y)
|
||||
r2:setCookie(component.InstanceId, "DisplayProp", 1)
|
||||
r2.requestInsertNode(r2:getCurrentAct().InstanceId, "Features", -1, "", component)
|
||||
end
|
||||
|
||||
local function posCancel() end
|
||||
|
||||
local creature = r2.Translator.getDebugCreature("object_component_trigger_zone.creature")
|
||||
--r2:choosePos(creature, posOk, posCancel, "createFeatureZoneTrigger")
|
||||
|
||||
local poly = {}
|
||||
local step = 2 * math.pi / ZoneTriggerNumCorners
|
||||
for k = 0, ZoneTriggerNumCorners - 1 do
|
||||
table.insert(poly, CVector2f(ZoneTriggerRadius * math.cos(k * step), ZoneTriggerRadius * math.sin(k * step)))
|
||||
end
|
||||
r2:choosePos(creature, posOk, posCancel, "createFeatureZoneTrigger",
|
||||
"curs_create.tga",
|
||||
"curs_stop.tga",
|
||||
{ poly }, r2.PrimRender.ComponentRegionLook, r2.PrimRender.ComponentRegionInvalidLook)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
function feature.registerForms()
|
||||
r2.Forms.ZoneForm =
|
||||
{
|
||||
Caption = "uiR2EdTriggerZoneParameters",
|
||||
PropertySheetHeader =
|
||||
[[
|
||||
<view type="text" id="t" multi_line="true" sizeref="w" w="-36" x="4" y="-2" posref="TL TL" global_color="true" fontsize="14" shadow="true" hardtext="uiR2EDTriggerZoneDescription"/>
|
||||
]],
|
||||
Prop =
|
||||
{
|
||||
{Name="Display", Type="Number", WidgetStyle="Boolean", DefaultValue="0", Translation="uiR2showMessageAgain", InvertWidget=true, CaptionWidth=5 },
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
--- register the curent Feature to menu
|
||||
|
||||
function component:getLogicTranslations()
|
||||
-- register trad
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["simulate on enter"] = { menu=i18n.get( "uiR2AA0ZoneTriggerSimEnter" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1ZoneTriggerSimEnter" ):toUtf8()},
|
||||
["simulate on leave"] = { menu=i18n.get( "uiR2AA0ZoneTriggerSimExit" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1ZoneTriggerSimExit" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["On Player Arrived"] = { menu=i18n.get( "uiR2Event0ZoneTriggerEntry" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1ZoneTriggerEntry" ):toUtf8()},
|
||||
["On Player Left"] = { menu=i18n.get( "uiR2Event0ZoneTriggerExit" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1ZoneTriggerExit" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
["is empty"] = { menu=i18n.get( "uiR2Test0ZoneTriggerEmpty" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1ZoneTriggerEmpty" ):toUtf8()},
|
||||
["is full"] = { menu=i18n.get( "uiR2Test0ZoneTriggerFull" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1ZoneTriggerFull" ):toUtf8()},
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
r2.Features["ZoneTrigger"] = feature
|
||||
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
-- main init function
|
||||
|
||||
r2.init = function ()
|
||||
local function protected()
|
||||
|
||||
debugInfo("r2.init begin")
|
||||
profileFunction(r2.registerHighLevel, "r2.registerHighLevel")
|
||||
profileFunction(r2.registerBasicBricks, "r2.registerBasicBricks")
|
||||
profileFunction(r2.loadFeatures, "r2.loadFeatures")
|
||||
profileFunction(r2.loadPalette, "r2.loadPalette")
|
||||
|
||||
profileFunction(r2.setupClasses, "r2.setupClasses")
|
||||
|
||||
-- tmp
|
||||
if r2.InClient == true then
|
||||
--r2:testPropertySheet()
|
||||
profileMethod(r2, "buildAllPropertySheetsAndForms", "r2:buildAllPropertySheetsAndForms")
|
||||
end
|
||||
-- IMPORTANT : should be called after all parameters of classes (displayers ...) have been initialized
|
||||
r2.TextMgr = r2.newComponent("TextManager")
|
||||
|
||||
|
||||
debugInfo("r2.init end")
|
||||
end
|
||||
|
||||
|
||||
local ok, errMsg = pcall(protected)
|
||||
|
||||
if not ok then
|
||||
debugInfo("Error while initialization:'".. errMsg.."'")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,316 +0,0 @@
|
||||
r2.logicComponents = {}
|
||||
|
||||
r2.logicComponents.logicEditors = {
|
||||
r2.activities,
|
||||
r2.dialogs,
|
||||
r2.events,
|
||||
}
|
||||
|
||||
r2.logicComponents.undoRedoInstances = {}
|
||||
|
||||
|
||||
----- INIT ALL EDITORS ----------------------------------------------------
|
||||
function r2.logicComponents:initLogicEditors()
|
||||
|
||||
for k, uiClass in pairs(self.logicEditors) do
|
||||
uiClass:initEditor()
|
||||
end
|
||||
end
|
||||
|
||||
------ SELECT ELEMENT --------------------------------------------
|
||||
function r2.logicComponents:selectElement(classUI, selectedButtonElt)
|
||||
|
||||
if selectedButtonElt == nil then
|
||||
selectedButtonElt = getUICaller()
|
||||
end
|
||||
assert(selectedButtonElt)
|
||||
|
||||
local sequenceUI = classUI:currentSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
local upDown = sequenceUI:find("order_group")
|
||||
assert(upDown)
|
||||
|
||||
-- new selected element
|
||||
if selectedButtonElt.pushed == true then
|
||||
|
||||
if classUI:currentEltUIId() then
|
||||
|
||||
local lastSelectedElement = classUI:currentEltUI()
|
||||
assert(lastSelectedElement)
|
||||
|
||||
local lastEltsList = lastSelectedElement.parent
|
||||
local editElt = lastEltsList:find("edit_element")
|
||||
assert(editElt)
|
||||
|
||||
if classUI:currentEltUIId() == selectedButtonElt.parent.parent.parent.id then
|
||||
return
|
||||
end
|
||||
|
||||
lastSelectedElement.active = true
|
||||
lastSelectedElement:find("select").pushed = false
|
||||
|
||||
editElt.active = false
|
||||
end
|
||||
|
||||
classUI:setCurrentEltUIId(selectedButtonElt.parent.parent.parent.id)
|
||||
|
||||
local selectedElement = selectedButtonElt.parent.parent.parent
|
||||
assert(selectedElement)
|
||||
|
||||
-- update element editor position in list
|
||||
local eltsList = sequenceUI:find("elements_list")
|
||||
assert(eltsList)
|
||||
local editElt = eltsList:find("edit_element")
|
||||
assert(editElt)
|
||||
|
||||
local indexSelectedElt = eltsList:getElementIndex(selectedElement)
|
||||
local indexEltEditor = eltsList:getElementIndex(editElt)
|
||||
|
||||
if indexEltEditor<indexSelectedElt then
|
||||
for i=indexEltEditor, indexSelectedElt-1 do
|
||||
eltsList:downChild(editElt)
|
||||
end
|
||||
else
|
||||
for i=indexSelectedElt, indexEltEditor-2 do
|
||||
eltsList:upChild(editElt)
|
||||
end
|
||||
end
|
||||
|
||||
editElt.active = true
|
||||
selectedElement.active = false
|
||||
classUI:updateElementEditor()
|
||||
|
||||
upDown.active = (classUI.elementOrder==true and eltsList.childrenNb>2)
|
||||
|
||||
-- cancel current selection
|
||||
else
|
||||
|
||||
local lastSelectedElement = classUI:currentEltUI()
|
||||
assert(lastSelectedElement)
|
||||
|
||||
upDown.active = false
|
||||
|
||||
local lastEltsList = lastSelectedElement.parent
|
||||
local editElt = lastEltsList:find("edit_element")
|
||||
assert(editElt)
|
||||
|
||||
editElt.active = false
|
||||
lastSelectedElement.active = true
|
||||
|
||||
classUI:setCurrentEltUIId(nil)
|
||||
end
|
||||
end
|
||||
|
||||
------ SELECT SEQUENCE --------------------------------------
|
||||
function r2.logicComponents:selectSequence(classUI, sequenceUI)
|
||||
|
||||
local sequenceUI = classUI:currentSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
-- select first chat of dialog
|
||||
local eltsList = sequenceUI:find("elements_list")
|
||||
assert(eltsList)
|
||||
-- if eltsList.childrenNb > 1 then
|
||||
|
||||
-- local firstElt = eltsList:getChild(0)
|
||||
-- element editor
|
||||
-- if r2.logicUI:getEltUIInstId(firstElt) == nil then
|
||||
-- firstElt = eltsList:getChild(1)
|
||||
-- end
|
||||
|
||||
-- local selectedButton = firstElt:find("select")
|
||||
-- assert(selectedButton)
|
||||
|
||||
-- selectedButton.pushed = true
|
||||
-- classUI:selectElement(selectedButton)
|
||||
-- end
|
||||
|
||||
-- deselect old selected element
|
||||
if classUI:currentEltUIId() then
|
||||
|
||||
local lastSelectedElement = classUI:currentEltUI()
|
||||
assert(lastSelectedElement)
|
||||
|
||||
local lastEltsList = lastSelectedElement.parent
|
||||
local editElt = lastEltsList:find("edit_element")
|
||||
assert(editElt)
|
||||
|
||||
lastSelectedElement.active = true
|
||||
lastSelectedElement:find("select").pushed = false
|
||||
|
||||
editElt.active = false
|
||||
|
||||
classUI:setCurrentEltUIId(nil)
|
||||
end
|
||||
|
||||
eltsList.Env.Minimize = true
|
||||
end
|
||||
|
||||
------ CREATE EDITOR -----------------------------------------------
|
||||
function r2.logicComponents:createElementEditor(classUI)
|
||||
|
||||
-- not necessary current sequenceUI
|
||||
local sequenceUI = classUI:updatedSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
-- create element editor
|
||||
local elementsList = sequenceUI:find("elements_list")
|
||||
assert(elementsList)
|
||||
|
||||
local newEditorElt = createGroupInstance(classUI.elementEditorTemplate, elementsList.id, {id="edit_element", active="false"})
|
||||
assert(newEditorElt)
|
||||
elementsList:addChild(newEditorElt)
|
||||
elementsList.parent:updateCoords()
|
||||
|
||||
newEditorElt.active = false
|
||||
|
||||
return newEditorElt
|
||||
end
|
||||
|
||||
----- CLOSE ELEMENT EDITOR ---------------------------------------------
|
||||
function r2.logicComponents:closeElementEditor(classUI)
|
||||
|
||||
local selectedEltUI = classUI:currentEltUI()
|
||||
if selectedEltUI then
|
||||
local selectedEltButton = selectedEltUI:find("select")
|
||||
assert(selectedEltButton)
|
||||
|
||||
selectedEltButton.pushed = false
|
||||
classUI:selectElement(selectedEltButton)
|
||||
end
|
||||
end
|
||||
|
||||
------ NEW ELEMENT INST ------------------------------------------
|
||||
function r2.logicComponents:newElementInst(classUI)
|
||||
end
|
||||
|
||||
------ UPDATE ELEMENT TITLE -------------------------------------------
|
||||
function r2.logicComponents:updateElementTitle(classUI, eltUI, showPartIndex)
|
||||
|
||||
local eltInst = r2:getInstanceFromId(r2.logicUI:getEltUIInstId(eltUI))
|
||||
assert(eltInst)
|
||||
|
||||
-- part index
|
||||
local partIndex = ""
|
||||
|
||||
if showPartIndex then
|
||||
local index = self:searchElementIndex(eltInst)
|
||||
partIndex = classUI.elementInitialName.." "..index.." : "
|
||||
end
|
||||
|
||||
local eltName = eltInst:getName()
|
||||
|
||||
-- title
|
||||
local title = eltUI:find("title")
|
||||
assert(title)
|
||||
local uc_title = ucstring()
|
||||
uc_title:fromUtf8(partIndex..eltName)
|
||||
title.uc_hardtext_format = uc_title
|
||||
end
|
||||
|
||||
------ REMOVE ELEMENT INST ----------------------------------------
|
||||
function r2.logicComponents:removeElementInst(classUI)
|
||||
|
||||
--r2.requestNewAction(i18n.get("uiR2EDRemoveLogicElementAction"))
|
||||
|
||||
local toErasedInstId = classUI:currentEltInstId()
|
||||
assert(toErasedInstId)
|
||||
|
||||
-- request erase node
|
||||
if toErasedInstId and r2:getInstanceFromId(toErasedInstId) then
|
||||
r2.requestEraseNode(toErasedInstId, "", -1)
|
||||
end
|
||||
end
|
||||
|
||||
------ UP ELEMENT INST -------------------------------------------
|
||||
function r2.logicComponents:upElementInst(classUI)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDMoveLogicElementUpAction"))
|
||||
|
||||
local sequenceUI = classUI:currentSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
local listElements = sequenceUI:find("elements_list")
|
||||
assert(listElements)
|
||||
|
||||
local selectedElement = classUI:currentEltUI()
|
||||
assert(selectedElement)
|
||||
|
||||
local index = listElements:getElementIndex(selectedElement)
|
||||
|
||||
if index>0 then
|
||||
local sequenceId = classUI:currentSequInstId()
|
||||
assert(sequenceId)
|
||||
|
||||
r2.requestMoveNode(sequenceId, "Components", index,
|
||||
sequenceId, "Components", index-1)
|
||||
end
|
||||
end
|
||||
|
||||
------ DOWN ELEMENT INST -----------------------------------------
|
||||
function r2.logicComponents:downElementInst(classUI)
|
||||
|
||||
r2.requestNewAction(i18n.get("uiR2EDMoveLogicElementDownAction"))
|
||||
|
||||
local sequenceUI = classUI:currentSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
local listElements = sequenceUI:find("elements_list")
|
||||
assert(listElements)
|
||||
|
||||
local selectedElement = classUI:currentEltUI()
|
||||
assert(selectedElement)
|
||||
|
||||
local index = listElements:getElementIndex(selectedElement)
|
||||
|
||||
local sequenceId = classUI:currentSequInstId()
|
||||
assert(sequenceId)
|
||||
if index < r2:getInstanceFromId(sequenceId).Components.Size-1 then
|
||||
r2.requestMoveNode(sequenceId, "Components", index,
|
||||
sequenceId, "Components", index+1)
|
||||
end
|
||||
end
|
||||
|
||||
---- TRANSLATE SECONDS IN HOURS, MINUTES AND ECONDS
|
||||
function r2.logicComponents:calculHourMinSec(totalSecNb)
|
||||
|
||||
local minSecNb, hourNb = totalSecNb, 0
|
||||
while minSecNb > 3599 do
|
||||
hourNb = hourNb+1
|
||||
minSecNb = minSecNb - 3600
|
||||
end
|
||||
|
||||
local minNb, secNb = 0, minSecNb
|
||||
while secNb > 59 do
|
||||
minNb = minNb+1
|
||||
secNb = secNb - 60
|
||||
end
|
||||
|
||||
return hourNb, minNb, secNb
|
||||
end
|
||||
|
||||
|
||||
--- SEARCH INDEX OF INSTANCE IN COMPONENT TABLE
|
||||
function r2.logicComponents:searchElementIndex(instance, fun)
|
||||
|
||||
local components = instance.Parent
|
||||
local decalSequ = 0
|
||||
|
||||
for i=0, components.Size-1 do
|
||||
local comp = components[i]
|
||||
if fun and not fun(comp) then
|
||||
decalSequ = decalSequ+1
|
||||
elseif comp.User.Deleted == true then
|
||||
decalSequ = decalSequ+1
|
||||
end
|
||||
if comp.InstanceId == instance.InstanceId then
|
||||
return i+1-decalSequ
|
||||
end
|
||||
end
|
||||
|
||||
return -1
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,598 +0,0 @@
|
||||
local logicEntity =
|
||||
{
|
||||
BaseClass = "WorldObject",
|
||||
Name="LogicEntity",
|
||||
InEventUI = false,
|
||||
|
||||
Parameters = {},
|
||||
ApplicableActions = {},
|
||||
Events = {},
|
||||
Conditions = {},
|
||||
TextContexts = {},
|
||||
TextParameters = {},
|
||||
LiveParameters = {},
|
||||
|
||||
DisplayerProperties = "R2::CDisplayerLua",
|
||||
DisplayerPropertiesParams = "logicEntityPropertySheetDisplayer",
|
||||
PermanentTreeIcon = "r2ed_icon_permanent_macro_components.tga",
|
||||
TreeIcon = "r2ed_icon_macro_components.tga",
|
||||
SelectBarType = i18n.get("uiR2EDMacroComponents"):toUtf8(),
|
||||
|
||||
Prop =
|
||||
{
|
||||
{Name="Behavior", Type="LogicEntityBehavior"},
|
||||
},
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getContextualTreeIcon = function(this)
|
||||
if this:getParentAct():isBaseAct() then
|
||||
return this:getPermanentTreeIcon()
|
||||
end
|
||||
return ""
|
||||
end,
|
||||
|
||||
getSelectBarIcon = function(this)
|
||||
return r2.Classes.BaseClass.getContextualTreeIcon(this)
|
||||
end,
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
getPermanentStatutIcon = function(this)
|
||||
|
||||
if not this:isBotObject() and this:getParentAct():isBaseAct() then
|
||||
return "r2ed_permanent_pins.tga"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end ,
|
||||
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- Get the currently selected sequence, or nil if there's no available sequence
|
||||
getSelectedSequenceIndex = function(this)
|
||||
local activities = this:getBehavior().Activities
|
||||
if activities.Size == 0 then return nil end
|
||||
local index = defaulting(this.User.SelectedSequence, 0)
|
||||
if index >= activities.Size then
|
||||
index = activities.Size - 1
|
||||
end
|
||||
return index
|
||||
end,
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- from WorldObject
|
||||
canChangeDisplayMode = function(this)
|
||||
return true
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get the "Category" for this logic entity (Category entry found in the palette)
|
||||
getCategory = function(this)
|
||||
return this.Category
|
||||
end,
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get the "Sub-Category" for this logic entity (Category entry found in the palette)
|
||||
getSubCategory = function(this)
|
||||
return this.SubCategory
|
||||
end,
|
||||
--------------------------------------------------------------------------------------------
|
||||
isNextSelectable = function(this)
|
||||
return true
|
||||
end,
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- return the behavior object, depending on wether this npc is grouped or not
|
||||
getBehavior = function(this)
|
||||
if this:isKindOf("NpcGrpFeature") then
|
||||
return this.Components[0].Behavior
|
||||
elseif this:isGrouped() and this.ParentInstance:isKindOf("NpcGrpFeature") then
|
||||
return this.ParentInstance.Components[0].Behavior
|
||||
else
|
||||
return this.Behavior
|
||||
end
|
||||
end,
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- check if that npc is part of a group
|
||||
isGrouped = function(this)
|
||||
if this.User.Grouped == true then return true end
|
||||
if this.ParentInstance then
|
||||
return this.ParentInstance:isKindOf("NpcGrpFeature")
|
||||
end
|
||||
return false
|
||||
end,
|
||||
|
||||
|
||||
-- get list of command for display in the toolbar
|
||||
getAvailableCommands = function(this, dest)
|
||||
r2.Classes.WorldObject.getAvailableCommands(this, dest)
|
||||
if not this:isBotObject() and not this:isKindOf("Act") then
|
||||
table.insert(dest, this:buildCommand(this.editActions, "edit_actions", "uiR2EDEditEventsTriggers", "r2ed_edit_events.tga", false))
|
||||
|
||||
if not this:getParentAct():isBaseAct() then
|
||||
table.insert(dest, this:buildCommand(this.togglePermanentCurrentAct, "permanent_content", "uimR2EDMenuPermanentContent", "r2ed_permanent_content.tga", true))
|
||||
else
|
||||
table.insert(dest, this:buildCommand(this.togglePermanentCurrentAct, "current_content", "uimR2EDMenuCurrentActContent", "r2ed_current_act_content.tga", true))
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
--
|
||||
togglePermanentCurrentAct = function(this, noNewAction)
|
||||
|
||||
local newAct
|
||||
local actionName=""
|
||||
if this:getParentAct():isBaseAct() then
|
||||
newAct = r2:getCurrentAct()
|
||||
actionName = "uiR2EDCurrentActEntityAction"
|
||||
else
|
||||
newAct = r2.Scenario:getBaseAct()
|
||||
actionName = "uiR2EDPermanentEntityAction"
|
||||
end
|
||||
|
||||
local parent = newAct.Features[0]
|
||||
local attr = "Components"
|
||||
local instance = this
|
||||
if not this:isInDefaultFeature() then
|
||||
parent = newAct
|
||||
attr = "Features"
|
||||
end
|
||||
|
||||
if this:isGrouped() or this:isKindOf("Creature") then
|
||||
instance = this.ParentInstance
|
||||
end
|
||||
|
||||
if noNewAction~=false then
|
||||
r2.requestNewAction(i18n.get(actionName))
|
||||
end
|
||||
r2.requestMoveNode(instance.InstanceId, "", -1, parent.InstanceId, attr, -1)
|
||||
end,
|
||||
|
||||
--
|
||||
onPostCreate = function(this)
|
||||
if this.User.DisplayProp and this.User.DisplayProp == 1 then
|
||||
r2:setSelectedInstanceId(this.InstanceId)
|
||||
r2:showProperties(this)
|
||||
this.User.DisplayProp = nil
|
||||
end
|
||||
end,
|
||||
--
|
||||
editActions = function(this)
|
||||
|
||||
r2.events:openEditor()
|
||||
end,
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- Test if this entity is a bot object
|
||||
isBotObject = function(this)
|
||||
return false
|
||||
end,
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- Test if thisentity is a plant
|
||||
isPlant = function(this)
|
||||
return false
|
||||
end,
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- from base class
|
||||
onPostHrcMove = function (this)
|
||||
-- if no more in a group, then mark as 'ungrouped'
|
||||
local grouped = false
|
||||
if this.ParentInstance then
|
||||
grouped = this.ParentInstance:isKindOf("NpcGrpFeature")
|
||||
end
|
||||
this.User.Grouped = grouped
|
||||
-- force update of the available options
|
||||
--if this == r2:getSelectedInstance() then
|
||||
r2.ContextualCommands:update()
|
||||
--end
|
||||
end,
|
||||
|
||||
getAiCost = function(this)
|
||||
if this.User.GhostDuplicate then return 0 end
|
||||
return r2.getAiCost(this)
|
||||
end,
|
||||
|
||||
getStaticObjectCost = function(this)
|
||||
return r2.getStaticObjectCost(this)
|
||||
end,
|
||||
|
||||
hasScenarioCost = function(this)
|
||||
return true;
|
||||
end,
|
||||
|
||||
createProtected = function(this)
|
||||
|
||||
if not r2:checkAiQuota() then return end
|
||||
|
||||
if this.create then
|
||||
this.create()
|
||||
end
|
||||
end,
|
||||
|
||||
--
|
||||
getApplicableActions = function(this)
|
||||
return r2.Classes[this.Class].ApplicableActions
|
||||
end,
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- add a line to the event sub menu
|
||||
initEventTypeMenu = function(this, subMenu, eventCategory)
|
||||
|
||||
local class = r2.Classes[this.Class]
|
||||
local eventsTable = {}
|
||||
if eventCategory=="ApplicableActions" then
|
||||
eventsTable = this:getApplicableActions()
|
||||
else
|
||||
eventsTable = class[eventCategory]
|
||||
end
|
||||
|
||||
for k, eventType in pairs(eventsTable) do
|
||||
local endRequest = (r2.events.eventTypeWithValue[eventType]==nil)
|
||||
|
||||
if not r2.getLogicAttribute(this.Class, eventCategory, eventType) then
|
||||
debugInfo("Error: '"..eventCategory.. "' '" ..eventType .. "' is not defined for class'"..this.Class.."'")
|
||||
assert(r2.getLogicAttribute(this.Class, eventCategory, eventType))
|
||||
end
|
||||
|
||||
local uc_eventType = ucstring()
|
||||
local menuTitle = r2.getLogicAttribute(this.Class, eventCategory, eventType)
|
||||
|
||||
local addLine = true
|
||||
if r2.events.memberManagement and this:isKindOf("Npc") and this:isGrouped() and menuTitle.groupIndependant~=true then
|
||||
addLine = false
|
||||
end
|
||||
|
||||
if addLine then
|
||||
uc_eventType:fromUtf8(menuTitle.menu)
|
||||
subMenu:addLine(uc_eventType, "lua",
|
||||
"r2.events:setEventType('".. eventType .."','" .. tostring(endRequest) .. "','" .. eventCategory .. "')", eventType)
|
||||
end
|
||||
end
|
||||
|
||||
if table.getn(class[eventCategory])==0 then
|
||||
subMenu:addLine(i18n.get("uiR2EdNoSelelection"), "", "", "")
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
function logicEntity:getLogicTranslations()
|
||||
local logicTranslations = {
|
||||
["ApplicableActions"] = {
|
||||
["activate"] = { menu=i18n.get( "uiR2AA0Activate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Activate" ):toUtf8()},
|
||||
["deactivate"] = { menu=i18n.get( "uiR2AA0Deactivate" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Deactivate" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2AA0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2AA1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Events"] = {
|
||||
["activation"] = { menu=i18n.get( "uiR2Event0Activation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Activation" ):toUtf8()},
|
||||
["deactivation"] = { menu=i18n.get( "uiR2Event0Deactivation" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Deactivation" ):toUtf8()},
|
||||
["trigger"] = { menu=i18n.get( "uiR2Event0Trigger" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Event1Trigger" ):toUtf8()},
|
||||
},
|
||||
["Conditions"] = {
|
||||
["is active"] = { menu=i18n.get( "uiR2Test0Active" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Active" ):toUtf8()},
|
||||
["is inactive"] = { menu=i18n.get( "uiR2Test0Inactive" ):toUtf8(),
|
||||
text=i18n.get( "uiR2Test1Inactive" ):toUtf8()},
|
||||
}
|
||||
}
|
||||
return logicTranslations
|
||||
end
|
||||
|
||||
-----------------------------------------
|
||||
--- register the curent Feature to menu
|
||||
|
||||
--function logicEntity.initLogicEntitiesMenu(this, logicEntityMenu)
|
||||
--
|
||||
-- if this.InEventUI == true then
|
||||
-- local name = i18n.get("uiR2ED" .. this.Name)
|
||||
-- local tableInstances = r2.Scenario:getAllInstancesByType(this.Name)
|
||||
-- if table.getn(tableInstances) > 0 then
|
||||
-- logicEntityMenu:addLine(name, "lua", "", this.Name)
|
||||
-- end
|
||||
-- end
|
||||
--end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- add a line to the event sub menu
|
||||
--function logicEntity.initLogicEntitiesInstancesMenu(this, subMenu, calledFunction)
|
||||
--
|
||||
-- local entitiesTable = r2.Scenario:getAllInstancesByType(this.Name)
|
||||
-- for key, entity in pairs(entitiesTable) do
|
||||
-- local uc_name = ucstring()
|
||||
-- uc_name:fromUtf8(entity.Name)
|
||||
-- subMenu:addLine(uc_name, "lua", calledFunction.."('".. entity.InstanceId .."')", entity.InstanceId)
|
||||
-- end
|
||||
--
|
||||
-- if table.getn(entitiesTable)==0 then
|
||||
-- subMenu:addLine(i18n.get("uiR2EdNoSelelection"), "", "", "")
|
||||
-- end
|
||||
--end
|
||||
|
||||
-----------------------------------------
|
||||
--- register the curent Feature to menu
|
||||
|
||||
function logicEntity.initLogicEntitiesMenu(this, logicEntityMenu)
|
||||
--debugInfo("####5")
|
||||
if this.InEventUI == true then
|
||||
local name = i18n.get("uiR2ED" .. this.Name)
|
||||
--local startTime = nltime.getPreciseLocalTime()
|
||||
local enumerator = r2:enumInstances(this.Name)
|
||||
--local endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for enumInstances is %f", endTime - startTime))
|
||||
startTime = endTime
|
||||
if enumerator:next() then
|
||||
logicEntityMenu:addLine(name, "lua", "", this.Name)
|
||||
end
|
||||
--endTime = nltime.getPreciseLocalTime()
|
||||
--debugInfo(string.format("time for next is %f", endTime - startTime))
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
---- add a line to the event sub menu
|
||||
function logicEntity.initLogicEntitiesInstancesMenu(this, subMenu, calledFunction)
|
||||
local enumerator = r2:enumInstances(this.Name)
|
||||
local found = false
|
||||
while 1 do
|
||||
local entity = enumerator:next()
|
||||
if not entity then break end
|
||||
found= true
|
||||
local uc_name = ucstring()
|
||||
uc_name:fromUtf8(entity.Name)
|
||||
subMenu:addLine(uc_name, "lua", calledFunction.."('".. entity.InstanceId .."')", entity.InstanceId)
|
||||
end
|
||||
if not found then
|
||||
subMenu:addLine(i18n.get("uiR2EdNoSelelection"), "", "", "")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
r2.registerComponent(logicEntity)
|
||||
|
||||
---------------------------------------------------
|
||||
--useful to represent a mission
|
||||
--an empty group, an active state, a inactive state
|
||||
--and a finished state. Use the createPseudoGroup
|
||||
--function to directly add these in the context
|
||||
--local pseudoGroup=
|
||||
--{
|
||||
-- BaseClass="BaseClass",
|
||||
-- Name="PseudoGroup",
|
||||
-- Prop=
|
||||
-- {
|
||||
-- {Name="RtGroup",Type="RtNpcGrp"},
|
||||
-- {Name="InactiveState",Type="RtAiState"},
|
||||
-- {Name="ActiveState",Type="RtAiState"},
|
||||
-- {Name="FinishedState",Type="RtAiState"},
|
||||
-- }
|
||||
--}
|
||||
--r2.registerComponent(pseudoGroup)
|
||||
|
||||
--insert a new text in the textManager, after it has been translated
|
||||
local insertTextRt = function(text,context)
|
||||
local rtEntry = r2.newComponent("RtEntryText")
|
||||
rtEntry.Text = text
|
||||
debugInfo(colorTag(128,128,0).."insertion : "..text.." "..rtEntry.Id)
|
||||
table.insert(context.RtScenario.Texts.Texts,rtEntry)
|
||||
debugInfo(colorTag(128,128,0).."new size : "..table.getn(context.RtScenario.Texts.Texts))
|
||||
return rtEntry.Id
|
||||
end
|
||||
|
||||
----------------------------------------------
|
||||
----create a psudo group to translate missions
|
||||
----insert the elements in the context
|
||||
--r2.createPseudoGroup = function(context)
|
||||
-- local PseudoGroup = r2.newComponent("PseudoGroup")
|
||||
-- local group = PseudoGroup.RtGroup
|
||||
-- group.Name = group.Id
|
||||
--
|
||||
-- table.insert(context.RtAct.NpcGrps, group)
|
||||
--
|
||||
-- do
|
||||
-- local state
|
||||
--
|
||||
-- state= PseudoGroup.InactiveState
|
||||
-- state.Name = state.Id
|
||||
-- table.insert(context.RtAct.AiStates,state)
|
||||
-- table.insert(state.Children,group.Id)
|
||||
--
|
||||
-- state= PseudoGroup.ActiveState
|
||||
-- state.Name = state.Id
|
||||
-- table.insert(context.RtAct.AiStates,state)
|
||||
--
|
||||
--
|
||||
-- state= PseudoGroup.FinishedState
|
||||
-- state.Name = state.Id
|
||||
-- table.insert(context.RtAct.AiStates,state)
|
||||
--
|
||||
-- end
|
||||
-- return PseudoGroup
|
||||
--end
|
||||
--
|
||||
--
|
||||
--
|
||||
local feature = {}
|
||||
|
||||
--
|
||||
--local logicTexts ={
|
||||
-- BaseClass="BaseClass",
|
||||
-- Name="LogicTexts",
|
||||
-- Prop=
|
||||
-- {
|
||||
-- {Name="Spontaneous",Type="Table"},
|
||||
-- {Name="Interrogated",Type="Table"},
|
||||
-- },
|
||||
--}
|
||||
--
|
||||
--local LogicTextsTranslator = function(this,context,logicEntity)
|
||||
-- local addTriggeredAction = r2.Features["ActivitySequence"].addTriggeredAction
|
||||
-- local action
|
||||
-- local index
|
||||
-- local counter =context.Counter
|
||||
--
|
||||
-- if logicEntity == nil
|
||||
-- then
|
||||
-- debugInfo("logic entity nil!!")
|
||||
-- end
|
||||
--
|
||||
-- if context.RtGroups == nil
|
||||
-- then
|
||||
-- debugInfo("context.RtGroups nil!!")
|
||||
-- end
|
||||
--
|
||||
-- if context.RtGroups[logicEntity.NpcGrpId] == nil
|
||||
-- then
|
||||
-- debugInfo("context.RtGroups[logicEntity.NpcGrpId] nil!!")
|
||||
-- end
|
||||
--
|
||||
-- for k,v in pairs(this.Spontaneous)
|
||||
-- do
|
||||
-- if k ~= "Keys"
|
||||
-- then
|
||||
-- --get the "npc_say" action
|
||||
-- action = Translator.LogicEntityTranslator(v,context,logicEntity)
|
||||
-- --add this action to the triggerable actions of the npc group which give the mission
|
||||
-- index = addTriggeredAction(context,context.RtGroups[logicEntity.NpcGrpId].Name,action)
|
||||
--
|
||||
-- local name = context.RtGroups[logicEntity.NpcGrpId].Name
|
||||
--
|
||||
-- --create an action to trigg the action to the npc group
|
||||
-- action = Actions.createAction("modify_variable",name..":v3 = "..index)
|
||||
--
|
||||
-- --then, add the action to the correct state/event
|
||||
--
|
||||
-- if k=="Activated"
|
||||
-- then
|
||||
-- r2.Utils.addReaction(counter.ActiveState,"start_of_state",action)
|
||||
-- end
|
||||
--
|
||||
-- if k=="Deactivated"
|
||||
-- then
|
||||
-- r2.Utils.addReaction(counter.InactiveState,"start_of_state",action)
|
||||
-- end
|
||||
--
|
||||
-- if k=="Progresses"
|
||||
-- then
|
||||
-- r2.Utils.addReaction(counter.ActiveState,"user_event_0",action)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- for k,v in pairs(this.Interrogated)
|
||||
-- do
|
||||
-- if k ~= "Keys"
|
||||
-- then
|
||||
-- --get the "npc_say" action
|
||||
-- action = r2.Translator.LogicEntityTranslator(v,context)
|
||||
-- --add this action to the triggerable actions of the npc group which give the mission
|
||||
-- index = addTriggeredAction(context,context.RtGroups[logicEntity.NpcGrpId].Name,action)
|
||||
-- local name = context.RtGroups[logicEntity.NpcGrpId].Name
|
||||
-- --create an action to trigg the action to the npc group
|
||||
-- action = Actions.createAction("modify_variable",name..":v3 = "..index)
|
||||
--
|
||||
-- --TODO insert the action in the correct state/event ...
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
--end
|
||||
--
|
||||
--r2.registerComponent(logicTexts)
|
||||
--
|
||||
--
|
||||
--r2.registerComponent(varText)
|
||||
---------------------------------------------------------
|
||||
--This component is linked to a BaseCounter.It's used in
|
||||
--the ParametrableText component to represent the value
|
||||
--of the variable
|
||||
--local var =
|
||||
--{
|
||||
-- BaseClass="BaseClass",
|
||||
-- Name="TextParam",
|
||||
-- Prop=
|
||||
-- {
|
||||
-- {Name="BaseCounterId",Type="String"}
|
||||
-- }
|
||||
--}
|
||||
--r2.registerComponent(var)
|
||||
--
|
||||
|
||||
----------------------------------------------------
|
||||
--this component represents a text with parameters.
|
||||
--It's a table of strings and/or TextParam elements.
|
||||
--It allows to build sentences with variables.
|
||||
--The Translator build a sentence with the strings
|
||||
-- and parameters, and returns a "npc_say" action.
|
||||
--see the UnitTest.testCounter() function.
|
||||
--local paramText =
|
||||
--{
|
||||
-- BaseClass="BaseClass",
|
||||
-- Name="ParametrableText",
|
||||
-- Prop=
|
||||
-- {
|
||||
-- --components are : "TextParam" objects or strings
|
||||
-- {Name="Components",Type="Table"},
|
||||
-- {Name="Npc",Type="String"}
|
||||
-- }
|
||||
--
|
||||
--}
|
||||
--r2.registerComponent(paramText)
|
||||
--
|
||||
--
|
||||
--local ParamTextTranslator = function(this,context)
|
||||
-- local text=""
|
||||
-- local param=""
|
||||
-- for k,v in pairs(this.Components)
|
||||
-- do
|
||||
-- if k~="Keys"
|
||||
-- then
|
||||
-- if type(v) == "string"
|
||||
-- then
|
||||
-- text = text..v
|
||||
-- else
|
||||
-- if v.Class == "TextParam"
|
||||
-- then
|
||||
-- local id = v.BaseCounterId
|
||||
-- local baseCounter = context.Components[id]
|
||||
-- local counterName = context.CounterNames[id]
|
||||
-- param = r2.Utils.concat(param,counterName)
|
||||
-- text = text.."$d "..baseCounter.Object.." "
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- end
|
||||
-- end
|
||||
-- local action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
-- action.Action = "npc_say"
|
||||
-- local who = r2.Utils.getNpcParam(this.Npc,context)
|
||||
-- action.Parameters = who.."\n"..insertTextRt(text,context).."\n"..param
|
||||
-- return action
|
||||
--end
|
||||
--
|
||||
-- Obsolette?
|
||||
--Translator.LogicEntityTranslator = function(logicEntity,context,ParentLogicEntity)
|
||||
-- local class = logicEntity.Class
|
||||
-- if class == "VarText"
|
||||
-- then
|
||||
-- return VarTextTranslator(logicEntity,context,ParentLogicEntity)
|
||||
-- end
|
||||
-- if class == "Counter"
|
||||
-- then
|
||||
-- return CounterTranslator(logicEntity,context,ParentLogicEntity)
|
||||
-- end
|
||||
-- if class == "LogicTexts"
|
||||
-- then
|
||||
-- return LogicTextsTranslator(logicEntity,context,ParentLogicEntity)
|
||||
-- end
|
||||
-- if class == "BaseCounter"
|
||||
-- then
|
||||
-- return BaseCounterTranslator(logicEntity,context,ParentLogicEntity)
|
||||
-- end
|
||||
-- if class == "ParametrableText"
|
||||
-- then
|
||||
-- return ParamTextTranslator(logicEntity,context)
|
||||
-- end
|
||||
--end
|
@ -1,388 +0,0 @@
|
||||
r2.logicUI =
|
||||
{
|
||||
MenuName = "ui:interface:r2ed_triggers_menu",
|
||||
Menu = nil,
|
||||
}
|
||||
|
||||
function r2.logicUI:openLogicMenu(caller)
|
||||
|
||||
launchContextMenuInGame(self.MenuName)
|
||||
if self.Menu == nil or self.Menu.isNil then
|
||||
self.Menu = getUI(self.MenuName)
|
||||
end
|
||||
|
||||
local menu = self.Menu
|
||||
|
||||
menu:setParentPos(caller)
|
||||
menu:setPosRef("BL TL")
|
||||
|
||||
local root = menu:getRootMenu()
|
||||
if (caller.y_real - root.h_real < 0) then
|
||||
menu.y = root.h_real + caller.h_real
|
||||
else
|
||||
menu.y = 0
|
||||
end
|
||||
menu:setMinW(85)
|
||||
menu:updateCoords()
|
||||
end
|
||||
|
||||
function r2.logicUI:getEltUIInstId(eltUI)
|
||||
return eltUI.Env.InstanceId
|
||||
end
|
||||
|
||||
function r2.logicUI:setEltUIInstId(eltUI, id)
|
||||
eltUI.Env.InstanceId = id
|
||||
end
|
||||
|
||||
function r2.logicUI:setSequUIInstId(sequUI, id)
|
||||
sequUI.Env.InstanceId = id
|
||||
end
|
||||
|
||||
function r2.logicUI:getSequUIInstId(sequUI)
|
||||
return sequUI.Env.InstanceId
|
||||
end
|
||||
|
||||
------- NEW ELEMENT UI ---------------------------------------------
|
||||
function r2.logicUI:newElementUI(classUI, newInst, withOrder)
|
||||
|
||||
local templateParams = classUI.eltTemplateParams
|
||||
|
||||
--not necessary current sequenceUI
|
||||
local sequenceUI = classUI:updatedSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
local listElements = sequenceUI:find("elements_list")
|
||||
assert(listElements)
|
||||
|
||||
for i=0, listElements.childrenNb-1 do
|
||||
local elt = listElements:getChild(i)
|
||||
local instId = self:getEltUIInstId(elt)
|
||||
if instId==newInst.InstanceId then return end
|
||||
end
|
||||
|
||||
classUI.elementsIdCounter = classUI.elementsIdCounter+1
|
||||
|
||||
local elementId = "elt"..classUI.elementsIdCounter
|
||||
|
||||
-- create new element
|
||||
local newElement = createGroupInstance("element_template", listElements.id,
|
||||
{id=elementId, posref="TL TL", x="0", y="0", sizeref="w", hardtext="",
|
||||
select_elt=templateParams.selectElt, open_elt_editor=templateParams.openEltEditor,
|
||||
max_min_elt=templateParams.maxMinElt, remove_elt=templateParams.removeElt, open_chat=templateParams.openChat,
|
||||
col_over=templateParams.colOver, col_pushed=templateParams.colPushed, multi_max_line=templateParams.multiMaxLine})
|
||||
assert(newElement)
|
||||
|
||||
-- add element to list
|
||||
local eltIndex = -1
|
||||
if withOrder then
|
||||
local comps = newInst.Parent
|
||||
for i=0, comps.Size-1 do
|
||||
local comp = comps[i]
|
||||
if comp.InstanceId == newInst.InstanceId then
|
||||
eltIndex = i
|
||||
break
|
||||
end
|
||||
end
|
||||
local eltEditor = listElements:find("edit_element")
|
||||
assert(eltEditor)
|
||||
local indexEltEditor = listElements:getElementIndex(eltEditor)
|
||||
if indexEltEditor<= eltIndex then eltIndex=eltIndex+1 end
|
||||
else
|
||||
eltIndex = listElements.childrenNb
|
||||
end
|
||||
|
||||
listElements:addChildAtIndex(newElement, eltIndex)
|
||||
listElements.parent:updateCoords()
|
||||
|
||||
-- active global minimize / maximize button
|
||||
if classUI.maxAndMin then
|
||||
|
||||
classUI:maximizeMinimizeElement(newElement)
|
||||
|
||||
if listElements.childrenNb == 2 then
|
||||
local maxElts = sequenceUI:find("maximize_elements")
|
||||
assert(maxElts)
|
||||
maxElts.active = true
|
||||
end
|
||||
end
|
||||
|
||||
-- scroll goes down to new element
|
||||
local scrollBar = sequenceUI:find("scroll_objects")
|
||||
assert(scrollBar)
|
||||
scrollBar.trackPos = 0
|
||||
|
||||
-- target sroll text
|
||||
local scroll = newElement:find("scroll_bar_text")
|
||||
assert(scroll)
|
||||
|
||||
local scrollText = newElement:find("scroll_text_gr")
|
||||
assert(scrollText)
|
||||
scroll:setTarget(scrollText.id)
|
||||
|
||||
self:setEltUIInstId(newElement, newInst.InstanceId)
|
||||
|
||||
-- update next elements title
|
||||
if eltIndex<listElements.childrenNb-1 then
|
||||
for i=eltIndex+1, listElements.childrenNb-1 do
|
||||
local elt = listElements:getChild(i)
|
||||
if r2.logicUI:getEltUIInstId(elt) then
|
||||
classUI:updateElementTitle(elt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if classUI.ownCreatedInstances[newInst.InstanceId] == true
|
||||
or r2.logicComponents.undoRedoInstances[newInst.InstanceId]==true then
|
||||
|
||||
local select = newElement:find("select")
|
||||
assert(select)
|
||||
select.pushed = true
|
||||
classUI:selectElement(select, self:getSequUIInstId(sequenceUI))
|
||||
classUI.ownCreatedInstances[newInst.InstanceId] = nil
|
||||
r2.logicComponents.undoRedoInstances[newInst.InstanceId] = nil
|
||||
end
|
||||
|
||||
classUI:updateElementUI(newElement)
|
||||
end
|
||||
|
||||
------ REMOVE ELEMENT UI -------------------------------------------
|
||||
function r2.logicUI:removeElementUI(classUI, removedEltUI)
|
||||
|
||||
local sequenceUI = classUI:currentSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
local listElements = sequenceUI:find("elements_list")
|
||||
assert(listElements)
|
||||
|
||||
-- update follow elements number
|
||||
local removedIndex = listElements:getElementIndex(removedEltUI)
|
||||
for i = removedIndex+1, (listElements.childrenNb-1) do
|
||||
local element = listElements:getChild(i)
|
||||
assert(element)
|
||||
|
||||
-- if this element is not the element editor, update its title
|
||||
if self:getEltUIInstId(element) then
|
||||
classUI:updateElementTitle(element)
|
||||
end
|
||||
end
|
||||
|
||||
-- delete element and update coordinates of elements list
|
||||
if removedEltUI == classUI:currentEltUI() then
|
||||
|
||||
classUI:setCurrentEltUIId(nil)
|
||||
|
||||
-- inactive element editor
|
||||
local eltEditor = listElements:find("edit_element")
|
||||
assert(eltEditor)
|
||||
eltEditor.active = false
|
||||
|
||||
-- disactive up and down element buttons
|
||||
local orderGr = sequenceUI:find("order_group")
|
||||
assert(orderGr)
|
||||
orderGr.active = false
|
||||
end
|
||||
|
||||
listElements:delChild(removedEltUI)
|
||||
listElements.parent:invalidateCoords()
|
||||
|
||||
-- if any elements in list, disactive global minimize / maximize button
|
||||
if listElements.childrenNb == 1 then
|
||||
local minElts = sequenceUI:find("minimize_elements")
|
||||
assert(minElts)
|
||||
|
||||
local maxElts = sequenceUI:find("maximize_elements")
|
||||
assert(maxElts)
|
||||
|
||||
minElts.active = false
|
||||
maxElts.active = false
|
||||
end
|
||||
end
|
||||
|
||||
------ UPDATE ELEMENT UI -------------------------------------------
|
||||
function r2.logicUI:updateElementUI(classUI, elementUI)
|
||||
|
||||
local instance = r2:getInstanceFromId(self:getEltUIInstId(elementUI))
|
||||
assert(instance)
|
||||
|
||||
classUI:updateElementTitle(elementUI)
|
||||
|
||||
if instance.InstanceId == classUI:currentEltInstId() then
|
||||
classUI:updateElementEditor()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------ DOWN/UP ELEMENT UI -------------------------------------------
|
||||
function r2.logicUI:downUpElementUI(classUI, elementUI, instance)
|
||||
|
||||
local listElements = elementUI.parent
|
||||
assert(listElements)
|
||||
|
||||
local eltEditor = listElements:find("edit_element")
|
||||
assert(eltEditor)
|
||||
|
||||
local index = listElements:getElementIndex(elementUI)
|
||||
local indexEditor = listElements:getElementIndex(eltEditor)
|
||||
|
||||
local indexInstance = -1
|
||||
for i=0, instance.Parent.Size-1 do
|
||||
if instance.Parent[i]==instance then
|
||||
indexInstance = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if index>=0 and indexEditor>=0 and indexInstance>=0 then
|
||||
|
||||
local finalIndex = indexInstance
|
||||
|
||||
if indexEditor-1 <= indexInstance then finalIndex=finalIndex+1 end
|
||||
|
||||
local selectedEltUI = classUI:currentEltUI()
|
||||
local isSelected = (selectedEltUI==elementUI)
|
||||
|
||||
local loop = math.abs(finalIndex-index)
|
||||
if loop>0 then
|
||||
|
||||
-- replace element UI
|
||||
for i=1, loop do
|
||||
if finalIndex < index then
|
||||
listElements:upChild(elementUI)
|
||||
else
|
||||
listElements:downChild(elementUI)
|
||||
end
|
||||
end
|
||||
|
||||
-- replace element editor
|
||||
if isSelected then
|
||||
for i=1, loop do
|
||||
if finalIndex < index then
|
||||
listElements:upChild(eltEditor)
|
||||
else
|
||||
listElements:downChild(eltEditor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local firstIndex = math.min(index, finalIndex)
|
||||
local lastIndex = math.min(listElements.childrenNb-1, math.max(index, finalIndex)+1)
|
||||
for i=firstIndex, lastIndex do
|
||||
local eltUI = listElements:getChild(i)
|
||||
if eltUI~=eltEditor then
|
||||
classUI:updateElementTitle(eltUI)
|
||||
end
|
||||
end
|
||||
|
||||
if selectedEltUI~=nil then
|
||||
selectedEltUI.active=false
|
||||
classUI:updateElementEditor()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
------ MAX/MIN ELEMENT UI -------------------------------------------
|
||||
function r2.logicUI:maximizeMinimizeElement(element, allMinimize)
|
||||
|
||||
if element == nil then
|
||||
element = getUICaller().parent.parent.parent.parent.parent.parent
|
||||
end
|
||||
assert(element)
|
||||
|
||||
local eltText = element:find("element_text")
|
||||
assert(eltText)
|
||||
|
||||
local allMin, allMax = true, true
|
||||
if allMinimize ~= nil then
|
||||
allMin = allMinimize
|
||||
allMax = not allMin
|
||||
end
|
||||
|
||||
local maxButton = element:find("maximize_element")
|
||||
assert(maxButton)
|
||||
local minButton = element:find("minimize_element")
|
||||
assert(minButton)
|
||||
|
||||
-- maximize
|
||||
if allMax and eltText.active==false then
|
||||
eltText.active = true
|
||||
maxButton.active = false
|
||||
minButton.active = true
|
||||
|
||||
-- minimize
|
||||
elseif allMin and eltText.active==true then
|
||||
eltText.active = false
|
||||
maxButton.active = true
|
||||
minButton.active = false
|
||||
end
|
||||
end
|
||||
|
||||
------ MAX/MIN ELEMENTS UI -------------------------------------------
|
||||
function r2.logicUI:maximizeMinimizeElements(classUI)
|
||||
|
||||
local sequenceUI = classUI:currentSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
local elements = sequenceUI:find("elements_list")
|
||||
assert(elements)
|
||||
|
||||
elements.Env.Minimize = not elements.Env.Minimize
|
||||
|
||||
for i = 0, elements.childrenNb-1 do
|
||||
local element = elements:getChild(i)
|
||||
assert(element)
|
||||
|
||||
-- if element is not the element editor
|
||||
if self:getEltUIInstId(element) and element~=classUI:currentEltUI() then
|
||||
classUI:maximizeMinimizeElement(element, elements.Env.Minimize)
|
||||
end
|
||||
end
|
||||
|
||||
local minElts = sequenceUI:find("minimize_elements")
|
||||
assert(minElts)
|
||||
local maxElts = sequenceUI:find("maximize_elements")
|
||||
assert(maxElts)
|
||||
|
||||
if elements.Env.Minimize == true then
|
||||
minElts.active = false
|
||||
maxElts.active = true
|
||||
else
|
||||
minElts.active = true
|
||||
maxElts.active = false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------ CLOSE EDITOR ------------------------------------------
|
||||
function r2.logicUI:closeEditor(classUI)
|
||||
|
||||
-- reset current dialog and current chat
|
||||
classUI:setCurrentEltUIId(nil)
|
||||
end
|
||||
|
||||
|
||||
------- UTILS ------------------------------------------------
|
||||
|
||||
function r2.logicUI:findElementUIFromInstance(classUI, instance)
|
||||
|
||||
local sequenceUI = classUI:currentSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
local eltsList = sequenceUI:find("elements_list")
|
||||
assert(eltsList)
|
||||
|
||||
for i=0,eltsList.childrenNb-1 do
|
||||
local element = eltsList:getChild(i)
|
||||
if r2.logicUI:getEltUIInstId(element) == instance.InstanceId then
|
||||
return element
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,213 +0,0 @@
|
||||
r2.miniActivities = {
|
||||
|
||||
|
||||
activityTextures = { ["Follow Route"] = "r2_mini_activity_follow_road.tga",
|
||||
["Patrol"] = "r2_mini_activity_patrol_road.tga",
|
||||
["Repeat Road"] = "r2_mini_activity_repeat_road.tga",
|
||||
["Wander"] = "r2_mini_activity_wander_zone.tga",
|
||||
["Stand Still"] = "r2_mini_activity_stand_still.tga",
|
||||
["Rest In Zone"] = "r2_mini_activity_rest_zone.tga",
|
||||
["Feed In Zone"] = "r2_mini_activity_feed_zone.tga",
|
||||
["Work In Zone"] = "r2_mini_activity_work_zone.tga",
|
||||
["Hunt In Zone"] = "r2_mini_activity_hunt_zone.tga",
|
||||
["Guard Zone"] = "r2_mini_activity_guard_zone.tga",
|
||||
},
|
||||
|
||||
maxActivities = 14,
|
||||
|
||||
uiId = "ui:interface:r2ed_mini_activity_view",
|
||||
|
||||
}
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- Show the mini activity view for this instance
|
||||
function r2.miniActivities:openEditor()
|
||||
|
||||
local selectedInstance = r2:getSelectedInstance()
|
||||
if not (selectedInstance:isPlant() or selectedInstance:isBotObject()) then
|
||||
r2.miniActivities:updateMiniActivityView()
|
||||
r2.miniActivities:updateSequenceButtonBar()
|
||||
|
||||
local miniActivityView = getUI(self.uiId)
|
||||
assert(miniActivityView)
|
||||
|
||||
miniActivityView.active = true
|
||||
end
|
||||
end
|
||||
|
||||
------ CLOSE EDITOR ------------------------------------------------------
|
||||
function r2.miniActivities:closeEditor()
|
||||
|
||||
local ui = getUI(self.uiId)
|
||||
assert(ui)
|
||||
if ui.active then
|
||||
ui.active = false
|
||||
end
|
||||
end
|
||||
|
||||
--- UPDATE SEQUENCE BUTTON BAR -------------------------------------------------
|
||||
function r2.miniActivities:updateSequenceButtonBar()
|
||||
|
||||
local selectBar = getUI("ui:interface:r2ed_select_bar")
|
||||
assert(selectBar)
|
||||
|
||||
local sequencesButton = selectBar:find("sequences")
|
||||
assert(sequencesButton)
|
||||
|
||||
local sequenceInst
|
||||
if r2.activities.isInitialized then
|
||||
sequenceInst = r2.activities:currentSequInst()
|
||||
else
|
||||
local logicEntity = r2:getSelectedInstance()
|
||||
if logicEntity== nil then return end
|
||||
|
||||
if logicEntity:getBehavior().Activities.Size > 0 then
|
||||
sequenceInst = logicEntity:getBehavior().Activities[logicEntity:getSelectedSequenceIndex()]
|
||||
end
|
||||
end
|
||||
|
||||
local uc_sequ = ucstring()
|
||||
if sequenceInst and sequenceInst.User.Deleted~=true then
|
||||
uc_sequ:fromUtf8(sequenceInst:getName())
|
||||
else
|
||||
uc_sequ = i18n.get("uiR2EDSequences")
|
||||
end
|
||||
sequencesButton.uc_hardtext = uc_sequ
|
||||
end
|
||||
|
||||
|
||||
--- UPDATE MINI ACTIVITIES VIEW ----------------------------------------------------
|
||||
function r2.miniActivities:updateMiniActivityView()
|
||||
|
||||
local miniActivityView = getUI(self.uiId)
|
||||
assert(miniActivityView)
|
||||
|
||||
local miniActivities = miniActivityView:find("mini_activities")
|
||||
assert(miniActivities)
|
||||
|
||||
local noActivityLabel = miniActivityView:find("no_activity")
|
||||
assert(noActivityLabel)
|
||||
|
||||
local startCount = 0
|
||||
|
||||
local sequenceInst
|
||||
if r2.activities.isInitialized then
|
||||
sequenceInst = r2.activities:currentSequInst()
|
||||
else
|
||||
local logicEntity = r2:getSelectedInstance()
|
||||
if logicEntity == nil then return end
|
||||
|
||||
if logicEntity:getBehavior().Activities.Size > 0 then
|
||||
sequenceInst = logicEntity:getBehavior().Activities[logicEntity:getSelectedSequenceIndex()]
|
||||
end
|
||||
end
|
||||
|
||||
if sequenceInst~=nil and sequenceInst.User.Deleted~=true then
|
||||
|
||||
local decalErased = 0
|
||||
|
||||
for i=0, sequenceInst.Components.Size-1 do
|
||||
|
||||
local activityInst = sequenceInst.Components[i]
|
||||
assert(activityInst)
|
||||
|
||||
if activityInst then
|
||||
|
||||
local activityZoneId = activityInst.ActivityZoneId
|
||||
if activityInst.User.Deleted~=true
|
||||
-- this zone just has been deleted
|
||||
and not (activityZoneId~="" and r2:getInstanceFromId(activityZoneId)==nil) then
|
||||
|
||||
local miniIndex = i - decalErased
|
||||
|
||||
local miniActivity = miniActivities[tostring(miniIndex)]
|
||||
assert(miniActivity)
|
||||
|
||||
miniActivity.active = true
|
||||
miniActivity.Env.InstanceId = activityInst.InstanceId
|
||||
|
||||
-- activity type button
|
||||
local activityButton = miniActivity:find("activity"):find("button")
|
||||
assert(activityButton)
|
||||
local activityTexture = activityInst:getMiniButtonTexture()
|
||||
if activityTexture then
|
||||
activityButton.texture = activityTexture
|
||||
activityButton.texture_pushed = activityTexture
|
||||
activityButton.texture_over = activityTexture
|
||||
end
|
||||
|
||||
-- activity type text
|
||||
local activityText = miniActivity:find("activity_name")
|
||||
assert(activityText)
|
||||
local activityType = activityInst:getVerb()
|
||||
if activityZoneId~="" then
|
||||
local place = r2:getInstanceFromId(activityZoneId)
|
||||
assert(place)
|
||||
activityType = activityType .. " '" .. place.Name .."'"
|
||||
end
|
||||
local uc_type = ucstring()
|
||||
uc_type:fromUtf8(activityType)
|
||||
activityText.uc_hardtext = uc_type
|
||||
else
|
||||
decalErased = decalErased+1
|
||||
end
|
||||
end
|
||||
end
|
||||
startCount = sequenceInst.Components.Size - decalErased
|
||||
|
||||
--label "No activity"
|
||||
if (sequenceInst.Components.Size==0) or (sequenceInst.Components.Size==1 and erasedInstId~=nil)
|
||||
or (startCount == 0) then
|
||||
noActivityLabel.active = true
|
||||
noActivityLabel.uc_hardtext = i18n.get("uiR2EdNoActivity")
|
||||
else
|
||||
noActivityLabel.active = false
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
noActivityLabel.active = true
|
||||
noActivityLabel.uc_hardtext = i18n.get("uiR2EdNoSequence")
|
||||
end
|
||||
|
||||
-- hide remaining mini activity templates
|
||||
for i=startCount, r2.activities.maxElements-1 do
|
||||
local miniActivity = miniActivities[tostring(i)]
|
||||
assert(miniActivity)
|
||||
miniActivity.active = false
|
||||
end
|
||||
end
|
||||
|
||||
-- OPEN ACTIVITIES EDITOR ON SELECTED MINI ACTIVITY -------------------------------
|
||||
function r2.miniActivities:openActivity()
|
||||
|
||||
r2.activities:openEditor()
|
||||
|
||||
local miniActivity = getUICaller().parent.parent.parent
|
||||
assert(miniActivity)
|
||||
|
||||
local sequenceUI = r2.activities:currentSequUI()
|
||||
assert(sequenceUI)
|
||||
|
||||
local activityList = sequenceUI:find("elements_list")
|
||||
assert(activityList)
|
||||
|
||||
local activityUI
|
||||
for i=0, activityList.childrenNb-1 do
|
||||
local activity = activityList:getChild(i)
|
||||
assert(activity)
|
||||
|
||||
if r2.logicUI:getEltUIInstId(activity) == miniActivity.Env.InstanceId then
|
||||
activityUI = activity
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if activityUI then
|
||||
local selectedButtonElt = activityUI:find("select")
|
||||
assert(selectedButtonElt)
|
||||
|
||||
selectedButtonElt.pushed = true
|
||||
r2.activities:selectElement(selectedButtonElt)
|
||||
end
|
||||
end
|
@ -1,348 +0,0 @@
|
||||
-- This file contains a set of miscellanous functions that don't fit in any other place
|
||||
-- TODO nico : could be useful outside r2 -> export this
|
||||
|
||||
|
||||
---------------
|
||||
-- FUNCTIONS --
|
||||
---------------
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- equivalent of the ? : C operator, execpt that the 2 sides are evaluated before assignement
|
||||
function select(cond, valueForTrue, valueForFalse)
|
||||
if cond then
|
||||
return valueForTrue
|
||||
else
|
||||
return valueForFalse
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- execute a function for each key pair in a table
|
||||
function forEach(table, fn)
|
||||
local i, v = next(table,nil) -- get first index of "o" and its value
|
||||
while i do
|
||||
fn(i, v)
|
||||
i, v = next(table,i) -- get next index and its value
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- whatever
|
||||
table.setn = function(table, n)
|
||||
assert(table)
|
||||
local mt = getmetatable(table)
|
||||
if mt ~= nil then
|
||||
if mt.__next ~= nil then
|
||||
table.Size = n
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- extension to table library : remove all content of a table without deleting the table object
|
||||
function table.clear(tbl)
|
||||
while next(tbl) do
|
||||
tbl[next(tbl)] = nil
|
||||
end
|
||||
table.setn(tbl, 0)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- extension to table library : merge the content of two table remove the element, remove fields with duplicated keys (except for number)
|
||||
function table.merge(tbl1, tbl2)
|
||||
local k, v = next(tbl2)
|
||||
while k do
|
||||
if (type(k) == "number") then
|
||||
table.insert(tbl1, v)
|
||||
else
|
||||
tbl1[k] = v
|
||||
end
|
||||
k, v = next(tbl2, k)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- Addtion to the string library : test wether a string match with the given pattern (returns true is so)
|
||||
function string.match(str, pattern)
|
||||
assert( type(str) == "string")
|
||||
if (str == nil) then
|
||||
debugInfo(debug.traceback())
|
||||
assert(0)
|
||||
end
|
||||
local startPos, endPos = string.find(str, pattern)
|
||||
if startPos == nil then return false end
|
||||
return startPos == 1 and endPos == string.len(str)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- clone content of a table
|
||||
function clone(t)
|
||||
local new = {}
|
||||
local i, v = next(t, nil)
|
||||
while i do
|
||||
if (type(v)=="table") then v= clone(v) end
|
||||
new[i] = v
|
||||
i, v = next(t, i)
|
||||
end
|
||||
return new
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- Test if 2 values are equal
|
||||
-- If values are table, then a member wise comparison is done
|
||||
function isEqual(lhs, rhs)
|
||||
if type(lhs) ~= type(rhs) then return false end
|
||||
if type(lhs) == "table" then
|
||||
local lk, lv = next(lhs) -- keys
|
||||
local rk, rv = next(rhs) -- values
|
||||
while lk and rk do
|
||||
if not isEqual(lk, rk) then
|
||||
return false
|
||||
end
|
||||
if not isEqual(lv, rv) then
|
||||
return false
|
||||
end
|
||||
lk, lv = next(lhs, lk)
|
||||
rk, rv = next(rhs, rk)
|
||||
end
|
||||
if lk ~= nil or rk ~= nil then
|
||||
return false
|
||||
-- not same table length
|
||||
end
|
||||
return true
|
||||
else
|
||||
return lhs == rhs
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- Test if 2 values are equal
|
||||
-- If values are table, then a member wise comparison is done
|
||||
-- special : function pointer are ignored and considered equals
|
||||
function isEqualIgnoreFunctions(lhs, rhs)
|
||||
if type(lhs) ~= type(rhs) then return false end
|
||||
if type(lhs) == "table" then
|
||||
local lk, lv = next(lhs) -- keys
|
||||
local rk, rv = next(rhs) -- values
|
||||
while lk and rk do
|
||||
if not isEqualIgnoreFunctions(lk, rk) then
|
||||
return false
|
||||
end
|
||||
if not isEqualIgnoreFunctions(lv, rv) then
|
||||
return false
|
||||
end
|
||||
lk, lv = next(lhs, lk)
|
||||
rk, rv = next(rhs, rk)
|
||||
end
|
||||
if lk ~= nil or rk ~= nil then
|
||||
return false
|
||||
-- not same table length
|
||||
end
|
||||
return true
|
||||
elseif type(lhs) == "function" then
|
||||
return true
|
||||
else
|
||||
return lhs == rhs
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- clone of a table, but with a depth of 1 ...
|
||||
function shallowClone(t)
|
||||
local new = {}
|
||||
local i, v = next(t, nil)
|
||||
while i do
|
||||
new[i] = v
|
||||
i, v = next(t, i)
|
||||
end
|
||||
return new
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
-- If args 'value' is nil then the arg 'default' is returned, else the actual 'value' is return
|
||||
function defaulting(value, default)
|
||||
if value == nil then
|
||||
return default
|
||||
else
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
-- return clamped value. Min and/or max are ignotred if null
|
||||
function clamp(value, min, max)
|
||||
local result = value
|
||||
if min then result = math.max(min, result) end
|
||||
if max then result = math.min(max, result) end
|
||||
return result
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
-- enclose a string by double quotes
|
||||
function strify(str)
|
||||
return [["]] .. tostring(str) .. [["]]
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
-- enclose a string by double quotes
|
||||
function strifyXml(str)
|
||||
local strxml = string.gsub(tostring(str), ">", ">")
|
||||
strxml = string.gsub(strxml, "<", "<")
|
||||
strxml = string.gsub(strxml, "&", "&")
|
||||
strxml = string.gsub(strxml, "'", "'")
|
||||
strxml = string.gsub(strxml, '"', """)
|
||||
return [["]] .. strxml .. [["]]
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
-- snap a position to ground, returning the z snapped coordinate
|
||||
function r2:snapZToGround(x, y)
|
||||
local x1, y1, z1 = r2:snapPosToGround(x, y)
|
||||
return z1
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------
|
||||
--
|
||||
--built an ordered table from a table whose index are strings
|
||||
--example :
|
||||
--
|
||||
--table =
|
||||
--{
|
||||
--"bar" = test(),
|
||||
--"foo" = { "hello" },
|
||||
--"abc" = 10,
|
||||
--}
|
||||
--
|
||||
--result = sortAlphabeticaly(table)
|
||||
--
|
||||
--
|
||||
--result is an integer indexed table :
|
||||
--{
|
||||
-- -- index = { sorted key, value }
|
||||
-- 1 = { "abc", 10 },
|
||||
-- 2 = { "bar", test() },
|
||||
-- 3 = { "foo", { "hello" } }
|
||||
--}
|
||||
--
|
||||
|
||||
function sortAlphabetically(src)
|
||||
local sortedTable = {}
|
||||
local index = 1
|
||||
for k, v in pairs(src) do
|
||||
sortedTable[index] = { key = k, value = v }
|
||||
index = index + 1
|
||||
end
|
||||
local function comp(val1, val2)
|
||||
return val1.key < val2.key
|
||||
end
|
||||
table.sort(sortedTable, comp)
|
||||
return sortedTable
|
||||
end
|
||||
|
||||
----------
|
||||
-- INIT --
|
||||
----------
|
||||
|
||||
-- redefine the 'next' function of lua to use a "__next" function in the metatable
|
||||
-- useful to traverse C++ objects that are exposed to lua through the use of the metatable
|
||||
assert(next ~= nil) -- default lib should have been opened
|
||||
|
||||
if oldNextFunction == nil then
|
||||
oldNextFunction = next
|
||||
end
|
||||
next = function(table, key)
|
||||
assert(table)
|
||||
local mt = getmetatable(table)
|
||||
if mt ~= nil then
|
||||
if mt.__next ~= nil then
|
||||
return mt.__next(table, key)
|
||||
end
|
||||
end
|
||||
-- tmp
|
||||
--if type(table) ~= "table" then
|
||||
-- debugInfo(debug.traceback())
|
||||
-- debugInfo("'next' expect a table (or user data with __next metamethod) as its first parameter")
|
||||
-- return
|
||||
--end
|
||||
-- else use default 'next' function
|
||||
return oldNextFunction(table, key)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- assert(table.getn ~= nil) -- default lib should have been opened
|
||||
|
||||
--if oldTableGetnFunction == nil then
|
||||
-- oldTableGetnFunction = table.getn
|
||||
--end
|
||||
--
|
||||
--table.getn = function(table)
|
||||
-- assert(table)
|
||||
-- local mt = getmetatable(table)
|
||||
-- if mt ~= nil then
|
||||
-- if mt.__next ~= nil then
|
||||
-- return table.Size
|
||||
-- end
|
||||
-- end
|
||||
-- return oldTableGetnFunction(table)
|
||||
--end
|
||||
|
||||
|
||||
table.getn = function(table)
|
||||
assert(table)
|
||||
local mt = getmetatable(table)
|
||||
if mt ~= nil then
|
||||
if mt.__next ~= nil then
|
||||
return table.Size
|
||||
end
|
||||
end
|
||||
return #table
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- redefine the hardcoded 'pairs' function to use the redefined 'next'
|
||||
-- hardcoded version uses the C version of next, not the lua one if it has been redefined
|
||||
|
||||
if oldPairsFunction ~= nil then
|
||||
pairs = oldPairsFunction
|
||||
end
|
||||
|
||||
if oldPairsFunction == nil then
|
||||
oldPairsFunction = pairs
|
||||
end
|
||||
|
||||
if true then
|
||||
-- TODO nico : bad init of editor if I name this 'pairs' directly (don't know why), so named it 'specPairs' and used
|
||||
-- 'specPairs' when I must iterate over C++ objects ...
|
||||
specPairs = function(table)
|
||||
local function iterFunc(table, key)
|
||||
return next(table, key)
|
||||
end
|
||||
return iterFunc, table
|
||||
end
|
||||
end
|
||||
|
||||
function r2.assert (param)
|
||||
if not param then assert(nil) end
|
||||
return param
|
||||
end
|
||||
|
||||
function r2.isTable(node)
|
||||
if not node then return false end
|
||||
|
||||
if type(node) == "table" then
|
||||
return true
|
||||
elseif type(node) == "userdata" then
|
||||
local mt = getmetatable(node)
|
||||
if mt~= nil and mt.__next ~= nil then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,238 +0,0 @@
|
||||
assert(nil) -- component oblsolete
|
||||
local registerFeature = function()
|
||||
local feature = {}
|
||||
feature.maxId=1
|
||||
feature.Name = "Piece"
|
||||
|
||||
feature.Description = "A npc dialog test"
|
||||
|
||||
feature.Components=
|
||||
{
|
||||
{
|
||||
Name="Piece",
|
||||
Prop =
|
||||
{
|
||||
{Name="Zone",Type="Region"},
|
||||
{Name="Npcs",Type="Table"},
|
||||
{Name="Actions",Type="Table"},
|
||||
{Name="Name", Type="String", MaxNumChar="32"}
|
||||
}
|
||||
},
|
||||
{
|
||||
Name="PieceEntry",
|
||||
Prop=
|
||||
{
|
||||
{Name="Who",Type="String"},
|
||||
{Name="Action",Type="String"},
|
||||
{Name="Parameters",Type="String"},
|
||||
{Name="Time",Type="String"}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
feature.createDialog = function(dialog,x,y,r)
|
||||
--local dialog = r2.newComponent("Piece")
|
||||
local nbNpc = table.getn(dialog.Npcs)
|
||||
local pas = (2 * math.pi) / nbNpc
|
||||
|
||||
local max = table.getn(dialog.Actions)
|
||||
--adding the texts to the TextManager
|
||||
for i=1,max do
|
||||
if dialog.Actions[i].Action == "npc_say"
|
||||
then
|
||||
local textParam = feature.getTextParam(dialog.Actions[i].Parameters)
|
||||
debugInfo("Text param: "..textParam)
|
||||
local entry=r2.registerText(textParam)
|
||||
dialog.Actions[i].Parameters = entry.InstanceId
|
||||
debugInfo("New params: "..dialog.Actions[i].Parameters)
|
||||
end
|
||||
end
|
||||
return dialog
|
||||
end
|
||||
|
||||
feature.getTextParam = function(param)
|
||||
debugInfo("param:: "..param)
|
||||
local pos=string.find(param,"\n")
|
||||
if pos==nil
|
||||
then
|
||||
return param
|
||||
else
|
||||
return string.sub(param,pos+1)
|
||||
end
|
||||
end
|
||||
|
||||
feature.setTextParam = function(param,value)
|
||||
local pos=string.find(param,"\n")
|
||||
if pos==nil
|
||||
then
|
||||
return param
|
||||
else
|
||||
local st = string.sub(param,1,pos)
|
||||
st = st..value
|
||||
return st
|
||||
end
|
||||
end
|
||||
|
||||
feature.removeDialog = function(dialog)
|
||||
local max = table.getn(dialog.Actions)
|
||||
for i=1,max do
|
||||
if dialog.Actions[i].Action == "npc_say"
|
||||
then
|
||||
r2.unregisterText(dialog.Actions[i].Parameters)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature.TranslateEntry = function(context)
|
||||
local entry = context.Component
|
||||
local multi_actions = r2.newComponent("RtNpcEventHandlerAction")
|
||||
multi_actions.Action = "multi_actions"
|
||||
local parameters = entry.Parameters
|
||||
local getRtId = r2.Features["TextManager"].getRtId
|
||||
if entry.Action == "npc_say"
|
||||
then
|
||||
parameters = getRtId(context,parameters)
|
||||
debugInfo("npc_say:: "..parameters)
|
||||
end
|
||||
local action = Actions.createAction(entry.Action,parameters,entry.Who)
|
||||
table.insert(multi_actions.Children,action)
|
||||
|
||||
|
||||
action = Actions.createAction("set_timer_t0",entry.Time)
|
||||
table.insert(multi_actions.Children,action)
|
||||
return multi_actions
|
||||
end
|
||||
|
||||
feature.loop = function(name)
|
||||
action = Actions.createAction("begin_state",name)
|
||||
return action
|
||||
end
|
||||
|
||||
feature.Translator = function(context)
|
||||
local actions = context.Feature.Actions
|
||||
local max = table.getn(actions)
|
||||
local switch_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
local endAction
|
||||
local action
|
||||
--endAction = feature.loop("init_"..context.Feature.Name)
|
||||
endAction = feature.loop("dialog")
|
||||
switch_action.Action="switch_actions"
|
||||
switch_action.Parameters = "v0"
|
||||
|
||||
|
||||
for i=1,max do
|
||||
context.Component = actions[i]
|
||||
local tmpAction = feature.TranslateEntry(context)
|
||||
table.insert(switch_action.Children,tmpAction)
|
||||
end
|
||||
table.insert(switch_action.Children,endAction)
|
||||
table.insert(context.RtAct.Actions,switch_action)
|
||||
|
||||
|
||||
--states creation
|
||||
local aiState = r2.newComponent("RtAiState")
|
||||
aiState.Name = "dialog"
|
||||
table.insert(context.RtAct.AiStates, aiState)
|
||||
--aiState = r2.newComponent("RtAiState")
|
||||
--aiState.Name = "init_"..context.Feature.Name
|
||||
--table.insert(context.RtAct.AiStates, aiState)
|
||||
|
||||
|
||||
--next action
|
||||
local event
|
||||
event = Actions.createEvent("timer_t0_triggered","dialog")
|
||||
table.insert(context.RtAct.Events,event)
|
||||
local multi_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
multi_action.Action = "multi_actions"
|
||||
table.insert(multi_action.Children,switch_action)
|
||||
action = Actions.createAction("modify_variable","v0 + 1")
|
||||
table.insert(multi_action.Children,action)
|
||||
table.insert(context.RtAct.Actions,multi_action)
|
||||
table.insert(event.ActionsId,multi_action.Id)
|
||||
|
||||
|
||||
--action
|
||||
event = Actions.createEvent("start_of_state","dialog")
|
||||
local m_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
m_action.Action = "multi_actions"
|
||||
table.insert(context.RtAct.Actions,m_action)
|
||||
action = Actions.createAction("modify_variable","v0 = 0")
|
||||
table.insert(m_action.Children,action)
|
||||
action = Actions.createAction("set_timer_t0","1")
|
||||
table.insert(m_action.Children,action)
|
||||
table.insert(event.ActionsId,m_action.Id)
|
||||
table.insert(context.RtAct.Events,event)
|
||||
|
||||
end
|
||||
|
||||
|
||||
feature.Translator2 = function(context)
|
||||
local actions = context.Feature.Actions
|
||||
local max = table.getn(actions)
|
||||
local switch_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
local endAction
|
||||
|
||||
endAction = feature.loop("init_"..context.Feature.Name)
|
||||
|
||||
switch_action.Action="switch_actions"
|
||||
switch_action.Parameters = "v0"
|
||||
|
||||
|
||||
for i=1,max do
|
||||
context.Component = actions[i]
|
||||
local tmpAction = feature.TranslateEntry(context)
|
||||
table.insert(switch_action.Children,tmpAction)
|
||||
end
|
||||
table.insert(switch_action.Children,endAction)
|
||||
table.insert(context.RtAct.Actions,switch_action)
|
||||
|
||||
|
||||
--states creation
|
||||
local aiState = r2.newComponent("RtAiState")
|
||||
aiState.Name = "dialog"
|
||||
table.insert(context.RtAct.AiStates, aiState)
|
||||
aiState = r2.newComponent("RtAiState")
|
||||
aiState.Name = "init_"..context.Feature.Name
|
||||
table.insert(context.RtAct.AiStates, aiState)
|
||||
|
||||
--next action
|
||||
local event
|
||||
event = Actions.createEvent("timer_t0_triggered","dialog")
|
||||
table.insert(context.RtAct.Events,event)
|
||||
local multi_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
multi_action.Action = "multi_actions"
|
||||
local action = Actions.createAction("modify_variable","v0 + 1")
|
||||
table.insert(multi_action.Children,action)
|
||||
action = Actions.createAction("begin_state","dialog")
|
||||
table.insert(multi_action.Children,action)
|
||||
table.insert(context.RtAct.Actions,multi_action)
|
||||
table.insert(event.ActionsId,multi_action.Id)
|
||||
|
||||
--dialog start
|
||||
event = Actions.createEvent("start_of_state","init_"..context.Feature.Name)
|
||||
local m_action = r2.newComponent("RtNpcEventHandlerAction")
|
||||
m_action.Action = "multi_actions"
|
||||
action = Actions.createAction("modify_variable","v0 = 0")
|
||||
table.insert(m_action.Children,action)
|
||||
action = Actions.createAction("begin_state","dialog")
|
||||
table.insert(m_action.Children,action)
|
||||
table.insert(context.RtAct.Actions,m_action)
|
||||
table.insert(event.ActionsId,m_action.Id)
|
||||
table.insert(context.RtAct.Events,event)
|
||||
|
||||
--action
|
||||
event = Actions.createEvent("start_of_state","dialog")
|
||||
table.insert(event.ActionsId,switch_action.Id)
|
||||
table.insert(context.RtAct.Events,event)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
return feature
|
||||
end
|
||||
|
||||
r2.Features["Piece"] = registerFeature()
|
||||
|
||||
|
@ -1,472 +0,0 @@
|
||||
-- plot items. They are global to the scenario and can be given
|
||||
-- by the DM to players
|
||||
|
||||
-- ////////////////////////////////
|
||||
-- // PLOT ITEM CLASS DEFINITION //
|
||||
-- ////////////////////////////////
|
||||
|
||||
local maxNumPlotItems = tonumber(getDefine("r2ed_max_num_plot_items"))
|
||||
local maxNumPlotItemSheets = tonumber(getDefine("r2ed_max_num_plot_item_sheets"))
|
||||
|
||||
local plotItem =
|
||||
{
|
||||
BaseClass = "BaseClass",
|
||||
Name = "PlotItem",
|
||||
DisplayerUI = "R2::CDisplayerLua", -- name of the C++ class that displays this object in the ui
|
||||
DisplayerUIParams = "plotItemDisplayer", -- parameters passed to the ui displayer when it is created
|
||||
Menu="ui:interface:r2ed_base_menu",
|
||||
Prop =
|
||||
{
|
||||
{ Name="SheetId", Type="Number", Visible=false },
|
||||
{ Name="Name", Type="String", MaxNumChar="32", MaxNumChar="32"},
|
||||
{ Name="Desc", Type="String" },
|
||||
{ Name="Comment", Type="String" },
|
||||
},
|
||||
-- rollout header : allows to view & change the item sheet
|
||||
PropertySheetHeader =
|
||||
[[
|
||||
<ctrl type="sheet" id="item_sheet"
|
||||
onclick_r=""
|
||||
value="LOCAL:R2:CURR_PLOT_ITEM"
|
||||
dragable="false"
|
||||
use_quantity="false"
|
||||
use_quality="false"
|
||||
posref="TL TL" x="0"
|
||||
onclick_l="lua"
|
||||
params_l="r2.PlotItemsPanel:changeItem(r2:getSelectedInstance().IndexInParent)"
|
||||
/>
|
||||
]],
|
||||
}
|
||||
|
||||
-- from base class
|
||||
function plotItem.isGlobalObject(this)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local plotItemNamePrefix = i18n.get("uiR2EDPlotItemNamePrefix")
|
||||
|
||||
|
||||
function plotItem.getDisplayName(this)
|
||||
r2.ScratchUCStr:fromUtf8(this.Name)
|
||||
return concatUCString(plotItemNamePrefix, r2.ScratchUCStr)
|
||||
end
|
||||
|
||||
function plotItem.isNextSelectable(this)
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get select bar type
|
||||
function plotItem.SelectBarType(this)
|
||||
return i18n.get("uiR2EDPlotItems"):toUtf8()
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------------------------------
|
||||
-- get first parent that is selectable in the select bar
|
||||
function plotItem.getFirstSelectBarParent(this)
|
||||
return r2:getCurrentAct()
|
||||
end
|
||||
|
||||
function plotItem.getSelectBarIcon(this)
|
||||
return "ICO_mission_purse.tga"
|
||||
end
|
||||
|
||||
r2.registerComponent(plotItem)
|
||||
|
||||
|
||||
|
||||
-- /////////////
|
||||
-- // PRIVATE //
|
||||
-- /////////////
|
||||
|
||||
local itemUCName = ucstring() -- keep a ucstring to avoid creation of string on the fly
|
||||
local itemUCDesc = ucstring() -- keep a ucstring to avoid creation of string on the fly
|
||||
local itemUCComment = ucstring() -- keep a ucstring to avoid creation of string on the fly
|
||||
|
||||
local plotItemSheetToDBPath = {}
|
||||
|
||||
local plotItemSheetNbRef = {} -- for each plot item sheet, store the number of references on it
|
||||
-- each sheet must be use 0 or 1 time in the scenario
|
||||
-- a ref count > 1 may happen during concurrent edition
|
||||
-- in which case the user should be warned that some items are duplicated
|
||||
|
||||
local validItemColor = CRGBA(255, 255, 255)
|
||||
local duplicatedItemColor = CRGBA(255, 0, 0)
|
||||
|
||||
-- /////////////////////////
|
||||
-- // PLOT ITEM DISPLAYER //
|
||||
-- /////////////////////////
|
||||
|
||||
-- Plot item displayer, shared between items
|
||||
r2.PlotItemDisplayerCommon = {}
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- update name for tooltip display + availability
|
||||
function r2.PlotItemDisplayerCommon:updateNameAndAvailability(instance, sheetId)
|
||||
if plotItemSheetNbRef[sheetId] == 0 then
|
||||
r2:setPlotItemInfos(sheetId, i18n.get("uiR2EDPlotItemDefaultName"), ucstring(), ucstring())
|
||||
setDbProp(plotItemSheetToDBPath[sheetId], sheetId) -- available again
|
||||
elseif plotItemSheetNbRef[sheetId] > 1 then
|
||||
-- duplicated slot, may happen during concurrent edition (bad luck)
|
||||
r2:setPlotItemInfos(sheetId, i18n.get("uiR2EDDuplicatedPlotItemName"), ucstring(), ucstring())
|
||||
setDbProp(plotItemSheetToDBPath[sheetId], 0) -- available again
|
||||
r2.PlotItemDisplayerCommon:touch() -- force to refresh the icon display
|
||||
else
|
||||
itemUCName:fromUtf8(instance.Name)
|
||||
itemUCDesc:fromUtf8(instance.Desc)
|
||||
itemUCComment:fromUtf8(instance.Comment)
|
||||
r2:setPlotItemInfos(sheetId, itemUCName, itemUCDesc, itemUCComment)
|
||||
setDbProp(plotItemSheetToDBPath[sheetId], 0) -- available again
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- add a reference on a sheet id for a r2 plot item
|
||||
function r2.PlotItemDisplayerCommon:addRef(sheetId)
|
||||
assert(plotItemSheetNbRef[sheetId] >= 0)
|
||||
plotItemSheetNbRef[sheetId] = plotItemSheetNbRef[sheetId] + 1
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- remove a reference on a sheet id for a r2 plot item
|
||||
-- add a reference on a sheet id
|
||||
function r2.PlotItemDisplayerCommon:decRef(sheetId)
|
||||
assert(plotItemSheetNbRef[sheetId] > 0)
|
||||
plotItemSheetNbRef[sheetId] = plotItemSheetNbRef[sheetId] - 1
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- show the property window and allows to edit the plot item name
|
||||
function r2.PlotItemDisplayerCommon:editPlotItemName(instance)
|
||||
r2:setSelectedInstanceId(instance.InstanceId)
|
||||
r2:showProperties(instance)
|
||||
local propWindow = r2.CurrentPropertyWindow
|
||||
-- tmp : quick & dirty access to the widget ...
|
||||
if propWindow.active then
|
||||
propWindow:blink(1)
|
||||
local editBox = propWindow:find("Name"):find("eb")
|
||||
if editBox then
|
||||
setCaptureKeyboard(editBox)
|
||||
editBox:setSelectionAll()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemDisplayerCommon:onPostCreate(instance)
|
||||
self:touch()
|
||||
setDbProp(plotItemSheetToDBPath[instance.SheetId], 0) -- not available for other plot items
|
||||
-- if created by this client, prompt to enter the name
|
||||
if instance.User.SelfCreate then
|
||||
instance.User.SelfCreate = nil
|
||||
self:editPlotItemName(instance)
|
||||
end
|
||||
--
|
||||
if instance.User.AddedMsg then
|
||||
instance.User.AddedMsg = nil
|
||||
displaySystemInfo(i18n.get("uiR2EDPlotItemAdded"), "BC")
|
||||
r2.PlotItemsPanel:pop()
|
||||
end
|
||||
--
|
||||
instance.User.OldSheetId = instance.SheetId
|
||||
self:addRef(instance.SheetId)
|
||||
self:updateNameAndAvailability(instance, instance.SheetId)
|
||||
if instance == r2:getSelectedInstance() then
|
||||
self:updatePropWindow(instance)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemDisplayerCommon:onErase(instance)
|
||||
self:touch()
|
||||
self:decRef(instance.SheetId)
|
||||
self:updateNameAndAvailability(instance, instance.SheetId)
|
||||
if instance == r2.PlotItemsPanel.ItemSelectCaller then
|
||||
-- discard item selection window if it was opened
|
||||
getUI("ui:interface:r2ed_choose_plot_item").active = false
|
||||
self.ItemSelectCaller = nil
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemDisplayerCommon:onSelect(instance, selected)
|
||||
self:touch()
|
||||
if selected then
|
||||
self:updatePropWindow(instance)
|
||||
end
|
||||
getUI("ui:interface:r2ed_scenario"):find("delete_plot_item").frozen = not selected
|
||||
getUI("ui:interface:r2ed_scenario"):find("plot_item_properties").frozen = not selected
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemDisplayerCommon:updatePropWindow(instance)
|
||||
-- change the icon displayed in the property sheet
|
||||
setDbProp("LOCAL:R2:CURR_PLOT_ITEM:SHEET", instance.SheetId)
|
||||
-- get the property window, maybe not shown yet ...
|
||||
local propWindow = getUI(r2:getDefaultPropertySheetUIPath("PlotItem"))
|
||||
-- update color of the sheet in the property window
|
||||
if propWindow then
|
||||
self:updateSheetColor(propWindow:find("item_sheet"), instance.SheetId)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemDisplayerCommon:onAttrModified(instance, attributeName, indexInArray)
|
||||
self:touch()
|
||||
if attributeName == "SheetId" then
|
||||
self:decRef(instance.User.OldSheetId)
|
||||
self:updateNameAndAvailability(instance, instance.User.OldSheetId)
|
||||
self:addRef(instance.SheetId)
|
||||
instance.User.OldSheetId = instance.SheetId
|
||||
self:updateNameAndAvailability(instance, instance.SheetId)
|
||||
if instance == r2:getSelectedInstance() then
|
||||
self:updatePropWindow(instance)
|
||||
end
|
||||
end
|
||||
if attributeName == "Name" or attributeName == "Desc" or attributeName == "Comment" then
|
||||
self:updateNameAndAvailability(instance, instance.SheetId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemDisplayerCommon:touch()
|
||||
-- update will be done in main loop only
|
||||
r2.UIMainLoop.PlotItemsModified = true
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemDisplayerCommon:updateSheetColor(slot, sheetId)
|
||||
if plotItemSheetNbRef[sheetId] and plotItemSheetNbRef[sheetId] > 1 then
|
||||
slot.color = duplicatedItemColor
|
||||
else
|
||||
slot.color = validItemColor
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemDisplayerCommon:updateAll()
|
||||
if r2.Mode ~= "Edit" then return end
|
||||
r2.PlotItemsPanel.Locked = true
|
||||
local window = getUI("ui:interface:r2ed_scenario")
|
||||
local groupListSheet = window:find("plot_items_list")
|
||||
-- update db sheets for items display
|
||||
local index = 0
|
||||
for k, v in specPairs(r2.Scenario.PlotItems) do
|
||||
setDbProp("LOCAL:R2:PLOT_ITEMS:" .. tostring(index) ..":SHEET", v.SheetId)
|
||||
local slot = groupListSheet["item_" .. tostring(index)]
|
||||
slot.but.pushed = (v == r2:getSelectedInstance()) -- update selection
|
||||
itemUCName:fromUtf8(v.Name)
|
||||
self:updateSheetColor(slot.sheet, v.SheetId)
|
||||
slot.t.uc_hardtext = itemUCName
|
||||
slot.t.global_color = true
|
||||
slot.active=true
|
||||
index = index + 1
|
||||
end
|
||||
-- last slot is the "create new item" slot
|
||||
if index <= maxNumPlotItems - 1 then
|
||||
-- special sheet here for new item creation
|
||||
--setDbProp("LOCAL:R2:PLOT_ITEMS:" .. tostring(index) ..":SHEET", getSheetId("r2_create_new_plot_item.sitem"))
|
||||
setDbProp("LOCAL:R2:PLOT_ITEMS:" .. tostring(index) ..":SHEET", 0)
|
||||
local slot = groupListSheet["item_" .. tostring(index)]
|
||||
slot.but.pushed = false
|
||||
slot.active=true
|
||||
slot.t.uc_hardtext = i18n.get("uiR2EDCreateNewItem")
|
||||
slot.t.global_color = false
|
||||
slot.sheet.color = validItemColor
|
||||
window:find("new_plot_item").frozen = false
|
||||
index = index + 1
|
||||
else
|
||||
window:find("new_plot_item").frozen = true
|
||||
end
|
||||
-- remove remaining sheets
|
||||
while index < maxNumPlotItems do
|
||||
setDbProp("LOCAL:R2:PLOT_ITEMS:" .. tostring(index) ..":SHEET", 0)
|
||||
local slot = groupListSheet["item_" .. tostring(index)]
|
||||
slot.active=false
|
||||
index = index + 1
|
||||
end
|
||||
r2.PlotItemsPanel.Locked = false
|
||||
end
|
||||
|
||||
|
||||
-- Displayer ctor, just return a ref on the shared displayer
|
||||
-- Works because we don't store per displayer infos
|
||||
function r2:plotItemDisplayer()
|
||||
return r2.PlotItemDisplayerCommon
|
||||
end
|
||||
|
||||
-- ///////////////////////////
|
||||
-- // PLOT ITEM UI HANDLING //
|
||||
-- ///////////////////////////
|
||||
|
||||
|
||||
-- UI part
|
||||
r2.PlotItemsPanel =
|
||||
{
|
||||
Locked = false, -- flag to avoid recursive selection
|
||||
CreateMode = "",
|
||||
ItemSelectCaller = nil, -- last plot item that called the 'select item' window (or nil if a new item is created)
|
||||
TargetRefId = -- if CreateMode is "CreateNewAndAffectToRefId", gives the name of the refid to which the item should be affected
|
||||
{
|
||||
Name="",
|
||||
ParentInstanceId = ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemsPanel:selectItem(index)
|
||||
if r2.PlotItemsPanel.Locked then return end -- this is a false selection
|
||||
-- we can't use the sheet here, because concurrent edition may lead to duplicated sheets
|
||||
-- here, a case that wecan resolve only when the scenario is about to be launched...
|
||||
if index > r2.Scenario.PlotItems.Size then
|
||||
debugInfo("bad item index")
|
||||
end
|
||||
if index == r2.Scenario.PlotItems.Size then
|
||||
-- this is the creation slot
|
||||
r2:setSelectedInstanceId("")
|
||||
enableModalWindow(getUICaller(), "ui:interface:r2ed_choose_plot_item")
|
||||
getUICaller().parent.but.pushed= false
|
||||
self.CreateMode = "CreateNew"
|
||||
self.ItemSelectCaller = nil
|
||||
else
|
||||
-- a new item is selected for real
|
||||
r2:setSelectedInstanceId(r2.Scenario.PlotItems[index].InstanceId)
|
||||
r2.PlotItemDisplayerCommon:touch()
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- for plot item ref. widget (see r2.PlotItemsWidget) : pop the item creation
|
||||
-- window, then affect the created widget to a refid (with name 'refIdName' in object with id 'targetInstanceId')
|
||||
function r2.PlotItemsPanel:createNewItemAnAffectToRefId(instanceId, refIdName)
|
||||
if r2.Scenario.PlotItems.Size >= maxNumPlotItems then
|
||||
displaySystemInfo(i18n.get("uiR2EDNoMorePlotItems"), "BC")
|
||||
self:pop()
|
||||
return
|
||||
end
|
||||
enableModalWindow(getUICaller(), "ui:interface:r2ed_choose_plot_item")
|
||||
self.CreateMode = "CreateNewAndAffectToRefId"
|
||||
self.ItemSelectCaller = nil
|
||||
self.TargetRefId.Name = refIdName
|
||||
self.TargetRefId.ParentInstanceId = instanceId
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemsPanel:changeItem(index)
|
||||
self:selectItem(index)
|
||||
-- this is the creation slot
|
||||
if index == r2.Scenario.PlotItems.Size then
|
||||
self.CreateMode = "CreateNew"
|
||||
self.ItemSelectCaller = nil
|
||||
else
|
||||
self.CreateMode = "Modify"
|
||||
self.ItemSelectCaller = r2.Scenario.PlotItems[index]
|
||||
end
|
||||
enableModalWindow(getUICaller(), "ui:interface:r2ed_choose_plot_item")
|
||||
self.ChangeIndex = index
|
||||
|
||||
local window = getUI("ui:interface:r2ed_scenario")
|
||||
local groupListSheet = window:find("plot_items_list")
|
||||
if index <= maxNumPlotItems - 1 then
|
||||
local slot = groupListSheet["item_" .. tostring(index)]
|
||||
slot.but.pushed = false
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemsPanel:rightClickItem(index)
|
||||
if r2.PlotItemsPanel.Locked then return end -- this is a false selection
|
||||
-- we can't use the sheet here, because concurrent edition may lead to duplicated sheets
|
||||
-- here, a case that wecan resolve only when the scenario is about to be launched...
|
||||
if index > r2.Scenario.PlotItems.Size then
|
||||
debugInfo("bad item index")
|
||||
end
|
||||
if index == r2.Scenario.PlotItems.Size then
|
||||
-- this is the creation slot -> no-op
|
||||
return
|
||||
else
|
||||
-- a new item is selected for real
|
||||
r2:setSelectedInstanceId(r2.Scenario.PlotItems[index].InstanceId)
|
||||
r2:displayContextMenu()
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- private
|
||||
function r2.PlotItemsPanel:createNewItem(sheetDbPath)
|
||||
local sheetId = getDbProp(sheetDbPath .. ":SHEET")
|
||||
if self.CreateMode == "CreateNew" then
|
||||
local newItem = self:requestNewItem(sheetId)
|
||||
-- since created from this client, add a cookie to pop the property window when the item is created for real
|
||||
r2:setCookie(newItem.InstanceId, "SelfCreate", true)
|
||||
elseif self.CreateMode == "CreateNewAndAffectToRefId" then
|
||||
r2.requestNewAction(i18n.get("uiR2EDCreatePlotItemAction"))
|
||||
local newItem = self:requestNewItem(sheetId)
|
||||
r2:setCookie(newItem.InstanceId, "AddedMsg", true)
|
||||
r2.requestSetNode(self.TargetRefId.ParentInstanceId, self.TargetRefId.Name, newItem.InstanceId)
|
||||
else
|
||||
r2.requestNewAction(i18n.get("uiR2EDChangeIconAction"))
|
||||
r2.requestSetNode(r2.Scenario.PlotItems[self.ChangeIndex].InstanceId, "SheetId", sheetId)
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- private: create a new item in the plot item list
|
||||
function r2.PlotItemsPanel:requestNewItem(sheetId)
|
||||
r2.requestNewAction(i18n.get("uiR2EDCreateNewPlotItemAction"))
|
||||
local newItem = r2.newComponent("PlotItem")
|
||||
newItem.SheetId = sheetId
|
||||
newItem.Name = i18n.get("uiR2EDPlotItemDefaultName"):toUtf8()
|
||||
newItem.Desc = ""
|
||||
newItem.Comment = ""
|
||||
r2.requestInsertNode(r2.Scenario.InstanceId, "PlotItems", -1, "", newItem)
|
||||
return newItem
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
function r2.PlotItemsPanel:reinit()
|
||||
-- map sheetid to the good slot in the db
|
||||
plotItemSheetToDBPath = {}
|
||||
plotItemSheetNbRef = {}
|
||||
--local window = getUI("ui:interface:r2ed_scenario")
|
||||
--local groupListSheet = window:find("plot_items_list")
|
||||
for k = 0, maxNumPlotItemSheets - 1 do
|
||||
local refDbPath = "LOCAL:R2:REFERENCE_PLOT_ITEMS:" .. tostring(k) ..":SHEET"
|
||||
local availableDbPath = "LOCAL:R2:AVAILABLE_PLOT_ITEMS:" .. tostring(k) ..":SHEET"
|
||||
local sheetId = getDbProp(refDbPath)
|
||||
local defaultPlotItemName = i18n.get("uiR2EDPlotItemDefaultName")
|
||||
if sheetId ~= 0 then
|
||||
plotItemSheetToDBPath[sheetId] = availableDbPath
|
||||
plotItemSheetNbRef[sheetId] = 0
|
||||
r2:setPlotItemInfos(sheetId, defaultPlotItemName, ucstring(), ucstring())
|
||||
setDbProp(availableDbPath, getDbProp(refDbPath))
|
||||
end
|
||||
--local slot = groupListSheet["item_" .. tostring(k)]
|
||||
--slot.active = false
|
||||
end
|
||||
-- empty all slots
|
||||
for k = 0, maxNumPlotItems - 1 do
|
||||
setDbProp("LOCAL:R2:PLOT_ITEMS:" .. tostring(k) .. ":SHEET", 0)
|
||||
end
|
||||
--
|
||||
getUI("ui:interface:r2ed_scenario"):find("delete_plot_item").frozen = true
|
||||
getUI("ui:interface:r2ed_scenario"):find("plot_item_properties").frozen = true
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
-- pop the plot item tab
|
||||
function r2.PlotItemsPanel:pop()
|
||||
local scenarioWnd = getUI("ui:interface:r2ed_scenario")
|
||||
if not scenarioWnd.active or scenarioWnd:find("scenario_tabs").selection ~= 3 then
|
||||
scenarioWnd.active = 1
|
||||
scenarioWnd:blink(1)
|
||||
scenarioWnd:find("scenario_tabs").selection = 3
|
||||
end
|
||||
end
|
||||
|
@ -1,304 +0,0 @@
|
||||
-- Definition file for primitives rendering
|
||||
|
||||
-- enums
|
||||
r2.PrimRender = {}
|
||||
r2.PrimRender.Shape = { Star = 0, PolyLine = 1, ClosedPolyLine = 2 }
|
||||
r2.PrimRender.WrapMode =
|
||||
{
|
||||
Repeat = 0,
|
||||
Centered = 1, -- centered & clamped texture
|
||||
Scaled = 2 -- the texture corver the whole quad surface on the world map (not supported for decals, resumes to Repeat)
|
||||
}
|
||||
|
||||
|
||||
-- definition of a primitive look
|
||||
-- should be passed as a parameter to the visual displayer of type R2ED::CDisplayerVisualGroup
|
||||
r2.DefaultPrimLook =
|
||||
{
|
||||
Shape = r2.PrimRender.Shape.Star,
|
||||
VertexShapeName = "",
|
||||
VertexShapeScale = 1,
|
||||
VertexLook =
|
||||
{
|
||||
DecalTexture = "",
|
||||
DecalSize = 1,
|
||||
DecalColor = CRGBA(255, 255, 255),
|
||||
DecalDistToEdgeDecal = 0,
|
||||
WorldMapTexture = "",
|
||||
WorldMapColor = CRGBA(255, 255, 255)
|
||||
},
|
||||
FirstVertexLook =
|
||||
{
|
||||
DecalTexture = "",
|
||||
DecalSize = 1,
|
||||
DecalColor = CRGBA(255, 255, 255),
|
||||
DecalDistToEdgeDecal = 0,
|
||||
WorldMapTexture = "",
|
||||
WorldMapColor = CRGBA(255, 255, 255)
|
||||
},
|
||||
EdgeLook =
|
||||
{
|
||||
ShapeName = "",
|
||||
ShapeScale = 1,
|
||||
DecalTexture = "",
|
||||
DecalUScale = 1,
|
||||
DecalWidth = 1,
|
||||
WorldMapTexture = "",
|
||||
WorldMapWidth = 0,
|
||||
WorldMapColor = CRGBA(255, 255, 255),
|
||||
WrapMode = r2.PrimRender.WrapMode.Repeat,
|
||||
VorldMapFiltered = true
|
||||
},
|
||||
LastEdgeIsValid = true
|
||||
}
|
||||
|
||||
-- look for region
|
||||
r2.PrimRender.RegionLook =
|
||||
{
|
||||
Shape = r2.PrimRender.Shape.ClosedPolyLine,
|
||||
VertexLook =
|
||||
{
|
||||
},
|
||||
EdgeLook =
|
||||
{
|
||||
DecalTexture = "r2_zone_edge.tga",
|
||||
DecalColor = CRGBA(0, 255, 0, 255),
|
||||
DecalUScale = 2,
|
||||
DecalWidth = 0.1,
|
||||
WrapMode = r2.PrimRender.WrapMode.Repeat,
|
||||
WorldMapTexture = "r2_map_zone_edge.tga",
|
||||
WorldMapWidth = 1,
|
||||
WorldMapColor = CRGBA(0, 255, 0, 255)
|
||||
}
|
||||
}
|
||||
|
||||
-- look for invalid region (self intersecting)
|
||||
r2.PrimRender.RegionInvalidLook =
|
||||
{
|
||||
Shape = r2.PrimRender.Shape.ClosedPolyLine,
|
||||
VertexLook =
|
||||
{
|
||||
DecalTexture = "r2_zone_vertex_invalid.tga",
|
||||
DecalSize = 0.2,
|
||||
},
|
||||
EdgeLook =
|
||||
{
|
||||
DecalTexture = "r2_zone_edge.tga",
|
||||
DecalColor = CRGBA(255, 0, 255),
|
||||
DecalUScale = 2,
|
||||
DecalWidth = 0.1,
|
||||
WrapMode = r2.PrimRender.WrapMode.Repeat,
|
||||
WorldMapTexture = "r2_map_edge_stipple.tga",
|
||||
WorldMapWrapMode = r2.PrimRender.WrapMode.Repeat,
|
||||
WorldMapUScale = 0.5,
|
||||
WorldMapWidth = 1,
|
||||
WorldMapColor = CRGBA(127, 127, 127)
|
||||
}
|
||||
}
|
||||
|
||||
-- look for region being drawn
|
||||
r2.PrimRender.RegionCreateLook = clone(r2.PrimRender.RegionLook)
|
||||
r2.PrimRender.RegionCreateLook.VertexShapeName = "r2_region_vertex.shape"
|
||||
r2.PrimRender.RegionCreateLook.VertexShapeScale = 0.25
|
||||
r2.PrimRender.RegionCreateLook.VertexShapeScale = 0.25
|
||||
r2.PrimRender.RegionCreateLook.VertexLook.WorldMapTexture ="r2_icon_map_entity_small.tga"
|
||||
r2.PrimRender.RegionCreateLook.Shape = r2.PrimRender.Shape.PolyLine
|
||||
--r2_icon_map_entity_small.tga
|
||||
r2.PrimRender.RegionCreateInvalidLook= clone(r2.PrimRender.RegionInvalidLook)
|
||||
r2.PrimRender.RegionCreateInvalidLook.VertexShapeName = ""
|
||||
r2.PrimRender.RegionCreateInvalidLook.Shape = r2.PrimRender.Shape.PolyLine
|
||||
r2.PrimRender.RegionCreateInvalidLook.VertexLook.WorldMapTexture ="r2_icon_map_entity_small.tga"
|
||||
r2.PrimRender.RegionCreateInvalidLook.EdgeLook.WorldMapColor = CRGBA(255, 0, 0)
|
||||
-- look when a region can be closed (mouse is on first vertex and there are at least 3 points)
|
||||
r2.PrimRender.RegionCreateCanCloseLook = clone(r2.PrimRender.RegionCreateLook)
|
||||
r2.PrimRender.RegionCreateCanCloseLook.EdgeLook.DecalColor = CRGBA(255, 255, 0)
|
||||
r2.PrimRender.RegionCreateCanCloseLook.EdgeLook.WorldMapColor = CRGBA(255, 255, 0)
|
||||
r2.PrimRender.RegionCreateCanCloseLook.VertexLook.WorldMapTexture ="r2_icon_map_entity_small.tga"
|
||||
r2.PrimRender.RegionCreateCanCloseLook.Shape = r2.PrimRender.Shape.ClosedPolyLine
|
||||
|
||||
|
||||
|
||||
-- look for road
|
||||
r2.PrimRender.RoadLook =
|
||||
{
|
||||
Shape = r2.PrimRender.Shape.PolyLine,
|
||||
VertexLook =
|
||||
{
|
||||
},
|
||||
EdgeLook =
|
||||
{
|
||||
DecalTexture = "r2_path.tga",
|
||||
DecalColor = CRGBA(0, 127, 255, 160),
|
||||
DecalUScale = 0.25,
|
||||
DecalWidth = 0.4,
|
||||
DecalWrapMode = r2.PrimRender.WrapMode.Repeat,
|
||||
WorldMapTexture = "r2_map_edge_arrow.tga",
|
||||
WorldMapWrapMode = r2.PrimRender.WrapMode.Centered,
|
||||
WorldMapUScale = 0.3,
|
||||
WorldMapWidth = 3.5,
|
||||
WorldMapColor = CRGBA(0, 127, 255, 160)
|
||||
},
|
||||
ClipDownFacing = true
|
||||
}
|
||||
|
||||
r2.PrimRender.RoadLookInvalid = clone(r2.PrimRender.RegionInvalidLook)
|
||||
r2.PrimRender.RoadLookInvalid.EdgeLook.WorldMapColor = CRGBA(127, 127, 127, 127)
|
||||
r2.PrimRender.RoadLookInvalid.EdgeLook.WorldMapTexture = "r2_map_edge_stipple.tga"
|
||||
r2.PrimRender.RoadLookInvalid.Shape = r2.PrimRender.Shape.PolyLine
|
||||
r2.PrimRender.RoadLookInvalid.ClipDownFacing = true
|
||||
|
||||
r2.PrimRender.RoadLookInaccessible = clone(r2.PrimRender.RoadLookInvalid)
|
||||
r2.PrimRender.RoadLookInaccessible.EdgeLook.WorldMapTexture = "*accessibility_texture*"
|
||||
r2.PrimRender.RoadLookInaccessible.EdgeLook.DecalTexture = "*accessibility_texture*"
|
||||
r2.PrimRender.RoadLookInaccessible.EdgeLook.WorldMapcolor = CRGBA(255, 0, 255, 255)
|
||||
r2.PrimRender.RoadLookInaccessible.EdgeLook.WorldMapWidth = 2
|
||||
r2.PrimRender.RoadLookInaccessible.EdgeLook.WorldMapFiltered = false
|
||||
r2.PrimRender.RoadLookInaccessible.EdgeLook.DecalFiltered = false
|
||||
r2.PrimRender.RoadLookInaccessible.ClipDownFacing = true
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- look for road being drawn
|
||||
r2.PrimRender.RoadCreateLook = clone(r2.PrimRender.RoadLook)
|
||||
r2.PrimRender.RoadCreateLook.VertexShapeName = "r2_road_flag.shape"
|
||||
r2.PrimRender.RoadCreateLook.VertexShapeScale = 0.4
|
||||
r2.PrimRender.RoadCreateLook.VertexLook.WorldMapTexture ="r2_icon_map_entity_small.tga"
|
||||
r2.PrimRender.RoadCreateInvalidLook = clone(r2.PrimRender.RegionCreateInvalidLook)
|
||||
|
||||
|
||||
|
||||
-- look for group
|
||||
r2.PrimRender.GroupLook =
|
||||
{
|
||||
Shape = r2.PrimRender.Shape.Star,
|
||||
VertexLook =
|
||||
{
|
||||
DecalTexture = "r2_selection_circle.tga",
|
||||
DecalSize = 0.5,
|
||||
DecalDistToEdgeDecal = 0.45,
|
||||
DecalColor = CRGBA(0, 255, 0, 255),
|
||||
},
|
||||
FirstVertexLook =
|
||||
{
|
||||
DecalTexture = "r2_selection_circle_double.tga",
|
||||
DecalSize = 0.7,
|
||||
DecalDistToEdgeDecal = 0.62,
|
||||
DecalColor = CRGBA(0, 255, 0, 255),
|
||||
},
|
||||
EdgeLook =
|
||||
{
|
||||
DecalTexture = "r2_arrow.tga",
|
||||
DecalUScale = 0.5,
|
||||
DecalWidth = 0.4,
|
||||
DecalWrapMode = r2.PrimRender.WrapMode.Centered,
|
||||
DecalColor = CRGBA(0, 255, 0, 255),
|
||||
WorldMapTexture = "r2_map_edge_arrow.tga",
|
||||
WorldMapWrapMode = r2.PrimRender.WrapMode.Centered,
|
||||
WorldMapUScale = -0.6,
|
||||
WorldMapWidth = 2.5,
|
||||
WorldMapColor = CRGBA(0, 255, 0, 160)
|
||||
},
|
||||
ClipDownFacing = true
|
||||
}
|
||||
|
||||
-- look for auto group
|
||||
r2.PrimRender.AutoGroupLook = clone(r2.PrimRender.GroupLook)
|
||||
r2.PrimRender.AutoGroupLook.VertexLook.DecalColor = CRGBA(0, 255, 0, 80)
|
||||
r2.PrimRender.AutoGroupLook.FirstVertexLook.DecalColor = CRGBA(0, 255, 0, 80)
|
||||
r2.PrimRender.AutoGroupLook.EdgeLook.DecalColor = CRGBA(0, 255, 0, 80)
|
||||
r2.PrimRender.AutoGroupLook.EdgeLook.WorldMapColor = CRGBA(0, 255, 0, 80)
|
||||
|
||||
|
||||
-- hightlight / selection boxs
|
||||
r2.PrimRender.SelectBoxLook =
|
||||
{
|
||||
Shape = r2.PrimRender.Shape.ClosedPolyLine,
|
||||
VertexLook =
|
||||
{
|
||||
DecalTexture = "r2_zone_corner.tga",
|
||||
DecalSize = 0.1,
|
||||
--DecalDistToEdgeDecal = 0.45,
|
||||
DecalColor = CRGBA(255, 0, 0, 255),
|
||||
},
|
||||
FirstVertexLook =
|
||||
{
|
||||
DecalTexture = "r2_zone_corner.tga",
|
||||
DecalSize = 0.1,
|
||||
--DecalDistToEdgeDecal = 0.62,
|
||||
DecalColor = CRGBA(255, 0, 0, 255),
|
||||
},
|
||||
EdgeLook =
|
||||
{
|
||||
DecalTexture = "r2_zone_edge.tga",
|
||||
DecalUScale = 0.5,
|
||||
DecalWidth = 0.1,
|
||||
DecalWrapMode = r2.PrimRender.WrapMode.Centered,
|
||||
DecalColor = CRGBA(255, 0, 0, 255),
|
||||
WorldMapTexture = "r2_map_edge_arrow.tga",
|
||||
WorldMapWrapMode = r2.PrimRender.WrapMode.Centered,
|
||||
WorldMapUScale = -0.6,
|
||||
WorldMapWidth = 2.5,
|
||||
WorldMapColor = CRGBA(255, 0, 0, 40)
|
||||
}
|
||||
}
|
||||
|
||||
-- nb : edge colors ignored for highlight & slect box : those are taken from hightlight & select decal instead (they are animated)
|
||||
|
||||
r2.PrimRender.HighlightBoxLook = clone(r2.PrimRender.SelectBoxLook)
|
||||
r2.PrimRender.HighlightBoxLook.VertexLook.DecalColor = CRGBA(255, 255, 255, 255)
|
||||
r2.PrimRender.HighlightBoxLook.FirstVertexLook.DecalColor = CRGBA(255, 255, 255, 255)
|
||||
r2.PrimRender.HighlightBoxLook.EdgeLook.DecalColor = CRGBA(255, 255, 255, 255)
|
||||
r2.PrimRender.HighlightBoxLook.EdgeLook.WorldMapColor = CRGBA(255, 255, 255, 40)
|
||||
|
||||
|
||||
r2.PrimRender.SelectBoxLook.EdgeLook.DecalTexture = "r2_select_edge.tga"
|
||||
r2.PrimRender.SelectBoxLook.EdgeLook.DecalUScale = 2
|
||||
r2.PrimRender.SelectBoxLook.EdgeLook.DecalWidth = 0.15
|
||||
r2.PrimRender.SelectBoxLook.VertexLook.DecalSize = 0.15
|
||||
r2.PrimRender.SelectBoxLook.FirstVertexLook.DecalSize = 0.15
|
||||
|
||||
|
||||
r2.PrimRender.ComponentRegionLook =
|
||||
{
|
||||
Shape = r2.PrimRender.Shape.ClosedPolyLine,
|
||||
VertexLook =
|
||||
{
|
||||
},
|
||||
EdgeLook =
|
||||
{
|
||||
DecalTexture = "r2_zone_edge.tga",
|
||||
DecalColor = CRGBA(0, 255, 0, 127),
|
||||
DecalUScale = 2,
|
||||
DecalWidth = 0.1,
|
||||
WrapMode = r2.PrimRender.WrapMode.Repeat,
|
||||
WorldMapTexture = "r2_map_zone_edge.tga",
|
||||
WorldMapWidth = 1,
|
||||
WorldMapColor = CRGBA(0, 255, 0, 32)
|
||||
}
|
||||
}
|
||||
|
||||
r2.PrimRender.ComponentRegionInvalidLook =
|
||||
{
|
||||
Shape = r2.PrimRender.Shape.ClosedPolyLine,
|
||||
VertexLook =
|
||||
{
|
||||
},
|
||||
EdgeLook =
|
||||
{
|
||||
DecalTexture = "r2_zone_edge.tga",
|
||||
DecalColor = CRGBA(255, 0, 0, 127),
|
||||
DecalUScale = 2,
|
||||
DecalWidth = 0.1,
|
||||
WrapMode = r2.PrimRender.WrapMode.Repeat,
|
||||
WorldMapTexture = "r2_map_edge_stipple.tga",
|
||||
WorldMapWrapMode = r2.PrimRender.WrapMode.Repeat,
|
||||
WorldMapUScale = 0.5,
|
||||
WorldMapWidth = 1,
|
||||
WorldMapColor = CRGBA(255, 0, 0, 32)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
-- A reference id : object like a string but for reference ids
|
||||
|
||||
|
||||
r2.RefIdMetatable =
|
||||
{
|
||||
__eq = function(op1, op2) return op1.Value == op2.Value end,
|
||||
__le = function(op1, op2) return op1.Value <= op2.Value end,
|
||||
__lt = function(op1, op2) return op1.Value < op2.Value end,
|
||||
__tostring = function(op) return op.Value end
|
||||
}
|
||||
|
||||
|
||||
|
||||
function r2.RefId(value)
|
||||
assert(value ~= r2) -- in case of r2:RefId(value)
|
||||
if value == nil then value = "" end
|
||||
local refId = { Value = tostring(value) }
|
||||
setmetatable(refId, r2.RefIdMetatable)
|
||||
return refId
|
||||
end
|
||||
|
||||
function r2.isRefId(value)
|
||||
return type(value) == "table" and getmetatable(value) == r2.RefIdMetatable
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -1,290 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,164 +0,0 @@
|
||||
local registerFeature = function()
|
||||
local feature = {}
|
||||
feature.Name = "TextManager"
|
||||
|
||||
feature.Description = "A little texts manager"
|
||||
feature.Components=
|
||||
{
|
||||
{
|
||||
Name="TextManager",
|
||||
Prop=
|
||||
{
|
||||
{Name="InstanceId",Type="String"},
|
||||
{Name="Texts",Type="Table"},
|
||||
}
|
||||
},
|
||||
{
|
||||
Name="TextManagerEntry",
|
||||
Prop=
|
||||
{
|
||||
{Name="InstanceId", Type="String" },
|
||||
{Name="Text",Type="String"},
|
||||
{Name="Count",Type="Number"}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
--returns nil if the text is still in the textManager
|
||||
--else, return a new entry, not inserted in the TextManager
|
||||
feature.checkText = function(textManager,text)
|
||||
local texts = r2.Scenario.Texts.Texts
|
||||
k,entry = next(texts,nil)
|
||||
while k ~=nil do
|
||||
local textEntry = entry.Text
|
||||
if textEntry==text
|
||||
then
|
||||
return entry
|
||||
end
|
||||
k,entry = next(texts,k)
|
||||
end
|
||||
entry = r2.newComponent("TextManagerEntry")
|
||||
entry.Text=text
|
||||
entry.Count=0
|
||||
return entry
|
||||
end
|
||||
|
||||
feature.getText = function (textManager, entry)
|
||||
|
||||
debugInfo("feature.getText")
|
||||
|
||||
for i=0, textManager.Texts.Size-1 do
|
||||
|
||||
local text = textManager.Texts[i]
|
||||
|
||||
if text.InstanceId == entry
|
||||
then
|
||||
return text.Text
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
--add a text to the text manager.
|
||||
--if the text exist, increment its counter
|
||||
feature.addText = function(textManager,text)
|
||||
local max = table.getn(textManager.Texts)
|
||||
local entry
|
||||
|
||||
for i=1,max do
|
||||
entry = textManager.Texts[i]
|
||||
if entry.Text==text
|
||||
then
|
||||
entry.Count = entry.Count+1
|
||||
return entry
|
||||
end
|
||||
end
|
||||
|
||||
entry = r2.newComponent("TextManagerEntry")
|
||||
entry.Text=text
|
||||
entry.Count=1
|
||||
table.insert(textManager.Texts,entry)
|
||||
return entry
|
||||
end
|
||||
|
||||
--decrement the counter of a text.
|
||||
--if this counter==0, remove the text from the TextManager
|
||||
feature.removeText = function(textManager, text)
|
||||
|
||||
for i=0,textManager.Texts.Size-1 do
|
||||
local entry = textManager.Texts[i]
|
||||
if entry.Text==text then
|
||||
|
||||
local newCount = entry.Count-1
|
||||
|
||||
if newCount==0 then
|
||||
r2.requestEraseNode(entry.InstanceId, "", -1)
|
||||
else
|
||||
r2.requestSetNode(entry.InstanceId, "Count", newCount)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
feature.Translator = function(context)
|
||||
local comp = context.Feature
|
||||
local texts = context.Feature.Texts
|
||||
local entry
|
||||
local rtTextMgr = context.RtScenario.Texts
|
||||
--for each entry
|
||||
local k,v = next(texts,nil)
|
||||
while v~=nil do
|
||||
if k~="Keys"
|
||||
then
|
||||
--create and fill a RT entry
|
||||
entry = r2.newComponent("RtEntryText")
|
||||
entry.Text = v.Text
|
||||
--insert it in the RT text manager
|
||||
table.insert(rtTextMgr.Texts,entry)
|
||||
local tmp = {}
|
||||
table.insert(tmp,v.InstanceId)
|
||||
table.insert(tmp,entry.Id)
|
||||
table.insert(context.TextTranslateId,tmp)
|
||||
end
|
||||
k,v = next(texts,k)
|
||||
end
|
||||
if table.getn(context.TextTranslateId)==0
|
||||
then
|
||||
debugInfo("translator:: pas d'entrees dans la table!!!")
|
||||
end
|
||||
end
|
||||
|
||||
-- ?
|
||||
feature.getRtId = function(context, instanceId)
|
||||
local tab = context.TextTranslateId
|
||||
assert(tab~=nil)
|
||||
for k,v in pairs(tab)
|
||||
do
|
||||
if instanceId == v[1]
|
||||
then
|
||||
return v[2]
|
||||
end
|
||||
end
|
||||
local max = table.getn(tab)
|
||||
if max==0
|
||||
then
|
||||
debugInfo(colorTag(255, 255, 0).."WAR: The text table is empty.")
|
||||
return
|
||||
end
|
||||
|
||||
for i=1,max do
|
||||
if instanceId == tab[i][1]
|
||||
then
|
||||
return tab[i][2]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return feature
|
||||
end
|
||||
|
||||
r2.Features["TextManager"] = registerFeature()
|
File diff suppressed because it is too large
Load Diff
@ -1,97 +0,0 @@
|
||||
-- In this file we define functions that serves as an interface between the framework of the
|
||||
-- editor (C++ code), and the ui. Ideally the C++ should never manipulate the ui directly.
|
||||
-- It should rather call functions in this interface to do the job.
|
||||
-- This allow for easy customisation, because users can replace any function with their
|
||||
-- own lua code (possibly forwarding to the previous function).
|
||||
-- This file works in close relation with the r2.xml file with contains the actual ui
|
||||
|
||||
|
||||
|
||||
-------------
|
||||
-------------
|
||||
-- GLOBALS --
|
||||
-------------
|
||||
-------------
|
||||
|
||||
-- The following table is intended to contain ui related classes & functions
|
||||
-- For now the ui stuffs are being migrated into this table
|
||||
-- TODO nico : move ui stuff here to 'depolute' the r2 table
|
||||
|
||||
r2.ui = {}
|
||||
|
||||
|
||||
-----------------
|
||||
-----------------
|
||||
-- GLOBAL INIT --
|
||||
-----------------
|
||||
-----------------
|
||||
|
||||
function r2:initUI()
|
||||
self:buildPaletteUI()
|
||||
r2.FeatureTree.buildFeatureTreeUI()
|
||||
r2:refreshWindowButtons()
|
||||
--updateAllLocalisedElements()
|
||||
-- init all forms
|
||||
for k, form in pairs(r2.Forms) do
|
||||
form.NameToProp = {}
|
||||
for l, prop in pairs(form.Prop) do
|
||||
form.NameToProp[prop.Name] = prop
|
||||
end
|
||||
end
|
||||
-- make the admin window point on the main page (obsolete, replaced by Session Browser)
|
||||
-- if browseRingWindowHomePage ~= nil then
|
||||
-- browseRingWindowHomePage()
|
||||
-- else
|
||||
-- debugInfo("---> ERROR: what is browseRingWindowHomePage?")
|
||||
-- end
|
||||
r2.SelectBar:init()
|
||||
local paletteWnd = getUI("ui:interface:r2ed_palette")
|
||||
local debugPanel = paletteWnd:find("debug_panel").button_enclosing
|
||||
local extDbg = (config.R2EDExtendedDebug == 1)
|
||||
|
||||
local chooseLocationWnd = getUI("ui:interface:r2ed_acts")
|
||||
local ringLevelDebug = chooseLocationWnd:find("ring_level")
|
||||
|
||||
if debugPanel then
|
||||
debugPanel.reset_ed.active = extDbg
|
||||
debugPanel.reset_ed_and_reload_ui.active = extDbg
|
||||
debugPanel.reload_core.active = extDbg
|
||||
debugPanel.inspect_r2.active = extDbg
|
||||
debugPanel.reset_display.active = extDbg
|
||||
ringLevelDebug.active = extDbg
|
||||
-- debugPanel.test.active = extDbg
|
||||
-- debugPanel.create_scenario.active = extDbg
|
||||
-- debugPanel.create_act.active = extDbg
|
||||
-- debugPanel.connect_scenario.active = extDbg
|
||||
-- debugPanel.reconnect_scenario.active = extDbg
|
||||
-- debugPanel.list_adventures.active = extDbg
|
||||
end
|
||||
paletteWnd:find("tab2").active = true
|
||||
paletteWnd:find("tab2_bm").active = true
|
||||
paletteWnd:find("tab4").active = extDbg
|
||||
paletteWnd:find("tab4_bm").active = extDbg
|
||||
end
|
||||
|
||||
|
||||
-----------
|
||||
-----------
|
||||
-- TESTS --
|
||||
-----------
|
||||
-----------
|
||||
function testTree()
|
||||
local headNode = SNode()
|
||||
local rootNode = SNode()
|
||||
headNode:addChild(rootNode)
|
||||
rootNode.Text = "Root"
|
||||
rootNode.Opened = true
|
||||
rootNode.Bitmap = "ICO_Atys.tga"
|
||||
local tree = getUI(r2.instanceTree);
|
||||
for i = 1,3 do
|
||||
local son = SNode()
|
||||
son.Text = "Node " .. tostring(i)
|
||||
rootNode:addChild(son)
|
||||
end
|
||||
tree:setRootNode(headNode)
|
||||
tree:forceRebuild()
|
||||
end
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,120 +0,0 @@
|
||||
---------------------------------------------------------------------------------------------
|
||||
-- UI for act management by the DM (animation mode)
|
||||
|
||||
|
||||
|
||||
-- class for runtime acts ui
|
||||
r2.ui.AnimActs =
|
||||
{
|
||||
ChosenActIndex = -1, -- the last act that was chosen in the act popup menu
|
||||
}
|
||||
|
||||
------------
|
||||
-- PUBLIC --
|
||||
------------
|
||||
|
||||
----------------------------------------------------------------------------------------------
|
||||
-- Called by the ui when the user clicks on the 'acts' button in animation mode
|
||||
-- This will pop a menu to choose between available acts
|
||||
function r2.ui.AnimActs:popMenu()
|
||||
local menuName = "ui:interface:r2ed_anim_acts_menu"
|
||||
local menu = getUI(menuName)
|
||||
local rootMenu = menu:getRootMenu()
|
||||
rootMenu:reset()
|
||||
local acts = self:getActTable()
|
||||
--
|
||||
if not acts then return end
|
||||
for k = 2, table.getn(acts) do
|
||||
if acts[k].Name == "" then
|
||||
r2.ScratchUCStr = i18n.get("uiR2EDUnamedAct")
|
||||
else
|
||||
r2.ScratchUCStr:fromUtf8(acts[k].Name)
|
||||
end
|
||||
rootMenu:addLine(r2.ScratchUCStr, "lua", "r2.ui.AnimActs:chooseAct(" .. tostring(k) .. ")", "")
|
||||
end
|
||||
launchContextMenuInGame(menuName)
|
||||
local but = getUI("ui:interface:r2ed_testbar"):find("r2ed_anim_acts")
|
||||
but:updateCoords()
|
||||
menu.x = but.x_real
|
||||
menu.y = but.y_real + but.w_real
|
||||
rootMenu.x = 0
|
||||
rootMenu.y = 0
|
||||
menu:updateCoords()
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------
|
||||
-- called by the acts context menu when one act has been chosen
|
||||
function r2.ui.AnimActs:chooseAct(index)
|
||||
|
||||
-- see if current act differs in location or season
|
||||
|
||||
-- acts[1] <==> permanent content
|
||||
if index == 1 then return end
|
||||
self.ChosenActIndex = index - 1
|
||||
|
||||
local acts = self:getActTable()
|
||||
|
||||
|
||||
local currentActIndex = r2.getCurrentActIndex() + 1
|
||||
|
||||
if acts[index].LocationId ~= acts[currentActIndex].LocationId then
|
||||
validMessageBox(i18n.get("uiR2EDActChangeWarning"), "lua", "r2.ui.AnimActs:validateActChange()", "", "", "ui:interface")
|
||||
return
|
||||
end
|
||||
|
||||
self:validateActChange()
|
||||
-- debugInfo(tostring(acts[index].Island))
|
||||
-- debugInfo(tostring(r2:getCurrentIslandName()))
|
||||
-- debugInfo(tostring(acts[index].Season))
|
||||
-- debugInfo(tostring(getServerSeason()))
|
||||
-- local targetSeason
|
||||
-- if acts[index].Season == 0 then
|
||||
-- targetSeason = getAutoSeason()
|
||||
-- else
|
||||
-- targetSeason = acts[index].Season
|
||||
-- end
|
||||
--
|
||||
-- if acts[index].Island ~= r2:getCurrentIslandName() or
|
||||
-- targetSeason ~= computeCurrSeason() then
|
||||
-- -- warn the user that changing to this act will cause a teleport
|
||||
-- validMessageBox(i18n.get("uiR2EDActChangeWarning"), "lua", "r2.ui.AnimActs:validateActChange()", "", "", "ui:interface")
|
||||
-- return
|
||||
-- end
|
||||
-- self:validateActChange()
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------
|
||||
function r2.ui.AnimActs:validateActChange()
|
||||
r2.requestStartAct(self.ChosenActIndex)
|
||||
end
|
||||
|
||||
-------------
|
||||
-- PRIVATE --
|
||||
-------------
|
||||
|
||||
-- private : Place holder for local mode : list of acts
|
||||
--
|
||||
---- Season enum is as follow :
|
||||
-- 0 -> auto, computed locally from the current day (or not received from server yet)
|
||||
-- 1 -> server force spring
|
||||
-- 2 -> server force summer
|
||||
-- 3 -> server force autumn
|
||||
-- 4 -> server force winter
|
||||
local dummyActsList =
|
||||
{
|
||||
{ Name = "Act 1", Island = "uiR2_Lakes01", Season=0 },
|
||||
{ Name = "Act 2", Island = "uiR2_Desert01", Season=1 },
|
||||
{ Name = "Act 3", Island = "uiR2_Lakes10", Season=2 },
|
||||
{ Name = "Act 4", Island = "uiR2_Lakes11", Season=3 },
|
||||
{ Name = "Act 5", Island = "uiR2_Lakes12", Season=4 }
|
||||
}
|
||||
|
||||
----------------------------------------------------------------------------------------------
|
||||
function r2.ui.AnimActs:getActTable()
|
||||
-- if false then -- config.Local == 1 then
|
||||
-- return dummyActsList
|
||||
-- else
|
||||
-- return r2.AnimGlobals.Acts
|
||||
-- end
|
||||
return r2.AnimGlobals.Acts
|
||||
end
|
@ -1,185 +0,0 @@
|
||||
-- Update of the anim bar found in animation mode
|
||||
|
||||
|
||||
r2.ui.AnimBar = {} -- the anim bar class
|
||||
|
||||
--------------
|
||||
-- PUBLIC --
|
||||
--------------
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
-- Update the anim bar content, except for the contextual actions (those that apply on the current selected entity)
|
||||
function r2.ui.AnimBar:update()
|
||||
local testModeAvailable = false
|
||||
local isDm = false
|
||||
if r2.Mode == "DM" or r2.Mode == "AnimationModeDm" then isDm = true end
|
||||
if r2.Mode == "DM" or r2.Mode == "AnimationModeDm" then -- Not in animation
|
||||
testModeAvailable = (r2.AccessMode == "Editor" or r2.AccessMode == "OutlandOwner")
|
||||
end
|
||||
self:getButton("r2ed_anim_test_mode").active = testModeAvailable
|
||||
self:getButton("r2ed_anim_dm_mode").active = (r2.Mode == "Test")
|
||||
local actReceived = (isDm and (r2.AnimGlobals.Acts ~= nil or config.Local == 1))
|
||||
debugInfo(tostring(actReceived))
|
||||
self:getButton("r2ed_anim_acts").active = actReceived
|
||||
local triggerReceived = (isDm and (r2.AnimGlobals.UserTriggers ~= nil or config.Local == 1))
|
||||
debugInfo(tostring(triggerReceived))
|
||||
self:getButton("r2ed_anim_triggers").active = triggerReceived
|
||||
self:getButton("r2ed_anim_weather").active = (isDm)
|
||||
self:getButton("r2ed_anim_dm_gift").active = r2:isCurrentSelectionPlayer()
|
||||
self:updateButtonsPos()
|
||||
end
|
||||
|
||||
|
||||
function r2.ui.AnimBar:activateTable(tbl)
|
||||
if (type(tbl) ~= "table")
|
||||
then
|
||||
local button = self:getButton(tbl)
|
||||
if button then button.active = true end
|
||||
return
|
||||
end
|
||||
|
||||
local i, j = next(tbl, nil)
|
||||
while i do
|
||||
if i ~= 'n' then
|
||||
self:activateTable(j)
|
||||
-- r2.ui.AnimBar:activateTable(j)
|
||||
end
|
||||
i, j = next(tbl, i)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
-- Update the anim bar from a list of accessibles options (passed as a list of strings)
|
||||
function r2.ui.AnimBar:updateActions(args)
|
||||
self:clearActions()
|
||||
getUI("ui:interface:r2ed_testbar:r2ed_anim_dm_gift").active = r2:isCurrentSelectionPlayer()
|
||||
self:activateTable(args)
|
||||
self:update()
|
||||
self:updateButtonsPos()
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
-- clear all accessible actions in the action bar
|
||||
function r2.ui.AnimBar:clearActions()
|
||||
self:getButton("r2ed_anim_speak_as").active = false
|
||||
self:getButton("r2ed_anim_stop_speak").active = false
|
||||
self:getButton("r2ed_anim_control").active = false
|
||||
self:getButton("r2ed_anim_stop_control").active = false
|
||||
self:getButton("r2ed_anim_add_hp").active = false
|
||||
self:getButton("r2ed_anim_grp_heal").active = false
|
||||
self:getButton("r2ed_anim_kill").active = false
|
||||
self:getButton("r2ed_anim_grp_kill").active = false
|
||||
self:getButton("r2ed_anim_despawn").active = false
|
||||
self:getButton("r2ed_anim_dm_gift").active = false
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
-- update the window of dm controlled entities
|
||||
function r2.ui.AnimBar:updateDMControlledEntitiesWindow()
|
||||
local wnd = getUI("ui:interface:dm_controlled_entities")
|
||||
local index = 0
|
||||
local maxNumPossessedEntities = tonumber(getDefine("r2_max_num_dm_controlled_entities"))
|
||||
--
|
||||
local talkingList = r2.getTalkingAsList()
|
||||
local numTalker = table.getn(talkingList)
|
||||
local incarnatingList = r2.getIncarnatingList()
|
||||
local numIncarnated = table.getn(incarnatingList)
|
||||
if numTalker == 0 and numIncarnated == 0 then
|
||||
wnd.active = false
|
||||
return
|
||||
end
|
||||
--
|
||||
wnd.active = r2.Mode ~= "Edit"
|
||||
wnd = wnd.inside
|
||||
for i = 0, (numTalker / 2) - 1 do
|
||||
local button = wnd["b" .. index]
|
||||
button.active = true
|
||||
button.b.texture="r2_icon_speak_as_small.tga"
|
||||
button.b.texture_pushed="r2_icon_speak_as_small_pushed.tga"
|
||||
button.b.texture_over="r2_icon_speak_as_small_over.tga"
|
||||
button.b.params_l="r2.ui.AnimBar:stopTalk(" .. talkingList[i * 2 + 1] .. ")"
|
||||
button.b.tooltip = i18n.get("uiR2EDStopDMSpeakAs")
|
||||
setDbProp("UI:VARIABLES:R2_DM_CONTROLLED:" .. index .. ":TEXT_ID", talkingList[i * 2 + 1])
|
||||
index = index + 1
|
||||
end
|
||||
for i = 0, (numIncarnated / 2) - 1 do
|
||||
local button = wnd["b" .. index]
|
||||
button.active = true
|
||||
button.b.texture="r2_icon_possess_small.tga"
|
||||
button.b.texture_pushed="r2_icon_possess_small_pushed.tga"
|
||||
button.b.texture_over="r2_icon_possess_small_over.tga"
|
||||
button.b.tooltip = i18n.get("uiR2EDStopDMControl")
|
||||
button.b.params_l="r2.ui.AnimBar:stopIncarnate(" .. incarnatingList[i * 2 + 1] .. ")"
|
||||
setDbProp("UI:VARIABLES:R2_DM_CONTROLLED:" .. index .. ":TEXT_ID", incarnatingList[i * 2 + 1])
|
||||
index = index + 1
|
||||
end
|
||||
while index < maxNumPossessedEntities do
|
||||
wnd["b" .. index].active = false
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
-- stop talk on an entity
|
||||
function r2.ui.AnimBar:stopTalk(entityId)
|
||||
r2:dssTarget('STOP_TALK ' .. entityId)
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
-- stop incarnate on an entity
|
||||
function r2.ui.AnimBar:stopIncarnate(entityId)
|
||||
r2:dssTarget('STOP_CONTROL ' .. entityId)
|
||||
end
|
||||
|
||||
---------------
|
||||
-- PRIVATE --
|
||||
---------------
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
-- get reference on a button in the select bar by its name
|
||||
function r2.ui.AnimBar:getButton(name)
|
||||
assert(name)
|
||||
return getUI("ui:interface:r2ed_testbar:" .. name)
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
-- Update pos of all buttons, so that x of first visible button will be 0
|
||||
function r2.ui.AnimBar:updateButtonsPos()
|
||||
local currX = 0
|
||||
local firstButton = true
|
||||
local function updateX(name, gap)
|
||||
local but = self:getButton(name)
|
||||
if but.active then
|
||||
if not firstButton then
|
||||
currX = currX + gap
|
||||
else
|
||||
firstButton = false
|
||||
end
|
||||
but.x = currX
|
||||
currX = currX + 44
|
||||
else
|
||||
but.x = 0
|
||||
end
|
||||
end
|
||||
|
||||
updateX("r2ed_anim_test_mode", 0)
|
||||
updateX("r2ed_anim_dm_mode", 4)
|
||||
updateX("r2ed_anim_acts", 4)
|
||||
updateX("r2ed_anim_triggers", 4)
|
||||
updateX("r2ed_anim_speak_as", 12)
|
||||
updateX("r2ed_anim_stop_speak", 4)
|
||||
updateX("r2ed_anim_control", 4)
|
||||
updateX("r2ed_anim_stop_control", 4)
|
||||
updateX("r2ed_anim_add_hp", 4)
|
||||
updateX("r2ed_anim_grp_heal", 4)
|
||||
updateX("r2ed_anim_kill", 4)
|
||||
updateX("r2ed_anim_grp_kill", 4)
|
||||
updateX("r2ed_anim_despawn", 4)
|
||||
updateX("r2ed_anim_weather", 12)
|
||||
updateX("r2ed_anim_dm_gift", 12)
|
||||
end
|
||||
|
||||
|
@ -1,84 +0,0 @@
|
||||
--------------------------------------------------------------------------------------
|
||||
-- Managment of the user trigger menu in anim mode
|
||||
|
||||
|
||||
-- the anim triggers class
|
||||
r2.ui.AnimUserTriggers =
|
||||
{
|
||||
}
|
||||
|
||||
------------
|
||||
-- PUBLIC --
|
||||
------------
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
-- Called when the user click on the triggers icon -> pop the menu with the trigger list
|
||||
function r2.ui.AnimUserTriggers:popMenu()
|
||||
local menuName = "ui:interface:r2ed_anim_triggers_menu"
|
||||
local menu = getUI(menuName)
|
||||
local rootMenu = menu:getRootMenu()
|
||||
rootMenu:reset()
|
||||
local triggers = self:getTriggerTable()
|
||||
if not triggers then return end
|
||||
for k = 1, table.getn(triggers) do
|
||||
if triggers[k].Act == 0 or triggers[k].Act == r2.getCurrentActIndex() then
|
||||
r2.ScratchUCStr:fromUtf8(triggers[k].Name)
|
||||
rootMenu:addLine(r2.ScratchUCStr, "lua",
|
||||
string.format("r2.ui.AnimUserTriggers:fireTrigger(%d, %d)", triggers[k].Act, triggers[k].Id), "")
|
||||
end
|
||||
end
|
||||
if rootMenu:getNumLine() == 0 then
|
||||
rootMenu:addLine(i18n.get("uiR2EDNoTriggersDefined"), "", "", "")
|
||||
end
|
||||
launchContextMenuInGame(menuName)
|
||||
local but = getUI("ui:interface:r2ed_testbar"):find("r2ed_anim_triggers")
|
||||
but:updateCoords()
|
||||
menu.x = but.x_real
|
||||
menu.y = but.y_real + but.w_real
|
||||
rootMenu.x = 0
|
||||
rootMenu.y = 0
|
||||
menu:updateCoords()
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
-- Called by the ui when the user has chosen a trigger in the menu
|
||||
function r2.ui.AnimUserTriggers:fireTrigger(triggerAct, triggerId)
|
||||
r2.triggerUserTrigger(triggerAct, triggerId)
|
||||
local trig = self:findTrigger(triggerAct, triggerId)
|
||||
if trig then
|
||||
r2.ScratchUCStr:fromUtf8(trig.Name)
|
||||
displaySystemInfo(concatUCString(i18n.get("uiR2EDTriggering"), r2.ScratchUCStr), "BC")
|
||||
end
|
||||
end
|
||||
|
||||
-------------
|
||||
-- PRIVATE --
|
||||
-------------
|
||||
|
||||
-- private : dummy list of triggers -> for local client mode
|
||||
local dummyUserTriggerList =
|
||||
{
|
||||
{ Name="Trigger1", Act=1, Id=1 },
|
||||
{ Name="Trigger2", Act=1, Id=2 },
|
||||
{ Name="Trigger3", Act=1, Id=3 }
|
||||
}
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
-- Get the table describing all the user triggers
|
||||
function r2.ui.AnimUserTriggers:getTriggerTable()
|
||||
if config.Local == 1 then
|
||||
return dummyUserTriggerList
|
||||
else
|
||||
return r2.AnimGlobals.UserTriggers
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
-- Find a trigger from an act / id pair, returns it definition as a table
|
||||
function r2.ui.AnimUserTriggers:findTrigger(act, id)
|
||||
local triggerTable = self:getTriggerTable()
|
||||
for k, v in pairs(triggerTable) do
|
||||
if v.Act == act and v.Id == id then return v end
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue