Scripts / Scripting Behaviors

Author
Message
LordFlacco_94
6
Years of Service
User Offline
Joined: 28th Sep 2018
Location:
Posted: 2nd Oct 2018 00:38
Hi,

I wanted to know if it was possible to script these behaviors and what would be the best approach. Any suggestions are much appreciated.

Behaviors:
NPC's come and go into a restaurant; money is spent once they're served. Display money spent and a image.
NPC's don't spend money when they're not served.
NPC's spend more money when player's table is upgraded.

So I've taken a look at scripting guides but I feel like I'll learn better by just asking. I don't need anyone to write it for me but help me think this out. Thanks
PM
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 2nd Oct 2018 01:28
There will meed custom animations for the npc as those animations are not stock.

You will need to script these behaviors to call the animations you have made for the npc,s

Not impossible, but a lot of work across a few fields of game making.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

LordFlacco_94
6
Years of Service
User Offline
Joined: 28th Sep 2018
Location:
Posted: 2nd Oct 2018 04:30
Yeah, I'm working on that now. However, I'm in the planning the stages the script, and how it's going to work.

So let's imagine I have the animation.

An NPC walks in a zone, upon entering that zone if a plate of food is served then plr_money ="random_amount" and that get's displayed on screen somewhere.
PM
LordFlacco_94
6
Years of Service
User Offline
Joined: 28th Sep 2018
Location:
Posted: 2nd Oct 2018 05:07



I'm not sure how this would work even if I did call the animation, any ideas?


-- NPC receives plate money added to player


function plateserved_init(e)

end



function plateserved_main(e)

If NPC detects table and plate then add "$50" to player;

PlaySound

If NPC doesn't detect plate and table then exit area.


Destroy(e);

end

end
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Oct 2018 09:11 Edited at: 2nd Oct 2018 09:14
Yep it's quite simple once you understand the basics.
You just need some waypoint code and then some variables to act as toggles between States and to check the different conditions (i.e. food is there, quality of food etc).

So something like this
If state = enter
Waypoint code to walk inside.
Check near to counter or seat etc.
Give order info on screen.
Change state to waiting to be served.
ElseIf state = waiting
If order is ready
give player money.
Change state to leaving.
If waited too long
Change state to leaving.
ElseIf state = leaving
Remove order from game so can't be reused for other ai (displayed request and any actual game object used to show order ).
If reached end of waypoints then delete this AI.

As you can see, just break your scripts down to logical states or conditions and it will make it much easier to control what is happening and when.

You'll want other scripts to manage stuff like table/food quality and if an order is ready or not... But that's the good thing about object oriented programming, it's super easy to make many scripts that relate to only certain objects.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-12-22 20:42:34
Your offset time is: 2024-12-22 20:42:34