• Shoutbox
    Active Users: 0
     
  • Notice: N/A
    Loading...
 
  • Active Users
     
  • There are currently no users chatting.
 
Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 37
  1. #21
    That's OK, I shared it as an idea which may come in handy for future work, not necessarily for your map .

    It wasn't printing twice for me, and just gone back and confirmed it. Even got it to print to the console before my 'waitthread' is called and again only prints once no matter how much I move in the trigger. Sounds like the code isn't quite right.

    If you're going to be moving other objects around the map and if you are changing the trigger states outside of 'togglegate', it would be worth using a version of the shorter thread:

    Code:
    //-------------------------------------------------------------------------------//
    // move object
    // [object] move_object [destination] [speed of object| default is 1]
    //-------------------------------------------------------------------------------//
    move_object local.dest local.speed:
       
    	if (local.speed == NIL) 
    		local.speed = 1  
    	self time local.speed
    	self moveto local.dest.origin
    	self waitmove
        
    end
    Then you can call it to move anything, including gates and flags.

    Code:
             $axis_flag1 thread move_object $axis_flag1_down 3 //made a bit slower
    Or use 'waitthread' if you want to wait for it to complete before processing the code after

    Code:
             $southgate waitthread move_object $southshut
    That is if you want your flags to move in the same way. Saves duplicating code . Anyway, I'll let you get on with whatever you want to do!
    Last edited by 1337Smithy; 09-16-2017 at 02:59 PM.

  2. #22
    As this has become the de facto script thread, I thought I'd post another code example.

    You are able to get your threads returning values.

    So, for example, say you have a thread that moves a flag up/down a flagpole (if the player is holding down use and inside a region):

    Code:
    //-------------------------------------------------------------------------------//
    // flag movement
    // returns true or false depending on success of move
    //
    // move_flag [objective] [flag] [direction]
    //-------------------------------------------------------------------------------//
    move_flag local.objective local.flag local.direction:
    	
    	local.FlagComplete = false								//set flag state to not moved
    	local.distance = 0										
    	local.player = parm.other								//get player
    	local.zone = $(local.objective + "_zone")				//get zone
     
    	local.flag loopsound tick_pulley
    	while ((isAlive local.player) && (local.player.useheld == 1) && (local.player isTouching local.zone))
    	{
    		local.flag time level.flag_speed					//get speed of flag
    		if(local.direction == up)
    			local.flag moveUp level.flag_move_rate			//move flag up once by a specified amount of units
    		else
    			local.flag moveDown level.flag_move_rate		//move flag down once by a specified amount of units
    		local.flag waitmove									//wait until moved
    		local.distance += level.flag_move_rate				//add up distance moved
    		if (local.distance >= level.flag_pole_length) 	
    		{
    			local.FlagComplete = true						//flag successfully moved
    			break 											//leave loop, it's completed!
    		}
    	}
    	local.flag stoploopsound tick_pulley
    
    end local.FlagComplete
    This will return a value of either 'true' or 'false' depending on the success of player. You can then grab the value as a variable in another thread:

    Code:
    	local.FlagComplete = waitthread move_flag local.num local.flag down		// move the flag	
    	if !(local.FlagComplete == true)									// interrupted, return the flag! (previous thread returned 'false')
    	{
    		local.player stopwatch 0									// kill stopwatch
    		local.time = waitthread get_return_duration local.flag1_time		        // calculate return duration
    		waitthread flag_return local.flag NIL local.up_pos NIL local.time
    	}

  3. #23
    Administrator Major_A's Avatar
    Join Date
    Jul 2016
    Location
    Huntington, IN USA
    Posts
    391
    Trophies
    Blog Entries
    15
    This is really nice!
    Smithy, Can you script something that can utilize crouchheld and jumpheld?

    Maybe something as simple as dropping a health pack?

    I ask because it should be possible, but I can't figure it out as simply putting crouchheld or jumpheld in scripts does not work.

    Any thoughts on this, because it could add some more neat functions I've been thinking of?

    I'm pretty sure it was crouch that has been done, as I used to play on a server that used it.
    and to be more specific, it was used as useheld + crouch to bring up a second weapon select menu,
    so actually seeing both able to use could be a huge leap for some things.
    Last edited by Major_A; 01-05-2018 at 09:32 PM.



  4. #24
    @Major_A: Theres no crouchheld but the server was checking if you was standing and crouching at the same time.

    Theres no way to check a jumpheld but you can detect when the player jumps.
    Last edited by DoubleKill; 01-06-2018 at 11:31 AM.

  5. #25
    I'm not sure about an inherent 'crouchheld' command in the engine, the only two I'm aware of are 'useheld' and 'fireheld'. I suppose as crouch can be toggled (rather than held down) it wasn't implemented. Can the 'getmovement' function be utilised here? For example:

    Code:
    local.player = parm.other
    local.stance = local.player getposition // or 'getmovement'
    
    while (local.player.useheld == 1 && local.stance == "crouching") 
    {
     // do stuff
    }
    Something along those lines (perhaps more conditions needed based on 'getposition' or 'getmovement'). Or the map you spoke of utilised 'isTouching' with a trigger high enough for players to crouch under. Though the example above seems better.

    EDIT: oops, didn't realise DoubleKill responded . As I suspected, more conditions are needed (standing and crouching).

    EDIT 2: adding all conditions (by 'standing' it means not currently moving I think, not literally standing up):

    Code:
    local.player = parm.other
    local.stance = local.player getposition 
    local.movement = local.player getmovement
    
    while (local.player.useheld == 1 && local.stance == "crouching" && local.movement == "standing") 
    {
     // do stuff
    }
    You could do local.movement == "running" or "walking" etc...
    Last edited by 1337Smithy; 01-06-2018 at 01:46 PM.

  6. #26
    Administrator Major_A's Avatar
    Join Date
    Jul 2016
    Location
    Huntington, IN USA
    Posts
    391
    Trophies
    Blog Entries
    15
    ok so what would useheld + jump button look like? detect player jump
    Not saying this is correct, just remembering console cmd.

    Code:
    while (local.player.useheld == 1 && +jump)
    {
     // do stuff
    }



  7. #27
    I've not tested most of this, so maybe a thread activated when a trigger is 'used':

    Code:
    jumpcheck:
    
    local.player = parm.other
    local.stance = local.player getposition
    
    if (local.stance == "offground")
    {
    
    while (local.player.useheld == 1) { //do stuff }
    } end
    or add the stance to your loop if you want to perform an action only while the player is mid-jump

  8. #28
    Administrator Major_A's Avatar
    Join Date
    Jul 2016
    Location
    Huntington, IN USA
    Posts
    391
    Trophies
    Blog Entries
    15
    hmmm,

    Is it possible to detect keypress?



  9. #29
    From what I understand, Reborn has added some event handling like player input, but I've never used Reborn so can't say how to use it. Without it, you'd have to keep track of the $player array and their actions.

  10. #30
    Administrator Major_A's Avatar
    Join Date
    Jul 2016
    Location
    Huntington, IN USA
    Posts
    391
    Trophies
    Blog Entries
    15
    I wish Spearhead had Reborn functions as I've see quite a bit of neat new things to play with.
    Maybe it's something in the works. idk but it'd be phenomenal!



Posting Permissions

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