Hi guys,
I have been playing around with Game Guru for about a month now. I am very new to scripting but have made some RPG scripts that may help you develop your own games. I will divide my scripts into a few forum posts as there are a lot of aspects to them which need explanation.
First of all I would like to mention a few things:
1. Yes, you can use and modify those scripts in any way you like.
2. Yes, you can use them in your own projects free of charge.
3. I am not a professional scripter and will not create scripts per request.
4. I know they are not perfect but as long as they work it's fine with me.
Ok, now that's out of the way let's go!
I will start with my RPG Menus script. What does it cover?
- 3 Menus - for character, journal and inventory
- Journal can track 7 quest lines at a time and displays propper messages according to quest phase.
- Inventory contains only weapons and potions
- Potions system included (weak potion, regular potion and strong potion). Also contains potions cooldown time.
- Simple dev values display (handy for creating quests and debugging)
- leveling system
- Current weapon slot tracker
- It works with current GG save system
Here is the script itself:
function rpg_menu_init(e)
-- FEEL FREE TO MODIFY THOSE VALUES
if g_weak_potion_count == nil then
g_weak_potion_count = 0 -- SET HOW MANY WEAK POTIONS PLAYES HAS AT THE BEGINNING
end
if g_potion_count == nil then
g_potion_count = 0 -- SET HOW MANY POTIONS PLAYES HAS AT THE BEGINNING
end
if g_strong_potion_count == nil then
g_strong_potion_count = 0 -- SET HOW MANY STRONG POTIONS PLAYES HAS AT THE BEGINNING
end
display_dev_menu = 1 -- DISPLAY/HIDE DEV MENU (1 = DISPLAY, 0 = HIDE)
inventory_key = 23 -- SET KEY TO OPEN INVENTORY BASED ON SCANCODE (in my case 23 is "i")
char_menu_key = 22 -- SET KEY TO OPEN CHARACTER MENU BASED ON SCANCODE (in my case 22 is "u")
journal_key = 36 -- SET KEY TO OPEN JOURNAL BASED ON SCANCODE (in my case 36 is "j")
weak_potion_key = 59 -- SET KEY TO USE WEAK POTION BASED ON SCANCODE (in my case 59 is "F1")
potion_key = 60 -- SET KEY TO USE POTION BASED ON SCANCODE (in my case 60 is "F2")
strong_potion_key = 61 -- SET KEY TO USE STRONG POTION BASED ON SCANCODE (in my case 61 is "F3")
SetFlashLightKeyEnabled(0) -- DISABLE FLASHLIGHT (DELETE THIS LINE IF YOU WANT TO ENABLE FLASHLIGHT)
player_health_limit = 360 -- SET MAXIMUM PLAYER HEALTH (THIS IS NECESSARY FOR THE SCRIPT TO WORK!!)
max_weak_potions = 10 -- SET HOW MANY WEAK POTIONS PLAYER CAN CARRY
max_potions = 5 -- SET HOW MANY POTIONS PLAYER CAN CARRY
max_strong_potions = 2 -- SET HOW MANY STRONG POTIONS PLAYER CAN CARRY
menu_wait_tweak = 50 -- TOGGLE MENU VALUE (WHEN HOLDING A KEY MENU WILL TOGGLE ON AND OFF. THIS SETS THE "FLICKERING" TIME)
-- END FEEL FREE TO MODIFY VALUES
display_quest_menu = 0
quest_menu_press_wait = 0
display_c_menu = 0
c_menu_press_wait = 0
display_inventory = 0
inventory_press_wait = 0
use_weak_potion = 0
use_potion_wait = 0
if g_exp_base == nil then
g_exp_base = 100
end
if g_level == nil then
g_level = 1
end
if g_exp == nil then
g_exp = 0
end
if g_weapon_slot == nil then
g_weapon_slot = 0
end
if g_weapon_1 == nil then
g_weapon_1 = ""
end
if g_weapon_2 == nil then
g_weapon_2 = ""
end
if g_weapon_3 == nil then
g_weapon_3 = ""
end
if g_weapon_4 == nil then
g_weapon_4 = ""
end
if g_weapon_5 == nil then
g_weapon_5 = ""
end
if g_weapon_6 == nil then
g_weapon_6 = ""
end
if g_weapon_7 == nil then
g_weapon_7 = ""
end
if g_weapon_8 == nil then
g_weapon_8 = ""
end
if g_weapon_9 == nil then
g_weapon_9 = ""
end
if g_slot_1 == nil then
g_slot_1 = 0
end
if g_slot_2 == nil then
g_slot_2 = 0
end
if g_slot_3 == nil then
g_slot_3 = 0
end
if g_slot_4 == nil then
g_slot_4 = 0
end
if g_slot_5 == nil then
g_slot_5 = 0
end
if g_slot_6 == nil then
g_slot_6 = 0
end
if g_slot_7 == nil then
g_slot_7 = 0
end
if g_slot_8 == nil then
g_slot_8 = 0
end
if g_slot_9 == nil then
g_slot_9 = 0
end
if g_weapon_1_level_disp == nil then
g_weapon_1_level_disp = ""
end
if g_weapon_2_level_disp == nil then
g_weapon_2_level_disp = ""
end
if g_weapon_3_level_disp == nil then
g_weapon_3_level_disp = ""
end
if g_weapon_4_level_disp == nil then
g_weapon_4_level_disp = ""
end
if g_weapon_5_level_disp == nil then
g_weapon_5_level_disp = ""
end
if g_weapon_6_level_disp == nil then
g_weapon_6_level_disp = ""
end
if g_weapon_7_level_disp == nil then
g_weapon_7_level_disp = ""
end
if g_weapon_8_level_disp == nil then
g_weapon_8_level_disp = ""
end
if g_weapon_9_level_disp == nil then
g_weapon_9_level_disp = ""
end
-- quests suggested level.
if g_quest_1_sug_lv == nil then
g_quest_1_sug_lv = ""
end
if g_quest_2_sug_lv == nil then
g_quest_2_sug_lv = ""
end
if g_quest_3_sug_lv == nil then
g_quest_3_sug_lv = ""
end
if g_quest_4_sug_lv == nil then
g_quest_4_sug_lv = ""
end
if g_quest_5_sug_lv == nil then
g_quest_5_sug_lv = ""
end
if g_quest_6_sug_lv == nil then
g_quest_6_sug_lv = ""
end
if g_quest_7_sug_lv == nil then
g_quest_7_sug_lv = ""
end
-- Quest Values
if g_quest_1_value == nil then
g_quest_1_value = 0
end
if g_quest_2_value == nil then
g_quest_2_value = 0
end
if g_quest_3_value == nil then
g_quest_3_value = 0
end
if g_quest_4_value == nil then
g_quest_4_value = 0
end
if g_quest_5_value == nil then
g_quest_5_value = 0
end
if g_quest_value == nil then
g_quest_6_value = 0
end
if g_quest_7_value == nil then
g_quest_7_value = 0
end
--end quest values
-- weapon slot level display
if g_slot_1_level == nil then
g_slot_1_level = ""
end
if g_slot_2_level == nil then
g_slot_2_level = ""
end
if g_slot_3_level == nil then
g_slot_3_level = ""
end
if g_slot_4_level == nil then
g_slot_4_level = ""
end
if g_slot_5_level == nil then
g_slot_5_level = ""
end
if g_slot_6_level == nil then
g_slot_6_level = ""
end
if g_slot_7_level == nil then
g_slot_7_level = ""
end
if g_slot_8_level == nil then
g_slot_8_level = ""
end
if g_slot_9_level == nil then
g_slot_9_level = ""
end
-- end weapon slot level display
end
function rpg_menu_main(e)
-- POTION COOLDOWN
potion_sum = g_weak_potion_count + g_potion_count + g_strong_potion_count
if use_potion_wait > 0 then
TextCenterOnX(45,5,1, "|")
TextCenterOnX(55,5,1, "|")
TextCenterOnX(50,7,2, "Potion Cooldown")
if use_potion_wait > 0 and use_potion_wait < 500 then
Text(45,5,2, "|||")
elseif use_potion_wait > 500 and use_potion_wait <= 1000 then
Text(45,5,2, "||||||")
elseif use_potion_wait > 1000 and use_potion_wait <= 1500 then
Text(45,5,2, "||||||||||")
elseif use_potion_wait > 1500 and use_potion_wait <= 2000 then
Text(45,5,2, "|||||||||||||")
elseif use_potion_wait > 2000 and use_potion_wait <= 2500 then
Text(45,5,2, "||||||||||||||||")
elseif use_potion_wait > 2500 and use_potion_wait <= 3000 then
Text(45,5,2, "|||||||||||||||||||")
elseif use_potion_wait > 3000 and use_potion_wait <= 3500 then
Text(45,5,2, "||||||||||||||||||||||")
elseif use_potion_wait > 3500 and use_potion_wait <= 4000 then
Text(45,5,2, "||||||||||||||||||||||||||")
elseif use_potion_wait > 4000 and use_potion_wait <= 4500 then
Text(45,5,2, "|||||||||||||||||||||||||||||")
elseif use_potion_wait > 4500 and use_potion_wait <= 5000 then
Text(45,5,2, "||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 5000 and use_potion_wait <= 5500 then
Text(45,5,2, "|||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 5500 and use_potion_wait <= 6000 then
Text(45,5,2, "||||||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 6000 and use_potion_wait <= 6500 then
Text(45,5,2, "||||||||||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 6500 and use_potion_wait <= 7000 then
Text(45,5,2, "|||||||||||||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 7000 and use_potion_wait <= 7500 then
Text(45,5,2, "||||||||||||||||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 7500 and use_potion_wait <= 8000 then
Text(45,5,2, "|||||||||||||||||||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 8000 and use_potion_wait <= 8500 then
Text(45,5,2, "||||||||||||||||||||||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 8500 and use_potion_wait <= 9000 then
Text(45,5,2, "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 9000 and use_potion_wait <= 9500 then
Text(45,5,2, "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
elseif use_potion_wait > 9500 and use_potion_wait <= 10000 then
Text(45,5,2, "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
end
elseif g_PlayerHealth < player_health_limit and use_potion_wait == 0 and potion_sum > 0 then
TextCenterOnX(50,5,1, "Press F1, F2 or F3 to use potions")
elseif g_PlayerHealth < player_health_limit and use_potion_wait == 0 and potion_sum <= 0 then
TextCenterOnX(50,5,1, "You have no potions")
end
-- END POTION COOLDOWN
-- WEAPON LEVEL TEXT DISPLAY
if g_weapon_1 ~= "" then
g_weapon_1_level_disp = "Level"
end
if g_weapon_2 ~= "" then
g_weapon_2_level_disp = "Level"
end
if g_weapon_3 ~= "" then
g_weapon_3_level_disp = "Level"
end
if g_weapon_4 ~= "" then
g_weapon_4_level_disp = "Level"
end
if g_weapon_5 ~= "" then
g_weapon_5_level_disp = "Level"
end
if g_weapon_6 ~= "" then
g_weapon_6_level_disp = "Level"
end
if g_weapon_7 ~= "" then
g_weapon_7_level_disp = "Level"
end
if g_weapon_8 ~= "" then
g_weapon_8_level_disp = "Level"
end
if g_weapon_9 ~= "" then
g_weapon_9_level_disp = "Level"
end
-- WEAPON LEVEL TEXT DISPLAY END
-- WEAPON SLOT TRACKER
if g_Scancode == 2 and g_slot_1 == 0 and g_weapon_1 ~= "" then
g_slot_1 = 1
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
elseif g_Scancode == 3 and g_slot_2 == 0 and g_weapon_2 ~= "" then
g_slot_1 = 0
g_slot_2 = 1
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
elseif g_Scancode == 4 and g_slot_3 == 0 and g_weapon_3 ~= "" then
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 1
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
elseif g_Scancode == 5 and g_slot_4 == 0 and g_weapon_4 ~= "" then
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 1
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
elseif g_Scancode == 6 and g_slot_5 == 0 and g_weapon_5 ~= "" then
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 1
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
elseif g_Scancode == 7 and g_slot_6 == 0 and g_weapon_6 ~= "" then
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 1
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
elseif g_Scancode == 8 and g_slot_7 == 0 and g_weapon_7 ~= "" then
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 1
g_slot_8 = 0
g_slot_9 = 0
elseif g_Scancode == 9 and g_slot_8 == 0 and g_weapon_8 ~= "" then
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 1
g_slot_9 = 0
elseif g_Scancode == 10 and g_slot_9 == 0 and g_weapon_9 ~= "" then
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 1
end
-- END WEAPON SLOT TRACKER
-- LEVELING
to_next_level = g_exp_base - g_exp
if g_exp >= g_exp_base then
g_level = g_level + 1
g_exp_base = 100 * g_level + g_exp_base
PlaySound(e,0)
PromptDuration("Level Up! you are now level " .. g_level .. ". [Journal updated]" ,3000)
end
-- END LEVELING
if display_dev_menu == 1 then
TextCenterOnX(10,10,1, "QUEST VALUES")
TextCenterOnX(10,13,1, "Q1 = " .. g_quest_1_value)
TextCenterOnX(10,16,1, "Q2 = " .. g_quest_2_value)
TextCenterOnX(10,19,1, "Q3 = " .. g_quest_3_value)
TextCenterOnX(10,22,1, "Q4 = " .. g_quest_4_value)
TextCenterOnX(10,25,1, "Q5 = " .. g_quest_5_value)
TextCenterOnX(10,28,1, "Q6 = " .. g_quest_6_value)
TextCenterOnX(10,31,1, "Q7 = " .. g_quest_7_value)
TextCenterOnX(10,37,1, "PLAYER POSITION")
TextCenterOnX(10,40,1, "POS X = " .. g_PlayerPosX)
TextCenterOnX(10,43,1, "POS Z = " .. g_PlayerPosZ)
TextCenterOnX(10,49,1, "PRESSED KEY SCANCODE")
TextCenterOnX(10,52,1, "g_Scancode = " .. g_Scancode)
end
-- QUEST MENU
if display_quest_menu == 1 then
Panel(13,8,87,9)
Panel(13,15,87,84)
TextCenterOnX(50,11,1, "Journal")
--Quest line 1
if g_quest_1_value == 0 then
TextCenterOnX(50,18,1, "1. QUEST 1 NAME " .. g_quest_1_sug_lv)
TextCenterOnX(50,21,1, "Message when quest_1_value is 0")
end
if g_quest_1_value == 1 then
TextCenterOnX(50,18,1, "1. QUEST NAME" .. g_quest_1_sug_lv)
TextCenterOnX(50,21,1, "Message when quest_1_value is 1")
end
-- End quest line 1
--Quest line 2
if g_quest_2_value == 0 then
TextCenterOnX(50,27,1, "2. QUEST 2 NAME")
TextCenterOnX(50,30,1, "Message when quest_2_value is 0")
end
if g_quest_2_value == 1 then
TextCenterOnX(50,27,1, "2. QUEST 2 NAME" .. g_quest_2_sug_lv)
TextCenterOnX(50,30,1, "Message when quest_2_value is 1")
end
--End quest line 2
--Quest line 3
if g_quest_3_value == 0 then
TextCenterOnX(50,36,1, "3. QUEST 3 NAME" .. g_quest_3_sug_lv)
TextCenterOnX(50,39,1, "Message when quest_3_value is 0")
end
if g_quest_3_value == 1 then
TextCenterOnX(50,36,1, "3. QUEST 3 NAME" .. g_quest_3_sug_lv)
TextCenterOnX(50,39,1, "Message when quest_3_value is 1")
end
--End quest line 3
--Quest line 4
if g_quest_4_value == 0 then
TextCenterOnX(50,45,1, "4. QUEST 4 NAME" .. g_quest_4_sug_lv)
TextCenterOnX(50,48,1, "Message when quest_4_value is 0")
end
if g_quest_4_value == 1 then
TextCenterOnX(50,45,1, "4. QUEST 4 NAME" .. g_quest_4_sug_lv)
TextCenterOnX(50,48,1, "Message when quest_4_value is 1")
end
--End quest line 4
--Quest line 5
if g_quest_5_value == 0 then
TextCenterOnX(50,54,1, "5. QUEST 5 NAME" .. g_quest_5_sug_lv)
TextCenterOnX(50,57,1, "Message when quest_5_value is 0")
end
if g_quest_5_value == 1 then
TextCenterOnX(50,54,1, "5. QUEST 5 NAME" .. g_quest_5_sug_lv)
TextCenterOnX(50,57,1, "Message when quest_5_value is 1")
end
--End quest line 5
--Quest line 6
if g_quest_6_value == 0 then
TextCenterOnX(50,63,1, "6. QUEST 6 NAME" .. g_quest_6_sug_lv)
TextCenterOnX(50,66,1, "Message when quest_6_value is 0")
end
if g_quest_6_value == 1 then
TextCenterOnX(50,63,1, "6. QUEST 6 NAME" .. g_quest_6_sug_lv)
TextCenterOnX(50,66,1, "Message when quest_6_value is 1")
end
--End quest line 6
--Quest line 7
if g_quest_7_value == 0 then
TextCenterOnX(50,72,1, "7. QUEST 7 NAME" .. g_quest_7_sug_lv)
TextCenterOnX(50,75,1, "Message when quest_7_value is 0")
end
if g_quest_7_value == 1 then
TextCenterOnX(50,72,1, "7. QUEST 7 NAME" .. g_quest_7_sug_lv)
TextCenterOnX(50,75,1, "Message when quest_7_value is 1")
end
--End quest line 7
end
if g_Scancode == journal_key and quest_menu_press_wait == 0 and display_quest_menu == 0 then
display_c_menu = 0
display_inventory = 0
display_quest_menu = display_quest_menu + 1
quest_menu_press_wait = quest_menu_press_wait + 1
end
if g_Scancode == journal_key and quest_menu_press_wait == 0 and display_quest_menu == 1 then
display_quest_menu = display_quest_menu - 1
quest_menu_press_wait = quest_menu_press_wait + 1
end
if quest_menu_press_wait > 0 then
quest_menu_press_wait = quest_menu_press_wait + 1
end
if quest_menu_press_wait > menu_wait_tweak then
quest_menu_press_wait = 0
end
-- END QUEST MENU
-- CHARACTER MENU
if display_c_menu == 1 then
Panel(13,8,87,9)
Panel(13,15,87,84)
TextCenterOnX(50,11,1, "Stats")
TextCenterOnX(50,18,1, "Level")
TextCenterOnX(50,21,1, g_level)
TextCenterOnX(50,27,1, "Experience")
TextCenterOnX(50,30,1, g_exp)
TextCenterOnX(50,36,1, "Next Level")
TextCenterOnX(50,39,1, to_next_level)
end
if g_Scancode == char_menu_key and display_c_menu == 0 and c_menu_press_wait == 0 then
display_inventory = 0
display_quest_menu = 0
display_c_menu = display_c_menu + 1
c_menu_press_wait = c_menu_press_wait + 1
end
if g_Scancode == char_menu_key and display_c_menu == 1 and c_menu_press_wait == 0 then
display_c_menu = display_c_menu - 1
c_menu_press_wait = c_menu_press_wait + 1
end
if c_menu_press_wait > 0 then
c_menu_press_wait = c_menu_press_wait + 1
end
if c_menu_press_wait > menu_wait_tweak then
c_menu_press_wait = 0
end
--END CHARACTER MENU
-- INVENTORY
if display_inventory == 1 then
Panel(13,8,87,9)
Panel(13,15,87,84)
TextCenterOnX(50,11,1, "Inventory")
TextCenterOnX(50,18,1, "Weapons")
TextCenterOnX(20,21,1, "1")
TextCenterOnX(20,24,1, g_weapon_1)
TextCenterOnX(20,30,1, g_weapon_1_level_disp)
TextCenterOnX(20,33,1, g_slot_1_level)
TextCenterOnX(28,21,1, "2")
TextCenterOnX(28,24,1, g_weapon_2)
TextCenterOnX(28,30,1, g_weapon_2_level_disp)
TextCenterOnX(28,33,1, g_slot_2_level)
TextCenterOnX(35,21,1, "3")
TextCenterOnX(35,24,1, g_weapon_3)
TextCenterOnX(35,30,1, g_weapon_3_level_disp)
TextCenterOnX(35,33,1, g_slot_3_level)
TextCenterOnX(43,21,1, "4")
TextCenterOnX(43,24,1, g_weapon_4)
TextCenterOnX(43,30,1, g_weapon_4_level_disp)
TextCenterOnX(43,33,1, g_slot_4_level)
TextCenterOnX(50,21,1, "5")
TextCenterOnX(50,24,1, g_weapon_5)
TextCenterOnX(50,30,1, g_weapon_5_level_disp)
TextCenterOnX(50,33,1, g_slot_5_level)
TextCenterOnX(57,21,1, "6")
TextCenterOnX(57,24,1, g_weapon_6)
TextCenterOnX(57,30,1, g_weapon_6_level_disp)
TextCenterOnX(57,33,1, g_slot_6_level)
TextCenterOnX(65,21,1, "7")
TextCenterOnX(65,24,1, g_weapon_7)
TextCenterOnX(65,30,1, g_weapon_7_level_disp)
TextCenterOnX(65,33,1, g_slot_7_level)
TextCenterOnX(72,21,1, "8")
TextCenterOnX(72,24,1, g_weapon_8)
TextCenterOnX(72,30,1, g_weapon_8_level_disp)
TextCenterOnX(72,33,1, g_slot_8_level)
TextCenterOnX(80,21,1, "9")
TextCenterOnX(80,24,1, g_weapon_9)
TextCenterOnX(80,30,1, g_weapon_9_level_disp)
TextCenterOnX(80,33,1, g_slot_9_level)
TextCenterOnX(25,55,1, "F1")
TextCenterOnX(25,58,1, "Weak Potions")
TextCenterOnX(25,61,1, g_weak_potion_count .. " / " .. max_weak_potions)
TextCenterOnX(50,55,1, "F2")
TextCenterOnX(50,58,1, "Potions")
TextCenterOnX(50,61,1, g_potion_count .. " / " .. max_potions)
TextCenterOnX(75,55,1, "F3")
TextCenterOnX(75,58,1, "Strong Potions")
TextCenterOnX(75,61,1, g_strong_potion_count .. " / " .. max_strong_potions)
end
if g_Scancode == inventory_key and inventory_press_wait == 0 and display_inventory == 0 then
display_quest_menu = 0
display_c_menu = 0
display_inventory = display_inventory + 1
inventory_press_wait = inventory_press_wait + 1
end
if g_Scancode == inventory_key and inventory_press_wait == 0 and display_inventory == 1 then
display_inventory = display_inventory - 1
inventory_press_wait = inventory_press_wait + 1
end
if inventory_press_wait > 0 then
inventory_press_wait = inventory_press_wait + 1
end
if inventory_press_wait > menu_wait_tweak then
inventory_press_wait = 0
end
--INVENTORY END
-- ITEMS AMOUNT
if g_weak_potion_count >= max_weak_potions then
g_weak_potion_count = max_weak_potions
elseif g_weak_potion_count <= 0 then
g_weak_potion_count = 0
end
if g_potion_count >= max_potions then
g_potion_count = max_potions
elseif g_potion_count <= 0 then
g_potion_count = 0
end
if g_strong_potion_count >= max_strong_potions then
g_strong_potion_count = max_strong_potions
elseif g_strong_potion_count <= 0 then
g_strong_potion_count = 0
end
-- END ITEMS AMOUNT
-- ITEMS FUNCTIONS
-- WEAK POTIONS
if g_Scancode == weak_potion_key then
if g_Scancode == weak_potion_key and use_potion_wait == 0 and g_PlayerHealth < player_health_limit and g_weak_potion_count > 0 then
use_weak_potion = 1
use_potion_wait = use_potion_wait + 1
SetPlayerHealth(g_PlayerHealth + player_health_limit/5)
g_weak_potion_count = g_weak_potion_count - 1
PromptDuration("Used weak potion",3000)
end
end
if use_potion_wait > 10000 then
use_potion_wait = 0
end
if use_potion_wait > 0 then
use_potion_wait = use_potion_wait + 1
use_weak_potion = 0
end
--END WEAK POTIONS
-- POTIONS
if g_Scancode == potion_key then
if g_Scancode == potion_key and use_potion_wait == 0 and g_PlayerHealth < player_health_limit and g_potion_count > 0 then
use_potion = 1
use_potion_wait = use_potion_wait + 1
SetPlayerHealth(g_PlayerHealth + player_health_limit/2)
g_potion_count = g_potion_count - 1
PromptDuration("Used potion",3000)
end
end
if use_potion_wait > 10000 then
use_potion_wait = 0
end
if use_potion_wait > 0 then
use_potion_wait = use_potion_wait + 1
use_potion = 0
end
--END POTIONS
-- STRONG POTIONS
if g_Scancode == strong_potion_key then
if g_Scancode == strong_potion_key and use_potion_wait == 0 and g_PlayerHealth < player_health_limit and g_strong_potion_count > 0 then
use_strong_potion = 1
use_potion_wait = use_potion_wait + 1
SetPlayerHealth(g_PlayerHealth + player_health_limit)
g_strong_potion_count = g_strong_potion_count - 1
PromptDuration("Used strong potion",3000)
end
end
if use_potion_wait > 10000 then
use_potion_wait = 0
end
if use_potion_wait > 0 then
use_potion_wait = use_potion_wait + 1
use_strong_potion = 0
end
--END STRONG POTIONS
-- END ITEMS FUNCTIONS
-- HEALTH LIMIT
if g_PlayerHealth > player_health_limit then
SetPlayerHealth(player_health_limit)
end
-- END HEALTH LIMIT
end
So how do you use it:
1. Custimize starting values
At the top of the script you have values that are marked as "Feel free to edit". They are pretty well explained there so there is no need for me to do the double work. Just make sure you set the value: player_health_limit to what you have set the player's health in Entity Edit mode in the engine.
I have set it to 360 as this seems to be a good value for an RPG taking the red low health screen into account.
When using this script player health will never go above the value you set there. So this will be somehow static for the entire game.
-- ADDED INFO (WILL BE BETTER EXPLAINED IN LATER POSTS)
(in order to achieve difficulty level enemies will give you more damage over time, they will have more health and weapons you pick up will have different damage values depending on the weapon level - you will be only allowed to pick up weapons on your level or lower.)
2. Journal
This one is the most complicated so lets explain. Journal starts in the script on line 426 "-- QUEST MENU".
What you need to know before editing this part (and you will have to in order to create a full game with this).
1. There are 7 Quest Lines available to be active at any given time.
2. Positions of Journal Entries is fixed, each entry can be only 1 line long.
3. Each line can be 80% of the screen width long.
Ok then. There is a set value for each quest. Those are:
g_quest_1_value
g_quest_2_value
g_quest_3_value ... etc. all the way up to 7.
You can display different message based on the quest value. The idea is that with each quest phase this value raises by 1.
Also all quest values are set to 0 by default when the game starts.
So for example:
if g_quest_1_value == 0 then
TextCenterOnX(50,18,1, "1. QUEST 1 NAME " .. g_quest_1_sug_lv)
TextCenterOnX(50,21,1, "Message when quest_1_value is 0")
end
This means that if quest 1 value is 0 following message will appear on screen.
1. QUEST 1 NAME
Message when quest_1_value is 0
Later when the quest phase changes and g_quest_1_value is set to 1 (for example: you talk to a quest giver or find an item that changes the quest value) you can add a different text. For example:
if g_quest_1_value == 1 then
TextCenterOnX(50,18,1, "1. QUEST NAME" .. g_quest_1_sug_lv)
TextCenterOnX(50,21,1, "Message when quest_1_value is 1")
end
This would display:
1. QUEST NAME
Message when quest_1_value is 1
You will have to change the messages and quest name between the " " and this will display your progress.
There are already sample messages created for each quest line for values 0 and 1.
All quest lines are marked with "-- Quest line 1" ,"2", "3" ... etc. in the script.
So to add new message for the next quest phase you need to copy this short if statement as in the above example and change one value.
The next one would be:
if g_quest_1_value == 2 then
TextCenterOnX(50,18,1, "1. QUEST NAME" .. g_quest_1_sug_lv)
TextCenterOnX(50,21,1, "Message when quest_1_value is 2")
end
3. Inventory
You don't actually change anything here. It just works for Custom Weapons and Potions I created.
It displays how many potions you have, which weapon you carry in which slot and each weapons level.
Here is the script for weapon level 1:
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects Weapon
weapon_therecanbeonlyone = 0
function rpg_weapon_lv1_init_name(e,name)
weapon_name[e] = name
end
function rpg_weapon_lv1_main(e)
if weapon_therecanbeonlyone==-1 then
if g_KeyPressE == 0 and g_InKey == "" then
weapon_therecanbeonlyone = 0
end
end
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if Result < 20.0 and weapon_therecanbeonlyone==0 then
weapon_therecanbeonlyone = e
end
if Result >= 20.0 and weapon_therecanbeonlyone==e then
weapon_therecanbeonlyone = 0
end
-- START HERE TOMORROW
if Result < 20.0 and weapon_therecanbeonlyone==e and g_level >= 1 then
if g_PlayerGunCount < 9 then
if g_PlayerGunID > 0 then
if g_PlayerController==0 then
Prompt ("Press E to pick up the " .. weapon_name[e] .. " level 1 or T to replace" )
else
Prompt ("Press Y Button to pick up the " .. weapon_name[e] )
end
else
if g_PlayerController==0 then
Prompt ("Press E To pick up the " .. weapon_name[e] .. " level 1" )
else
Prompt ("Press Y Button to pick up the " .. weapon_name[e] )
end
end
if g_KeyPressE == 1 then
if g_weapon_slot == 0 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_1 = weapon_name[e]
g_weapon_slot = 1
g_slot_1 = 1
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_1_level = "1"
elseif g_weapon_slot == 1 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_2 = weapon_name[e]
g_weapon_slot = 2
g_slot_1 = 0
g_slot_2 = 1
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_2_level = "1"
elseif g_weapon_slot == 2 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_3 = weapon_name[e]
g_weapon_slot = 3
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 1
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_3_level = "1"
elseif g_weapon_slot == 3 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_4 = weapon_name[e]
g_weapon_slot = 4
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 1
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_4_level = "1"
elseif g_weapon_slot == 4 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_5 = weapon_name[e]
g_weapon_slot = 5
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 1
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_5_level = "1"
elseif g_weapon_slot == 5 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_6 = weapon_name[e]
g_weapon_slot = 6
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 1
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_6_level = "1"
elseif g_weapon_slot == 6 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_7 = weapon_name[e]
g_weapon_slot = 7
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 1
g_slot_8 = 0
g_slot_9 = 0
g_slot_7_level = "1"
elseif g_weapon_slot == 7 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_8 = weapon_name[e]
g_weapon_slot = 8
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 1
g_slot_9 = 0
g_slot_8_level = "1"
elseif g_weapon_slot == 8 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_9 = weapon_name[e]
g_weapon_slot = 9
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 1
g_slot_9_level = "1"
end
end
else
if g_PlayerController==0 then
if g_PlayerGunID > 0 then
Prompt ("Press T to replace with " .. weapon_name[e] )
else
Prompt ("Cannot collect any more weapons" )
end
else
Prompt ("Cannot collect any more weapons" )
end
end
if g_InKey == "t" and g_PlayerGunID > 0 and g_level >= 1 then
if g_slot_1 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_1 = weapon_name[e]
g_slot_1_level = "1"
elseif g_slot_2 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_2 = weapon_name[e]
g_slot_2_level = "1"
elseif g_slot_3 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_3 = weapon_name[e]
g_slot_3_level = "1"
elseif g_slot_4 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_4 = weapon_name[e]
g_slot_4_level = "1"
elseif g_slot_5 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_5 = weapon_name[e]
g_slot_5_level = "1"
elseif g_slot_6 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_6 = weapon_name[e]
g_slot_6_level = "1"
elseif g_slot_7 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_7 = weapon_name[e]
g_slot_7_level = "1"
elseif g_slot_8 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_8 = weapon_name[e]
g_slot_8_level = "1"
elseif g_slot_9 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 1" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_9 = weapon_name[e]
g_slot_9_level = "1"
end
end
elseif Result < 20.0 and weapon_therecanbeonlyone==e and g_level < 1 then
Prompt ("You need to be level 1 to pick up this " .. weapon_name[e])
end
else
if weapon_therecanbeonlyone==e then
weapon_therecanbeonlyone = 0
end
end
end
And weapon level 3:
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects Weapon
weapon_therecanbeonlyone = 0
function rpg_weapon_lv3_init_name(e,name)
weapon_name[e] = name
end
function rpg_weapon_lv3_main(e)
if weapon_therecanbeonlyone==-1 then
if g_KeyPressE == 0 and g_InKey == "" then
weapon_therecanbeonlyone = 0
end
end
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if Result < 20.0 and weapon_therecanbeonlyone==0 then
weapon_therecanbeonlyone = e
end
if Result >= 20.0 and weapon_therecanbeonlyone==e then
weapon_therecanbeonlyone = 0
end
-- START HERE TOMORROW
if Result < 20.0 and weapon_therecanbeonlyone==e and g_level >= 3 then
if g_PlayerGunCount < 9 then
if g_PlayerGunID > 0 then
if g_PlayerController==0 then
Prompt ("Press E to pick up the " .. weapon_name[e] .. " level 3 or T to replace" )
else
Prompt ("Press Y Button to pick up the " .. weapon_name[e] )
end
else
if g_PlayerController==0 then
Prompt ("Press E To pick up the " .. weapon_name[e] .. " level 3" )
else
Prompt ("Press Y Button to pick up the " .. weapon_name[e] )
end
end
if g_KeyPressE == 1 then
if g_weapon_slot == 0 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_1 = weapon_name[e]
g_weapon_slot = 1
g_slot_1 = 1
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_1_level = "3"
elseif g_weapon_slot == 1 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_2 = weapon_name[e]
g_weapon_slot = 2
g_slot_1 = 0
g_slot_2 = 1
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_2_level = "3"
elseif g_weapon_slot == 2 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_3 = weapon_name[e]
g_weapon_slot = 3
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 1
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_3_level = "3"
elseif g_weapon_slot == 3 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_4 = weapon_name[e]
g_weapon_slot = 4
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 1
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_4_level = "3"
elseif g_weapon_slot == 4 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_5 = weapon_name[e]
g_weapon_slot = 5
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 1
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_5_level = "3"
elseif g_weapon_slot == 5 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_6 = weapon_name[e]
g_weapon_slot = 6
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 1
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 0
g_slot_6_level = "3"
elseif g_weapon_slot == 6 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_7 = weapon_name[e]
g_weapon_slot = 7
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 1
g_slot_8 = 0
g_slot_9 = 0
g_slot_7_level = "3"
elseif g_weapon_slot == 7 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_8 = weapon_name[e]
g_weapon_slot = 8
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 1
g_slot_9 = 0
g_slot_8_level = "3"
elseif g_weapon_slot == 8 then
PromptDuration("Collected the " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_9 = weapon_name[e]
g_weapon_slot = 9
g_slot_1 = 0
g_slot_2 = 0
g_slot_3 = 0
g_slot_4 = 0
g_slot_5 = 0
g_slot_6 = 0
g_slot_7 = 0
g_slot_8 = 0
g_slot_9 = 1
g_slot_9_level = "3"
end
end
else
if g_PlayerController==0 then
if g_PlayerGunID > 0 then
Prompt ("Press T to replace with " .. weapon_name[e] )
else
Prompt ("Cannot collect any more weapons" )
end
else
Prompt ("Cannot collect any more weapons" )
end
end
if g_InKey == "t" and g_PlayerGunID > 0 and g_level >= 3 then
if g_slot_1 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_1 = weapon_name[e]
g_slot_1_level = "3"
elseif g_slot_2 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_2 = weapon_name[e]
g_slot_2_level = "3"
elseif g_slot_3 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_3 = weapon_name[e]
g_slot_3_level = "3"
elseif g_slot_4 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_4 = weapon_name[e]
g_slot_4_level = "3"
elseif g_slot_5 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_5 = weapon_name[e]
g_slot_5_level = "3"
elseif g_slot_6 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_6 = weapon_name[e]
g_slot_6_level = "3"
elseif g_slot_7 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_7 = weapon_name[e]
g_slot_7_level = "3"
elseif g_slot_8 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_8 = weapon_name[e]
g_slot_8_level = "3"
elseif g_slot_9 == 1 then
PromptDuration("Replaced with " .. weapon_name[e] .. " level 3" ,3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
g_weapon_9 = weapon_name[e]
g_slot_9_level = "3"
end
end
elseif Result < 20.0 and weapon_therecanbeonlyone==e and g_level < 3 then
Prompt ("You need to be Level 3 to pick up this " .. weapon_name[e])
end
else
if weapon_therecanbeonlyone==e then
weapon_therecanbeonlyone = 0
end
end
end
(I added 2 weapon level scripts to make it easier for you to analyze how to change them for any level)
also here are the potions:
Weak Potion
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
function weak_potion_init(e,name)
weapon_name[e] = "Weak Potion"
end
function weak_potion_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 and g_weak_potion_count < max_weak_potions then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if g_KeyPressE == 1 then
PromptDuration("Collected the " .. weapon_name[e],3000)
PlaySound(e,0)
Destroy(e)
g_weak_potion_count = g_weak_potion_count + 1
end
TextCenterOnX(50,45,1, "Press [E] To collect " .. weapon_name[e])
elseif PlayerDist < 150 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 and g_weak_potion_count == max_weak_potions then
Prompt("You have maximum Weak Potions amount")
end
end
Normal Potion
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
function normal_potion_init(e,name)
weapon_name[e] = "Potion"
end
function normal_potion_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 and g_potion_count < max_potions then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if g_KeyPressE == 1 then
PromptDuration("Collected the " .. weapon_name[e],3000)
PlaySound(e,0)
Destroy(e)
g_potion_count = g_potion_count + 1
end
TextCenterOnX(50,45,1, "Press [E] To collect " .. weapon_name[e])
elseif PlayerDist < 150 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 and g_potion_count == max_potions then
Prompt("You have maximum Potions amount")
end
end
Strong Potion
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
function strong_potion_init(e,name)
weapon_name[e] = "Strong Potion"
end
function strong_potion_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 and g_strong_potion_count < max_strong_potions then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if g_KeyPressE == 1 then
PromptDuration("Collected the " .. weapon_name[e],3000)
PlaySound(e,0)
Destroy(e)
g_strong_potion_count = g_strong_potion_count + 1
end
TextCenterOnX(50,45,1, "Press [E] To collect " .. weapon_name[e])
elseif PlayerDist < 150 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 and g_strong_potion_count == max_strong_potions then
Prompt("You have maximum Strong Potions amount")
end
end
4. Leveling system
This is pretty simple and does not need explanation also. For each level you need to gather +100 XP. This means.
To get to level:
2 - you need 100 XP
3 - you need another 200 XP
4 - You need another 300 XP
etc.
So in this case to get to level 4 you need 100+200+300 XP = 600 XP
5. So how to put this into your game?
1. add the scripts somewhere to Game Guru scriptbank folder:
DiskLetter:\Steam\steamapps\common\Game Guru\Files\scriptbank
2. Attach the rpg_menu script to any object on the map
3. Set the object to:
Static - No
Always Active - Yes
It needs to be always active because otherwise it will work only around this object.
To add custom RPG weapons:
Just place any weapon in the editor and change the script to the custom one.
To add potions
You need to set the object Static to No
It could work with any object really but I advise to use it with something that fits
.
[KNOWN BUGS]
1. The slot tracker may not catch the weapon change and replaces the wrong weapon in the inventory.
2. I have not found any solution to disable or track mouse wheel weapon change so you have to use keys 1-9 to change weapons - Otherwise replacing the weapon will always change the wrong one.
I do not know how to fix this but maybe someone on the forums will be able to help.
3. For some reason the sound doesn't play when you Level up.
This is all I have for you for now. I know it is very long post but also hope I went in depth to the level that anyone will be able to edit those scripts and put them in their games.
I will be happy if you give me feedback as I have more in store for you including: Custom RPG Radar, AI quest givers, Readable notes, Enemies crafted to work with those scripts setup and radar, zones that save and load RPG values when changing levels, Escort Quest scripts setup and Items that change quest values when picked up.
If you like this please let me know what should I post next.
Thanks,
Krupar
PS. I have asked support if it is ok to share modified stock GG scripts on the forums. I have received a Yes message so please contact me if there are any doubts about this post or scripts attached.