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 / Can I make a character shoot at an entity?

Author
Message
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 30th Sep 2010 05:24
I have a target range in one of my game's levels, with a character entity stood placed as though he is using the range.

Is there a script I can use that makes the character shoot at one of the targets on the range?

Can I also make the character turn and shoot at the player when he spots him/her?

I game therefore I am.
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 30th Sep 2010 06:02 Edited at: 30th Sep 2010 06:02
Use of the following commands might yield the result you are looking for. However, I have not tried it in any way.

settargetname=
settarget
lookattarget

useweapon - supposed to shoot at set target if character has a weapon.

I reject your reality and substitute my own!

Add more adventure to your game -- use RPG Mod
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 30th Sep 2010 20:05 Edited at: 30th Sep 2010 20:52
Oh dear, I was hoping there was a stock script I could use, I hate scripting, I can never seem to get my head round it lol.

Here's what I do understand; the difference between a condition and an action.

Here's what I don't understand; how to put it all together to make a usable script!

Here's what I need to achieve; when the player is across the room from the character entity, the entity stands and snipes at a target on the range. As the player aproaches the character entity, it turns and snipes at the player instead. The character entity is armed with the stock 'Tavor' gun.

Flatlander has given me a hint about settargetname etc (thanks Flatlander), but I'm clueless about how to incorporate it into a full script.

I'm not asking for someone to write the script for me, but can someone point me in the right direction please?

I game therefore I am.
anayar
15
Years of Service
User Offline
Joined: 19th Aug 2009
Location: Minneapolis, MN
Posted: 30th Sep 2010 21:08
Bruce, have you seen the animation list??
If not here is a link: http://www.thegamecreators.com/?m=view_product&id=2001&page=AnimationTemplate

My idea is simple... have the enemy facing the target you want it to shoot at. Then in his script activate the shooting animation. But in addition to this, set it up so that if he senses the player (plrdistwithin??) then he attacks the player via the normal AI script. It shouldnt be too hard to modify the stock scripts, and I can try for you once i get home

Cheers,
Anayar


For KeithC
Flatlander
FPSC Tool Maker
17
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 1st Oct 2010 06:18
anayar is probably a lot closer to a solution. As so often is the case, the commands do not work as I would think they should work. I played around with it for about 45 minutes and have given up for now.

I reject your reality and substitute my own!

Add more adventure to your game -- use RPG Mod
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 06:24 Edited at: 1st Oct 2010 06:41
Here is a
that I wrote for a puppet script that shoots an enemy.
The enemy is named isshot for this example script. (set in state=0 initialization state)
The script uses the Right-Shift key (scancodekeypressed=54) to shoot the enemy.
Here is the link to the Puppet Script Thread if you want it...

Controls

'R' = run forward
'T' = walk forward
'F' = turn left
'H' = turn right
'G' = retrace steps
'N' = Rotate head left
'M' = Rotate head right
'Right-Shift' = Shoot an Enemy named isshot

There are the controls if you want to play around with it.
Here is how you set it up...

1) Place a character with a gun and assign him the puppetshooter script (your new script) to his AI MAIN
     Also edit his rate of fire to 100

2) Place a character without a gun to get shot and change his name to isshot
     You can adjust his health lower than 100 also if you wish for a faster death

3) Have fun using the right shift key to shoot!

Hope this helps get you started.

States 10 & 11 are the ones you will be most interested in.

   Conjured Entertainment

 WARNING: Intense Madness
Michael Thompson
16
Years of Service
User Offline
Joined: 15th Aug 2008
Location: Behind you (if not, in australia)
Posted: 1st Oct 2010 06:41
Looks great Conjured Entertainment, i will be looking forward to seeing it in action. What are the legal agreements (or whatever you want to call it)? are we allowed to use it in commercial games?

Windows 7 ultimate x64, Intel i7, 4 GB RAM, NVIDIA GEFORCE 330m 1GB
Flash Star Game Creations
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 06:42
All of my scripts are for use however you like.
Just don't edit it to make FPSC crash and then blame it on my script.

   Conjured Entertainment

 WARNING: Intense Madness
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 17:28
Sorry for not replying sooner, thanks for your comments guys, yoiu've given me plenty to get started with, now I just need to get stuck in, thanks!

