Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Config
- -- tag_type can be vehi or bipd
- -- stun_time is the length of time shields do not recharge after taking damage
- -- recharge_time is the length of time it would take for shields to recharge after being completely depleted
- -- stun_time and recharge_time are both in seconds
- VITALITY_SETTINGS = {
- ["bigass_falcon"] = {
- ["tag_path"] = "vehicles\\falcon\\falcon",
- ["tag_type"] = "vehi",
- ["max_health"] = 0,
- ["max_shield"] = 500,
- ["stun_time"] = 40,
- ["recharge_time"] = 30,
- },
- ["default_biped"] = {
- ["tag_path"] = "characters\\cyborg_mp\\cyborg_mp",
- ["tag_type"] = "bipd",
- ["max_health"] = 75,
- ["max_shield"] = 75,
- ["stun_time"] = 6,
- ["recharge_time"] = 4,
- },
- }
- --End of config
- object_table_pointer = nil
- old_collision_geometry_settings = {}
- api_version = "1.9.0.0"
- function OnScriptLoad()
- object_table_pointer = sig_scan("A1????????8B48348B44910881A004020000FFFFFFFDC3") + 0x1
- register_callback(cb['EVENT_GAME_START'], "OnGameStart")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- local ticks = tonumber(get_var(0, "$ticks"))
- if(ticks > 0) then
- OnGameStart()
- end
- end
- function OnGameStart()
- for k,v in pairs(VITALITY_SETTINGS) do
- if(type(v.tag_path) == "string" and type(v.tag_type) == "string") then
- if(v.tag_type == "vehi" or v.tag_type == "bipd") then
- local unit_tag = lookup_tag(v.tag_type, v.tag_path)
- if(unit_tag ~= 0) then
- local unit_meta = read_dword(unit_tag + 0xC)
- local unit_data = read_dword(unit_tag + 0x14)
- local collision_meta = read_dword(unit_data + 0x7C)
- if(collision_meta ~= 0xFFFFFFFF) then
- local collision_tag = lookup_tag(collision_meta)
- if(collision_tag ~= 0) then
- local collision_data = read_dword(collision_tag + 0x14)
- local old_data = {
- ["collision_meta"] = collision_meta,
- ["unit_meta"] = unit_meta,
- ["max_health"] = read_float(collision_data + 0x8),
- ["max_shield"] = read_float(collision_data + 0xCC),
- ["stun_time"] = read_float(collision_data + 0x10C),
- ["recharge_time"] = read_float(collision_data + 0x110),
- }
- table.insert(old_collision_geometry_settings, old_data)
- if(type(v.max_health) == "number") then
- write_float(collision_data + 0x8, v.max_health)
- end
- if(type(v.max_shield) == "number") then
- write_float(collision_data + 0xCC, v.max_shield)
- end
- if(type(v.stun_time) == "number") then
- write_float(collision_data + 0x10C, v.stun_time)
- end
- if(type(v.recharge_time) == "number") then
- write_float(collision_data + 0x110, v.recharge_time)
- end
- SetVitalityOfObjects(unit_meta, v.max_health, v.max_shield)
- end
- end
- end
- end
- end
- end
- end
- function OnGameEnd()
- old_collision_geometry_settings = {}
- end
- function SetVitalityOfObjects(MetaID, MaxHealth, MaxShield)
- if(type(MetaID) == "number") then
- local object_table = read_dword(read_dword(object_table_pointer))
- local object_count = read_word(object_table + 0x2E)
- local object_data = read_dword(object_table + 0x34)
- for i=0,object_count-1 do
- local object = read_dword(object_data + i*12 + 0x8)
- if(object ~= 0 and object ~= 0xFFFFFFFF) then
- local object_meta = read_dword(object)
- if(object_meta == MetaID) then
- if(type(MaxHealth) == "number") then
- write_float(object + 0xD8, MaxHealth)
- end
- if(type(MaxShield) == "number") then
- write_float(object + 0xDC, MaxShield)
- end
- end
- end
- end
- end
- end
- function OnScriptUnload()
- for k,v in pairs(old_collision_geometry_settings) do
- local collision_tag = lookup_tag(v.collision_meta)
- if(collision_tag ~= 0) then
- local collision_data = read_dword(collision_tag + 0x14)
- write_float(collision_data + 0x8, v.max_health)
- write_float(collision_data + 0xCC, v.max_shield)
- write_float(collision_data + 0x10C, v.stun_time)
- write_float(collision_data + 0x110, v.recharge_time)
- SetVitalityOfObjects(v.unit_meta, v.max_health, v.max_shield)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement