Make an actor stay within the radius of a player?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Make an actor stay within the radius of a player?
Hi, I am currently working on a marine ally actor which fights alongside you, the problem is that they generally run directly into large groups of monsters without the logic of a player, and as a result die easily. Is there any way to implement code in DECORATE that would make the actor always stay within a radius of the player?
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Make an actor stay within the radius of a player?
Definetily yes, but it depends on pointers relations between player nd mrine lly.
For ex. in cse if that marine is player's friendly summon (lets assume tht it was spwned via A_SpawnItemEx(0,0,0,0,0,0,0,SXF_SETMSTER)) then mke some check longside of its See stte:
For ex. in cse if that marine is player's friendly summon (lets assume tht it was spwned via A_SpawnItemEx(0,0,0,0,0,0,0,SXF_SETMSTER)) then mke some check longside of its See stte:
Code: Select all
States
{
See:
TNT1 A 0 A_Chase
ABCD AA 1
{
If(GetDistance(1,AAPTR_MASTER)>Radius+1024)
{
A_ClerTarget //Optionlly
Return A_Warp(AAPTR_MASTER,frandom(-Radius,Radius));
}
Else{Return state("");}
}
TNT1 A 0 A_Chase
ABCD BB 1
{
If(GetDistance(1,AAPTR_MASTER)>Radius+1024)
{
A_ClerTarget //Optionlly
Return A_Warp(AAPTR_MASTER,frandom(-Radius,Radius));
}
Else{Return state("");}
}
TNT1 A 0 A_Chase
ABCD CC 1
{
If(GetDistance(1,AAPTR_MASTER)>Radius+1024)
{
A_ClerTarget //Optionlly
Return A_Warp(AAPTR_MASTER,frandom(-Radius,Radius));
}
Else{Return state("");}
}
TNT1 A 0 A_Chase
ABCD DD 1
{
If(GetDistance(1,AAPTR_MASTER)>Radius+1024)
{
A_ClerTarget //Optionlly
Return A_Warp(AAPTR_MASTER,frandom(-Radius,Radius));
}
Else{Return state("");}
}
Loop
Re: Make an actor stay within the radius of a player?
Thanks, I will either implement this or maybe have the ally check the distance from player at the end of the see state, and clear targets if so, so they return to the player automatically.Void Weaver wrote:Definetily yes, but it depends on pointers relations between player nd mrine lly.
For ex. in cse if that marine is player's friendly summon (lets assume tht it was spwned via A_SpawnItemEx(0,0,0,0,0,0,0,SXF_SETMSTER)) then mke some check longside of its See stte:Code: Select all
States { See: TNT1 A 0 A_Chase ABCD AA 1 { If(GetDistance(1,AAPTR_MASTER)>Radius+1024) { A_ClerTarget //Optionlly Return A_Warp(AAPTR_MASTER,frandom(-Radius,Radius)); } Else{Return state("");} } TNT1 A 0 A_Chase ABCD BB 1 { If(GetDistance(1,AAPTR_MASTER)>Radius+1024) { A_ClerTarget //Optionlly Return A_Warp(AAPTR_MASTER,frandom(-Radius,Radius)); } Else{Return state("");} } TNT1 A 0 A_Chase ABCD CC 1 { If(GetDistance(1,AAPTR_MASTER)>Radius+1024) { A_ClerTarget //Optionlly Return A_Warp(AAPTR_MASTER,frandom(-Radius,Radius)); } Else{Return state("");} } TNT1 A 0 A_Chase ABCD DD 1 { If(GetDistance(1,AAPTR_MASTER)>Radius+1024) { A_ClerTarget //Optionlly Return A_Warp(AAPTR_MASTER,frandom(-Radius,Radius)); } Else{Return state("");} } Loop