View Single Post
Old 09-21-07, 09:43 AM   #125
CB..
Ace of the Deep
 
Join Date: Apr 2002
Location: UK
Posts: 1,278
Downloads: 0
Uploads: 0
aha...the surprise attack..

managed to create the code for a surprise attack from a british/enemy sub..or similar..depending on how you set it up


very VERY simplistic at the second as it depends on a stright up and down timer...
(mind you finding the timer code was good in itself and can be used for other things)
but i'm just messing about for something to do right now..


anyway here's the code for an enemy sub springing a surprise attack on your vessel..

you need these entrys to set it up (at the top under id mysim)

id u2
float gt
int processed


then under
everyframe

if
Alive [mysim]
then
GameTime [gt]
ifall
sameint [processed],$0
greater [gt],20
then
CreateServerSimulationObject [u2],"E34"
SimSetName [u2],"E-class"
SimSetPosition [u2],-200,200,200
SimSetStartSpeed [u2],15
AddStateEngine [u2]
AddStateItem [u2],"s:2"
AddStateItem [u2],"a:1,Course:10,20"
AddStateItem [u2],"a:1,Ramm:"
AddStateItem [u2],"a:1,FireAtWill:"
AddStateItem [u2],"c:0,1,EnemyVisible:5000"
AddStateItem [u2],"c:1,0,-EnemyVisible:8000"
setint [processed],$1
endif
endif


///////////


after the alloted time period has elapsed (set here greater [gt],20) 20 minutes here i think...

the sub appears off your beam and once it wakes up (and it confirms you as enemy and so on..usualy take 5 or 6 seconds..it attacks launching torps

very VERY hard to get the heck out of it's way at this close range..and it often kills you before you can evade and launch your own attack...

this nicely simulates an enemy sub spotting you and sneaking into a firing position as was often the case during Ww1...there was a lot of effort put into sub killer submarines and quite a few large scale sub versus sub battles...as far as i have been able to find out any way...

for realism fanatics remember it IS 2000% easier to evade than it would have been in real life...as the enemy sub would not show itself prior to firing...it would launch it's torps from a submerged and unseen position..this way you have at least a short period of grace to react (panic lol) and get out of it's sights

i do not think you could use this method for surface ships ie destroyers etc as they would not have the ability to get this close without you spotting them...but maybe with some adaption depending on weather etc it could also be used for some occasional lapses in concentration from the watch crews..or even whilst submerged and lining up your torpedo attacks on another vessel...a DD may well be able to catch you un-awares under those circumstances..


more code needed here....really to randomise the surprise attack...and make it a dynamic element in the campaign...it's a great pity i don't really have the background for the code work other wise i could extremely easily in fact write almost literaly ANY event into the campaign and make it dynamic aswell..

as it is i'm struggling ...i don't have the experience

this same snippet of code could also be used to iron the porblems i was having with the MORSELAMP message ..as i can use a friendly sub just as easily...it will appear nearby and send the morselamp message ..tho there ARE some strange time excell issues with friendly vessels....they do and can occasional cause the time excell to become limited to X16 even when they are out side visual range...the answer to this is to delete the vessel once it's purpose has been served..which the code allows for...again i can set up a timer to do this ...so that should in theory take care of that slightly idiotic glitch

a point to note is that there are no enemy subs as stock in the game BUT there is an AI only sub written into the game...and it is a simple matter to change it's nationailty to English....and then use that sub...it does seem to exhibit some specialy abilities not seen elsewhere i believe but am not sure that it does on occasion surface and dive by it's own set of rules..

as it is i've been using my own E34 brit sub model file which i adpated from the german u35 model file...but it does have the occasional texture glitch..so if i do incorporate the surprise attack into the campain i will use the stock AI sub with a simple edit to make it british..(believe me it's far simplier than all the work needed to add a brand new vessel to the game)
__________________
the world's tinyiest sh3 supermod-
and other SH3/SH2 stuff

http://www.ebort2.co.uk/


The best lack all conviction, while the worst
Are full of passionate intensity.

W.B.Yeats

Last edited by CB..; 09-21-07 at 10:09 AM.
CB.. is offline   Reply With Quote