Home   Help Search Login Register  

Author Topic: How to know if a soldier target something or not?  (Read 1193 times)

0 Members and 1 Guest are viewing this topic.

zaitoh

  • Guest
How to know if a soldier target something or not?
« on: 29 Jun 2006, 15:51:51 »
Hi,

I've been looking for a way to tell if a specific soldier is targeting something or not? I've been looking for something like "target != objNull", but I'm not able to find anything.

/ZaiToh

zaitoh

  • Guest
Re: How to know if a soldier target something or not?
« Reply #1 on: 30 Jun 2006, 11:20:07 »
Perhaps the reason I didn't find any way to do it was that there simply arn't any.

Another solution that would solve my problem would be to check when the soldier last fired his weapon. I assume I should solve this by writing a function and then use it from a script. How should this script be constructed to use as little CPU as possible while still beeing able to check this kinda often (at least once per sec for a group of 8 men)? If no bullet has been fired for a specific time, there should be a soldier fire weaponName after a random time.

Is there any basic tutorial out there? All I can find these days is dead links to what seems to be goald mines for a noob like myself.

/ZaiToh

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: How to know if a soldier target something or not?
« Reply #2 on: 30 Jun 2006, 12:12:54 »
Hello zaitoh,

Have you checked the tutorials in the Temporary Editors Depot.....click the link at the top of the page.

Also, on the Home page there is a link to a Command Reference in the sidebar.

You will most likely need to use an eventhandler for each soldier you wish to check, a 'fired' eventHandler in this case.

The Command Reference has a section about the different eventhandlers here.


Planck

I know a little about a lot, and a lot about a little.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: How to know if a soldier target something or not?
« Reply #3 on: 30 Jun 2006, 12:15:17 »
experiment with the knowsabout command. if a unit sees an enemy, and knows a certain amount about that enemy, and has ammo of the correct type, he'll shoot it.

if there are many enemies around a unit, the one with the highest knowsabout number will be the one he's paying attention to.

so. make a trigger covering the whole map, make it activate when the enemy is present, and in the 'on activation' box type

Code: [Select]
all_enemy = thislist
then in a script, you can loop through the newly created array all_enemy and find out both which one your specific unit is targetting, and also which of the enemy is targetting your specific unit.

this can be looped quite quickly, and the array of all_enemy will automatically be updated if any are killed.

zaitoh

  • Guest
Re: How to know if a soldier target something or not?
« Reply #4 on: 30 Jun 2006, 13:30:08 »
@Planck

Yep, I've read most of them and everything that somehow could do something with scripting. The most useful ones are snYpirs guide to functions and cameras. I've been reading the comref for some days now and it's really great. I just wish there were more comments and more examples.

The big problem is that there's so little script to download and look at. I read as much as possible at the forum trying to get the hang of it, but I miss a place to find lots of complete scripts.

A thougt it had something to do with the eventhander... the problem is that I don't know how it really works. I havn't found any useful script to look at that's been using the evanthandler... but then I havn't really searched the forum yet so I'll come back and wine after I've tried that ;)

@bedges

It sound like a really great idea to check for the knowsabout! Have I got it right if I assume that if the returen value is below 0.7, the soldier doesn't have enough info to fire?

"all_enemy = thislist"

I don't understand what 'thislist' really is. Should that be replaced with something else or is it a command I can't find in the ComRef?

Thanks for your replies. I'm at work atm but will be able to check how it works when i return home.


Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: How to know if a soldier target something or not?
« Reply #5 on: 30 Jun 2006, 15:53:25 »
triggers are (surprise surprise) triggered by something. whatever causes them to activate is caught in an array called thislist, specific to the trigger concerned. thislist for one trigger will be different from another trigger's thislist.

a handy introduction to the this property can be found in general barron's "all about 'this' " in the tutorials section. while not covering thislist (as far as i remember) it covers the concept of values returned by functions etc. very well. if you wished to use eventhandlers for example, knowing about the values this can return is vital.

however, there's no better way to learn than seeing it done and trying it for yourself. i'll make a missionette to illustrate the concept.

EDIT - m'kay, missionette attached below. the script is fully commented - may make it more difficult to read :P - but it works as far as i can tell.

[attachment deleted by admin]
« Last Edit: 30 Jun 2006, 16:51:51 by bedges »

zaitoh

  • Guest
Re: How to know if a soldier target something or not?
« Reply #6 on: 01 Jul 2006, 00:33:24 »
No, thislist wasn't mentioned in the this-tutorial. I've read most of the ones that's here on OFPEC, and havn't found anything about it. I see that you use all_enemy in the script you gave me... looks like there's a lot of very useful information out there I was scared I'd have to create myself. Is there any place to read about all this ones? Can't find anything in the comref.

I've been doing some research about the knowsAbout all evening know and came to the resolution that it wont work for me. Even though some unit has the highest knowsabout it isn't sure that it's the target. It was great fun finding out and I learned alot from it.

Seems like I have to stick with the idea of checking when a soldier last fired his weapon. Since the link General Barron gave in the comref is dead, is there any other good place to read about this? It's kinda hard to understand from the comref alone.

/ZaiToh

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: How to know if a soldier target something or not?
« Reply #7 on: 01 Jul 2006, 01:23:00 »
attached is igor drukov's eventhandler tutorial. i'll see about uploading it to the ed depot, it's a good piece of work.

[attachment deleted by admin]