Jump to content
Sign in to follow this  
tracy_t

Executing scripts from within addons?

Recommended Posts

Hi all, I have a problem that is driving me nuts. OFP bombs when a call to movemalezombie.sqs is done. You can replicate this bug by:

a) Installing the zombie pbo from

http://www.freewebs.com/tunstals/zombies.pbo

b) Creating a GAME LOGIC unit where initialisation string is set to

gblAllUnits = [Player]

then placing a few zombies on the map.

Here's the scripts:

InitMaleZombie.sqs

Note how only when the gblAllUnits global variable contains data (it's an array of units for the zombies to consider valid targets) that movemalezombie.sqs is exec'd

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_zombie = _this select 0

_zombie setunitpos "UP"

_zombie setdamage 0.8

_zombie SetBehaviour "CARELESS"

_zombie DisableAI "TARGET"

_zombie DisableAI "AUTOTARGET"

_zombie allowfleeing 0

_zombie SetMimic "Agresive"

? count gblAllUnits !=0: [_zombie] exec "\zombies\movemalezombie.sqs"

exit

MoveMaleZombie.sqs

This code works alright STAND ALONE (ie: inside a mission) but when included inside the addon's pbo, it crashes.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_z = _this Select 0

_t = _this Select 1

#Main

~1

?(!alive _z) : goto "End"

?(!Isnull(_t)) && (!alive _t) : goto "rmv"

?(!alive _t) || (IsNull(_t)) : goto "fnt"

#rmv

gblAllUnits = gblAllUnits - [_t]

#fnt

_y = 0

_uc = count gblAllUnits

#lp

? _y>= _uc: goto "premove"

_u = gblAllUnits select _y

? _z distance _u < _z distance _t: _t = _u

#nx

~2

_y=_y+1

goto "lp"

#premove

_z dowatch _t

#move

_d = _z distance _t

? _d > 600 : Goto "end"

? _d > 5 : goto "walk"

? _d < 5 : goto "engage"

Goto "Main"

#walk

_z PlayMove "moan1"

~3

_z domove getpos _t

~2

goto "Main"

#engage

? !alive _z: goto "end"

_z setPos getpos _t

_z PlayMove "standstrokefist"

_t setDammage (getDammage _t + gblZombieDamage)

~1.5

? getDammage _t >= 1: goto "eat"

goto "Main"

#eat

gblAllUnits = gblAllUnits - [_t]

_z DoMove getpos _t

@unitready _z

_y = 0

#eatlp

? !alive _z: goto "end"

_z PlayMove "eat1"

~7

_y = _y+1

? _y != 4: goto "eatlp"

goto "fnt"

#End

~5

DeleteVehicle _z

exit

Anyone have any ideas?

Share this post


Link to post
Share on other sites

at a first glance you need to send in the second parameter that your trying to call in the movemalezombie.sqs file. You have the zombie being sent to that file, but there is no other variable or parameter going to it (for _t= _this select 0). In this case I guess it is the player(s)

Share this post


Link to post
Share on other sites

Hi,

I'm beginning to think that might be the problem because everything else seems OK. This code runs alright as part of a mission, but when you put it in the addon it bombs...

The 2nd parameter is the zombie's target, and is supposed optional. If you don't specify it, the code will automatically find a target for the zombie. I will remove this parameter and try again.

Share this post


Link to post
Share on other sites

How are you calling it from your addon when you put it in the pbo?

Calling teh script yourself or using a eventhandler?

I just want to mention that depending what eventhandler you are using (_this select 0) and such will be different

Share this post


Link to post
Share on other sites

I am using the Init eventhandler in my addon.

It executes like so:

class EventHandlers

{

Init = [_this select 0] exec {initmalezombie.sqs}

}

I know _this select 0 works because I have used it to make the zombies go prone.

Feel free to UNPBO the work I've done and look at the config.cpp if you like (if you can be bothered biggrin_o.gif ). I'm stumped!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×