I created a set of scripts that turn games created with GameGuru into Action RPG. Parts of the script are published in the Asset Store and the rest I'll post to this thread. Video about my scripts so far:
https://www.youtube.com/watch?v=3iBF_PH9kxA
Note for all the users of RPG or Survival Module:
Parts of RPG Module, Quest system and Survival module are not fully compatible with the official Save Game and Load Game function of GameGuru out-of-box. In order to make the scripts work properly, please use the modified gamedata.lua provided in the bottom of this post. With that, all of my sripts in the Store should work properly. If not, please PM me with a bug report.
If you are having problems, first make sure you are using the latest versions of the scripts (you can check the file edit dates of the newest updates of the Store scripts in this thread). If (for some reason) you want to use the older version of the script set, you can use the alternative Save Game / Load Game system provided in the script "RPG Menu with Save Game / Load Game".
Status 24.10.2016. All the scripts in The Game Creators Asset Store have been updated. The free scripts in this thread (except modified gamedata.lua) are not yet compatible with the official Save Game / Load Game system. I'm currently updating them, but testing the updated versions takes time, so please be patient! I'll update all of them at the same time when the whole work is finished. If the publishing of your game is dependent on the functionality of my free script, please PM me, so I'll send you the newest version of the individual script you need. Otherwise please wait for the updates in this post.
moshroom_rpg_ai_fantasycharacter.lua (version 1.4.1, 10.10.2016)
The Action RPG Battle Mechanics script or "RPG AI" replaces the default damage control of GameGuru by one that is based on RPG statistics. Player will have four basic statistics: Power (SpellPower), Vitality, Agility and Sight. Power determines how many points of damage player's attack will cause to an enemy in addition to the damage caused by equipped weapon. For 3rd person wizard character, Power determines the size of the fireball. Vitality determines (inversely) how many points of damage enemy's attack will cause to player. Agility determines how often player can infilct damage to an entity and Sight how far away. If player tries to hit too often, enemy will evade and if too far away, the hit will miss. Every kill will grant player EXP, which will result in Level up in time to time. In each level up, one of the basic statistics will be upgraded. Player will also be granted gold. The "RPG AI" is published in the Asset Store:
https://en.tgcstore.net/product/25685
moshroom_rpg_menu.lua (version 1.4.1, 10.10.2016)
This script creates RPG Menu where player can access Inventory, Equipment and Status screens. The options screen give player a possibility to change font size, cursor behaviour, set the info text of RPG Menu and Shop Menu on/off and change the style of dialogue in the game. The behaviour of the menu depends on the other RPG scripts on the map.
The RPG Menu is published in the Asset Store:
https://en.tgcstore.net/product/25687
moshroom_rpg_shop.lua (version 1.4.1, 10.10.2016)
This script creates Shop Menu where player can buy items, weapons, armor and accessory, depending on other scripts used in the game.
If this is used alone without my other RPG Scripts, player starts with 10000 Gold. Items player buys will be used right away. In 1st person mode there are 4 items: Healing Potion, High Potion and Elixir that fill players health up to MAXHP and Boost Potion that can add health over MAXHP. In 3rd person mode there is an additional item Power Source that raises SpellPower of wizard character. (NOTE: This overrides the default Power stat with g_RPG_SpellPower which mean that it nullifies the collected Magic items.)
If there is an entity with moshroom_rpg_ai_fantasycharacter.lua on the map, player starts with 0 Gold. In addition to 4 healing item available in the shop, there are 4 RPG items, Power Source, Vitality Source, Agility Source and Sight Source that raise corresponding RPG statistics. If there is an entity with moshroom_rpg_menu.lua or moshroom_rpg_menu_savepoint.lua in the map, the items bought from the shop are not used right away, but stored into the Inventory for later use. If moshroom_rpg_ai_fantasycharacter.lua as well as the moshroom_rpg_menu.lua are placed on the map and third person mode is active, player can also buy equipment.
The RPG Shop is published in the Asset Store:
https://en.tgcstore.net/product/25686
moshroom_rpg_npc_talking.lua (version 1.4.1, 10.10.2016)
This script creates and NPC who talks. Depending on the settings, the NPC will talk either custom lines determined by user or random generic lines. The Talking NPC is published in the Asset Store:
https://en.tgcstore.net/product/25834
moshroom_quest_*.lua (version 1.131, 10.10.2016)
For my Quest script, please visit this thread in the Store forum:
https://forum.game-guru.com/thread/214274
moshroom_map_*.lua (version 2.1, 18.10.2016)
This is an enhanced version of my winzone/returnzone scripts. It stores player data between maps and enables returning to the last checkpoint of previous map. It's a bit tricky to use so read the instructions carefully. The script is published in the Asset Store:
https://en.tgcstore.net/product/26457
moshroom_time_*.lua (version 1.131, 13.10.2016)
This script creates a set of doors that are operated by time. The script is published in the Asset Store:
https://www.tgcstore.net/product/27997
moshroom_rpg_status_prompt.lua
If there is no RPG Menu, this can be used to check the status. Creates an NPC who tells player his/her RPG statistics.
-- LUA Script - precede every function and global member with lowercase name of script
-- The Status Prompt is temporary part of the Moshroom's RPG Module
-- Define flags to communicate with other RPG scripts
FLAG_DIALOG = 1
-- Define the constants
TALK_DISTANCE = 100
DIV_PARAM = 25
LEVEL_PARAM_A = 105
LEVEL_PARAM_B = 75
LEVEL_PARAM_C = 5
-- Define table to store entity names
EntityName = {}
-- Define table for status changes
State = {"Normal", "Critical", "Overdrive"}
Line = {}
-- Init when level first runs
function moshroom_rpg_status_prompt_init_name(e, name)
-- Load the entity name
EntityName[e] = name
-- Init the options
TextSize = 1
MessageWindow = 1
ShopActive = 0
MenuActive = 0
-- Init the RPG stats
g_RPG_Level = 1
g_RPG_EXP = 0
g_RPG_Threshold = 0
g_RPG_ToNextLevel = 0
g_RPG_SpellPower = 100
g_RPG_Vitality = 100
g_RPG_Agility = 100
g_RPG_Sight = 100
g_RPG_State = 1
g_RPG_Gold = 0
-- Init the text
StoryLine = 0
TextTime = 0
end
function MultiMessage(e, WindowHeight, MessageID, MessageFinal)
if MenuActive == 0 and ShopActive == 0 then
-- If MessageWindow is set on, show it
if MessageWindow == 1 then
Panel(20,90 - 5 * WindowHeight,80,95)
-- Show who's speaking
Text(22,90 - 5 * (WindowHeight - 1),TextSize,"<" .. EntityName[e] .. ">")
-- Show the message
if Line[MessageID] == nil or MessageID == MessageFinal then
Text(22,90 - 5 * (WindowHeight - 2),TextSize,Line[MessageFinal])
else
Text(22,90 - 5 * (WindowHeight - 2),TextSize,Line[MessageID])
TextCenterOnX(50,90 - 5 * (WindowHeight - 3),TextSize,"-- Press E to hear more --")
end
else
-- If MessageWindo is set off, just show regular prompt
if Line[MessageID] == nil or MessageID == MessageFinal then
Prompt(Line[MessageFinal])
else
Prompt(Line[MessageID] .. " (Press E to hear more)")
end
end
end
end
function moshroom_rpg_status_prompt_main(e)
PlayerDist = GetPlayerDistance(e)
-- Initiate RPG Module parts that can't be initiated in the init() function
if g_RPG_MAXHP == nil then
g_RPG_MAXHP = g_PlayerHealth
end
-- Process player state
if g_PlayerHealth <= g_RPG_MAXHP and g_PlayerHealth >= g_RPG_MAXHP / 4 then
g_RPG_State = 1 -- Normal
end
if g_PlayerHealth < g_RPG_MAXHP / 4 then
g_RPG_State = 2 -- Critical
end
if g_PlayerHealth > g_RPG_MAXHP then
g_RPG_State = 3 -- Overdrive
end
-- Process leveling
g_RPG_Threshold = g_RPG_Level * LEVEL_PARAM_A + (g_RPG_Level - 1) * LEVEL_PARAM_B + (g_RPG_Level - 2) * LEVEL_PARAM_C
g_RPG_ToNextLevel = g_RPG_Threshold - g_RPG_EXP
-- Set the messages
Line[0] = "Do you want to know your status?"
Line[1] = "Your Level is " .. g_RPG_Level .. "."
Line[2] = "You have " .. g_RPG_EXP .. " EXP. You need " .. g_RPG_ToNextLevel .. " before Level up."
Line[3] = "Your Power is " .. g_RPG_SpellPower / DIV_PARAM .. ", Vitality " .. g_RPG_Vitality / DIV_PARAM .. ", Agility " .. g_RPG_Agility / DIV_PARAM .. " and Sight " .. g_RPG_Sight / DIV_PARAM .. "."
Line[4] = "Your HP is " .. g_PlayerHealth .. " and your state is " .. State[g_RPG_State] .. "."
Line[5] = "You have " .. g_RPG_Gold .. " Gold."
Line[6] = "That's all I know."
-- Check if player is near enough to interact
if PlayerDist < TALK_DISTANCE then
LookAtPlayer(e)
-- If E is pressed, initiate or move forward with the conversation
if g_KeyPressE == 1 and GetTimer(e) > TextTime then
TextTime = GetTimer(e) + 1000
StoryLine = StoryLine + 1
end
-- Variable StoryLine controls the phase of the conversation
-- storyLine 0 = Ask player to interact
MultiMessage(e, 3, StoryLine, 6)
-- If player moves away, end the conversation
else
StoryLine = 0
TextTime = 0
end
end
moshroom_rpg_collectable.lua
If there is no RPG Menu script active on the map, this works just as regular collectable (health.lua). If there is RPG Menu, an item will be added to the inventory. The item can be chosen by assigning a number between 1-14 as the entity name (1 = Healing Potion, 2 = High Potion, 3 = Boost Potion, 4 = Elixir, 5 = Antidote, 6 = Stimulant, 7 = Tonic, 8 = Hourglass, 9 = Eye Drops, 10 = Panacea, 11 = Power Source, 12 = Vitality Source, 13 = Agility Source, 14 = Sight Source).
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects Health
-- Define constants to set the limits for item table
ITEM_FIRST = 1
ITEM_LAST = 14
-- Define table for inventory
InvItem = {}
ColItem = {}
DCounter = {}
function moshroom_rpg_collectable_init_name(e, name)
ColItem[e] = name
ColItem[e] = tonumber(ColItem[e])
end
function moshroom_rpg_collectable_main(e)
PlayerDist = GetPlayerDistance(e)
-- If (and only if) Counter[e] returns nil, initiate it
if DCounter[e] == nil then
DCounter[e] = 0
end
-- Checkt that ColItem[e] is a real item. Otherwise set it as 1 (Healing Potion)
if ColItem[e] ~= nil then
-- Make sure that ColItem[e] as integer
ColItem[e] = math.floor(ColItem[e])
-- If ColItem[e] is smaller or larger than item list limits, set it as 1
if ColItem[e] < ITEM_FIRST or ColItem[e] > ITEM_LAST then
ColItem[e] = 1
end
else
-- If ColItem[e] doesn't exist, set it as 1
ColItem[e] = 1
end
-- If player is near enough, alive and the item hasn't yet been collected, collect it
if PlayerDist < 80 and g_PlayerHealth > 0 and DCounter[e] == 0 then
PlaySound(e,0)
if FLAG_MENU == nil then
-- If there is no menu, use the item right away
PromptDuration("Collected health",3000)
AddPlayerHealth(e)
else
-- If there is menu, save the item to the inventory as "Healing Potion"
PromptDuration("Picked up " .. Item[ColItem[e]] .. "!",3000)
if InvItem[ColItem[e]] == nil then
InvItem[ColItem[e]] = 1
else
InvItem[ColItem[e]] = InvItem[ColItem[e]] + 1
end
end
ActivateIfUsed(e)
DCounter[e] = 1
end
if DCounter[e] == 1 then
Hide(e)
CollisionOff(e)
end
if DCounter[e] == 0 then
Show(e)
CollisionOn(e)
end
end
moshroom_rpg_expdoor.lua
This script creates a door that can be opened when player has enough EXP. Set the EXP limit by changing the 'Strenght' value of the door entity.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Based on door.lua script.
-- Define flags to communicate with other RPG scripts
FLAG_DIALOG = 1
-- Define table to store EXP limits
ExpLimit = {}
-- Define table to store entity names
EntityName = {}
-- State to ensure user must release E key before can open/close again
door_pressed = 0
function moshroom_rpg_expdoor_init_name(e, name)
ShopActive = 0
MenuActive = 0
-- Init the RPG Module parts needed
g_RPG_EXP = 0
-- Init the name
EntityName[e] = name
end
function FieldMessage(e, WindowHeight, MessageString1, MessageString2, MessageType)
if MenuActive == 0 and ShopActive == 0 then
-- If MessageWindow is set on, show it
if MessageWindow == 1 then
Panel(20,90 - 5 * WindowHeight,80,95)
-- Show who's speaking
Text(22,90 - 5 * (WindowHeight - 1),TextSize,"<" .. EntityName[e] .. ">")
-- Show the message
if MessageType == 0 then
Text(22,90 - 5 * (WindowHeight - 2),TextSize,MessageString1)
Text(22,90 - 5 * (WindowHeight - 3),TextSize,MessageString2)
end
if MessageType == 1 then
Text(22,90 - 5 * (WindowHeight - 2),TextSize,MessageString1)
TextCenterOnX(50,90 - 5 * (WindowHeight - 3),TextSize,"-- " .. MessageString2 .. " --")
end
else
Prompt(MessageString1 .. " " .. MessageString2 .. ".")
end
end
end
function moshroom_rpg_expdoor_main(e)
-- Process player EXP
if ExpLimit[e] == nil then
ExpLimit[e] = g_Entity[e]['health']
end
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 75 and g_PlayerHealth > 0 then
GetEntityPlayerVisibility(e)
if 1 then
-- If the door is locked (activated = 0)
if g_Entity[e]['activated'] == 0 then
-- If player doesn't have enough EXP, show message a demand
if g_RPG_EXP < ExpLimit[e] then
FieldMessage(e, 2, "The door is locked! You need " .. ExpLimit[e] .. " EXP to open it!", "", 0)
end
-- If player has enough EXP, set the door as opened (activated = 1)
if g_RPG_EXP >= ExpLimit[e] then
SetActivated(e,1)
end
-- If the door is unlocked
else
-- Check whether player has loaded saved game after opening the door
-- If the opening condition hasn't been met, set the door as locked (activated = 0)
if g_RPG_EXP < ExpLimit[e] then
SetActivated(e,0)
end
-- If the door is not locked (activated = 1)
if g_Entity[e]['activated'] == 1 then
if g_Entity[e]['plrvisible'] == 1 then
-- Open the door by pressing E
Prompt("Press E to open")
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,2)
ActivateIfUsed(e)
PlaySound(e,0)
StartTimer(e)
door_pressed = 1
end
end
else
-- If the door is unlocked and open (activated = 2)
if g_Entity[e]['activated'] == 2 then
-- Door collision off after 1 second
if GetTimer(e) > 1000 then
CollisionOff(e)
end
if g_Entity[e]['plrvisible'] == 1 then
-- Close the door by pressing E
if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then
SetAnimation(1)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
SetActivated(e,1)
PlaySound(e,1)
CollisionOn(e)
door_pressed = 1
end
end
end
end
end
end
end
-- If player walks away and the door is open, close the door
if PlayerDist > 200 and g_Entity[e]['activated'] == 2 then
SetAnimation(1)
PlayAnimation(e)
SetActivated(e,1)
CollisionOn(e)
door_pressed = 1
end
if g_KeyPressE == 0 then
door_pressed = 0
end
--PromptLocal ( e, "activated=" .. g_Entity[e]['activated'] .. "PlayerDist=" .. PlayerDist .. " plrvisible=" .. g_Entity[e]['plrvisible'] .. " haskey=" .. g_Entity[e]['haskey'] )
end
moshroom_rpg_expweapon.lua
This script creates a 1st person weapon that can be collected when player has enough EXP. Set the EXP limit by changing the 'Strenght' value of the weapon entity.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Based on deafult weapon.lua script.
-- Define flags to communicate with other RPG scripts
FLAG_DIALOG = 1
FLAG_AI = 1 -- This activates EXP system in case there isn't any rpg_ai in the map
-- Define the constants
TALK_DISTANCE = 75
-- Define flag table to enable the message system
Flag_Done = {}
-- Set the counters for custom timer
MsgTime = {}
CountTime = {}
Timed = {}
weapon_therecanbeonlyone = 0
function moshroom_rpg_expweapon_init_name(e,name)
-- Initiate the shop and menu state
ShopActive = 0
MenuActive = 0
-- Init the RPG Module parts needed
g_RPG_EXP = 0
-- Initiate the options
MessageWindow = 1
TextSize = 1
-- Initiate the Timed[e] message
Timed[e] = 0
MsgTime[e] = 0
CountTime[e] = 0
weapon_name[e] = name
end
function QuestMessage(e, WindowHeight, MessageString0, MessageString1, MessageString2, MessageType)
if MenuActive == 0 and ShopActive == 0 then
-- If MessageWindow is set on, show it
if MessageWindow == 1 then
Panel(20,90 - 5 * WindowHeight,80,95)
-- Show who's speaking
Text(22,90 - 5 * (WindowHeight - 1),TextSize,MessageString0)
-- Show the message
if MessageType == 0 then
Text(22,90 - 5 * (WindowHeight - 2),TextSize,MessageString1)
Text(22,90 - 5 * (WindowHeight - 3),TextSize,MessageString2)
end
if MessageType == 1 then
Text(22,90 - 5 * (WindowHeight - 2),TextSize,MessageString1)
TextCenterOnX(50,90 - 5 * (WindowHeight - 3),TextSize,"-- " .. MessageString2 .. " --")
end
else
Prompt(MessageString1 .. " " .. MessageString2 .. ".")
end
end
end
function CustomTimer(e, MessageTime, FlagDestroy)
if Timed[e] == 0 then
if CountTime[e] == 0 then
CountTime[e] = GetTimer(e)
MsgTime[e] = GetTimer(e) + MessageTime
end
-- If the timer is running, use it
if CountTime[e] ~= 0 then
CountTime[e] = GetTimer(e)
end
-- If the the timer reaches goal, reset it and deactivate prompt
if CountTime[e] > MsgTime[e] then
Timed[e] = 1
MsgTime[e] = 0
CountTime[e] = 0
if FlagDestroy == 1 then
Destroy(e)
end
if FlagDestroy == 2 then
SetEntityHealth(e,0)
end
end
end
end
function moshroom_rpg_expweapon_main(e)
-- Process player EXP
if ExpLimit == nil then
ExpLimit = g_Entity[e]['health']
end
PlayerDist = GetPlayerDistance(e)
if PlayerDist < TALK_DISTANCE and g_PlayerThirdPerson == 0 and Flag_Done[e] ~= 1 then
-- If player approaches the item, but the Quest is inactive, show message
if g_RPG_EXP < ExpLimit then
QuestMessage(e, 2, "<" .. weapon_name[e] .. ">", "You need " .. ExpLimit .. " EXP to pick up the weapon!", "", 0)
end
end
-- If player has completed the Quest, the weapon becomes collectable
if QCounter[QID[e]] > 2 and Flag_Done[e] ~= 1 then
if weapon_therecanbeonlyone==-1 then
if g_KeyPressE == 0 and g_InKey == "" then
weapon_therecanbeonlyone = 0
end
end
if PlayerDist < TALK_DISTANCE 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
if Result < 20.0 and weapon_therecanbeonlyone==e then
if g_PlayerGunCount < 9 then
if g_PlayerGunID > 0 then
if g_PlayerController == 0 then
QuestMessage(e, 3, "<" .. weapon_name[e] .. ">", "EXP limit exceeded!", "Press E to pick up the weapon or T to replace", 1)
else
QuestMessage(e, 3, "<" .. weapon_name[e] .. ">", "EXP limit exceeded!", "Press Y button to pick up the weapon", 1)
end
else
if g_PlayerController == 0 then
QuestMessage(e, 3, "<" .. weapon_name[e] .. ">", "EXP limit exceeded!", "Press E to pick up the weapon or T to replace", 1)
else
QuestMessage(e, 3, "<" .. weapon_name[e] .. ">", "EXP limit exceeded!", "Press Y button to pick up the weapon", 1)
end
end
if g_KeyPressE == 1 then
Flag_Done[e] = 1
PlaySound(e,0)
AddPlayerWeapon(e)
Hide(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
end
else
if g_PlayerController==0 then
if g_PlayerGunID > 0 then
QuestMessage(e, 3, "<" .. weapon_name[e] .. ">", "EXP limit exceeded!", "Press T to replace your weapon", 1)
else
QuestMessage(e, 3, "<" .. weapon_name[e] .. ">", "EXP limit exceeded!", "Cannot collect any more weapons", 1)
end
else
QuestMessage(e, 3, "<" .. weapon_name[e] .. ">", "EXP limit exceeded!", "Cannot collect any more weapons", 1)
end
end
if g_InKey == "t" and g_PlayerGunID > 0 then
Flag_Done[e] = 1
PlaySound(e,0)
ReplacePlayerWeapon(e)
Hide(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
end
end
else
if weapon_therecanbeonlyone==e then
weapon_therecanbeonlyone = 0
end
end
end
-- If the weapon has been collected, show the message
if Flag_Done[e] == 1 then
CustomTimer(e, 2500, 1)
if Timed[e] == 0 then
QuestMessage(e, 1, "Collected the weapon!", "", "", 0)
end
end
end
moshroom_rpg_battlemessage.lua
This script changes battlemessage from prompt to windowed. This feature can be turned on/off from the upcoming updated version of the RPG Menu which I try to publish next week (whenever the Quest system is ready).
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- This script changes the battle message of Moshroom's RPG script from prompt to windowed
-- This feature can be turned on/off from the upcoming version of RPG menu
function moshroom_rpg_battlemessage_init(e)
-- Initiate the options
BMessageWindow = 1
TextSize = 1
-- Initiate the Timed message
BTimed = 0
BMsgTime = 0
BCountTime = 0
BMsgActive = 0
BMessageString = 0
BMessageTime = 1
end
function BattleMessage(e, MessageID, MessageTime)
-- Message 1 = Enemy damaged
if MessageID == 1 then
BMessageString = EntityName[e] .. " lost " .. math.floor(LOST_HP[e]) .. " HP! Remaining: " .. math.floor(Entity_HP[e] - DCounter[e]) .. " / " .. Entity_HP[e] .. "."
end
-- Message 2 = Enemy defeated
if MessageID == 2 then
BMessageString = EntityName[e] .. " defeated! You gained " .. Entity_EXP[e] .. " EXP! You got " .. Entity_Gold[e] .. " gold!"
end
-- Message 21 = Enemy defeated + level up
if MessageID == 21 then
BMessageString = EntityName[e] .. " defeated! You gained " .. Entity_EXP[e] .. " EXP! Your level rose to " .. g_RPG_Level .. "! You got " .. Entity_Gold[e] .. " gold!"
end
-- Message 3 = Too fast
if MessageID == 3 then
BMessageString = "Evaded! You are too slow!"
end
-- Message 4 = Too far away
if MessageID == 4 then
BMessageString = "Missed! " .. EntityName[e] .. " is too far away!"
end
-- Message 5 = You hurt
if MessageID == 5 then
if Entity_STR[e] - g_RPG_Vitality / DIV_PARAM - g_Eq_Armor * EQ_PARAM > 0 then
BMessageString = "You lost " .. math.floor(Entity_STR[e] - g_RPG_Vitality / DIV_PARAM - g_Eq_Armor * EQ_PARAM) .. " HP!"
else
BMessageString = "You lost 1 HP!"
end
end
if BMessageWindow == 1 then
-- If message is set as window, view window
BMessageTime = MessageTime
BTimed = 1
else
-- If message is set as prompt, view prompt
PromptDuration(BMessageString,MessageTime)
end
end
function BMWindow(e)
if BTimed == 1 then
if BCountTime == 0 then
BCountTime = GetTimer(e)
BMsgTime = GetTimer(e) + BMessageTime
end
-- If the timer is running, use it
if BCountTime ~= 0 then
BCountTime = GetTimer(e)
Panel(20,85,80,95)
TextCenterOnX(50,90,TextSize,BMessageString)
end
-- If the the timer reaches goal, reset it and deactivate prompt
if BCountTime > BMsgTime then
BTimed = 0
BMsgTime = 0
BCountTime = 0
end
end
end
function moshroom_rpg_battlemessage_main(e)
-- Process Battle Message Window
if BMessageWindow == 1 then
BMWindow(e)
end
end
moshroom_rpg_winzone.lua
This script saves the RPG data to a temporary file in the end of a map so it can be reloaded in the next map. Note: 1st person weapons and entity damage counters are not saved.
-- LUA Script - precede every function and global member with lowercase name of script
-- Define the constants
NUM_INV = 14
-- Define tables for inventory
InvItem = {}
InvWeapon = {}
InvArmor = {}
InvAccessory = {}
function moshroom_rpg_winzone_init(e)
-- Init the clock
TimeSecond = 0
TimeMinute = 0
TimeHour = 0
-- Init the options
CursorPosition = 1
TextSize = 1
FrontPageText = 1
MessageWindow = 1
BMessageWindow = 1
-- Init the RPG stats
g_RPG_Level = 1
g_RPG_EXP = 0
g_RPG_Threshold = 0
g_RPG_ToNextLevel = 0
g_RPG_SpellPower = 100
g_RPG_Vitality = 100
g_RPG_Agility = 100
g_RPG_Sight = 100
g_RPG_State = 1
g_RPG_Gold = 0
-- Init the equipment
g_Eq_Weapon = 0
g_Eq_Armor = 0
g_Eq_Accessory = 0
end
function moshroom_rpg_winzone_main(e)
if g_Entity[e]['plrinzone'] == 1 then
-- Create local variable file and link it to temp.dat
local file = io.open("temp.dat", "w")
-- Write player data to file
file:write(
TimeHour .. "\n" ..
TimeMinute .. "\n" ..
TimeSecond .. "\n" ..
g_RPG_Gold .. "\n" ..
g_RPG_Level .. "\n" ..
g_RPG_EXP .. "\n" ..
g_RPG_SpellPower .. "\n" ..
g_RPG_Vitality .. "\n" ..
g_RPG_Agility .. "\n" ..
g_RPG_Sight .. "\n" ..
g_RPG_State .. "\n" ..
g_PlayerHealth .. "\n" ..
g_PlayerLives .. "\n" ..
g_Eq_Weapon .. "\n" ..
g_Eq_Armor .. "\n" ..
g_Eq_Accessory .. "\n" ..
TextSize .. "\n" ..
CursorPosition .. "\n" ..
FrontPageText .. "\n" ..
MessageWindow .. "\n" ..
BMessageWindow .. "\n")
-- Write the inventory tables to file
for i = 1,NUM_INV do
if InvItem[i] ~= nil then
file:write(InvItem[i] .. "\n")
else
file:write("0\n")
end
end
for i = 1,NUM_INV do
if InvWeapon[i] ~= nil then
file:write(InvWeapon[i] .. "\n")
else
file:write("0\n")
end
end
for i = 1,NUM_INV do
if InvArmor[i] ~= nil then
file:write(InvArmor[i] .. "\n")
else
file:write("0\n")
end
end
for i = 1,NUM_INV do
if InvAccessory[i] ~= nil then
file:write(InvAccessory[i] .. "\n")
else
file:write("0\n")
end
end
file:close()
-- Jump to level specified in IfUsed field
JumpToLevelIfUsed(e)
end
end
moshroom_rpg_memoryzone.lua
This script loads the RPG data from a temporary file.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Define the constants
NUM_INV = 14
-- Define tables for inventory
InvItem = {}
InvWeapon = {}
InvArmor = {}
InvAccessory = {}
function moshroom_rpg_memoryzone_init(e)
-- Init the clock
TimeSecond = 0
TimeMinute = 0
TimeHour = 0
-- Init the options
CursorPosition = 1
TextSize = 1
FrontPageText = 1
MessageWindow = 1
BMessageWindow = 1
-- Init the RPG stats
g_RPG_Level = 1
g_RPG_EXP = 0
g_RPG_Threshold = 0
g_RPG_ToNextLevel = 0
g_RPG_SpellPower = 100
g_RPG_Vitality = 100
g_RPG_Agility = 100
g_RPG_Sight = 100
g_RPG_State = 1
g_RPG_Gold = 0
-- Init the equipment
g_Eq_Weapon = 0
g_Eq_Armor = 0
g_Eq_Accessory = 0
-- Init the memoryzone
Flag_Memory = 0
end
function moshroom_rpg_memoryzone_main(e)
-- Make sure that RPG data has been loaded before activating the memoryzone
if g_Time > 10 and g_Time < 100 then
Flag_Memory = 1
end
if g_Entity[e]['plrinzone'] == 1 then
-- Test whether the memoryzone is active
if Flag_Memory == 1 then
-- Create local variable file and link it to temp.dat
local file = io.open("temp.dat", "r")
-- If temp.dat doesn't exist, return nil
if file == nil then
-- Do nothing
else
-- Load and set the clock
TimeHour = file:read("*n", "*l")
TimeMinute = file:read("*n", "*l")
TimeSecond = file:read("*n", "*l")
-- Load and set the RPG variables
g_RPG_Gold = file:read("*n", "*l")
g_RPG_Level = file:read("*n", "*l")
g_RPG_EXP = file:read("*n", "*l")
g_RPG_SpellPower = file:read("*n", "*l")
g_RPG_Vitality = file:read("*n", "*l")
g_RPG_Agility = file:read("*n", "*l")
g_RPG_Sight = file:read("*n", "*l")
g_RPG_State = file:read("*n", "*l")
-- Load player health and lives
local fHealth = file:read("*n", "*l")
local fLives = file:read("*n", "*l")
-- Load and set player equipment
g_Eq_Weapon = file:read("*n", "*l")
g_Eq_Armor = file:read("*n", "*l")
g_Eq_Accessory = file:read("*n", "*l")
-- Load and set the RPG menu options
TextSize = file:read("*n", "*l")
CursorPosition = file:read("*n", "*l")
FrontPageText = file:read("*n", "*l")
MessageWindow = file:read("*n", "*l")
BMessageWindow = file:read("*n", "*l")
-- Load and set the inventory
for i = 1,NUM_INV do
InvItem[i] = file:read("*n", "*l")
end
for i = 1,NUM_INV do
InvWeapon[i] = file:read("*n", "*l")
end
for i = 1,NUM_INV do
InvArmor[i] = file:read("*n", "*l")
end
for i = 1,NUM_INV do
InvAccessory[i] = file:read("*n", "*l")
end
-- Set GameGuru specific player data : Basic stats
SetPlayerHealth(fHealth)
SetPlayerLives(e, fLives)
-- Set GameGuru specific palyer data : RPG Module
SetPlayerPower(e, g_RPG_SpellPower)
-- Reset Inventory to prevent crash
for i = 1,NUM_INV do
if InvItem[i] == 0 then
InvItem[i] = nil
end
end
file:close()
end
-- Set the memory flag as 2 to prevent repeated loads
Flag_Memory = 2
end
end
end
gamedata.lua
This version of the gamedata.lua file saves/load all the tables of RPG Module and my Quest script to/from an additional save file, which creates a compatibility to the official Save/Load system. To use it, replace the gamedata.lua file in your titlesbank folder. It is recommended to backup the original file before doing so. Also make sure that you have the latest versions of the RPG and Quest scripts. Following scripts are currently up to date: All of the store scripts.
Use this version if you use my RPG scripts AND my Quest scripts in your game.
If you don't have the Quest scripts, uncomment lines 20-31 from this file. The reason for this is that the quest_begin script constantly calculates targets for quantitative quests (e.g. kill, collect, destroy) in the background and will return error if the Save Game function redefines the tables between initiating and saving. If you don't have Quest scripts active, the Save Game returns error because the tables aren't defined at all.
I'm aware that this fix has too many steps (1. Read the script 2. Paste it into a LUA file 3. Save it into a right folder 4. If you don't use Quests, edit the file manually) to be regarded easy-to-use. Fear not. I'm going to create a more sophisticated version of the gamedata script as soon as I've finished with the grand update of all the other RPG scripts.
-- Gamedata.lua. Edits by Moshroom 10.10.2016
-- This is an edited versio of the gamedata.lua file of GameGuru version 1.131. This enables
-- saving of the tables of my RPG and Quest scripts and therefore makes them compatible
-- with the official Save Game/Load Game system.
-- Define RPG and Quest tables for save/load system
InvItem = {}
InvWeapon = {}
InvArmor = {}
InvAccessory = {}
Counter = {}
DCounter = {}
QCounter = {}
HP = {}
-- Uncomment these if you don't have Quest scripts active, so the gamedata.lua won't return error
--[[
QQuantity = {}
QProgress = {}
QCountable = {}
QRequest = {}
QRequest_Get = {}
QRequest_Carry = {}
QRequest_Bribe = {}
QRequest_KillCreature = {}
QRequest_KillCharacter = {}
QRequest_KillZombie = {}
QRequest_KillSoldier = {}
QRequest_Destroy = {}
]]--
local gamedata = {}
-- Define RPG Globals
NUM_INV = 14
NUM_COUNTERS = 9999
function gamedata.save(slotnumber,uniquename)
-- save slot file
file = io.open("savegames\\gameslot" .. slotnumber .. ".dat", "w")
io.output(file)
-- header for game ID
io.write(123 .. "\n")
io.write(g_iGameNameNumber .. "\n")
io.write(uniquename .. "\n")
io.write(g_LevelFilename .. "\n")
io.write(0 .. "\n")
-- player stats
io.write("g_PlayerPosX=" .. g_PlayerPosX .. "\n")
io.write("g_PlayerPosY=" .. g_PlayerPosY .. "\n")
io.write("g_PlayerPosZ=" .. g_PlayerPosZ .. "\n")
io.write("g_PlayerAngX=" .. g_PlayerAngX .. "\n")
io.write("g_PlayerAngY=" .. g_PlayerAngY .. "\n")
io.write("g_PlayerAngZ=" .. g_PlayerAngZ .. "\n")
io.write("g_PlayerHealth=" .. g_PlayerHealth .. "\n")
io.write("g_PlayerLives=" .. g_PlayerLives .. "\n")
io.write("g_PlayerGunName=" .. g_PlayerGunName .. "\n")
-- weapon stats
UpdateWeaponStats()
for i = 1, 10, 1 do
io.write("g_WeaponSlotGot[" .. i .. "]=" .. g_WeaponSlotGot[i] .. "\n")
end
for i = 1, 10, 1 do
io.write("g_WeaponSlotPref[" .. i .. "]=" .. g_WeaponSlotPref[i] .. "\n")
end
for i = 1, 20, 1 do
io.write("g_WeaponAmmo[" .. i .. "]=" .. g_WeaponAmmo[i] .. "\n")
end
for i = 1, 20, 1 do
io.write("g_WeaponClipAmmo[" .. i .. "]=" .. g_WeaponClipAmmo[i] .. "\n")
end
for i = 1, 100, 1 do
io.write("g_WeaponPoolAmmo[" .. i .. "]=" .. g_WeaponPoolAmmo[i] .. "\n")
end
-- entity stats
io.write("g_EntityElementMax=" .. g_EntityElementMax .. "\n")
for e = 1, g_EntityElementMax, 1 do
if g_Entity[e] ~= nil then
io.write("g_Entity[" .. e .. "]['x']=" .. g_Entity[e]['x'] .. "\n")
io.write("g_Entity[" .. e .. "]['y']=" .. g_Entity[e]['y'] .. "\n")
io.write("g_Entity[" .. e .. "]['z']=" .. g_Entity[e]['z'] .. "\n")
io.write("g_Entity[" .. e .. "]['anglex']=" .. GetEntityAngleX(e) .. "\n")
io.write("g_Entity[" .. e .. "]['angley']=" .. GetEntityAngleY(e) .. "\n")
io.write("g_Entity[" .. e .. "]['anglez']=" .. GetEntityAngleZ(e) .. "\n")
io.write("g_Entity[" .. e .. "]['active']=" .. GetEntityActive(e) .. "\n")
io.write("g_Entity[" .. e .. "]['activated']=" .. g_Entity[e]['activated'] .. "\n")
io.write("g_Entity[" .. e .. "]['collected']=" .. g_Entity[e]['collected'] .. "\n")
io.write("g_Entity[" .. e .. "]['haskey']=" .. g_Entity[e]['haskey'] .. "\n")
io.write("g_Entity[" .. e .. "]['health']=" .. g_Entity[e]['health'] .. "\n")
io.write("g_Entity[" .. e .. "]['frame']=" .. g_Entity[e]['frame'] .. "\n")
io.write("g_EntityExtra[" .. e .. "]['visible']=" .. GetEntityVisibility(e) .. "\n")
io.write("g_EntityExtra[" .. e .. "]['spawnatstart']=" .. GetEntitySpawnAtStart(e) .. "\n")
end
end
-- radarobjectives array
if radarObjectives ~= nil then
for i = 0, g_objectiveCount, 1 do
if radarObjectives[i] ~= nil then
io.write("radarObjectives[" .. i .. "]=" .. radarObjectives[i] .. "\n")
end
end
end
-- stray script created globals
for n in pairs(_G) do
if string.find(tostring(_G[n]), "function:") == nil and string.find(tostring(_G[n]), "table:") == nil then
dumpout = 1
if n == "file" then dumpout = 0 end
if n == "_G" then dumpout = 0 end
if n == "io" then dumpout = 0 end
if n == "math" then dumpout = 0 end
if string.lower(string.sub(n,1,2)) == "g_" then
if n == "g_PlayerPosX" then dumpout = 0 end
if n == "g_PlayerPosY" then dumpout = 0 end
if n == "g_PlayerPosZ" then dumpout = 0 end
if n == "g_PlayerAngX" then dumpout = 0 end
if n == "g_PlayerAngY" then dumpout = 0 end
if n == "g_PlayerAngZ" then dumpout = 0 end
if n == "g_PlayerHealth" then dumpout = 0 end
if n == "g_PlayerLives" then dumpout = 0 end
if n == "g_PlayerGunName" then dumpout = 0 end
if n == "g_EntityElementMax" then dumpout = 0 end
if n == "g_imgCursor" then dumpout = 0 end
if n == "g_imgBackdrop" then dumpout = 0 end
if n == "g_iGameNameNumber" then dumpout = 0 end
if n == "g_posAboutBackdropAngle" then dumpout = 0 end
if n == "g_imgHeading" then dumpout = 0 end
if n == "g_iGraphicChoice" then dumpout = 0 end
if n == "g_sprHeading" then dumpout = 0 end
if n == "g_strStyleFolder" then dumpout = 0 end
if n == "g_sprSlider" then dumpout = 0 end
if n == "g_sprSliderM" then dumpout = 0 end
if n == "g_sprProgressF" then dumpout = 0 end
if n == "g_sprAboutBackdrop" then dumpout = 0 end
if n == "g_strBestResolution" then dumpout = 0 end
if n == "g_sprCursor" then dumpout = 0 end
if n == "g_sprSliderS" then dumpout = 0 end
if n == "g_iLoadingCountdown" then dumpout = 0 end
if n == "g_posBackdropAngle" then dumpout = 0 end
if n == "g_sprAboutCursor" then dumpout = 0 end
if n == "g_imgAboutBackdrop" then dumpout = 0 end
if n == "g_imgAboutCursor" then dumpout = 0 end
if n == "g_sprProgressB" then dumpout = 0 end
if n == "g_imgProgressB" then dumpout = 0 end
if n == "g_sprBackdrop" then dumpout = 0 end
if n == "g_imgProgressF" then dumpout = 0 end
if n == "g_LevelFilename" then dumpout = 0 end
if n == "g_PlayerGunZoomed" then dumpout = 0 end
if n == "g_PlayerController" then dumpout = 0 end
if n == "g_iMusicChoice" then dumpout = 0 end
if n == "g_PlayerGunMode" then dumpout = 0 end
if n == "g_PlayerGunClipCount" then dumpout = 0 end
if n == "g_PlayerFlashlight" then dumpout = 0 end
if n == "g_gameloop_StartHealth" then dumpout = 0 end
if n == "g_InKey" then dumpout = 0 end
if n == "g_KeyPressA" then dumpout = 0 end
if n == "g_KeyPressR" then dumpout = 0 end
if n == "g_PlayerObjNo" then dumpout = 0 end
if n == "g_PlayerGunAmmoCount" then dumpout = 0 end
if n == "g_PlayerDeadTime" then dumpout = 0 end
if n == "g_DebugStringPeek" then dumpout = 0 end
if n == "g_KeyPressF" then dumpout = 0 end
if n == "g_MouseX" then dumpout = 0 end
if n == "g_iSoundChoice" then dumpout = 0 end
if n == "g_Scancode" then dumpout = 0 end
if n == "g_GameStateChange" then dumpout = 0 end
if n == "g_KeyPressC" then dumpout = 0 end
if n == "g_MouseWheel" then dumpout = 0 end
if n == "g_PlayerThirdPerson" then dumpout = 0 end
if n == "g_gameloop_RegenDelay" then dumpout = 0 end
if n == "g_MouseClick" then dumpout = 0 end
if n == "g_PlayerLastHitTime" then dumpout = 0 end
if n == "g_PlayerGunID" then dumpout = 0 end
if n == "g_gameloop_RegenSpeed" then dumpout = 0 end
if n == "g_KeyPressSPACE" then dumpout = 0 end
if n == "g_PlayerFOV" then dumpout = 0 end
if n == "g_Time" then dumpout = 0 end
if n == "g_gameloop_RegenRate" then dumpout = 0 end
if n == "g_KeyPressS" then dumpout = 0 end
if n == "g_PlayerGunFired" then dumpout = 0 end
if n == "g_KeyPressD" then dumpout = 0 end
if n == "g_MouseY" then dumpout = 0 end
if n == "g_KeyPressW" then dumpout = 0 end
if n == "g_TimeElapsed" then dumpout = 0 end
if n == "g_KeyPressE" then dumpout = 0 end
if n == "g_KeyPressSHIFT" then dumpout = 0 end
if n == "g_PlayerGunCount" then dumpout = 0 end
if dumpout == 1 then
if tonumber(_G[n]) ~= nil then
strType = "number"
else
strType = "string"
end
io.write("GLOBALDUMP=" .. n .. "=" .. strType .. "=" .. tostring(_G[n]) .. "\n")
end
end
end
end
-- end of file
io.close(file)
-- RPG AND QUEST ADDITIONS HERE
-- Open another file
file = io.open("savegames\\gameslot" .. slotnumber .. "b.dat", "w")
--io.output(file) -- not needed
-- Write non-globals to file
file:write(
TimeHour .. "\n" ..
TimeMinute .. "\n" ..
TimeSecond .. "\n" ..
TextSize .. "\n" ..
CursorPosition .. "\n" ..
FrontPageText .. "\n")
-- Write the inventory tables to file
for i = 1,NUM_INV do
if InvItem[i] ~= nil then
file:write(InvItem[i] .. "\n")
else
file:write("0\n")
end
end
for i = 1,NUM_INV do
if InvWeapon[i] ~= nil then
file:write(InvWeapon[i] .. "\n")
else
file:write("0\n")
end
end
for i = 1,NUM_INV do
if InvArmor[i] ~= nil then
file:write(InvArmor[i] .. "\n")
else
file:write("0\n")
end
end
for i = 1,NUM_INV do
if InvAccessory[i] ~= nil then
file:write(InvAccessory[i] .. "\n")
else
file:write("0\n")
end
end -- end for
-- Write the Counter table to file
for i = 1,NUM_COUNTERS do
if Counter[i] ~= nil then
file:write(Counter[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the DCounter table to file
for i = 1,NUM_COUNTERS do
if DCounter[i] ~= nil then
file:write(DCounter[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the QCounter table to file
for i = 1,NUM_COUNTERS do
if QCounter[i] ~= nil then
file:write(QCounter[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if HP[i] ~= nil then
file:write(HP[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QQuantity[i] ~= nil then
file:write(QQuantity[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QProgress[i] ~= nil then
file:write(QProgress[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QCountable[i] ~= nil then
file:write(QCountable[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest[i] ~= nil then
file:write(QRequest[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest_Get[i] ~= nil then
file:write(QRequest_Get[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest_Carry[i] ~= nil then
file:write(QRequest_Carry[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest_Bribe[i] ~= nil then
file:write(QRequest_Bribe[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest_KillCreature[i] ~= nil then
file:write(QRequest_KillCreature[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest_KillCharacter[i] ~= nil then
file:write(QRequest_KillCharacter[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest_KillZombie[i] ~= nil then
file:write(QRequest_KillZombie[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest_KillSoldier[i] ~= nil then
file:write(QRequest_KillSoldier[i] .. "\n")
else
file:write("0\n")
end
end
-- Write the HP table to file
for i = 1,NUM_COUNTERS do
if QRequest_Destroy[i] ~= nil then
file:write(QRequest_Destroy[i] .. "\n")
else
file:write("0\n")
end
end
io.close(file)
g_JustLoaded = 1
end
function gamedata.load(slotnumber)
-- load game data
successful = 0
file = io.open("savegames\\gameslot" .. slotnumber .. ".dat", "r")
if file ~= nil then
io.input(file)
-- header for game ID
iMagicNumber = tonumber(io.read())
iGameNameNumber = tonumber(io.read())
uniquename = io.read()
strLevelFilename = io.read()
iReserved = tonumber(io.read())
-- get all game data
strField = io.read()
while strField ~= nil do
-- get each data item
iDivision = string.find(strField, "=", 1)
strProperty = string.sub(strField, 1, iDivision-1)
strData = string.sub(strField, iDivision+1)
-- player stats
if string.lower(strProperty) == string.lower("g_PlayerPosX") then iPlayerPosX = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_PlayerPosY") then iPlayerPosY = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_PlayerPosZ") then iPlayerPosZ = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_PlayerAngX") then iPlayerAngX = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_PlayerAngY") then iPlayerAngY = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_PlayerAngZ") then iPlayerAngZ = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_PlayerHealth") then iPlayerHealth = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_PlayerLives") then iPlayerLives = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_PlayerGunName") then strPlayerGunName = strData end
-- weapon stats
for i = 1, 10, 1 do
if string.lower(strProperty) == string.lower("g_WeaponSlotGot[" .. i .. "]") then g_WeaponSlotGot[i] = tonumber(strData) end
end
for i = 1, 10, 1 do
if string.lower(strProperty) == string.lower("g_WeaponSlotPref[" .. i .. "]") then g_WeaponSlotPref[i] = tonumber(strData) end
end
for i = 1, 20, 1 do
if string.lower(strProperty) == string.lower("g_WeaponAmmo[" .. i .. "]") then g_WeaponAmmo[i] = tonumber(strData) end
end
for i = 1, 20, 1 do
if string.lower(strProperty) == string.lower("g_WeaponClipAmmo[" .. i .. "]") then g_WeaponClipAmmo[i] = tonumber(strData) end
end
for i = 1, 100, 1 do
if string.lower(strProperty) == string.lower("g_WeaponPoolAmmo[" .. i .. "]") then g_WeaponPoolAmmo[i] = tonumber(strData) end
end
-- entity stats
if string.lower(strProperty) == string.lower("g_EntityElementMax") then g_EntityElementMax = tonumber(strData) end
if string.lower(string.sub(strProperty,1,9)) == string.lower("g_Entity[") or string.lower(string.sub(strProperty,1,14)) == string.lower("g_EntityExtra[") then
iSubscriptEndPos = string.find(strProperty, "]", 1)
if string.lower(string.sub(strProperty,1,9)) == string.lower("g_Entity[") then
strSubscript = string.sub(strProperty,10,iSubscriptEndPos-1)
else
strSubscript = string.sub(strProperty,15,iSubscriptEndPos-1)
end
e = tonumber(strSubscript)
if g_Entity[e] ~= nil then
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['x']") then g_Entity[e]['x'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['y']") then g_Entity[e]['y'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['z']") then g_Entity[e]['z'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['anglex']") then g_Entity[e]['anglex'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['angley']") then g_Entity[e]['angley'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['anglez']") then g_Entity[e]['anglez'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['active']") then g_Entity[e]['active'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['activated']") then g_Entity[e]['activated'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['collected']") then g_Entity[e]['collected'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['haskey']") then g_Entity[e]['haskey'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['health']") then g_Entity[e]['health'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_Entity[" .. e .. "]['frame']") then g_Entity[e]['frame'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_EntityExtra[" .. e .. "]['visible']") then g_EntityExtra[e]['visible'] = tonumber(strData) end
if string.lower(strProperty) == string.lower("g_EntityExtra[" .. e .. "]['spawnatstart']") then g_EntityExtra[e]['spawnatstart'] = tonumber(strData) end
end
end
-- radarobjectives array
if radarObjectives ~= nil then
if string.lower(string.sub(strProperty,1,16)) == string.lower("radarObjectives[") then
iSubscriptEndPos = string.find(strProperty, "]", 1)
strSubscript = string.sub(strProperty,17,iSubscriptEndPos-1)
i = tonumber(strSubscript)
if radarObjectives[i] ~= nil then
if string.lower(strProperty) == string.lower("radarObjectives[" .. i .. "]") then radarObjectives[i] = tonumber(strData) end
end
end
end
-- global dump data
if string.upper(string.sub(strField,1,11)) == string.upper("GLOBALDUMP=") then
iVarNamePos = string.find(strField, "=", 12)
iVarTypePos = string.find(strField, "=", iVarNamePos+1)
local strVarName = string.sub(strField,12,iVarNamePos-1)
local strVarType = string.sub(strField,iVarNamePos+1,iVarTypePos-1)
local strVarValue = string.sub(strField,iVarTypePos+1)
if strVarName~="file" and strVarName~="_G" and strVarName~="io" and strVarName~="math" and strVarName~="arrayread" then
if strVarType == "number" then
_G[strVarName] = tonumber(strVarValue)
else
_G[strVarName] = strVarValue
end
end
end
-- next item
strField = io.read()
end
-- end of file
io.close(file)
-- RPG AND QUEST ADDITIONS HERE
local file = io.open("savegames\\gameslot" .. slotnumber .. "b.dat", "r")
-- If slotx.dat doesn't exist, return nil
if file == nil then
-- Ignore
else
-- Load and set the clock
TimeHour = file:read("*n", "*l")
TimeMinute = file:read("*n", "*l")
TimeSecond = file:read("*n", "*l")
-- Load and set the RPG menu options
TextSize = file:read("*n", "*l")
CursorPosition = file:read("*n", "*l")
FrontPageText = file:read("*n", "*l")
-- Load and set the inventory
for i = 1,NUM_INV do
InvItem[i] = file:read("*n", "*l")
end
for i = 1,NUM_INV do
InvWeapon[i] = file:read("*n", "*l")
end
for i = 1,NUM_INV do
InvArmor[i] = file:read("*n", "*l")
end
for i = 1,NUM_INV do
InvAccessory[i] = file:read("*n", "*l")
end
-- Load and set counters
for i = 1,NUM_COUNTERS do
Counter[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
DCounter[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QCounter[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
HP[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QQuantity[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QProgress[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QCountable[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest_Get[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest_Carry[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest_Bribe[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest_KillCreature[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest_KillCharacter[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest_KillZombie[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest_KillSoldier[i] = file:read("*n", "*l")
end
for i = 1,NUM_COUNTERS do
QRequest_Destroy[i] = file:read("*n", "*l")
end
-- Reset Inventory to prevent crash
for i = 1,NUM_INV do
if InvItem[i] == 0 then
InvItem[i] = nil
end
end -- end for
end -- end if
io.close(file)
successful = 1
g_JustLoaded = 1
end
return successful
end
return gamedata
Alternative solution for users without Quest script (and no willingness to edit the script manually). Use the gamedata.lua version provided in this thread:
https://forum.game-guru.com/thread/214754