Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Replace Frag Grenades with Plasma by H® Shaft for SAPP
- -- This script will:
- -- Set Frag and Plasma Grenade counts to what you specify
- -- Replace both the frag grenade equipment and projectile with the plasma 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 Plasma Grenades with Frags, see other script. http://pastebin.com/tkWh9bCZ
- -- set grenade counts to what you want them. I suggest leaving 'frag'_count to 0 (zero)
- -- Note: frag count will show, but only plasma will be thrown/picked up.
- frag_count = 0
- plasma_count = 2
- -- 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 frag grenade eqip/equipment with plasma grenades:
- if MapID == get_tag_info("eqip", "weapons\\frag grenade\\frag grenade") then
- return true, get_tag_info("eqip", "weapons\\plasma grenade\\plasma grenade")
- end
- -- replace frag grenade proj/projectiles with plasma projectiles (doesn't happen until you throw):
- if MapID == get_tag_info("proj", "weapons\\frag grenade\\frag grenade") then
- return true, get_tag_info("proj", "weapons\\plasma grenade\\plasma 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