RVT Script Repository

Status
Not open for further replies.

WhoronaVirus

Expert
Oct 6, 2020
21
3
61
This thread will contain pre-written blocks to work with when writing a script. Thanks to Cantaloupe, TrustySn00ze and GamerGotten for putting these together.
 

WhoronaVirus

Expert
Oct 6, 2020
21
3
61
Check for player projectiles:

Code:
declare global.number[0] with network priority local
declare global.player[0] with network priority local
declare global.object[0] with network priority local
declare global.object[1] with network priority local

for each player do
      if current_player.biped != no_object then 
         global.object[0] = current_player.try_get_weapon(primary)
         global.object[1] = current_player.try_get_armor_ability()
         for each object with label 0 do
            if not current_object.is_of_type(spartan) and not current_object.is_of_type(elite) and not current_object.is_of_type(particle_emitter_fire) and not current_object.is_of_type(magnum) and global.object[0] != current_object and global.object[1] != current_object then 
               global.player[0] = current_object.try_get_carrier()
               if global.player[0] == no_player then 
                  global.number[0] = current_object.get_distance_to(global.object[1])
                  if global.number[0] < 11 then 
                     global.number[0] = current_object.get_speed()
                     if global.number[0] > 70 then 
                        --
                        -- code to run on projectile
                        --
                     end
                  end
               end
            end
         end
      end
end
 

WhoronaVirus

Expert
Oct 6, 2020
21
3
61
Run code only on clients, potentially useful for running non sync'd actions on CGB

Code:
 declare global.number[0] with network priority local

do
   global.number[0] = 1
end

on local: do
   if global.number[0] == 0 then
      --
      -- code to run on clients
      --
   end
end
 

WhoronaVirus

Expert
Oct 6, 2020
21
3
61
Script to replenish Target Locator ammo curtesy of Cantaloupe


Code:
alias locator_timer = global.timer[3]
alias target_locator_uses = global.number[8]
alias opt_max_locator_uses = script_option[9]
declare target_locator_uses with network priority high = 0
declare locator_timer = 0

on object death: do
    if death_event_damage_type == enums.damage_reporting_type.target_locator and locator_timer.is_zero() then
    target_locator_uses+= 1
    locator_timer = 10
    locator_timer.set_rate(-100%)
    end
end

if target_locator_uses == opt_max_locator_uses then
target_locator_uses = 0
    for each object do
        if current_object.is_of_type(target_locator) then
        current_object.delete()
        end
    end
end

for each player do  
global.object[0] = current_player.get_weapon(primary)  
if global.object[0].is_of_type(target_locator) then
      current_player.apply_traits(script_traits[6])
   end
end
 

WhoronaVirus

Expert
Oct 6, 2020
21
3
61
Gate/Door Controls(proximity and button controlled, re closes)

Code:
for each object with label "Door Rotate" do
   for each player do
   --go up
    if current_object.number[1] < 1  and current_object.number[2] <= 10 and current_object.shape_contains(current_player.biped) then 
      current_object.object[0] = current_object.place_at_me(hill_marker, none, never_garbage_collect, 0, 0, 1, none)
      current_object.attach_to(current_object.object[0], 0, 0, 0, relative)
      current_object.detach()
      current_object.object[0].delete()
      current_object.object[0] = no_object
      current_object.number[1] = 30
      current_object.number[2] += 1
   end
   
   --go down if nobody is there
   if current_object.number[1] < 1 and current_object.number[2] > 0 and not current_object.shape_contains(current_player.biped) then 
      current_object.object[0] = current_object.place_at_me(hill_marker, none, never_garbage_collect, 0, 0, -1, none)
      current_object.attach_to(current_object.object[0], 0, 0, 0, relative)
      current_object.detach()
      current_object.object[0].delete()
      current_object.object[0] = no_object
      current_object.number[1] = 2
      current_object.number[2] -= 1
   end
   
   current_object.number[1] -= 1
  end
end
 

WhoronaVirus

Expert
Oct 6, 2020
21
3
61
Moving Platforms

-Put one way shield on each side of the platform if moving fast.
--Limit for moving at 100% play move speed is 10, otherwise they will fall off if no back wall
--Can be used as elevator with max move speed of 10, does require some amount of mass below the object to force players up, can be button triggered
--Very odd movement and depends on object orientation. Not all objects default the same direction, monitors do not respawn and cause issues as parent terminal
--Objects not touched by player disappear and respawn even while moving in vincinity
--objects partly moving below maps surface boundaries will go invisible but still have physics boundaries.
--Putting object min = max will spawn multiple objects during the objects despawn and respawn time, recommended to put 1 second spawn timer instead

