Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a Trap
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#2
RE: Making a Trap

From what it looks like I think something like this should work: (With Mudbill's if tip and some corrections)
PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""spike_trap""SpikeTrapAltar"false0);
}

void SpikeTrapAltar(string &in asParentstring &in asChildint alState)

    
PlaySoundAtEntity("swomp""L01_pierce01""spike_trap"0.0false);
    
PlaySoundAtEntity("swomp2""L01_pierce02""spike_trap"0.0false);

    for (
int x 0<= 11+= 1)
    {
        
RotatePropToSpeed("roof_wheel_"+x1300, -1false"");
    }
    for (
int i 0<= 6+= 1)
    {
        
SetMoveObjectStateExt("roof_pole_"+i, -0.4f2.0f5.0f1.0ftrue);
    }
    
    if (
alState == 1)
        
AddTimer("dead"0.7f"YourDeadBoy");
    else
        
AddTimer("pierce1"0.3f"TimerStopPierce"); 
}

void YourDeadBoy string &in asTimer )
{
    
PlaySoundAtEntity("""stab_impact.snt""Player"1.0ffalse);
    
PlaySoundAtEntity("""spiketrap_death""Player"1.0ffalse);
    
SetPlayerHealth(0);
}
void TimerStopPierce string &in asTimer )
{
    
RemoveTimer("dead");


alStates don't refresh once their called, but if the callback's bool abDeleteOnCollide is set to false, it will fire again when alState condition is fulfilled again.

Take a note of the last two parameters in these examples.
This will trigger every time Player Enters or Leaves the area.
PHP Code: (Select All)
AddEntityCollideCallback("Player""spike_trap""SpikeTrapAltar"false0); 

This will trigger Only once when Player Enters or Leaves the area for the first time.
PHP Code: (Select All)
AddEntityCollideCallback("Player""spike_trap""SpikeTrapAltar"true0); 

More examples:
Spoiler below!

This will trigger every time Player Enters the area.
PHP Code: (Select All)
AddEntityCollideCallback("Player""spike_trap""SpikeTrapAltar"false1); 

This will trigger every time Player Leaves the area.
PHP Code: (Select All)
AddEntityCollideCallback("Player""spike_trap""SpikeTrapAltar"false, -1); 

This will trigger Only once Player Enters the area.
PHP Code: (Select All)
AddEntityCollideCallback("Player""spike_trap""SpikeTrapAltar"true1); 

This will trigger Only once Player Leaves the area.
PHP Code: (Select All)
AddEntityCollideCallback("Player""spike_trap""SpikeTrapAltar"true, -1); 


Useful note:
Mudbill Wrote:I can't remember if using 0 and "true" can trigger exiting if the player starts the map within the area. It might not count spawning as entering, and thus trigger exit first.


Also you Check for alState 0, which never happens.
PHP Code: (Select All)
(alState == 0)
{
 
//Never happens
 //alState is 1 or -1 inside the function you called


Because once the Callback is decided it can't be 0 (both) at once, it will be either -1 (leave) or 1 (enter).
(This post was last modified: 12-27-2015, 12:11 AM by Spelos.)
12-26-2015, 11:01 PM
Find


Messages In This Thread
Making a Trap - by Southlaguna - 12-26-2015, 10:45 PM
RE: Making a Trap - by Spelos - 12-26-2015, 11:01 PM
RE: Making a Trap - by Mudbill - 12-26-2015, 11:39 PM
RE: Making a Trap - by Spelos - 12-26-2015, 11:46 PM
RE: Making a Trap - by Mudbill - 12-26-2015, 11:53 PM
RE: Making a Trap - by Spelos - 12-26-2015, 11:59 PM
RE: Making a Trap - by Southlaguna - 01-03-2016, 08:26 AM
RE: Making a Trap - by Traggey - 01-03-2016, 10:32 PM



Users browsing this thread: 1 Guest(s)