I'veadded a prettierlookingsky, and I'veadded a countdowntimeronhealth.
ButAndi, thereareteamsofworms, but I'm notgoingtogointoverymuchdetaillike a usuallywouldabouthowallofthat's done.
Instead, we'regoingtofocusonthe A I.
TheCodySelfWormsgamehasnowbecomequite a largeproject.
Infact, there's about 1000 linesofcode, butpleasebelievemewhen I saymostofthecodeyouhaveseenintheprevioustwovideos, I'venotmadeanychangestothecreatemapfunction.
I'venotmadeanychangestothepearlinnoisefunction.
I'venotmadeanychangestotheboomfunction.
And I'vemadeoneslightchangetotheseaphysicsobjectclass, whichistheinclusionoffthisdamagefunction, whichwe'llseelater.
I'vealsomadenochangestothecameratrackingallthefiringweaponroutines, and I'vemadeabsolutelynochangesatalltothephysicsengine.
Solet's have a quicklookatthe C teamclassonthisclassisreallyjust a rapperfor a vectoroffwormobjectsonthespecterscalledbackmembersonthosetwofunctionsthisclassprovides, andoneishisteamalive, whichjustiteratedthroughallofthemembersinthevectorandcheckstoseeiftheirhealthisgreaterthanzero.
Ifanyofthewormshave a healththatisgreaterthanzero, thentheteamisstillalive.
It's stillavailabletotakepartincombat.
OnthesecondfunctionisgetNextmember, whichreturns a pointerto a seawormobjectonDTH.
But I'm alsomakingsurethatwhen I increasedtheteamcounterthatthatcurrentteamisalive, dotheyactuallyhavetheabilitytoplay?
Iftheydon't, itjustgoesaroundandincrementsagain.
Itwillkeepdoingthisnow.
Thisleavesuswith a situationwherethenextteamtoplaycouldbethesameasthecurrentscenethatisplaying, andinthiscasethatmeanstheremustonlybethatoneteamleftthereforethatteamhasone, sowelookforthatspecifically.
I'm justiteratingthroughalloftheteammembersonaccumulatingtheirhealth, and I usedthefillfunctiontodraw a coloredrectangleintheteamcolors, theappropriatelengthacrossthescreen.
Thecountdowntimerinthecornerwas a sevensegmentdisplayonthiscode.
Sowithallthatout, thewaywecannowfocusontherealcontentofthisvideo, whichistheartificialintelligenceorAI I I decidedearlyonthatthe A I shouldn't beallowedtocheat.
So I'm goingtorestricttheeyetousingthesamecontrolsthattheplayercanuseontheonethatmany.
Sohowdowedeterminetheanglethatthe A I wormshouldaimforinordertohit a target?
Well, let's makeanassumptionthatthewormundercontrolexistsat 00 in a two D planeonthetargetwormexistssomewhererelativeto 00 withinthatplate.
Thisgivesus a changeinelevationon a changeinrange.
I'm goingtodraw a linebetweenthesetwopoints.
Weknowinourphysicssimulationthatalloftheprojectorswillfollow a parabolictrajectory, andwhatwewanttofindistheanglethatweshouldaimthecursorinordersfortheprojectiletofollowthattrajectoryandhitthatpoint.
Thisisactuallyquitecomplexontheirtwounknowns.
Oneistheangleandthesecondisthemuzzlevelocity?
A whatvelocitydowefiretheprojectileout?
Andtomakethissimpler, the I willalwaysfireitsprojectileat a fixedvelocity.
Well, it's lookingthroughthemathsForthisproject, I discoveredthisexcellentWikipediapage, whichisprojectilemotion.
Thesedownhillslopesaredefinitelyfavoringtheredteam, andit's a lovelyshotsofthepigsthatpinkRoomgot, I think, verystupidlystoneanotherworddownintothehole.
I thinkhe's gonnahavelittlechoice.
ButtheblastitswayoutwayGreen's doing a veryriskyopendowncouldhavetookitselfoutthere, butnoniceshotonthepigbringsthepigbackintoplay.
Lookslike a safetystrategyfromtheredteamtakesout.
Trytotakeout a wholeclusterofworms.
That's thefirstdamagetheRedteamhastaken.
It's stormingintothelead.
I almostlostthepigsthere.
Wedidlose a redatthesametime.
That's it.
Thebigteamaround.
Soit's redversusgreen.
Green's gotlittlechoice, buttomove a bitclosernow.
Sohiswordsyouwillbeshottonothing.
Red's gotquitesomeobstaclestoovercome.
Doesn't needtogetoverthewall.
Anditlookslikeit's Ah, no, it's a mess.
It's fullofshortthinkingaboutit.
Notquitesure.
No, it's justgonnafireandhopeWealmostdiditaswell.
ReadJust a littlebitscaredbythat.
Goingtobe a littlelittledefensivenow.
Butnowhe's got a problem.
Stuckitselfin.
Yep, blewitselfup.
StupidredwoodGreen.
Unsureofwhattodohere.
I thinkshe's gonnahavetoblastitswayout.
Anditblasteditswayoutofflife, too.
Movingintakesaim, but I thinkwe'retoofaraway.
Yeah, we'regonnahavetomove a bitcloser.
Greetings.
Gottherightidea.
Navigatestheobstaclewiththesetakesaim.
Oh, andit's a goodhitonthatredworm.
Lookatthat.
Redovercamethatobstaclewithnoproblematall, butnow I thinkthisonemightprove a bitchallengingforit, butit's a goodhit.