Jump to content

is there a way to read out Damage inside a zone?


Recommended Posts

Posted (edited)

Hey Folks!

I want to place a target with different zones like a dart. Once you finished the run, i want that it gives me the statistics how good/precise my gunrun was. Is there a way to realize it?

My thought so far:

-is there a way to read out the bullet impacts inside a zone, is there a way to calculate the amout of impacts? Or do you have any other ideas how to realise that?

 

Cheers

and thanks for the help

 

Is there a way to ask this in Lua like that

 

if(Events.id== 2 && Events.target=='Circle1_inf1'){ //id 2 is the Hit event isnt it?, cause injured as generel given trigger doesn't work.

return true;

}

 

to make something like that a rule

Edited by GottHold

Have a nice day!

Posted

You are going to need an event handler, which is a function that is run each time any event occurs. Generally you'd check for a certain type of event like shot, hit, or eject within the function. If your target is an actual object then several hit events may occur on a gun run. If the target is "simulated" and not a real object then your task gets a little more complicated.

 

For example this might count hits on a target. I stress the might part of it since I didn't actually test it or try it out.

local targets = {}

local function targetsHit(event)
if event.id == world.event.S_EVENT_HIT and event.target then 
	if Object.getCategory(event.target) == 1 then
		local uName = Unit.getName(event.target)
		if not targets[uName] then
			targets[uName] = 0
		end
		targets[uName] = targets[uName] + 1
	end
end
end

mist.addEventHandler(targetsHit)

 

Tracking if a bullet (or any other object) impacts inside a zone is a bit more difficult in that you need to get the objects and then continuously track them via script until they impact. In the case of bullets there will be quite a few objects to track. You also need to use world.searchObjects to get bullet objects since any rapid fire weapon in game uses the event shooting start/end which does not return any weapon objects.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...