Scripts / Flying insect script

Author
Message
Gtox
3D Media Maker
9
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 20th Mar 2015 11:27
I've created a simple script for flying?stinging insects, and it works quite well apart from a few issues. Firstly, the MoveUp command doesn't work. It worked in an earlier version of the script, but the insect wouldn't follow the ground contours. After fiddling with the FPE file, I got it to follow the contours, but MoveUp no longer works. Is there another command that could fulfil this function? Secondly, the HurtPlayer command does too much damage - even set at 1 it's still a two-shot kill for the player (not the end of the world - it could be a super deadly insect ). Lastly, for some reason PlayerDist returns the distance between the entity and the start marker, not the entity and the player. Once the distance gets above 500 and the insect is flying, you can run alongside the insect and the PlayerDist value just gets bigger and bigger. This one is a complete mystery to me, as it's worked fine other scripts.
Any help would be appreciated.

smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Mar 2015 18:19
it may be because you are using PlayerDist as the global variable and it's getting confused, try making it a local or use a new name entirely (personally i just use the call as GetPlayerDistance(e) but that's just personal pref)

for the damage it's likely because once it starts "stinging" it wont stop until you are 500 or more away - as your script currently stands, you should be using elseif or reorder your current script- and with no time delay that damage is applied very fast

i assume you tried with much larger up values too?
you could try positioning the butterfly instead of moveup?
i.e.
up = up + 20
SetPosition(e,g_Entity[e]['x'],g_Entity[e]['y']+up,g_Entity[e]['z'])

and then reset up slowly back to 0 in the other part when it starts to come down

think i got everything
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Gtox
3D Media Maker
9
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 20th Mar 2015 20:14
Thanks, smallg, I'll give it a bash.
Gtox
3D Media Maker
9
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 20th Mar 2015 20:57 Edited at: 20th Mar 2015 20:58
Now I'm officially confused. If I set ischaracter to 1, the entity moves, but PlayerDist is broken (I tried several iterations of PlayerDist, including the original complex formula as well as GetPlayerDistance(e) ). If ischaracter is set to 0, PlayerDist works but the entity doesn't move.
Could you test this on your system to see if you get the same results? You can use any entity, with the FPE file below . You may to add Prompt(PlayerDist) somewhere in the script to make things easier.



Also, I couldn't get it to move vertically, but I may have implemented your suggestion incorrectly.
Gtox
3D Media Maker
9
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 20th Mar 2015 21:35
I removed the 'MoveUp' commands, and that seems to have improved it. It's not completely fixed (the GetPlayerDistance(e) value varies - it can be 800 even when you're right on top of the entity, or it can be less than 50). I'll keep at it until I've figured it out.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Mar 2015 21:42 Edited at: 20th Mar 2015 21:43
maybe you need to specify the model?
;orientation
model = xxxx.X

i cant seem to use your fpe, it gives me a non existent entity

GetPlayerDistance(e) works fine for me in my scripts though

if you dont want the butterflies to die then you can turn off physics or set collisionoff in the script when they arent characters, should fix the movement

edit, are you testing with 1 butterfly only?
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Gtox
3D Media Maker
9
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 20th Mar 2015 21:46
Removed the 'SetPosition(e,g_Entity[e]['x'],g_Entity[e]['y']+up,g_Entity[e]['z'])' command, and now it's working properly. Why that should affect the GetPlayerDistance(e) value I have no idea, but at least it works (except for the lack of vertical movement, but I can live with that for now).
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Mar 2015 21:56 Edited at: 20th Mar 2015 22:25
your script works for me (with a few minor tweaks)
edit: i should say that my script still wont follow the ground though because i turned collision off.



video uploading
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Gtox
3D Media Maker
9
Years of Service
User Offline
Joined: 5th Jun 2014
Location: South Africa
Posted: 21st Mar 2015 04:47
That's basically what I was looking for - thanks smallg.
SomeT
9
Years of Service
User Offline
Joined: 24th Mar 2015
Location:
Posted: 25th Mar 2015 15:23
hey smallg tried your code named the file test.lua applied the script via AI System Main in the properties of the same box you used, clicked apply but did not change anything else in the properties, the script is in the scriptbank folder, I get the following error message when I run my game and the box does not move: LUA ERROR: No function called test_main
PM
Lance
20
Years of Service
User Offline
Joined: 22nd Jul 2003
Location: Third planet from Sun
Posted: 25th Mar 2015 16:37 Edited at: 25th Mar 2015 16:39
SomeT :

If you change the name of the lua file you have to change

function insectflying_init(e) to test_init(e)

and
function insectflying_main(e) to test_main(e)

I think that's all you have to do to it .

Lance
PM
SomeT
9
Years of Service
User Offline
Joined: 24th Mar 2015
Location:
Posted: 25th Mar 2015 20:35
That seems to work now thanks! Now I am trying to figure out how to make my object killable?
PM
SomeT
9
Years of Service
User Offline
Joined: 24th Mar 2015
Location:
Posted: 25th Mar 2015 20:51
Ok so how would I make two objects with this same script not collide into each other when they are coming after me? Additionally can I not make them killable (like a box for example) becayse the AI system is not opened up yet?
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 26th Mar 2015 11:18
you'd need to make them into characters to kill them- change the fpe to ischaracter = 1
there is no default collision really yet but as characters if you use the AIGoToPosition() command there is some simple collision but might be easier just to ignore that for now
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
SomeT
9
Years of Service
User Offline
Joined: 24th Mar 2015
Location:
Posted: 26th Mar 2015 14:54
Hi,

So I edited the .fpe file for my object as you indicated, it comes up with the relevant properties for AI settings. Next I changed the 'Take weapons ammo value to 1' and basically made sure all the other properties were similar to a zombie character. When I shoot my object it does not die? Do I need to edit the .fpe of my original inaminate object or the .lua file to achieve this or both? Specifically what lines of code do I need to add to them?

Thanks for all the help so far!
PM

Login to post a reply

Server time is: 2024-05-06 07:18:31
Your offset time is: 2024-05-06 07:18:31