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 / enemy AI activate switch

Author
Message
pandaHunter
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location:
Posted: 9th Mar 2009 15:52
Hi, im new to the forum. I am attempting to write a script for an enemy to run over to a switch and activate it. I am able to activate the switch( with a change to the switches script, testing if its activated and setting ifused if it is)

I can also run toward the switch, however i cannot test for when the entity reaches the switch. I also would like the entity to activate the switch after they reach it.

Heres the code:



some things to note, i think reachtarget may not work here as i would wish, as i have the switch on a wall so the entity never really reaches the switch.

I have also tried this with raycast=20 50 instead of reachtarget and it still does not work.

I have tried movefore instead of movetotarget and try a raycast everytime before movefore again but doesn't work.

Also i realise that the script cannot access states 2,3 and 4, im just trying to get the switch part to work.

any help would be greatly appreciated.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 9th Mar 2009 23:19
Why not set up a waypoint system leading to the switch. When the entity reaches the end of the waypoint line, you'll know that they reached the switch.


The one and only,


pandaHunter
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location:
Posted: 9th Mar 2009 23:46
well i was wanting to have the entity patrol an area(using a series of waypoints) and when they spotted the player head for the alarm/switch.

But i will try redoing the script with waypoints.

Could you tell me why replacing "reachtarget" with "raycast=20 50" wouldn't work for me? it just didn't seem to return true when the entity was approaching a wall.
pandaHunter
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location:
Posted: 10th Mar 2009 00:27
ok i have managed to factor in a waypoint. basically use one waypoint, and when he spots the player moves to that waypoint, targets the switch, activates switch.



but i would still like to have a patrolling guard that moves to the switch when they spot the player.

Any suggestions/pointers how i could script that?
pandaHunter
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location:
Posted: 10th Mar 2009 01:10
for posterities sake heres my latest version of code



allowing the entity i was using to head to a switch and activate it. But it doesn't seem very reusable/versatile. It suits the setup on my map, but if i create another switch and guard elsewhere i will probably have to write a completely new script.

If anyone can suggest i better way to deal with waypoints, i'd be greatful.

also thanks to Plystire for suggesting waypoints.

Login to post a reply

Server time is: 2024-11-24 21:42:11
Your offset time is: 2024-11-24 21:42:11