I game therefore I am.
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 19:44
I had a go at writing a script, based on the first part of CE's puppet script, combined with the stock snipe script. Infortunately, it didn't work, here's what I came up with;



The entity just stands at the shooting range, doesn't shoot the named target and doesn't react to the player's presence. Can anyone tell me where I went wrong?

I game therefore I am.
anayar
15
Years of Service
User Offline
Joined: 19th Aug 2009
Location: Minneapolis, MN
Posted: 1st Oct 2010 20:03
Im not a scripter, but maybe you should add "state=" commands to this part of the script, and then add "plrcanbeseen" command activate that portion-

:plrcanbeseen:settarget,rotatetotarget,resethead
:plrdistwithin=200:rotatetoplr,resethead

Cheers,
Anayar


For KeithC
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 20:14 Edited at: 1st Oct 2010 20:24
Quote: "I had a go at writing a script, based on the first part of CE's puppet script, combined with the stock snipe script. Infortunately, it didn't work, here's what I came up with;"

Quote: "The entity just stands at the shooting range, doesn't shoot the named target and doesn't react to the player's presence. Can anyone tell me where I went wrong?"


Yeah, you mutilated state=5

:state=5:useweapon,rundecal=6,state=3
:state=4:state=5
:state=3:state=4
:state=2:state=3

So you are stuck in this loop from state=2 going to 3 then 4 then 5 and back to 3 then 4 then 5 then back to 3... get it?

However, your script never gets there because of this...

:state=1,ifweapon=1,rateoffire:useweapon,rundecal=6
:state=1,ifweapon=0:state=2,setframe=6

:state=2,:incframe=6
:state=2,frameatend=6:state=1,reloadweapon,sound=audiobank\guns\reload.wav

You are in another loop here going from state=2 back to 1 then 2 then 1 then 2 then 1.... get it?

So, your problem is endless loops, because the only stateless conditions to pull you out....

:plrcanbeseen:settarget,rotatetotarget,resethead
:plrdistwithin=200:rotatetoplr,resethead

...will never get you out of the loop because they don't go to any state, so you are always stuck in that stateless condition.

So, you want the stock snipe script, but you want to add in shooting the player if they can be seen and if not then shoot at the named enemy?

   Conjured Entertainment

 WARNING: Intense Madness
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 20:23
OK, I think I understand, just one question, was the general idea sound? Would it work if I somehow got rid of the loops?

I game therefore I am.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 20:26 Edited at: 1st Oct 2010 20:34
Quote: "Is there a script I can use that makes the character shoot at one of the targets on the range?

Can I also make the character turn and shoot at the player when he spots him/her?"

Yes, I can make him shoot at the target until the player walks up and then he will attack the player.
That is basically what you what you want,right?

Quote: "was the general idea sound? Would it work if I somehow got rid of the loops?"

Loops are fine, and you want loops in most scripts, just not endless loops. (you need a way out of the loop)

Yeah, I think it is sound (doable).
I'll play around with it and see if I can get a basic one for you and then you can go from there.

   Conjured Entertainment

 WARNING: Intense Madness
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 20:33
Quote: "Yes, I can make him shoot at the target until the player walks up and then he will attack the player."


Yes, that's exactly what I'm trying to achieve.

I'm just trying to add these all little details to my game, which will hopefully bring it to life better.

Basically, I want all the NPCs in the game to be where they are for a reason, not just looking like they've been placed randomly.

For example, what's the point of having an NPC standing at a shooting range if he's not actually shooting at the targets?!

I game therefore I am.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 20:36 Edited at: 1st Oct 2010 20:39
Quote: "For example, what's the point of having an NPC standing at a shooting range if he's not actually shooting at the targets?!"

lol

You want him to shoot at just one target or more?

   Conjured Entertainment

 WARNING: Intense Madness
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 20:40
Just one target, it's an indoor shooting range, with individual shooting lanes. I'm using heltor's shooting target models.

