How to combine continual and discrete function?

I’m building one strategy war game, and I want to create mathematics function for hits chance (y axis) based on distance (x axis). I defined manualy one discrete function with coordinate pairs that will serve as main function, then I need to add another (continual) function that will serve as an increase of hits chance.

Discrete Function:

cList = {{0, 100}, {1, 95}, {5, 80}, {10, 70}, {15, 40}, {20, 
   25}, {25, 15}, {30, 10}}
ListLinePlot[cList]

Continual Function:

Plot[Sin[2 x^2]*x/4 + Sin[0.3 x] + (8/30)*x, {x, 0, 30}]

I need combined function that I can use later in C++ programming language to calculate hits chance.
for example: if is target and shooting unit at distance 5, then I will use randomly choosen point on combined function from interval X [4.5, 5.5]

So, first question is: “How to combine those functions?” and second is “How to use that combined function in my C++ application?”

Well, I found solution. I was blinded with graphical reprezentation of functions. I forgot for a moment that I have same functions in Math library in C++ :slight_smile: But Wolfram helped a lot because I can see function and can do improvement by adding some changes in function definition, but I’m realy interested about my fisrst question.

Thanks.

The most conceptually simple answer must be to use programming instead of mathematics to add these two functions.
f:= Which[x<1, 100, x<2, 95, x<5, 80, …]
g:=Sin[2 x^2]*x/4 + Sin[0.3 x] + (8/30)*x
h:=f+g

In terms of C-implementation, and efficiency, there could be some nonobvious solutions. For instance, convert the discrete function to a continuous function by making it piecewise linear, and then maybe using abs to make it a single expression. Then they can all be added together.

But to be more practical, you probably want to approximate. A linear fit works well enough possibly but you can try other functions too, e.g.,

Fit[{{0, 100}, {1, 95}, {5, 80}, {10, 70}, {15, 40}, {20, 25}, {25, 
   15}, {30, 10}}, {1, x, Sin[(Pi/15) x]}, x]