target low level by number idea

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
fps
Posts: 504
Joined: Mon Sep 26, 2005 9:54 pm
Location: in a magical land devoid of hope, happiness, and sanity.

target low level by number idea

Post by fps »

would it be possible to set a pawns target to equal the entynames of several pawns at once.
like this.

SetTarget(foe_(1-12))

i may need to use a right or left copy command in there some were i think, but if im right i can keep the pawn in low level.

i may even need to cycle the order constantly throughout the script but it would still save me a lot of wasted effort. can anyone confirm or deny my theory?


Thanks,
fps
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

Excellent idea!
Yes, you could get the enemies' names that way and then check if any of them is visible and then target that one.

Though I don't recommend doing the 'check' very often. If there are, say, 10 pawns each checking if there are enemies nearby like 10 times per second, things may get slow. Also, the pawn number in one level will be limited, but I don't think that's a major issue.

Anyway, Great thinking! :)
Pain is only psychological.
User avatar
fps
Posts: 504
Joined: Mon Sep 26, 2005 9:54 pm
Location: in a magical land devoid of hope, happiness, and sanity.

Post by fps »

i am planning on having (for my test) friendly_1-10 and foe_1-10.
they need to attack each other accordingly. which way would you suggest i use. the check method. or the right copy in setup method?
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

I personally would do it like this:

Code: Select all

for enemynumber = 0 to 10
{
     if(IsEntityVsible("foe_" # enemynumber))
     {
          SetTarget("foe_" # enemynumber);
     }
}
Pain is only psychological.
revolutiongames2004
Posts: 75
Joined: Tue Jul 05, 2005 4:29 pm

Post by revolutiongames2004 »

oo indifference

also visible is spelled wrong

Code: Select all

 if(IsEntityVsible("foe_" # enemynumber)) 
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

revolutiongames2004 wrote: also visible is spelled wrong

Code: Select all

 if(IsEntityVsible("foe_" # enemynumber)) 
That's how it is in the manual. I just pasted it here. :wink:
Pain is only psychological.
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams »

hm... seems to be spelled wrong in the source code too, so IsEntityVsible is the version that actually works...
User avatar
fps
Posts: 504
Joined: Mon Sep 26, 2005 9:54 pm
Location: in a magical land devoid of hope, happiness, and sanity.

Post by fps »

thats nice to know. if they fix that in the next release it would mess up older scripts.

so the order should look somthing like this in the script.

{
Spawn[ ()
{
Console(true);
Ect(true);
LowLevel("Setup");
} ]

Setup[ ()
{
BlaBla = "bla";
self.think = "Idle";
} ]

Idle[ ()
{
idleactions
self.think = "AquireTargets"
}]

AquireTargets[ ()
{
self.ThinkTime = "0.2"; //what should this be set at?
for enemynumber = 0 to 10
{
if(IsEntityVsible("foe_" # enemynumber))
{
SetTarget("foe_" # enemynumber);
}
}]

rest of script
}


Will this check the visible pawns throughout the entire duration of the script or will i need to but it else were in the code also?
what do you think would happen if more than one pawn becomes visible while this is setting its target?
(i think i may have asked that elsewere :roll: )
would it work if the players entity name to friendly_1?

i think i will need to have it check for distance too but it may already do that in my full script.


i feel like im getting somewere with this finally,
thanks for the help,
fps
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis »

No, it wouldn't work the way you wrote it. You see, in the 'Idle' order you command the script to go to 'AquireTargets', but it doesn't come back to 'Idle'. So the script will only run the order 'AquireTargets' and do nothing else. I would recommend making this 'AquireTargets' a custom command (or something like that). I mean like this:

Code: Select all

 AquireTargets[ ()
{
for enemynumber = 0 to 10
{
if(IsEntityVsible("foe_" # enemynumber))
{
SetTarget("foe_" # enemynumber);
}
}] 
Then you could call this function from anywhere in the script. So whenever you would need to get a target, you would add line 'AquireTargets();' in the script. For example, if you wanted the pawn to check for new targets every 1 seconds while in 'Idle', you would add this to the 'Idle' order:

Code: Select all

if(FindTargetTimer < self.time)
{
AquireTargets();
FindTargetTimer = self.time + 1;
}
Where 'FindTargetTimer' is a variable which you need to define in the top of the script.


If there are multiple enemies visible at the same time, I believe the last one (the one with the biggest number) will be targeted.
Also, I would check for targets like every 1-2 seconds. In the end, it's up to you, though. Try different numbers and try to optimize it, so that it doesn't take too long for the pawns to find targets but it doesn't drop the framerate either.
Pain is only psychological.
Post Reply