Code: Select all
function champspeech()
x = math.random(1,4)
if party:getChampion(x):isAlive() then
local Name1 = party:getChampion(x):getName()
hudPrint(""..Name1.." whispers: WHAT was that?..")
playSound("secret")
else
end
end
Thanks
George
Code: Select all
function champspeech()
x = math.random(1,4)
if party:getChampion(x):isAlive() then
local Name1 = party:getChampion(x):getName()
hudPrint(""..Name1.." whispers: WHAT was that?..")
playSound("secret")
else
end
end
Code: Select all
function champspeech()
x = math.random(1,4)
if party:getChampion(x):isAlive() then
local Name1 = party:getChampion(x):getName()
hudPrint(""..Name1.." whispers: WHAT was that?..")
playSound("secret")
else
end
end
Code: Select all
function champspeech()
-- build a list of alive champions
local champIds = {}
for i = 1, 4 do
if party:getChampion(i):isAlive() then
table.insert(champIds, i)
end
end
-- only allow a champion to speech if anyone was actually alive
local num = table.getn(champIds)
if num > 0 then
-- fetch a random champion from the list of alive ones
local x = math.random(1,num)
local champId = champIds[x]
local champName = party:getChampion(champId):getName()
-- print information to screen that the champion found something
hudPrint( champName .. " whispers: WHAT was that?" )
playSound("secret")
end
end
Code: Select all
discern_triggers = true --set false to disable special handling of button and switches
function speak(caller, message, action, ordinal, secret, option) --ordinal nil for random champion; secret and option are booleans
local ordinal = ordinal or math.random(4)
--=-------------------------------------------------------------------------------[check for live PC]--
for x = 0,3 do
local z = (((ordinal - 1) + x) % 4) +1
local champion = party:getChampion(z)
if champion:isAlive() then
local message = message or _randomAlert() --=-----[ensures default values]--
if option then
message = _randomAction().." "..message
else
local action = action or "says"
message = action..": "..message
end
if discern_triggers and _isSwitch(caller) then --=---------------------[button/switch check]--
message, secret = _buttonSpeak(caller, champion)
end
if secret then --=--------------------------------[check for sound and then print to screen]--
if type(secret) == "string" then
playSound(secret)
else playSound("secret")
end
end
hudPrint(tostring(champion:getName().." "..message))
break
end
end
end
function _buttonSpeak(caller, champion)
--=-----------------------------------------------------------[special handling for switches]--
--Ids and messages for the connected switches, and optional sound effect.
local switch_trigger_data = { --switch id, --action, --message, --sound
"pressure_plate_hidden_1", "shouts" , _randomAlert(3), "", --no sound -- no sound
"pressure_plate_hidden_2", _randomAction(), _randomAlert(), "secret", -- secret sound
"pressure_plate_hidden_3", "yells", "OUCH! I think I stepped on a tack.", "default_pain", --correct PC pain sound
}
local secret
local message
for t = 1, #switch_trigger_data, 4 do
if caller.id == switch_trigger_data[t] then
message = switch_trigger_data[t+1]..": "..switch_trigger_data[t+2]
if switch_trigger_data[t+3] == "default_pain" then
champion:playDamageSound()
elseif switch_trigger_data[t+3] ~= "" then
secret = switch_trigger_data[t+3]
end
break
end
end
return message, secret
end
--=-----------------------------------------------[utilities]--
function _isSwitch(target)
local switches = { "Receptor", "Lock", "Lever", "Button", "PressurePlate",
"Alcove", "Counter", "Timer", "TorchHolder",
}
for check = 1,#switches do
if switches[check] == target.class then
return true
end
end
end
function _randomAlert(pick)
local response = {"WHAT was that?", "Did you hear that?", "I heard something!", } --You can add as many responses to the list as you like; same with the actions.
if pick and type(pick) == "number" and pick <= #response then
return " "..response[pick]
end
return " "..response[math.random(#response)]
end
function _randomAction(pick)
local response = {"wispers", "says", "[startled] says", }
if pick and type(pick) == "number" and pick <= #response then
return " "..response[pick]
end
return " "..response[math.random(#response)]
end
function help()
print("Usage: speak(self, message, action, ordinal, secret, optional_expression)")
print("All arguments are optional, and any argument can be nil.")
print("Calling speak() will pick a champion and print their [random] announcement.")
print("")
print("Calling speak(\"Hello!\"), will use the given string as a random champion's statement.")
print("")
print("Calling speak(\"Hello!\", \"screams\"), will use \"screams\" instead of the default \"says\".")
print("")
print("Calling speak(\"Hello!\",nil,2), will choose champion [ordinal] 2 as the speaker; and use the default \"says\".")
print("")
print("Calling speak(\"Hello!\",nil,nil,[any non-string input]), will play the \"secret\" sound; or...")
print("You may enter the name of ant valid sound effect [in quotes] to play instead of the default of \"secret\".")
print("")
print("Calling speak(nil,nil,nil,\"gate_lock\", true), will play the \"gate_lock\" sound, and have a random champion")
print("exclaim a random alert.")
end