Here's an in-game screenie of the shooting range if it helps at all.



I game therefore I am.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 20:42
ok, [terminatorvoice]I'll be back[/terminatorvoice] and post my results here in a few... (hours)

   Conjured Entertainment

 WARNING: Intense Madness
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 20:50
Thanks, in the meantime, I'll have another go, then I'll compare mine with yours to see where I went wrong and if I did anything right.

I game therefore I am.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 21:42 Edited at: 1st Oct 2010 22:08
So you want an effect similar to this, right? (see attached video)

It just so happened that we were doing some target practice for a beta test I am running on the Cosmic Prophet's 'Wastelanders' pack.
So, the Ranger was nice enough to lend a hand with your request. (although I think he just liked the idea of shooting at me)

Anyway, I changed the name of the target to range01, and I used the plrdistwithin and plrdistfurther for the triggering conditions.
The plrcanbeseen and plrcannotbeseen are too dependent on the cone etc., so the using the distance worked better.
You can adjust that 200 to suit the range you want a response, or you can replace the condition with something else.
Do whatever you want with it, and remember it was on the fly so it may not be as optimal as it could be. (just a base for editing)
You'll also notice I did a little random thing for the damage to the player (5 to 15), which explains why I stood still while he was shooting me. (for health illustration)



   Conjured Entertainment

 WARNING: Intense Madness

Attachments

Login to view attachments
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 21:49
Yes, that's pretty much exactly what I'm after!

Maybe with the player getting a bit closer before being shot at?

Because of the layout of the shooting range, with the partitions between each shooting lane, the player will be almost on top of the character before being spotted.

And of course, the character will be sniping with the stock Tavor rifle.

Nice head shot at the end BTW!

I game therefore I am.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 21:53 Edited at: 1st Oct 2010 21:57
Quote: "Yes, that's pretty much exactly what I'm after!

Maybe with the player getting a bit closer before being shot at?

Because of the layout of the shooting range, with the partitions between each shooting lane, the player will be almost on top of the character before being spotted."


:plrdistwithin=200,activated=0:activate=2,rotatetoplr,state=4
:plrdistfurther=199,activated=0:activate=1,settargetname=range01,state=1

Those two numbers are your adjustment for how close you need to be to him for him to shoot at you instead of the target.
Try 150 and 149 and go from there, just always have the second value (plrdistfurther=x) total 1 less than the first value (plrdistwithin=x).

Quote: "And of course, the character will be sniping with the stock Tavor rifle."

Give him any weapon you want and you can adjust that damage in state=5...

plraddhealth=-15

Just use a negative number if you use the plraddhealth=x to subtract health. (they have a new action for that but the old way still works, so...)
Anyway, adjust those three values for weapons that have more or less damage.

Have Fun!

   Conjured Entertainment

 WARNING: Intense Madness
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 21:59
Ok, thanks for that, much appreciated!

Sorry for being dense but is that all I need, or do I put it at the start of the snipe script, (replacing the first three lines)?

I game therefore I am.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Oct 2010 22:01 Edited at: 1st Oct 2010 22:07
This is all you need for the effect in the video.

1) Give your player a weapon and this script for their main AI

2) Name your target entity range01 (that is range zero one) and make it dynamic by setting STATIC MODE to NO

That is all you need to do for this to work like the video.
Any other changes are up to you, so do whatever you want with it.

   Conjured Entertainment

 WARNING: Intense Madness
bruce3371
14
Years of Service
User Offline
Joined: 4th Aug 2010
Location: Englishland
Posted: 1st Oct 2010 23:20
Ok, after various 'blond moments' (including not reading the post about the video fully the first time lol) I got it to work! It works exactly how I imagined it would, all I did was to adjust the 'plrdistwithin' and 'plrdistfurther' to 150 and 149 respectively as you suggested. Thanks CE, your name will be added to my game's credits.

I game therefore I am.

Login to post a reply

Server time is: 2024-11-24 20:00:39
Your offset time is: 2024-11-24 20:00:39