Trying to get two scripts to work and play together, the pickupquest and the new weapon_upgrader, I was thinking it would be great to use the pickup quest as a way for the player to get money to spend with the weapon_upgrader.
I thought that Local= cash was a global available to all scripts, so I changed money to cash so both scripts would have access.
However I could not figure out how to get the cash from the pickupQuest to go to the WeaponUpgrader.
the FPM is attached, as are the scripts. The horse is really a ghost, because it refuses to allow a image, (25 attempts ) I did everything, Enitymaker, ModelConverter , gameguru import and hand editing. One of the very few models that I have not been able to finish.
The edited pickup_questtest.lua
--[[ pick up and deliver quest script by smallg
new pick up and deliver quests (no visual carry, just variables)
it does need a short tutorial so here goes....
1. place an npc that will give the quest
1.a. check his entity number and put it into the script under quest 1
example
Quote: "--set the number for the quest (i.e, 1, 2, 3 etc)
quest_number = 1
--set to the entity number of the quest giver
pickup_questtest_npc[quest_number] = 2"
in this case the entity number is 2
2. place an object that is to be collected (static or dynamic is fine but you will likely want to remove any scripts attached to it)
2.a. get the object entity number and put it in the settings for quest 1
Quote: "--entity number of the first item to be collected (lowest entity number)
first_pickup_e[quest_number] = 3"
in this case it's entity number 3
2.b. place as many objects as you wish to be collected
2.c. when you have place the last object check it's entity number and put it in the script
Quote: "--entity number of the last item to be collected (highest entity number)
last_pickup_e[quest_number] = 7"
in this case it's number 7, therefore there will be 5 items to collect (entities 3,4,5,6 & 7)
3. give the item a name in the script (just so the prompts look nicer)
4.a&b. set the ranges of the quest (player distances)
Quote: "--how close the player needs to be to accept and hand-in the quest
quest_talk_range[quest_number] = 150
--how close the player needs to be to pickup the collectable items
pickup_range[quest_number] = 100"
5. set if it's a repeatable quest (1 = yes, 0 = no) *note; quest will reset as soon as player moves out of quest_talk_range*
and repeat for all quests (remember to increase the quest_number by 1 each time)
--]]
local quest_stage = {}
local time1 = 0
local time2 = 0
local timepassed = 0
local delay = 100
local pressed = 0
local quests = 0
local pickup_questtest_npc = {}
local first_pickup_e = {}
local last_pickup_e = {}
local quest_talk_range = {}
local items_collected = {}
local collected = {}
local item_name = {}
local repeatable = {}
local pickup_range = {}
local x = {}
local y = {}
local z = {}
local cash = 0
function pickup_questtest_init(e)
quests = quests + 1
quest_stage[quests] = 0
items_collected[quests] = 0
end --init
--setup quests here (***change the entity numbers to fit your own map or script will not work correctly***)
--set the number for the quest (i.e, 1, 2, 3 etc)
quest_number = 1
--set to the entity number of the quest giver
pickup_questtest_npc[quest_number] = 25
--entity number of the first item to be collected (lowest entity number)
first_pickup_e[quest_number] = 2
--entity number of the last item to be collected (highest entity number)
last_pickup_e[quest_number] = 6
--name of item to be collected here (for prompts)
item_name[quest_number] = "Pads of Life"
--how close the player needs to be to accept and hand-in the quest
quest_talk_range[quest_number] = 150
--how close the player needs to be to pickup the collectable items
pickup_range[quest_number] = 100
--set to 1 if quest can be repeated (no limit) or 0 if a one time only quest
repeatable[quest_number] = 1
--quest2
quest_number = 2
pickup_questtest_npc[quest_number] = 25
item_name[quest_number] = "Health Pack"
first_pickup_e[quest_number] = 11
last_pickup_e[quest_number] = 12
quest_talk_range[quest_number] = 150
pickup_range[quest_number] = 100
repeatable[quest_number] = 0
--quest3
--------
function pickup_questtest_main(e)
for quest_number = 1, quests do
if g_Entity[pickup_questtest_npc[quest_number]] ~= nil then
--check player in range of a quest giver
if GetPlayerDistance(pickup_questtest_npc[quest_number]) <= quest_talk_range[quest_number] then
CharacterControlStand(e)
RotateToPlayer(pickup_questtest_npc[quest_number])
--if quest not started yet
if quest_stage[quest_number] == 0 then
Prompt("Press (e) to continue Hi there, please collect " .. 1 + last_pickup_e[quest_number] - first_pickup_e[quest_number] .. " " .. item_name[quest_number] .. "s for me")
--if player accepts quest
if g_KeyPressE == 1 and pressed == 0 then
pressed = 1
PromptDuration("Come back with my " .. item_name[quest_number] .. "s soon please",2000)
quest_stage[quest_number] = quest_stage[quest_number] + 1
end --end accepted quest
--if quest already started
elseif quest_stage[quest_number] == 1 then
--check how many items the player has
if items_collected[quest_number] > 0 then
--if not collected enough then show how many are left to collect
if items_collected[quest_number] < 1 + last_pickup_e[quest_number] - first_pickup_e[quest_number] then
Prompt("Press (e) to continue I still need " .. 1 + (last_pickup_e[quest_number] - first_pickup_e[quest_number]) - items_collected[quest_number] .. " " .. item_name[quest_number])
else
Prompt("Finish quest? Press(e)to continue, Then go see a weapon upgrader")
--if player has collected all needed items
if g_KeyPressE == 1 and pressed == 0 then
-----
--insert reward code here
--example reward
cash = cash + 10000
-----
--change prompt to match reward
PromptDuration("Thank you, cash = " .. cash,3000)
items_collected[quest_number] = 0
quest_stage[quest_number] = quest_stage[quest_number] + 1
pressed = 1
-----
end --player hands quest in
end --items collected number check
end --items collected above 0
end --stage number check
else
--if quest finished but repeatable reset it
if repeatable[quest_number] == 1 and quest_stage[quest_number] == 2 then
quest_stage[quest_number] = 0
--replace collectables
for item = first_pickup_e[quest_number], last_pickup_e[quest_number] do
Show(item)
CollisionOn(item)
collected[item] = 0
end --for item loop
end --quest reset check
end --player in quest giver range check
for item = first_pickup_e[quest_number], last_pickup_e[quest_number] do
if g_Entity[item] ~= nil then
if collected[item] == nil then
collected[item] = 0
end
if GetPlayerDistance(item) <= pickup_range[quest_number] and quest_stage[quest_number] == 1 and collected[item] == 0 then
Prompt("Collect " .. item_name[quest_number] .. "?")
if g_KeyPressE == 1 and pressed == 0 then
pressed = 1
collected[item] = 1
items_collected[quest_number] = items_collected[quest_number] + 1
Hide(item)
CollisionOff(item)
end --collected item
end --player in range of item
end --exist check
end --for item loop
end --quest giver exist
end --for quest_number loop
--reset input
if g_KeyPressE == 0 then
pressed = 0
end
end --main
The weapon_upgrader_rapidfire.lua
*****************************************
local gun = {}
local upgrade_base_cost = {}
state = {}
upgrade_level = {}
local upgrade_base_amount = {}
local upgrade_cost = {}
local max_guns = 9
local highlighted = 1
local max_upgrades = 3
local allowed_weapons = {}
local temp = 0
local gunid = 0
local cash = 0
pressed = 0
cash = 10000 --starting cash player has to spend on upgrades
local culmative_upgrade_costs = 1 --set to 1 if you want costs to increase after each upgrade
function weapon_upgrader_rapidfire_init(e)
--note costs are muliplied by the current upgrade level if culmative_upgrade_costs is set to 1
upgrade_base_cost["damage"] = 100 --how much it costs to upgrade damage per level
upgrade_base_cost["accuracy"] = 50 --how much it costs to upgrade accuracy per level
upgrade_base_cost["clip size"] = 180 --how much it costs to upgrade clip size per level
upgrade_base_amount["damage"] = 1 --how much damage to add per level
upgrade_base_amount["accuracy"] = 5 --how much accuracy to add per level
upgrade_base_amount["clip size"] = 20 --how many bullets to add to clip size per level (no ammo is added)
--name of allowed weapons here (can find these by walking up to character with desired weapon held)
allowed_weapons[1] = "SCAR"
allowed_weapons[2] = "uzi"
allowed_weapons[3] = "AK47"
state[e] = "greet"
upgrade_level["damage"] = {}
upgrade_level["accuracy"] = {}
upgrade_level["clip size"] = {}
upgrade_cost["damage"] = 0
upgrade_cost["accuracy"] = 0
upgrade_cost["clip size"] = 0
end
function weapon_upgrader_rapidfire_main(e)
if GetPlayerDistance(e) < 300 then
RotateToPlayer(e)
elseif GetPlayerDistance(e) < 600 then
RotateToPlayerSlowly(e,1)
end
if state[e] == "greet" then
if PlayerLooking(e,200,5) == 1 then
if g_PlayerGunName ~= "" then
temp = string.find(g_PlayerGunName, "\\")
if temp == nil then
temp = 0
end
new_gun_name = string.sub(g_PlayerGunName,temp+1)
temp = 0
Prompt("Sorry, I can't upgrade that "..new_gun_name)
repeat
temp = temp+1
if allowed_weapons[temp] == nil then
return
end
until new_gun_name == allowed_weapons[temp]
Prompt("Hey there, would you like me to upgrade that "..new_gun_name.."?")
if g_KeyPressE == 1 and pressed == 0 then
pressed = 1
state[e] = "upgrade menu"
gunid = g_PlayerGunID
SetPlayerWeapons(0)
FreezePlayer()
highlighted = 1
end
else
Prompt("Hey there, I can upgrade your weapon if you bring me one")
end
end
elseif state[e] == "upgrade menu" then
TextCenterOnX(50,85,4,"Upgrading "..new_gun_name)
TextCenterOnX(50,90,3,"(W or S to cycle menu, E to select , press Q to exit)")
if highlighted == 1 then
Panel(30,30,70,40)
TextCenterOnX(50,33,4,"[1] DAMAGE")
upgrading = "damage"
else
TextCenterOnX(50,33,4,"[1] DAMAGE")
Panel(30,30,70,40)
end
if highlighted == 2 then
Panel(30,45,70,55)
TextCenterOnX(50,48,4,"[2] ACCURACY")
upgrading = "accuracy"
else
TextCenterOnX(50,48,4,"[2] ACCURACY")
Panel(30,45,70,55)
end
if highlighted == 3 then
Panel(30,60,70,70)
TextCenterOnX(50,63,4,"[3] CLIP SIZE")
upgrading = "clip size"
else
TextCenterOnX(50,63,4,"[3] CLIP SIZE")
Panel(30,60,70,70)
end
if g_KeyPressW == 1 and pressed == 0 then
pressed = 1
if highlighted > 1 then
highlighted = highlighted - 1
else
highlighted = max_upgrades
end
end
if g_KeyPressS == 1 and pressed == 0 then
pressed = 1
if highlighted < max_upgrades then
highlighted = highlighted + 1
else
highlighted = 1
end
end
if g_Scancode == 16 and pressed == 0 then
pressed = 1
UnFreezePlayer()
state[e] = "greet"
SetPlayerWeapons(1)
ChangePlayerWeaponID(gunid)
end
if g_KeyPressE == 1 and pressed == 0 then
pressed = 1
--upgrading = highlighted
state[e] = "upgrading"
end
elseif state[e] == "upgrading" then
Panel(30,45,70,55)
if upgrading == "damage" then
TextCenterOnX(50,48,4,"Current Damage = "..GetWeaponDamage(gunid,0))
end
if upgrading == "accuracy" then
TextCenterOnX(50,48,4,"Current ACCURACY = "..GetWeaponAccuracy(gunid,0))
end
if upgrading == "clip size" then
TextCenterOnX(50,48,4,"Current Clip size = "..GetWeaponReloadQuantity(gunid,0))
end
if upgrade_level[upgrading][gunid] == nil then
upgrade_level[upgrading][gunid] = 1
end
if culmative_upgrade_costs == 1 then
upgrade_cost[upgrading] = upgrade_level[upgrading][gunid]*upgrade_base_cost[upgrading]
else
upgrade_cost[upgrading] = upgrade_base_cost[upgrading]
end
Panel(30,60,70,70)
TextCenterOnX(50,63,4,"Upgrade level = "..upgrade_level[upgrading][gunid].." , Upgrade cost = "..upgrade_cost[upgrading])
TextCenterOnX(50,80,4,"cash = "..cash)
TextCenterOnX(50,85,4,"Upgrading "..new_gun_name.." damage")
TextCenterOnX(50,90,3,"(Press E to confirm or Q to go back)")
if g_KeyPressE == 1 and pressed == 0 then
pressed = 1
if cash >= upgrade_cost[upgrading] then
PlaySound(e,1)
cash = cash - upgrade_cost[upgrading]
upgrade_level[upgrading][gunid] = upgrade_level[upgrading][gunid]+1
if upgrading == "damage" then
SetWeaponDamage(gunid,0,GetWeaponDamage(gunid,0)+upgrade_base_amount[upgrading])
elseif upgrading == "accuracy" then
SetWeaponAccuracy(gunid,0,GetWeaponAccuracy(gunid,0)+upgrade_base_amount[upgrading])
elseif upgrading == "clip size" then
SetWeaponReloadQuantity(gunid,0,GetWeaponReloadQuantity(gunid,0)+upgrade_base_amount[upgrading])
end
end
end
if g_Scancode == 16 and pressed == 0 then
pressed = 1
--UnFreezePlayer()
state[e] = "upgrade menu"
--SetPlayerWeapons(1)
--ChangePlayerWeaponID(gunid)
end
end --state
if g_Scancode == 0 then
pressed = 0
end
end
function weapon_upgrader_rapidfire_exit(e)
end
function PlayerLooking(e,dis,v)
if g_Entity[e] ~= nil then
if dis == nil then
dis = 3000
end
if v == nil then
v = 0.5
end
if GetPlayerDistance(e) <= dis then
local destx = g_Entity[e]['x'] - g_PlayerPosX
local destz = g_Entity[e]['z'] - g_PlayerPosZ
local angle = math.atan2(destx,destz)
angle = angle * (180.0 / math.pi)
if angle <= 0 then
angle = 360 + angle
elseif angle > 360 then
angle = angle - 360
end
while g_PlayerAngY < 0 or g_PlayerAngY > 360 do
if g_PlayerAngY <= 0 then
g_PlayerAngY = 360 + g_PlayerAngY
elseif g_PlayerAngY > 360 then
g_PlayerAngY = g_PlayerAngY - 360
end
end
local L = angle - v
local R = angle + v
if L <= 0 then
L = 360 + L
elseif L > 360 then
L = L - 360
end
if R <= 0 then
R = 360 + R
elseif R > 360 then
R = R - 360
end
if (L < R and math.abs(g_PlayerAngY) > L and math.abs(g_PlayerAngY) < R) then
return 1
elseif (L > R and (math.abs(g_PlayerAngY) > L or math.abs(g_PlayerAngY) < R)) then
return 1
else
return 0
end
else
return 0
end
end
end
the horse if you can put a texture to it, you can use it but never sell the model please.
horseOK.x
Had to put it in LUA as for some reason the is no option for direct x files?
xof 0302txt 0032
Header {
1;
0;
1;
}
// Created with: DeleD 3D Editor
// Scene: DeleD Scene
// Author: Christine Reardon
// Comment:
// Date: 12/15/2016
Mesh horse1 {
SEE ATTACHED to download