Scripts / How to stop AI to follow me on zombie script ? (Read before posting)

Author
Message
Vuk
9
Years of Service
User Offline
Joined: 3rd Mar 2015
Location:
Posted: 27th Mar 2015 13:18 Edited at: 27th Mar 2015 13:51
Hi, I try to use script for slow zombie walk on other character and it work fine, but they keep follow me, so can you help me to stop doing that ? I made i short video for example: https://www.youtube.com/watch?v=m18MEu_VONw&feature=youtu.be
(I also try to use waypoints but they don't work either)?
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 27th Mar 2015 14:07 Edited at: 27th Mar 2015 14:13
There are two types of characters.

Waypoint characters and free roam characters. One has waypoint code and only goes free only when the player get within 800 range. (soldiers)

the free roam ones (zombies) uses ranges to start animations.
Switching scripts may yield animation weirdness, as the scripts are links to those characters, for animation calls.

Ok now for the first question:

I would have to open the script and see where I could stop that for you. as all the scripts are set to follow the player and attack them. What is your final goal for these zombies?
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Vuk
9
Years of Service
User Offline
Joined: 3rd Mar 2015
Location:
Posted: 27th Mar 2015 15:20 Edited at: 27th Mar 2015 16:48
Actually i want to make them like a real people (I mean character not zombie, i was thinking about zombie script), example: https://www.youtube.com/watch?v=OpnQdLxAMJI
They walking and don't follow you, they avoid you..... I have idea for big project. I was thinking to make a Large city with people and more cool stuff like Vehicles,planes and more
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 29th Mar 2015 13:11 Edited at: 29th Mar 2015 13:12
He is using the Fantasy characters, there script uses Waypoints to mill about.
I suspect that he modifies the script and just left the in a patrol alert mode. or set this line towards the end of the script:

if PlayerDist >= 900 and ai_soldier_state[e]~="patrol" then <------ orig line

if PlayerDist >= 1 and ai_soldier_state[e]~="patrol" then <------- ***modified line

Therefore keeping these characters in a constant patrol state following the way points.

this is probably the only thing you would need to change in the script.

ai_fantasycharacter.lua is the original scripts for the fantasy characters.

You could duplicate this script and change the way it functions, and assign that script to your characters you want to use this on. If you are doing custom characters, be sure you match the animation frames to the script calls, or you may get some weird animations of these characters.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Vuk
9
Years of Service
User Offline
Joined: 3rd Mar 2015
Location:
Posted: 29th Mar 2015 15:05
Thanks all doing great when I am away from them, but when i come close they follow me... I edited everything you said..
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 29th Mar 2015 15:18
I will mess with the script later today or tomorrow, and test some things, you can modify anything in the to change the behavior. You just need to fiddle with it. You want no interaction what so ever, even at under 5 units away?
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Vuk
9
Years of Service
User Offline
Joined: 3rd Mar 2015
Location:
Posted: 29th Mar 2015 16:05
Okey thanks,
,,You want no interaction what so ever, even at under 5 units away?'' - , I just want everyone to go their own way, and don't follow me , like real people
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 29th Mar 2015 19:56
You will be using waypoint for these right?

it is the only way to get the medieval ones to wander a specific path.

they will just not go around in circles on there own with out some major script rewriting, that is way over my head.

I will tinker with there script and see if I can completely make them stop chasing the player at any range and just follow the waypoint path.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Vuk
9
Years of Service
User Offline
Joined: 3rd Mar 2015
Location:
Posted: 29th Mar 2015 20:09
Thank you, I will also try to find something
PM
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 29th Mar 2015 21:59
Please post whole script (what you have achieved so far) so we can take a look.
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 29th Mar 2015 23:54
Awesome, A script guy, thank you Avram.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Vuk
9
Years of Service
User Offline
Joined: 3rd Mar 2015
Location:
Posted: 30th Mar 2015 07:06
Script:
-- LUA Script - precede every function and global member with lowercase name of script

attackstart = {}
attackend = {}
damageframestart = {}
damageframeend = {}
lastroar = {}
lastswipe = {}

function ai_fantasycharacter_init(e)
ai_soldier_state[e] = "patrol"
ai_soldier_pathindex[e] = -1
SetAnimationFrames(236,265)
LoopAnimation(e)
ModulateSpeed(e,1.0)
SetAnimationSpeed(e,1.0)
attackstart[e]=160
attackend[e]=189
damageframestart[e]=170
damageframeend[e]=180
lastroar[e] = 0
lastswipe[e] = 0
ai_old_health[e] = -1
SetCharacterSoundSet(e)
end

function ai_fantasycharacter_main(e)

PlayerDist = GetPlayerDistance(e)
EntObjNo = g_Entity[e]['obj']

if ai_soldier_state[e] == "patrol" then
if ai_soldier_pathindex[e] == -1 then
ai_soldier_pathindex[e] = -2
CharacterControlArmed(e)
PathIndex = -1
PathPointIndex = -1
pClosest = 99999
for pa = 1, AIGetTotalPaths(), 1 do
for po = 1 , AIGetPathCountPoints(pa), 1 do
pDX = g_Entity[e]['x'] - AIPathGetPointX(pa,po)
pDZ = g_Entity[e]['z'] - AIPathGetPointZ(pa,po)
pDist = math.sqrt(math.abs(pDX*pDX)+math.abs(pDZ*pDZ))
if pDist < pClosest and pDist < 200 then
pClosest = pDist
PathIndex = pa
PathPointIndex = po
end
end -- po
end -- pa
if PathIndex > -1 then
ai_soldier_pathindex[e] = PathIndex
ai_path_point_index[e] = PathPointIndex
ModulateSpeed(e,1.0)
SetCharacterToWalk(e)
ai_path_point_direction[e] = 1
ai_path_point_max[e] = AIGetPathCountPoints(ai_soldier_pathindex[e])
end
end
if ai_soldier_pathindex[e] > -1 then
ai_patrol_x[e] = AIPathGetPointX(ai_soldier_pathindex[e],ai_path_point_index[e])
ai_patrol_z[e] = AIPathGetPointZ(ai_soldier_pathindex[e],ai_path_point_index[e])
AIEntityGoToPosition(EntObjNo,ai_patrol_x[e],ai_patrol_z[e])
tDistX = g_Entity[e]['x'] - ai_patrol_x[e]
tDistZ = g_Entity[e]['z'] - ai_patrol_z[e]
DistFromPath = math.sqrt(math.abs(tDistX*tDistX)+math.abs(tDistZ*tDistZ))
if DistFromPath < 50 then
if ai_path_point_direction[e] == 1 then
ai_path_point_index[e] = ai_path_point_index[e] + 1
if ( ai_path_point_index[e] > ai_path_point_max[e] ) then
ai_path_point_index[e] = ai_path_point_max[e] - 1
ai_path_point_direction[e] = 0
end
else
ai_path_point_index[e] = ai_path_point_index[e] - 1
if ( ai_path_point_index[e] < 1 ) then
ai_path_point_index[e] = 2
ai_path_point_direction[e] = 1
end
end
end
end
end

if PlayerDist < 900 then

if GetPlayerDistance(e)<100 then
if ai_soldier_state[e] ~= "attack" then
AIEntityStop(EntObjNo)
ai_soldier_state[e] = "attack"
CharacterControlLimbo(e)
SetAnimationFrames(160,189)
LoopAnimation(e)
end
else
if ai_soldier_state[e] ~= "charge" then
ai_soldier_state[e] = "charge"
CharacterControlArmed(e)
SetCharacterToWalk(e)
ModulateSpeed(e,1.5)
end
end
if ai_soldier_state[e] == "charge" then
RotateToPlayer(e)
AIEntityGoToPosition(EntObjNo,g_PlayerPosX,g_PlayerPosZ)
end
if ai_soldier_state[e] == "attack" then
RotateToPlayer(e)
if GetAnimationFrame(e)>damageframestart[e] and GetAnimationFrame(e)<damageframeend[e] then
if GetPlayerDistance(e)<100 then
PlaySound(e,1)
HurtPlayer(e,1)
end
end
end

end

if ai_old_health[e]==-1 then
ai_old_health[e] = g_Entity[e]['health']
end
if g_Entity[e]['health'] < ai_old_health[e] then
ai_old_health[e] = g_Entity[e]['health']
PlayCharacterSound(e,"onHurt")
end

if PlayerDist >= 1 and ai_soldier_state[e]~="patrol" then
ai_soldier_state[e] = "patrol"
SetCharacterToWalk(e)
ModulateSpeed(e,1.0)
end

end

function ai_fantasycharacter_exit(e)
PlayCharacterSound(e,"onDeath")
CollisionOff(e)
end

I just edited if PlayerDist >= 900 and ai_soldier_state[e]~="patrol" then from 900 to 1

btw. You are from Serbia right ? (I am from Serbia too )
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 30th Mar 2015 11:26
civilian_waypoint.lua
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 30th Mar 2015 16:03
Oh well, smallg always posts reply faster than me there's no point in posting my code now (I haven't even tested it) as I'm sure all smallg's scripts work as expected.

@Vuk: Yes I am from Serbia, and I'm not the only one here from this part of the planet.
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 30th Mar 2015 16:50
that smallg, over achiever.

Avram, post yours also. maybe an offshoot, might be useful to someone else.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 30th Mar 2015 17:01
Oh well, smallg always posts reply faster than me there's no point in posting my code now (I haven't even tested it) as I'm sure all smallg's scripts work as expected.

@Vuk: Yes I am from Serbia, and I'm not the only one here from this part of the planet.
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 30th Mar 2015 17:02
Nice script smallg, works like a charm. thank you.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 30th Mar 2015 18:32
Haven't got time to test this, but I hope this should work. I simply took out the charging/attacking part of the code.

Attachments

Login to view attachments
Vuk
9
Years of Service
User Offline
Joined: 3rd Mar 2015
Location:
Posted: 30th Mar 2015 19:34
Thank you all for replaying and helping me All working Thanks again
PM

Login to post a reply

Server time is: 2024-05-23 22:55:51
Your offset time is: 2024-05-23 22:55:51