This example or scenario is when we have store-keeper or clerk. For my test I have two weapons a colt45 and an mas36. The pistol is 10 Kyats and the mas36 is 20 Kyats. For this example I use a script for each weapon. I am going to look at this more closely to see if I can't get something that would work in just one script for multiple items. But I wanted to at least get the code of this down. The first code snippet is for the 45 and the second is for the rifle.
;Artificial Intelligence Script
;Header
desc = Select object #1 (G5) that costs 10 Kyats
;Triggers
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\selectweapon_prompt_10.png,hudname=sw_prompt_10,hudhide=1,hudmake=display
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\no_money.png,hudname=no_money_prompt,hudhide=1,hudmake=display
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\buy_prompt_10.png,hudname=buy_prompt_10,hudhide=1,hudmake=display
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\buy_10.png,hudname=buy_10,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\10p.png,hudname=money_10,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\20p.png,hudname=money_20,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\30p.png,hudname=money_30,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\40p.png,hudname=money_40,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\50p.png,hudname=money_50,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\100p.png,hudname=money_100,hudhide=1,hudmake=display,state=1
:state=1:globalvar=5,setvar=0
:state=1,plrdistwithin=60:hudshow=sw_prompt_10,state=4
:state=4,plrusingaction=1:hudunshow=sw_prompt_10,state=5
:state=4,plrdistfurther=59:hudunshow=sw_prompt_10,state=1
:state=5:globalvar=10
:state=5,vargreater=9:state=6
:state=5,varless=10:hudunshow=buy_prompt_10,hudshow=no_money_prompt
:state=5,plrdistfurther=59:hudunshow=no_money_prompt,state=1
:state=6:hudunshow=buy_prompt_10
:state=6:globalvar=5,incvar=1,state=10
:state=10:globalvar=10,decvar=10,state=20
:state=20,varequal=0:hudunshow=money_10,state=200
:state=20,varless=0:hudunshow=money_10,state=200
:state=20,vargreater=9,varless=20:state=101
:state=20,vargreater=19,varless=30:state=102
:state=20,vargreater=29,varless=40:state=103
:state=20,vargreater=39,varless=50:state=104
:state=20,vargreater=49,varless=100:state=105
:state=20,vargreater=99,varless=200:state=106
:state=101:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=101:hudshow=money_10,state=200
:state=102:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=102:hudshow=money_20,state=200
:state=103:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=103:hudshow=money_30,state=200
:state=104:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=104:hudshow=money_40,state=200
:state=105:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=105:hudshow=money_50,state=200
:state=106:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=106:hudshow=money_100,state=200
:state=200:destroy
;End of Script
;Artificial Intelligence Script
;Header
desc = Select object #1 that costs 20 Kyats
;Triggers
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\selectweapon_prompt_20.png,hudname=sw_prompt_20,hudhide=1,hudmake=display
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\no_money.png,hudname=no_money_prompt,hudhide=1,hudmake=display
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\buy_prompt_20.png,hudname=buy_prompt_20,hudhide=1,hudmake=display
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\buy_20.png,hudname=buy_20,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\10p.png,hudname=money_10,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\20p.png,hudname=money_20,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\30p.png,hudname=money_30,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\40p.png,hudname=money_40,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\50p.png,hudname=money_50,hudhide=1,hudmake=display
:state=0:hudreset,hudx=94,hudy=95,hudimagefine=gamecore\huds\Store_Huds\100p.png,hudname=money_100,hudhide=1,hudmake=display,state=1
:state=1:globalvar=6,setvar=0
:state=1,plrdistwithin=60:hudshow=sw_prompt_20,state=4
:state=4,plrusingaction=1:hudunshow=sw_prompt_20,state=5
:state=4,plrdistfurther=59:hudunshow=sw_prompt_20,state=1
:state=5:globalvar=10
:state=5,vargreater=19:state=6
:state=5,varless=20:hudshow=no_money_prompt
:state=5,plrdistfurther=59:hudunshow=no_money_prompt,state=1
:state=6:hudunshow=buy_prompt_20
:state=6:globalvar=6,incvar=1,state=10
:state=10:globalvar=10,decvar=20,state=20
:state=20,varequal=0:hudunshow=money_20,state=200
:state=20,varless=0:hudunshow=money_20,state=200
:state=20,vargreater=9,varless=20:state=101
:state=20,vargreater=19,varless=30:state=102
:state=20,vargreater=29,varless=40:state=103
:state=20,vargreater=39,varless=50:state=104
:state=20,vargreater=49,varless=100:state=105
:state=20,vargreater=99,varless=200:state=106
:state=101:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=101:hudshow=money_10,state=200
:state=102:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=102:hudshow=money_20,state=200
:state=103:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=103:hudshow=money_30,state=200
:state=104:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=104:hudshow=money_40,state=200
:state=105:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=105:hudshow=money_50,state=200
:state=106:hudunshow=money_10,hudunshow=money_20,hudunshow=money_30,hudunshow=money_40,hudunshow=money_50,hudunshow=money_100
:state=106:hudshow=money_100,state=200
:state=200:destroy
;End of Script
We are able to select which weapons we want and the script will be able to determine if there is enough money for the selected item(s). Once the player selects the items he must go to the store-keeper and actually make the purchase. Once he makes the purchase the player will receive all of the items -- in this case weapons -- he has purchased. Here is the "clerk" code snippet.
;Artificial Intelligence Script
;Header
desc = Clerk Check Out
;G10 = money
;G5-9 = weapons
;G5 = 1 (true) if weapon selected
;G6 = 1 (true) if weapon selected, and so on - we need to keep track of that
;Triggers
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\like2purchase.png,hudname=like2purchase,hudhide=1,hudmake=display
:state=0:hudreset,hudx=50,hudy=90,hudimagefine=gamecore\huds\Store_Huds\thanks.png,hudname=thanks_prompt,hudhide=1,hudmake=display,state=1
:state=1,plrdistwithin=60:hudshow=like2purchase,state=2
:state=2,plrusingaction=1:hudunshow=like2purchase,timerstart,state=3
:state=2,plrdistfurther=59:hudunshow=like2purchase,state=1
:state=3,timergreater=500:state=4
:state=4:globalvar=5
:state=4,varequal=0:state=5
:state=4,varequal=1:settargetname=g5,activatetarget=1,state=5
:state=5:globalvar=6
:state=5,varequal=0:state=10
:state=5,varequal=1:settargetname=g6,activatetarget=1,hudshow=thanks_prompt,timerstart,state=10
:state=10,timergreater=1000:state=20
:state=20,plrdistfurther=60:hudunshow=thanks_prompt,timerstart,state=25
:state=25,timergreater=1000:state=1
;End of Script
Now, there is a lot that can be done with this. There can be more interaction with the clerk for example.
Screenies will follow and I will then follow that up with a download of all the huds and such for this example.