Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Replace Plasma Grenades with Frags by H® Shaft for SAPP
- -- This script will:
- -- Set Frag and Plasma Grenade counts to what you specify
- -- Replace both the plasma grenade equipment and projectile with the frag grenade equipment and projectiles
- -- will only work with UNPROTECTED maps with stock frags and plasma grenades
- -- requested by @Captain@
- -- If you would like to do the opposite; replace Frag Grenades with Plasma, see other script. http://pastebin.com/8amXdW02
- -- set grenade counts to what you want them. I suggest leaving 'plasma'_count to 0 (zero)
- -- Note: plasma count will show, but only frags will be thrown/picked up. If you pickup frags, only frag count will increase:
- frag_count = 2
- plasma_count = 0
- -- sapp api version
- api_version = "1.8.0.0"
- -- do not edit below unless you know what you are doing --
- game_started = false
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'],"OnNewGame")
- register_callback(cb['EVENT_GAME_END'],"OnGameEnd")
- register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
- register_callback(cb['EVENT_OBJECT_SPAWN'],"OnObjectSpawn")
- end
- function OnScriptUnload() end
- function OnPlayerSpawn(PlayerIndex)
- if (game_started == true) then
- -- set grenade counts as they are set above
- if (player_alive(PlayerIndex) == true) then
- local player_object = get_dynamic_player(PlayerIndex)
- safe_write(true)
- write_word(player_object + 0x31E, frag_count)
- write_word(player_object + 0x31F, plasma_count)
- safe_write(false)
- end
- end
- end
- function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
- if (game_started == true) then
- -- Note: you cannot replace one object type for another, they must be the same type.
- -- obj_types: vehi, weap, bipd, eqip, proj
- -- obj_names: there are many, example: "weapons\\plasma grenade\\plasma grenade"
- -- replace plasma grenade eqip/equipment with frag grenades:
- if MapID == get_tag_info("eqip", "weapons\\plasma grenade\\plasma grenade") then
- return true, get_tag_info("eqip", "weapons\\frag grenade\\frag grenade")
- end
- -- replace plasma grenade proj/projectiles with frag projectiles (doesn't happen until you throw):
- if MapID == get_tag_info("proj", "weapons\\plasma grenade\\plasma grenade") then
- return true, get_tag_info("proj", "weapons\\frag grenade\\frag grenade")
- end
- -- end --
- return true
- else
- return false
- end
- end
- -- note: calls to this function must provide both arguments of obj_type & obj_name separated by comma as shown above.
- function get_tag_info(obj_type, obj_name)
- local tag_id = lookup_tag(obj_type, obj_name)
- return tag_id ~= 0 and read_dword(tag_id + 0xC) or nil
- end
- function OnNewGame()
- game_started = true
- end
- function OnGameEnd()
- game_started = false
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement