Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Roving Guard script

Author
Message
Darkfoil
18
Years of Service
User Offline
Joined: 7th Jan 2006
Location: Montanchez (Spain)
Posted: 9th Mar 2007 01:18
This is my first real attempt at writing a script. Any comments or critisism,(constructive only please),welcome. The enemy character walks forwards until it meets an obstacle at which point it will turn 90 degrees,(random left or right),and continue walking. It will keep doing this until,
1: It sees the player.
2: It is shot.
If it sees the player, or it is shot before it sees the player,it will close in and start shooting and also attempt to follow if the player runs away. If it's health falls to 30 or below it will beat a hasty retreat and will run away if the player gets too close but will fire a parting shot as it does so.
Like I said, this is my first attempt so be gentle with me

Darkfoil.

[;Artificial Intelligence Script

;Header

desc = Search area Shoot player if seen Return fire if shot Run away if too much damage taken

;Triggers

:state=0:state=1
:state=1,losetarget=5:state=10
:state=1,plrcanbeseen,plrdistwithin=400:state=20
:state=1,shotdamage=1:rotatetoplr,state=20
:state=1,random=20:rotateheadrandom=55
:state=1:animate=2,movefore=2.5

:state=10,random=1:state=11
:state=10:rotatey=90,animate=2,movefore=2.5,state=0
:state=11:rotatey=-90,animate=2,movefore=2.5,state=0

:state=20,plrcanbeseen:state=21
:state=21,plrcanbeseen:settarget
:state=21,plrcannotbeseen,losetarget=1:state=10
:state=21,healthless=31:state=40
:state=21,ifweapon=1,plrdistfurther=100:followplr=1,animate=5
:state=21,plrdistwithin=101:rotatetoplr
:state=21,ifweapon=1,plrdistwithin=301,plrcanbeseen=46:animate=1,rotatetoplr,freeze,useweapon,rundecal=6
:state=21,ifweapon=0:animate=1,freeze,state=22,setframe=6
:state=21,plrdistwithin=300,random=20:state=25
:state=21,plrdistwithin=100:state=30
:state=22:incframe=6
:state=22,frameatend=6:state=21,reloadweapon,sound=audiobank\guns\reload.wav
:state=25,random=1:state=26,setframe=4
:state=25:state=27,setframe=3
:state=26:incframe=4,strafe=90,rotatetoplr
:state=26,frameatend=4:state=21,animate=1
:state=27:incframe=3,strafe=-90,rotatetoplr
:state=27,frameatend=3:state=21,animate=1
:state=30:state=31,setframe=5
:state=31:incframe=5,strafe=180,rotatetoplr
:state=31,frameatend=5:state=21,animate=1

:state=40:state=42
:state=42,ifweapon=1,plrdistwithin=601,plrcanbeseen=46:animate=1,rotatetoplr,freeze,useweapon,rundecal=6
:state=42:rotatetotarget,rotatey=180,resethead,animate=5,state=43
:state=43:runfore=10
:state=43,random=5:rotateheadrandom=65
:state=43,losetarget=1:state=50
:state=43,plrcanbeseen:settarget,state=42

:state=50:timerstart,state=51,rotatey=180,animate=31
:state=51,timergreater=5000:state=10,animate=5
:state=51,random=5:rotateheadrandom=35

;End of Script]
migit matt man
18
Years of Service
User Offline
Joined: 4th Oct 2006
Location: Somewhere...
Posted: 10th Mar 2007 10:45
Sounds nice! Could we have a video of it in action? Or screenshots?

Thanks!

Zdrok
17
Years of Service
User Offline
Joined: 19th Dec 2006
Location: Pittsburgh
Posted: 10th Mar 2007 19:31
Darkfoil, congrats on an excellent script! This will help GREATLY in my game! Once again, this script is a very good first one. This is a generous offer, and I hope you keep making scripts like this! 10/10 on a fine script, DF!!

Clarion: Violent Clash

Arriving in 2007.
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 10th Mar 2007 19:36
Darkfoil,

Thanks for this script. It's more intelligent than many I've seen. I just installed V1.05 and I'm happy to report that the 7 enemies I placed in a small test level were all active, moving and shooting like they should be. I haven't dissected it yet, but it looks good.

Best.

I'm sorry, my answers are limited. You must ask the right question.

Darkfoil
18
Years of Service
User Offline
Joined: 7th Jan 2006
Location: Montanchez (Spain)
Posted: 10th Mar 2007 21:44
Thanks for the feedback guys. Glad you like the script . V1.05 sounds like a good upgrade. I found that with V1.04 I could only have three enemies active using this script.

Xplosys. If you want to put this script up on fpsfree be my guest.

One last request. Can anybody explain exactly how the settarget command works. I've been trying to write a script that changes the focus of an enemy to a new target but so far I've had no luck.

Darkfoil.
Inspire
17
Years of Service
User Offline
Joined: 23rd Dec 2006
Location: Rochester, NY
Posted: 10th Mar 2007 22:46
I thought that was only with emptys mod. I'm not sure though...

Darkfoil
18
Years of Service
User Offline
Joined: 7th Jan 2006
Location: Montanchez (Spain)
Posted: 11th Mar 2007 21:23
I've made a minor alteration to the Roving Guard script because I realised that I hadn't written in the ability for the enemy to reload when it was in retreat. This meant that once it's weapon was empty it wouldn't fire off a shot before running. Now if it's weapon runs dry it will reload.

I've also made another version of the same script called RovingGuard2.fpi that causes the entity to follow a waypoint path before going into retreat when it's health falls below 30. There is a problem with this though. When the entity starts to follow the waypoint path it's goes from running around to casually strolling along. I've tried to get it to run along the waypoints but haven't been able to. If anyone figures out how to make the entity run the waypoints please let me know how.

Darkfoil.

Attachments

Login to view attachments
FPSC Scripts
18
Years of Service
User Offline
Joined: 2nd Oct 2006
Location: Curacao
Posted: 11th Mar 2007 23:57
Quote: "One last request. Can anybody explain exactly how the settarget command works. I've been trying to write a script that changes the focus of an enemy to a new target but so far I've had no luck.
"



Quote: "I thought that was only with emptys mod. I'm not sure though...
"


accourding to my mind i think both can do the same thing but maybe i'm wrong,anyone knowthe correct answer.

yo yo yo.

Login to post a reply

Server time is: 2024-11-23 13:25:54
Your offset time is: 2024-11-23 13:25:54