Code:
for each object with label "ParentPlatformMover" do
    global.number[1] = current_object.health
    script_widget[1].set_value_text("Health: %n", global.number[1])
   for each player do
   --go up if there is someone there and the counter isn't max height of raise
    if current_object.number[1] < 1  and current_object.number[2] <= 200 and current_object.shape_contains(current_player.biped) then
      current_object.object[0] = current_object.place_at_me(hill_marker, none, never_garbage_collect, 1, 0, 0, none)
      current_object.attach_to(current_object.object[0], 0, 0, 0, relative)
      current_object.detach()
      current_object.object[0].delete()
      current_object.object[0] = no_object
      for each object with label "ChildPlatformMover" do
      current_object.object[0] = current_object.place_at_me(hill_marker, none, never_garbage_collect, 1, 0, 0, none)
      current_object.attach_to(current_object.object[0], 0, 0, 0, relative)
       current_object.detach()
      current_object.object[0].delete()
      current_object.object[0] = no_object
      end
      current_object.number[1] = 10
      current_object.number[2] += 1
   end
   for each object with label "ChildPlatformMover" do
      current_object.object[0] = current_object.place_at_me(hill_marker, none, never_garbage_collect, 1, 0, 0, none)
      current_object.attach_to(current_object.object[0], 0, 0, 0, relative)
      current_object.detach()
      current_object.object[0].delete()
      current_object.object[0] = no_object
      end
      current_object.number[1] = 10
      current_object.number[2] += 1
   end
 
   --go down if nobody is there and count is higher than 1
   if current_object.number[1] < 1 and current_object.number[2] > 0 and not current_object.shape_contains(current_player.biped) then
      current_object.object[0] = current_object.place_at_me(hill_marker, none, never_garbage_collect, -1, 0, 0, none)
      current_object.attach_to(current_object.object[0], 0, 0, 0, relative)
      current_object.detach()
      current_object.object[0].delete()
      current_object.object[0] = no_object
      for each object with label "ChildPlatformMover" do
      current_object.object[0] = current_object.place_at_me(hill_marker, none, never_garbage_collect, -1, 0, 0, none)
      current_object.attach_to(current_object.object[0], 0, 0, 0, relative)
      current_object.detach()
      current_object.object[0].delete()
      current_object.object[0] = no_object
      end
      current_object.number[1] = 10
      current_object.number[2] -= 1
   end
   current_object.number[1] -= 1
  end
end
 

WhoronaVirus

Expert
Oct 6, 2020
21
3
61
Falcon Carpet Bomb


Code:
alias currplayerspeed = global.number[11] 
alias currplayervehicle = global.object[11]
--Carpet Bomb
for each player do
    currplayerspeed = current_player.biped.get_speed()
    script_widget[2].set_value_text("speed %n", currplayerspeed)
    currplayervehicle = current_player.get_vehicle()
    script_widget[1].set_value_text("vehicle %s", currplayervehicle)
    global.object[0] = current_player.biped
    if currplayerspeed > 65 and currplayervehicle.is_of_type(falcon) and current_player.number[1] < 10 then
        global.object[2] = global.object[0].place_at_me(landmine, none, none, 45, 0, -15, none)
        global.object[2] = global.object[0].place_at_me(landmine, none, none, 45, 5, -15, none)
        global.object[2] = global.object[0].place_at_me(landmine, none, none, 45, -5, -15, none)
        current_player.number[1] = 40
    end 
    current_player.number[1] -= 1
end
 

WhoronaVirus

Expert
Oct 6, 2020
21
3
61
Detect and turn grenades into fusion coils with no latency

Code:
for each object with label 0 do
global.number[0] = 0
global.number[0] = current_object.health
    if global.number[0] == 100 then
    global.object[0] = current_object
        for each object do
            if current_object == global.object[0] then
            global.number[0] = -1
            end
        end
        if global.number[0] == 100 then
            global.number[1] = -2
            for each object do
                if global.number[1] != 0 and current_object.is_of_type(spartan) or current_object.is_of_type(elite) then
                global.number[1] = current_object.get_distance_to(global.object[0])
                end
            end
            if global.number[1] != 0 then
            global.object[1] = current_object.place_at_me(fusion_coil, none, none, 0, 0, 0, none)
            global.object[1].attach_to(current_object, 0, 0, 0, relative)
            global.object[1].detach()
            current_object.delete()
            end
        end
    end
end
 
Status
Not open for further replies.