-- LUA Script - precede every function and global member with lowercase name of script -- globals local aniplaying = 0 ai_newdest_time = {} ai_cover_on = {} lastswipe = {} damageframestart = {} damageframeend = {} haveAddedObjective = {} function ai_quest_giver_1_init(e) -- FEEL FREE TO CHANGE THOSE VALUES ai_quest_giver_1_name = "Vern" -- This value sets characters name. It will be displayed when you walk close to him. ai_bot_state[e] = "Green" -- This value set's AI Colour on Custom RPG Radar. (This can be set to: "Green", "Red" and "Yellow") ai_quest_giver_1_talking_wait = 100 -- This sets how fast will your Character speak. The larger the value the longer you have to wait for text to change. -- END FEEL FREE TO CHANGE ai_soldier_state[e] = "patrol"; ai_soldier_pathindex[e] = -1; ai_start_x[e] = nil ai_starting_heath[e] = nil ai_ran_to_cover[e] = 0 ModulateSpeed(e,1.0) ai_old_health[e] = 0 SetAnimationFrames(236,265) ai_quest_giver_1_attack = 0 ai_quest_giver_1_disp_text = 0 ai_quest_giver_1_wait = 0 ai_newdest_time[e] = -1 ai_cover_on[e] = 0 ai_alerted_spoken[e] = 0 SetAnimationFrames(236,265) lastswipe[e] = 0 damageframestart[e]=170 damageframeend[e]=180 SetEntityHealth(e,500) end function ai_quest_giver_1_main(e) EntObjNo = g_Entity[e]['obj'] PlayerDist = GetPlayerDistance(e) AnimationFrame = GetAnimationFrame(e) if ai_old_health[e]==0 then ai_old_health[e] = g_Entity[e]['health'] end if g_Entity[e]['health'] < ai_old_health[e] then ai_old_health[e] = g_Entity[e]['health'] PlayCharacterSound(e,"onHurt") end if ai_quest_giver_1_attack == 0 then if ai_soldier_state[e] == "patrol" and PlayerDist > 100 then if ai_soldier_pathindex[e] == -1 then ai_soldier_pathindex[e] = -2 CharacterControlUnarmed(e) PathIndex = -1 PathPointIndex = -1 pClosest = 99999 for pa = 1, AIGetTotalPaths(), 1 do for po = 1 , AIGetPathCountPoints(pa), 1 do pDX = g_Entity[e]['x'] - AIPathGetPointX(pa,po) pDZ = g_Entity[e]['z'] - AIPathGetPointZ(pa,po) pDist = math.sqrt(math.abs(pDX*pDX)+math.abs(pDZ*pDZ)) if pDist < pClosest and pDist < 200 then pClosest = pDist PathIndex = pa PathPointIndex = po end end -- po end -- pa if PathIndex > -1 then ai_soldier_pathindex[e] = PathIndex ai_path_point_index[e] = PathPointIndex ModulateSpeed(e,1.0) SetCharacterToWalk(e) ai_path_point_direction[e] = 1 ai_path_point_max[e] = AIGetPathCountPoints(ai_soldier_pathindex[e]) end end if ai_soldier_pathindex[e] > -1 then ai_patrol_x[e] = AIPathGetPointX(ai_soldier_pathindex[e],ai_path_point_index[e]) ai_patrol_z[e] = AIPathGetPointZ(ai_soldier_pathindex[e],ai_path_point_index[e]) AIEntityGoToPosition(EntObjNo,ai_patrol_x[e],ai_patrol_z[e]) tDistX = g_Entity[e]['x'] - ai_patrol_x[e] tDistZ = g_Entity[e]['z'] - ai_patrol_z[e] DistFromPath = math.sqrt(math.abs(tDistX*tDistX)+math.abs(tDistZ*tDistZ)) if DistFromPath < 50 then if ai_path_point_direction[e] == 1 then ai_path_point_index[e] = ai_path_point_index[e] + 1 if ( ai_path_point_index[e] > ai_path_point_max[e] ) then ai_path_point_index[e] = ai_path_point_max[e] - 1 ai_path_point_direction[e] = 0 end else ai_path_point_index[e] = ai_path_point_index[e] - 1 if ( ai_path_point_index[e] < 1 ) then ai_path_point_index[e] = 2 ai_path_point_direction[e] = 1 end end end end else CharacterControlFidget(e) end if ai_soldier_state[e] == "patrol" and PlayerDist < 100 then AIEntityStop(EntObjNo); RotateToPlayerSlowly(e,20) -- TEXT START -- TEXT BLOCK 1 -- EDIT BLOCK HERE if PlayerDist < 100 and g_quest_1_value == 0 then if ai_quest_giver_1_disp_text == 1 then Panel(15,80,80,20) TextCenterOnX(50,83,1, "This is the 1st line I say if quest 1 value is 0") end if ai_quest_giver_1_disp_text == 2 then Panel(15,80,80,20) TextCenterOnX(50,83,1, "This is the 2nd line I say if quest 1 value is 0") end if ai_quest_giver_1_disp_text == 3 then Panel(15,80,80,20) TextCenterOnX(50,83,1, "This is the 3rd line I say if quest 1 value is 0") end if ai_quest_giver_1_disp_text == 4 then g_quest_1_sug_lv = "[Level 1]" -- THIS LINE IS OPTIONAL. SHOWS QUEST LEVEL IN JOURNAL. PlaySound(e,1) -- PLAY SOUND ASSIGNED TO CHARACTER. I USE IT AS A SOUND OF JOURNAL BEING UPDATED. TO SET IT PLEASE SET "Sound 1" in Entity Edit. PromptDuration("[Journal updated]",3000) -- DISPLAYS PROMPT THAT JOURNAL IS UPDATED. g_quest_1_value = g_quest_1_value + 1 -- CHANGES THE QUEST 1 VALUE. end -- DO NOT EDIT THE BLOCK BELOW THIS POINT if g_KeyPressE == 1 and ai_quest_giver_1_wait == 0 then ai_quest_giver_1_disp_text = ai_quest_giver_1_disp_text + 1 ai_quest_giver_1_wait = ai_quest_giver_1_wait + 1 end TextCenterOnX(50,45,1, "Press [E] To Talk to " .. ai_quest_giver_1_name) if ai_quest_giver_1_wait > ai_quest_giver_1_talking_wait then ai_quest_giver_1_wait = 0 end if ai_quest_giver_1_wait > 0 then ai_quest_giver_1_wait = ai_quest_giver_1_wait + 1 end RotateToPlayerSlowly(e,20) end -- END TEXT BLOCK 1 -- TEXT BLOCK 2 -- EDIT BLOCK HERE if PlayerDist < 100 and g_quest_1_value == 1 then if ai_quest_giver_1_disp_text == 1 then Panel(15,80,80,20) TextCenterOnX(50,83,1, "This is the 1st line I say if quest 1 value is 1") end if ai_quest_giver_1_disp_text == 2 then Panel(15,80,80,20) TextCenterOnX(50,83,1, "This is the 2nd line I say if quest 1 value is 1") end if ai_quest_giver_1_disp_text == 3 then Panel(15,80,80,20) TextCenterOnX(50,83,1, "This is the 3rd line I say if quest 1 value is 1") end -- DO NOT EDIT THE BLOCK BELOW THIS POINT if g_KeyPressE == 1 and ai_quest_giver_1_wait == 0 then ai_quest_giver_1_disp_text = ai_quest_giver_1_disp_text + 1 ai_quest_giver_1_wait = ai_quest_giver_1_wait + 1 end TextCenterOnX(50,45,1, "Press [E] To Talk to " .. ai_quest_giver_1_name) if ai_quest_giver_1_wait > ai_quest_giver_1_talking_wait then ai_quest_giver_1_wait = 0 end if ai_quest_giver_1_wait > 0 then ai_quest_giver_1_wait = ai_quest_giver_1_wait + 1 end RotateToPlayerSlowly(e,20) end -- END TEXT BLOCK 2 -- END TEXT end end if PlayerDist > 100 then ai_quest_giver_1_wait = 0 ai_quest_giver_1_disp_text = 0 end if g_Entity[e]['health'] < 500 then SetEntityHealth(e,500) end if ai_old_health[e]==-1 then ai_old_health[e] = g_Entity[e]['health'] end end function ai_quest_giver_1_exit(e) PlayCharacterSound(e,"onDeath") CollisionOff(e) end