Event: | S_EVENT_SHOT | Added with: 1.2.4 | |
Enum ID: | 1 | Event Locality: None | |
Description: | Occurs whenever any unit in a mission fires a weapon. But not any machine gun or autocannon based weapon, those are handled by shooting_start. | ||
Table Format: | The shot event table is in the following format.
Event = { id = 1, time = Time, initiator = Unit, weapon = Weapon } | ||
Examples: | The following creates a message box stating the unit name has fired a weapon with the given name. If the weapon object returns a target then that target will also be displayed.
local e = {} function e:onEvent(event) if event.id == 1 then local m = {} m[#m+1] = event.initiator:getName() m[#m+1] = ' has fired a ' m[#m+1] = event.weapon:getDisplayName() local tgt = event.weapon:getTarget() if tgt then m[#m+1] = ' at a target ' m[#m+1] = tgt:getTypeName() end trigger.action.outText(table.concat(m), 60) end end world.addEventHandler(e) | ||
Notes: | |||
Events: | shot, hit, takeoff, land, crash, ejection, refueling, dead, pilot_dead, base_captured, mission_start, mission_end, took_control, refueling_stop, birth, human_failure, detailed_failure, engine_startup, engine_shutdown, player_enter_unit, player_leave_unit, player_comment, shooting_start, shooting_end, mark_added, mark_change, mark_remove, kill, score, unit_lost, landing_after_ejection, discard_chair_after_ejection, weapon_add, landing_quality_mark, ai_abort_mission, weapon_drop, runway_takeoff, runway_touch, |