Lightning effect on Character

Here's a revised Sandbox+ sr3_city.lua that creates a new hellrider thread and toggles on and off your function with R+PGUP so you can see how it works. I'll likely be revising some names and using that as a standard effects function for users to cycle through different effects.

This is just the important stuff with a couple comments here and there from me (NOTE: The attached lua has this in working form.
Code:
-- Attach effects thread vars
Hellrider_Handle = INVALID_THREAD_HANDLE  --<- new thread var
HELLRIDER_THREAD_ON = 1 --<- var for the do while loop
hellflame_toggle = false --<- boolean that is switched when R+PGUP is invoked
 
-- new thread created within the sr3_city_main() function. The main function is called one time at loading of your save
function sr3_city_main()
    Keycombo_Handle = thread_new("keycombo_thread")
    TOD_Handle = thread_new ("tod_thread")
    Hellrider_Handle = thread_new("hellrider_thread")
end
 
-- this is the thread that got created. Notice the hellflame_toggle conditional block. Since we declared it as false then that conditional block
-- will never resolve until we change it to true coming up in the actual R+PGUP conditional block
function hellrider_thread()
    while HELLRIDER_THREAD_ON == 1 do
        if hellflame_toggle then
            explosion_create("Ammo - Incendiary", LOCAL_PLAYER)
        end
        delay(.5)
    end
end
 
        elseif player_action_is_pressed("CBA_OFC_PICKUP_RELOAD") then -- R(eload) - SPECIAL COMMANDS
--..
 
-- Each time you push this keycombo it flips the hellflame_toggle boolean. When true the above thread that is always running
-- will create those explosions
            elseif player_action_is_pressed(B_PGUP) and not RELOAD_PUSHED then
                if hellflame_toggle then
                    hellflame_toggle = false
                    sandboxplus_message("Hellrider effect DEACTIVATED")
                else
                    hellflame_toggle = true
                    sandboxplus_message("Hellrider effect ACTIVATED")
                end
                RELOAD_PUSHED = true
 

Attachments

  • sr3_city.lua
    140.2 KB · Views: 591
You're almost there. You would want to create a new thread for it with a do while loop, that would keep repeating indefinitely and then call that hellrider() function from there. Then you can create a boolean to toggle the state on and off. I am right now throwing this into Sandbox+ so you can see how it all works.
Thank you! Lesson learned. Maybe next thing of mine will work :)
 
Code:
local myflamingride = get_char_vehicle_name(LOCAL_PLAYER)
vehicle_set_smoke_and_fire_state(myflamingride, false, true)

YEAH!

(Well, it's not that final "YEAH" we're all hoping for but it's also good!)
 
I spent some time with function found above, took some lesson (thank again, IdolNinja) and came up with this. It attaches flame and smoke effects to player's vehicle so you can ride with even more style. It's meant to work in Sandbox+ but I decided to post it here since I take this mod as a step towards making a conviencing Raiden\Ghostrider-like character.

Main problem of this mod and how I solved it (n00b programmer alarm on):
When player enters the vehicle and activates this effect, his vehicle starts to burn. Flames don't do any damage nor to player, nor to vehicle itself - they're just VFX and SFX. Problems start to appear when player exits that thing because game engine prevents player from entering a burning vehicle.

This made me think of a way to "extinguish" player rides upon exiting. Checking if player is in car did the trick in 50% (see it's code on "Alternative part two" section). It worked for player's leaving via "E" button but didn't work for players being thrown out of vehicles (for example: falling off the bike). I couldn't find any function preventing player from falling off the vehicles (fasten_seat_belts(LOCAL_PLAYER) didn't work either ;) ) so I had to go back to my old-fashioned thing: turning flames on and off one after another, so does each FLAMES_THREAD cycle ends in turning flames off.

Here's the code. I tried to do it as good as it gets...

Code:
-- Part one
 
Flames_Handle = INVALID_THREAD_HANDLE
FLAMES_THREAD_ON = 1
on_flames = 0
flames_activated = 0
 
-- Part two
 
function flames_thread()
   while ( FLAMES_THREAD_ON == 1 ) do
   if (flames_activated == 1) then
       local local_ride = get_char_vehicle_name(LOCAL_PLAYER)
       vehicle_set_smoke_and_fire_state(local_ride, false, true)
       vehicle_set_smoke_and_fire_state(local_ride, true, false)
            if COOP_COMMANDS and coop_is_active() then
                local remote_ride = get_char_vehicle_name(REMOTE_PLAYER)
                vehicle_set_smoke_and_fire_state(remote_ride, false, true)
                vehicle_set_smoke_and_fire_state(remote_ride, true, false)
             end
        end
    delay(1.0)
 end
end
           
-- Part three - button-press
 
if flames_activated == 0 then
    flames_activated = 1
    sandboxplus_message("Burning vehicles activated.")
elseif flames_activated == 1 then
    flames_activated = 0
    sandboxplus_message("Burning vehicles deactivated.")
end
                   
 
--Alternative part two
--It seems to be a bit more elegant - at least it's not calling two contradictory
--functions one after another - but it's  buggy. It doesn't allow to player to enter
--a vehicle he just has fallen off. That's because I couldn't find a function that
--registers "player has fell off the vehicle" event.
--[[
function flames_thread()
    while ( FLAMES_THREAD_ON == 1 ) do
        local myride = get_char_vehicle_name(LOCAL_PLAYER)
            if character_is_in_vehicle(LOCAL_PLAYER) then           
                if (flames_activated == 1 and on_flames == 0) then
                    vehicle_set_smoke_and_fire_state(myride, true, true)                   
                    on_flames = 1
                elseif (flames_activated == 0 and on_flames == 1) then
                    vehicle_set_smoke_and_fire_state(myride, false, false)
                    on_flames = 0
                end
                else
                vehicle_set_smoke_and_fire_state(myride, false, false)         
                on_flames = 0
            end
        delay(1.0)
    end
end
]]--

And now, for the character effects:

character_ignite(LOCAL_PLAYER)

Set the player on fire. However it also makes the player react to that fire, i.e. screaming and running uncontrolable. Calling set_animation_state(LOCAL_PLAYER, "idle") reverts controls but disables any animations.
 
Thanks for this i have now understand how code works but how do u know the args to put in functions ? i've found some lua files but there is no function like

Code:
vehicle_set_smoke_and_fire_state("vehicle", false, true)

or half or more of this very helpfull list
http://www.saintsrowmods.com/forum/index.php?threads/srtt-functions.1107/
thanks ;)

edit: Its fine i haven't read the line for str2_pc here
http://www.saintsrowmods.com/forum/index.php?threads/saints-row-the-third-modding-basics.597/
i gona check that ;) thx
 
Weirder and weirder. This line of code when added to Sandbox+ only works in m24:
effect_play_on_human("Effect BloodHit", LOCAL_PLAYER, "Head")

But it does not work in the open world at all. Also, there is nothing in any table file with that specfic name. i.e. "Effect Bloodhit". There is only "BloodHit" in both effects.xtbl and vfx.xtbl (which I also tried and it didn't work.)

It also doesn't work while in any mission other than m24 so it must be something specific loading for it.
I found Blood Hit, Blood Pool and Blood Impact in the decal_info.xtbl folder but I had no luck making anything significant happen there.
 
Back
Top