That makes sense but that usually throws an error message in the chat, right?
Also just to make sure i understand, if a targeting function returns nil, will the defaults take over?
nop, mostly chat does not show the errors.
Sorry english is not my native language, Sometimes it is difficult for me to say what I want.
An Example that how it works.
Percy Source:
--- OnSelectCard ---
--
-- Called when AI has to select a card. Like effect target or attack target.
-- Note: "Always check if your return value has the correct amount of targets as specified by minTargets, maxTargets"
-- Example card(s): Caius the Shadow Monarch, Chaos Sorcerer, Elemental HERO The Shining
--
-- Parameters:
-- cards = table of cards to select
-- minTargets = how many you must select min
-- maxTargets = how many you can select max
-- triggeringID = (deprecated) id of the card that is responsible for the card selection. This parameter is deprecated. Please use triggeringCard instead.
-- triggeringCard = card object of the card that is responsible for the card selection. If card is unknown, triggerCard will be false
--
-- Return:
-- result = table containing target indices
function OnSelectCard(cards, minTargets, maxTargets, triggeringID, triggeringCard)
local result = {}
print("OnSelectCard",minTargets,maxTargets)
if triggeringCard ~= false then
print("OnSelectCard triggered by: " .. triggeringCard.id)
else
print("triggeringCard is unknown!")
end
-- Example implementation: always choose the mimimum amount of targets and select the index of the first available targets
for i=1,minTargets do
result[i]=i
end
return result
end
Snarkie Base (ai/mod/SelectCard.lua):Steps (This structure applies to almost all functions: Card, Battle, Chain, etc.)
1. Some priority stuffs.
2. Check if your function (WattCard for example) returns a value.
if d and d.Card then3. else returns generic results.
4. else returns random minimum amount of values.
function OnSelectCard(cards, minTargets, maxTargets, triggeringID,triggeringCard)
local result = {}
... --hidden "1. PRIORITY STUFFS"
local d = DeckCheck() -- "2.THIS WILL FIND YOUR OWN SCRIPT."
if d and d.Card then
result = d.Card(cards,minTargets,maxTargets,triggeringID,triggeringCard)
end
... -- "hidden 3. Generic functions"
-- "4. always choose the mimimum amount of targets and select random targets"
local targets = {}
for i,c in pairs(cards) do
targets[i]=c
c.index=i
end
for i=1,minTargets do
local r=math.random(1,#targets)
local c=targets[r]
table.remove(targets,r)
result[i]=c.index
end
return result
end
EDIT: So, if your own script fails the application will do incorrect things, like omit the cost of activation, omit cost materials, etc etc..
Edited by user
2017-03-27T23:56:53Z
|
Reason: Not specified