forked from Devieth/Halo-Lua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spawn_w_pistol.lua
65 lines (56 loc) · 2.17 KB
/
spawn_w_pistol.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
-- Generated by Glazed Doughnut v1.0 by 002
api_version = "1.8.0.0"
function OnScriptLoad()
register_callback(cb['EVENT_GAME_START'], "Apply")
end
function OnScriptUnload() end
function SwapDependency(Address,ToTag,ToClass)
local tag_address = read_dword(0x40440000)
local tag_count = read_dword(0x4044000C)
for i=0,tag_count-1 do
local tag = tag_address + 0x20 * i
if(read_dword(tag) == ToClass and read_string(read_dword(tag + 0x10)) == ToTag) then
write_dword(Address,read_dword(tag + 0xC))
return
end
end
end
function Apply()
ContinueAnyway = 1
local required_tags = {
{ 2003132784, "weapons\\pistol\\pistol"},
{ 2003132784, "weapons\\assault rifle\\assault rifle"},
{ 1651077220, "characters\\cyborg_mp\\cyborg_mp"}
}
local tag_address = read_dword(0x40440000)
local tag_count = read_dword(0x4044000C)
for i=0,tag_count-1 do
local tag = tag_address + 0x20 * i
local tag_name = read_string(read_dword(tag + 0x10))
local tag_class = read_dword(tag)
for key,value in pairs(required_tags) do
if(tag_class == value[1] and tag_name == value[2]) then
table.remove(required_tags,key)
end
end
end
if(ContinueAnyway == 1 and #required_tags > 0) then
cprint("WARNING: Some tags are missing from this map. Continuing.")
elseif(#required_tags > 0) then
cprint("ERROR: Some tags are missing from this map. Script failed.")
cprint("Note: use \"lua_call <scriptname> Apply 1\" to override.")
return
end
-- characters\cyborg_mp\cyborg_mp.bipd
for i=0,tag_count-1 do
local tag = tag_address + 0x20 * i
local tag_name = read_string(read_dword(tag + 0x10))
local tag_class = read_dword(tag)
if(tag_class == 1651077220 and tag_name == "characters\\cyborg_mp\\cyborg_mp") then
local tag_data = read_dword(tag + 0x14)
SwapDependency(tag_data + 0x92c, "weapons\\pistol\\pistol", 2003132784)
SwapDependency(tag_data + 0x950, "weapons\\assault rifle\\assault rifle", 2003132784)
break
end
end
end