Results 1 to 10 of 10

Thread: Efficiently scripting many many triggers and script objects

  1. #1

    Default Efficiently scripting many many triggers and script objects

    Hi folks,

    I'm attempting to recreate something like the 'hex-a-gone' level from Fall Guys within mohaa. For anyone not sure what this is - the basic premise is if you stand on a hexagon tile too long, it disappears and you fall so you have to keep moving from tile to tile.

    I have created the hexagons as script objects and added their corresponding triggers within radiant, with key/variable cnt as 1 and a setthread key of, for example, hextrig1thread

    hextrig1thread:

    local.player = parm.other
    if ((local.player.dmteam == "allies") || (local.player.dmteam == "axis"))
    {
    wait 0.5
    $layer2tile001 delete
    $layer2tile001a show
    wait 0.25
    $layer2tile001a delete
    $layer2tile001b show
    wait 0.25
    $layer2tile001b playsound disappear_snd
    $layer2tile001b delete
    }

    end

    The tile 001, 001a and 001b are the various colours [eg blue, lightblue white] of the hexagon in the same location as each other to make it look somewhat animated over the course of a second or so, before disappearing.

    The issue is, I would need to replicated this for each of the many hundreds of hexagonal tiles. Is there any way I can efficiently script this without creating hundreds threads, with there being one thread for each tile?

    I tried something along the lines of pointing the setthread of all the triggers to the same thread using it as a template and just replacing the figures within the thread to the appropriate targetname based on the triggername but I cant connect the trigger to the values correctly.

    something like:

    wait 0.5
    local.figure1 delete
    local.figure2 show
    wait 0.25
    local.figure2 delete
    local.figure3 show
    wait 0.25
    local.figure3 playsound disappear_snd
    local.figure3 delete

    I'm more adept at mapping than scripting and struggled with creating efficiently written scripts so any advice is welcome.

    Cheers

    Twenty
    Last edited by twenty2man; November 4th, 2021 at 11:25 AM.

  2. #2

    Default

    The best way for this you will need 2 targetnames for 2 layers of hexs so we can hide one and show the other or viceversa
    The hide one we will need too is to make notsolid so the play fall down in case if stays for long time.
    To spawn a trigger on every block you can use 2 for loops, one for the first layer and the other for the second.

    The targetnames will work like a array so then you can use like this:

    //layer1
    for(local.i = 1;local.i <= $layer1.size;local.i++)
    {
    local.hex = $layer1[local.i]

    local.trig = spawn trigger_multipleall
    local.trig.origin = ( local.hex.origin )
    local.trig setsize ( 0 0 0 ) ( 0 0 0 )
    local.trig setthread hex_block

    }

    //layer2
    for(local.i = 1;local.i <= $layer2.size;local.i++)
    {
    local.hex = $layer2[local.i]

    local.trig = spawn trigger_multipleall
    local.trig.origin = ( local.hex.origin )
    local.trig setsize ( 0 0 0 ) ( 0 0 0 )
    local.trig setthread hex_block

    }


    Before this code we will need to add a variable to each layer so we know wich one is hidden or show like this

    $layer1.visibility = 0 // hidden
    $layer1.visibility = 1 //show


    Then on the thread of the trigger we put like this:

    hex_block:

    self nottriggerable // prevents the trigger to get triggerd very fast again

    if($layer1.visibility == 0)
    {
    $layer1 show
    $layer1 solid
    wait 0.25
    $layer2 hidde
    $layer2 notsolid

    $layer1.visibility = 1
    $layer2.visibility = 0
    }
    else
    {
    $layer1 hidde
    $layer1 notsolid
    wait 0.25
    $layer2 show
    $layer2 solid

    $layer1.visibility = 0
    $layer2.visibility = 1
    }

    self triggerable // renable the trigger
    Last edited by DoubleKill; November 4th, 2021 at 01:33 PM.

  3. #3

    Default

    I tried to make something very similar time ago, with the difference that I was trying to recreate the TNT Run gamemode from minecraft
    But It was a fail because of the entity limit in mohaa and radiant, and the blocks needed to be 48x48 units so you need thousands to make it look nice.

    Anyways, there is a simpler way to do what you want without having 3 duplicated hexagons in the same spot and without adding extra triggers.

    First of all you need to get rid of all extra layers of exagons, just leave one layer. And remove all the triggers too.
    All hexagon have to have the exact same targetname, and just the targetname, no setthread needed.
    And the shader of the exagons has to be like this:

    Code:
    your_hexagon_shader
    {
        qer_editorimage textures/common/white.tga
        surfaceparm nolightmap
        {
            map textures/common/white.tga
            blendFunc add
            rgbGen fromEntity
        }
    }
    Using this white.tga texture plus the rgbGen fromEntity statement will allow you to change the color of the shader from the script using the light command.
    For example $entity light 1 0 0 0 ($entity light <red> <green> <blue> <radius>)
    Will change the color of the shader to red

    You can see and example of that in this test map I made: https://www.youtube.com/watch?v=1OLgLlP3pn4 Download here: http://www.mohaaaa.co.uk/AAAAMOHAA/c...ow-tunnel-test

    For the trigger part you can do everything from script very easily
    With every hexagon having the same targetname, for example $hexagons, you can do something like this:


    main:
    $hexagons thread hextrigthread
    end

    hextrigthread:
    self light 0 0 1 0 // normal hexagon color (red green blue radius)

    self waittill touch

    self time 0.5 // Travel time
    self movedown 10 // Move the position down 10 units
    self waitmove // Move the script slave and wait until finished

    self light 1 1 1 0 // hexagon color before being removed

    wait 0.5

    self playsound "disappear_snd"
    self remove

    //local.player = parm.other // The player who touches the hexagon
    end


    I hope this helps you
    Have fun!

    And please let us know when you finish the map. I would like to see how it looks.

  4. #4

    Default

    BTW Zappa, no need for loop, $targetname thread label will create a thread for every entity automatically.

  5. #5

    Default

    Quote Originally Posted by 1337Smithy View Post
    BTW Zappa, no need for loop, $targetname thread label will create a thread for every entity automatically.
    Thx, I edited it.
    I'm into the "Less is More" philosophy now

  6. #6

    Default

    Hi guys.

    Thanks for your replies. I've been playing around with both methods.

    Zappa the mechanics of your method work great and are exactly what I was looking for. However the transparency of the hexagons is an issue as I'm looking to keep it a solid colour. Is there anything I can add to the shader file to make it solid? I understand that since we're using light as a surface it will naturally have a transparency. It shows up well against a black background like in your rainbow tunnel map but gets lost against a brighter, busier background. I had a look through the Q3 shader manual but there didn't seem to me anything that might help. I'm pretty sure this approach cant work with changing textures on a surface instead as this is hard baked into the BSP upon compiling? But worth double checking.


    Doublekill - I tried your approach. I have a cannot cast 'array' to listener error in console with respect to:

    $layer1.visibility = 1 // show
    $layer2.visibility = 0 // hidden <- I'm guessing line this should say layer2 and not layer1 as shown in your code above.

    I've put it before the trigger spawns.

    Code:
    ///////////////////////
    level waittill spawn //
    ///////////////////////
    
    
    $layer1.visibility = 1 // show
    $layer2.visibility = 0 // hidden
    
    
    //layer1
    
    for(local.i = 1;local.i <= $layer1.size;local.i++)
    {
    local.hex = $layer1[local.i]
    
    local.trig = spawn trigger_multipleall
    local.trig.origin = ( local.hex.origin )
    local.trig setsize ( -32 -32 0 ) ( 32 32 16 )
    local.trig setthread hex_trigger
    
    }
    
    //layer2
    
    for(local.i = 1;local.i <= $layer2.size;local.i++)
    {
    local.hex = $layer2[local.i]
    
    local.trig = spawn trigger_multipleall
    local.trig.origin = ( local.hex.origin )
    local.trig setsize ( -32 -32 0 ) ( 32 32 16 )
    local.trig setthread hex_trigger
    
    }
    
    end
    
    
    
    hex_trigger:
    
    self nottriggerable // prevents the trigger to get triggerd very fast again
    
    if($layer1.visibility == 0)
    {
    	$layer1 show
    	$layer1 solid
    	wait 0.25
    	$layer2 hide
    	$layer2 notsolid
    
    	$layer1.visibility = 1
    	$layer2.visibility = 0
    }
    else
    {
    	$layer1 hide
    	$layer1 notsolid
    	wait 0.25
    	$layer2 show
    	$layer2 solid
    	
    	$layer1.visibility = 0
    	$layer2.visibility = 1
    }
    
    self triggerable // renable the trigger
    
    
    end
    Couple of questions:
    When does layer2 trigger get triggered? I'm assuming its not at the same time as the layer1 trigger as initially layer2 will not but visible but instead triggered when layer2 visibility is shown?
    How does changing the $layer1.visibility value from say 1 to 0 for one tile not then apply this value to all tiles with $layer1? When I tested it with two tiles sets of tiles, standing on one tile removing layer1 object also removed the adjacent tiles' layer1 object also without touching it.

    Forgive the questions but I like to try to understand a little of what I'm doing even if it gives me a headache. I appreciate the help.

    Thanks

    Twenty

  7. #7

    Default

    Quote Originally Posted by twenty2man View Post
    $layer2.visibility = 0 // hidden <- I'm guessing line this should say layer2 and not layer1 as shown in your code above.
    Yes, you are right, was a typo, sorry.

    Quote Originally Posted by twenty2man View Post
    When does layer2 trigger get triggered? I'm assuming its not at the same time as the layer1 trigger as initially layer2 will not but visible but instead triggered when layer2 visibility is shown?
    Gets triggered like the layer1 trigger and not at the same time. They are working individualy.

    Quote Originally Posted by twenty2man View Post
    How does changing the $layer1.visibility value from say 1 to 0 for one tile not then apply this value to all tiles with $layer1? When I tested it with two tiles sets of tiles, standing on one tile removing layer1 object also removed the adjacent tiles' layer1 object also without touching it.
    When you add the same name to alot of entitys, you get a array of entitys. A array is a group of entitys and when you use that entity name you affect all entitys with that name at the same time.
    Last edited by DoubleKill; November 6th, 2021 at 03:32 AM.

  8. #8

    Default

    Quote Originally Posted by twenty2man View Post
    Is there anything I can add to the shader file to make it solid?
    Remove "blendFunc add" and it will look solid
    Also you can use whatever texture you want. The color of it will still change as long as it has "rgbGen fromEntity" statement in it.

  9. #9

    Default

    Thanks Zappa,

    Looks pretty good now.

    Click image for larger version. 

Name:	hexagone.gif 
Views:	9 
Size:	10.00 MB 
ID:	2298

    I imagined with an entity limit of 1024 I could have more layers to drop down but as soon as I hit about 600, the player models disappear and after about 703 entities the game crashes when loading Mohaa although the complile was fine with no errors. There's another limit I'm not aware of presumably. I think I will have to adapt the run speed and length of time each hexagon takes to disappear to compensate.

  10. #10

    Default

    It sucks that the game can't handle huge amounts of entities, otherwise I'm sure there would be more minigame maps like yours.
    But still, what you have done so far looks awesome.
    I hope you can find a way to make it more stable

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •