BSL:Snippets: Difference between revisions

From OniGalore
Jump to navigation Jump to search
(moving in from main BSL page; made some comment corrections and tweaks)
(No difference)

Revision as of 04:42, 3 December 2015

Character setup

# an old but useful character setup function by geyser
func SpawnNameFlagHealthReset(string n, int f, int h, int r)
{
    ai2_spawn(n); chr_teleport(n, f)
    if(h) chr_set_health(n, h)
    if(r) chr_inv_reset(n)
}

# sample usage
func wave_setup
{
    # note that the health and inventory-reset parameters can be omitted
    SpawnNameFlagHealthReset Griffin 23 600
    SpawnNameFlagHealthReset Muro 22 2500
    SpawnNameFlagHealthReset F_Er89 22 80 1
    SpawnNameFlagHealthReset A_S1 24
}

Follow me

var bool follow_me = 1;

### beginning of the journey
func follow_me_TV
{
    # ai2_spawn charname # or somewhere else
    chr_lock_active charname

    fork follow
}

func follow
{
    if (follow_me eq 1)
    {
        ai2_followme charname
        ai2_setmovementmode charname run
        sleep 180
        fork follow
    }
}


### events
func dont_follow_me_TV_enter
{
    follow_me = 0
}

func dont_follow_me_TV_extit
{
    follow_me = 1
    fork follow
}


### player orders
func main
{
    # Original code here
    fork do_follow_me
    fork dont_follow_me
}

func do_follow_me
{
    chr_wait_animation 0 ORDERbk_fw_kick
    follow_me = 1
    follow
    # in case he/she is passive right now
    ai2_passive charname 0

    # sleep until anim finishes
    sleep 60
    fork do_follow_me
}

func dont_follow_me
{
    chr_wait_animation 0 ORDERbk_fw_punch
    follow_me = 0
    ai2_idle charname

    # sleep until anim finishes
    sleep 60
    fork dont_follow_me
}