/***************************************************************/ /* */ /* PBDEFINES.PKG */ /* */ /* plug-in PhotoPaintBall */ /* global definitions */ /* version 5 : Loïc Berthelot, dec 2000 */ /* */ /* nouvelle version 4.5 : Loïc Berthelot nov 2000 */ /* */ /* Photo3 Plugin - DMS - march 00 - by Sylvain HUET */ /* */ /***************************************************************/ /***************************************************************/ /* */ /* */ /* DATA STRUCT : */ /* var pbItemsPath : S */ /* var pbNbItems : I */ /* struct PBdefault */ /* typeof pbDefault : PBdefault */ /* struct PBparamsNames */ /* typeof pbParamsNames : PBparamsNames */ /* struct PBparams */ /* typeof pbParams : PBparams */ /* struct PBflags */ /* typeof pbFlags : PBflags */ /* struct PBkeys */ /* typeof pbKeys : PBkeys */ /* struct PBitems */ /* typeof pbItems : PBitems */ /* */ /* */ /* INTERNAL BODY : */ /* defines_resFilesToList : fun [[[S r1] r1]] [S r1] */ /* defines_init : fun [] I */ /* */ /* */ /* EXTERNAL BODY : */ /* pbFlags_set : fun [S] I */ /* defines_warningMissingFiles : fun [S] */ /* defines_loadError : fun [S S] I */ /* defines_fofError : fun [S S] I */ /* defines_getResFiles : fun [] [S r1] */ /* defines_start : fun [] I */ /* */ /* */ /***************************************************************/ /*******************************************************************/ /* */ /* D A T A S T R U C T */ /* */ /*******************************************************************/ /* items files path */ var pbItemsPath = "dms/3d/plugins/paintballav/items/";; /* nb of sort of items */ var pbNbItems = 10;; /********************************/ /* default ressources filenames */ /********************************/ struct PBdefault = [ /* 2d interface alphabitmaps */ bkgAmmosBmpFln_PBD : S, bkgScoreBmpFln_PBD : S, bkgLifeBmpFln_PBD : S, iconAmmoBmpFln_PBD : S, iconGunsBmpFln_PBD : S, /* gun sight */ sightBmpFln_PBD : S, /* ammo impact */ impactBmpFln_PBD : S, /* m3d and texture filenames */ ammoItemFln_PBD : S, ammoTxtFln_PBD : S, gunGunCamFln_PBD : S, gunItemFln_PBD : S, gunTxtFln_PBD : S, /* sound filenames */ shootSndFln_PBD : S, hurtSndFln_PBD : S, reloadSndFln_PBD : S, /* items filenames */ lifeSndFln_PBD : S, spinachDamageSndFln_PBD : S, /* others parameters */ impactTimeout_PBD : I, ammoFramerate_PBD : I, matList_PBD : [S r1], gunCamFramerate_PBD : I ] mkPBdefault;; typeof pbDefault = PBdefault;; /*******************************/ /* params names */ /* */ /* m3d files contain a few */ /* parameters, about guns and */ /* ammos. */ /*******************************/ struct PBparamsNames = [ objName_PBPN : S, name_PBPN : S, nbMaxAmmos_PBPN : S, nbAmmos_PBPN : S, clipCapacity_PBPN : S, power_PBPN : S, camPos_PBPN : S, camOrient_PBPN : S, camScale_PBPN : S, reload_PBPN : S, shoot_PBPN : S, wait_PBPN : S, walk_PBPN : S, avPos_PBPN : S, avOrient_PBPN : S, avScale_PBPN : S, ammoDelta_PBPN : S, ammoPos_PBPN : S, ammoPos2_PBPN : S, ammoAvPos_PBPN : S, ammoAvPos2_PBPN : S, ammoScale_PBPN : S, ammoAvScale_PBPN : S, gunTimeout_PBPN : S, impactTimeout_PBPN : S, ammoFramerate_PBPN : S, matList_PBPN : S, gunCamFramerate : S ] mkPBparamsNames;; typeof pbParamsNames = PBparamsNames;; /*******************************/ /* global parameters */ /*******************************/ struct PBparams = [ /* nb resources to download */ nbRessources_PBP : I, /* current nb resources downloaded */ nbLoadedRessources_PBP : I, /* impact timeout removing */ impactTimeout_PBP : I, ammoFramerate_PBP : I, /* list of texture to paint with impacts */ matList_PBP : [S r1], /* framerate gun animation */ gunCamFramerate_PBP : I ] mkPBparams;; typeof pbParams = PBparams;; /* flags to specify the end */ /* of library downloading */ struct PBflags = [ impactsLoaded_PBF : I, ammosLoaded_PBF : I, gunsLoaded_PBF : I, sightsLoaded_PBF : I, soundsLoaded_PBF : I, interfLoaded_PBF : I, allParamsLoaded_PBF : I, /* lock writing in avatars spots tab */ lock_PBF : I, /* 1 when you enter for the first time */ /* then 0. */ firstTime_PBF : I, /* 1 if parameters loaded */ paramsLoaded_PBF : I, /* 1 when paintball started */ started_PBF : I ] mkPBflags;; typeof pbFlags = PBflags;; /* keys that can be used by players */ struct PBkeys = [ start_PBK : S, quit_PBK : I, /* MODIF */ enter_PBK : I, backspace_PBK : I, /* write a chat sequence */ talk_PBK : S, reload_PBK : S, shoot_PBK : S, /* switch 2d interface */ interf_PBK : S, /* print the controls screen */ control_PBK : S, config_PBK : I, /* guns */ g1_PBK : I, g2_PBK : I, g3_PBK : I, g4_PBK : I, g5_PBK : I, g6_PBK : I, g7_PBK : I, g8_PBK : I, g9_PBK : I, g0_PBK : I ] mkPBkeys;; typeof pbKeys = PBkeys;; /* names of items which can be taken bye players */ struct PBitems = [ gun2_PBITM : S, gun3_PBITM : S, gun4_PBITM : S, gun5_PBITM : S, gun6_PBITM : S, gun7_PBITM : S, gun8_PBITM : S, gun9_PBITM : S, gun0_PBITM : S, ammo1_PBITM : S, ammo2_PBITM : S, ammo3_PBITM : S, ammo4_PBITM : S, ammo5_PBITM : S, ammo6_PBITM : S, ammo7_PBITM : S, ammo8_PBITM : S, ammo9_PBITM : S, ammo0_PBITM : S, life1_PBITM : S, life2_PBITM : S, spinachDamage_PBITM : S ] mkPbitems;; typeof pbItems = PBitems;; /*******************************************************************/ /* */ /* I N T E R N A L B O D Y */ /* */ /*******************************************************************/ /***********************************************/ /* defines_resFilesToList [[[S r1] r1]] [S r1] */ /* */ /* read the content of the paintball config */ /* file and return the list of resources */ /* filenames. */ /***********************************************/ fun defines_resFilesToList (content) = if (content == nil) then nil else let content -> [fstLine nxtLines] in let fstLine -> [fstWord [scdWord _]] in let substr fstWord 0 1 -> fstChar in if ((fstWord == nil) || (!strcmp fstChar "#")) then defines_resFilesToList nxtLines else fstWord::(defines_resFilesToList nxtLines);; /************************************/ /* */ /* I N I T I A L I S A T I O N of */ /* paintBall Parameters data struct */ /* */ /************************************/ fun defines_init () = set pbDefault = mkPBdefault [ "bkgAmmos.png" "bkgScore.png" "bkgLife.png" "iconAmmo.png" "iconGuns.png" "sight.png" "impact.png" "ammo.m3d" "ammo.jpg" "gun.m3d" "gunItem.m3d" "gun.jpg" "shoot.wav" "hurt.wav" "reload.wav" "life.wav" "spinachDamage.wav" 6000 30 "face"::nil 30 ]; set pbParamsNames = mkPBparamsNames [ "#paintBallObjName" "#paintBallName" "#paintBallNbMaxAmmos" "#paintBallNbAmmos" "#paintBallClipCapacity" "#paintBallPower" "#paintBallCamPos" "#paintBallCamOrient" "#paintBallCamScale" "#paintBallReload" "#paintBallShoot" "#paintBallWait" "#paintBallWalk" "#paintBallAvPos" "#paintBallAvOrient" "#paintBallAvScale" "#paintBallAmmoDelta" "#paintBallAmmoPos" "#paintBallAmmoPos2" "#paintBallAmmoAvPos" "#paintBallAmmoAvPos2" "#paintBallAmmoScale" "#paintBallAmmoAvScale" "#paintBallGunTimeout" "impactTimeout" "ammoFramerate" "matList" "gunCamFramerate" ]; set pbParams = mkPBparams [0 0 nil nil nil nil]; set pbFlags = mkPBflags [ 0 0 0 0 0 0 0 0 1 0 0 ]; set pbKeys = mkPBkeys [nil nil nil nil nil nil nil nil nil nil/**/ /* MODIF */ nil nil nil nil nil nil nil nil nil nil ]; set pbKeys.start_PBK = "START" /*31 63 */; set pbKeys.quit_PBK = 65; /* MODIF */ set pbKeys.enter_PBK = 28; set pbKeys.backspace_PBK = 8; set pbKeys.talk_PBK = "CHAT" /*20*/; set pbKeys.reload_PBK = "RELOAD"; set pbKeys.shoot_PBK = "SHOOT"; set pbKeys.interf_PBK = "SCORE" /*15*/; set pbKeys.control_PBK = "SCREEN" /*46*/; set pbKeys.config_PBK = 47; /* config du clavier */ set pbKeys.g1_PBK = 2; set pbKeys.g2_PBK = 3; set pbKeys.g3_PBK = 4; set pbKeys.g4_PBK = 5; set pbKeys.g5_PBK = 6; set pbKeys.g6_PBK = 7; set pbKeys.g7_PBK = 8; set pbKeys.g8_PBK = 9; set pbKeys.g9_PBK = 10; set pbKeys.g0_PBK = 11; set pbItems = mkPbitems [ "paintBallGunItem2" "paintBallGunItem3" "paintBallGunItem4" "paintBallGunItem5" "paintBallGunItem6" "paintBallGunItem7" "paintBallGunItem8" "paintBallGunItem9" "paintBallGunItem0" "paintBallAmmoItem1" "paintBallAmmoItem2" "paintBallAmmoItem3" "paintBallAmmoItem4" "paintBallAmmoItem5" "paintBallAmmoItem6" "paintBallAmmoItem7" "paintBallAmmoItem8" "paintBallAmmoItem9" "paintBallAmmoItem0" "paintBallLifeItem1" "paintBallLifeItem2" "paintBallSpinachDamageItem" ]; 1;; /*******************************************************************/ /* */ /* E X T E R N A L B O D Y */ /* */ /*******************************************************************/ /********************************/ /* pbFlags_set [S] I */ /* */ /* set a flag to precise the */ /* end of a library downloading */ /********************************/ fun pbFlags_set (param) = if (!strcmp param "impacts") then ( _fooS "PAINTBALL impacts library started"; set pbFlags.impactsLoaded_PBF = 1; 1; ) else if (!strcmp param "ammos") then ( _fooS "PAINTBALL ammos library started"; set pbFlags.ammosLoaded_PBF = 1; 1; ) else if (!strcmp param "guns") then ( _fooS "PAINTBALL guns library started"; set pbFlags.gunsLoaded_PBF = 1; 1; ) else if (!strcmp param "sights") then ( _fooS "PAINTBALL sights library started"; set pbFlags.sightsLoaded_PBF = 1; 1; ) else if (!strcmp param "sounds") then ( _fooS "PAINTBALL sounds library started"; set pbFlags.soundsLoaded_PBF = 1; 1; ) else if (!strcmp param "interf") then ( _fooS "PAINTBALL interf library started"; set pbFlags.interfLoaded_PBF = 1; 1; ) else ( _DLGMessageBox _channel nil "PAINBALL photodefines.pkg" "pbFlags_set [S] : unknown param" 0; 0; ); if ( pbFlags.impactsLoaded_PBF && pbFlags.ammosLoaded_PBF && pbFlags.gunsLoaded_PBF && pbFlags.sightsLoaded_PBF && pbFlags.soundsLoaded_PBF && pbFlags.interfLoaded_PBF ) then ( _fooS "PAINTBALL all librarys started"; set pbFlags.allParamsLoaded_PBF = 1; ) else nil; 1 ;; /***************************************/ /* defines_warningMissingFiles [S] */ /* */ /* warn if some files are missing */ /***************************************/ fun defines_warningMissingFiles (listMissingFiles) = _DLGMessageBox _channel nil "!! PaintBall Server WARNING !!" (strcat "some files are missing : \n\n" (strcatn listMissingFiles)) 0 ;; /***************************************/ /* defines_loadError [S S] I */ /* */ /* warn if a parameter is missing in */ /* a m3d file */ /***************************************/ fun defines_loadError (param, filename) = let strcatn "PaintBall Client load ERROR : \""::param::"\" parameter is missing in ":: filename::nil -> msg in ( _fooS msg; _DLGMessageBox _channel nil "!! PaintBall Client WARNING !!" msg 0; 0; ) ;; /***************************************/ /* defines_fofError [S S] I */ /* */ /* warn if a file can't be opened */ /***************************************/ fun defines_fofError (funname, filename) = let strcatn "PaintBall Client ERROR : "::funname::" : filename "::filename::" not found!"::nil -> msg in ( _fooS msg; _DLGMessageBox _channel nil "!! PaintBall Client WARNING ::" msg 0; 0; ) ;; /***********************************************/ /* defines_getResFiles [] [S r1] */ /* */ /* public interface for */ /* defines_resFilesToList */ /***********************************************/ fun defines_getResFiles () = let (strcat pbItemsPath "paintball.cfg") -> configFln in let strextr _getpack _checkpack configFln -> content in if (content == nil) then ( defines_fofError "defines_getResFiles" configFln; nil/*;*/ ) else let defines_resFilesToList content -> filesList in let sizelist filesList -> nbFiles in ( set pbParams.nbRessources_PBP = nbFiles; filesList/*;*/ );; /*******************************************/ /* defines_start [] I */ /* */ /* get the PhotoPB Parameters */ /* */ /*******************************************/ fun defines_start() = defines_init; /* read the name of the data file */ let PLUGparams thisplug -> params in let atoi getInfo params pbParamsNames.impactTimeout_PBPN -> impactTimeout in let atoi getInfo params pbParamsNames.ammoFramerate_PBPN -> ammoFramerate in let getInfos params pbParamsNames.matList_PBPN -> matList in let atoi getInfo params pbParamsNames.gunCamFramerate -> gunCamFramerate in let if (impactTimeout == nil) then pbDefault.impactTimeout_PBD else impactTimeout -> impactTimeout in let if (ammoFramerate == nil) then pbDefault.ammoFramerate_PBD else ammoFramerate -> ammoFramerate in let if (matList == nil) then pbDefault.matList_PBD else matList -> matList in let if (gunCamFramerate == nil) then pbDefault.gunCamFramerate_PBD else gunCamFramerate -> gunCamFramerate in ( set pbParams.impactTimeout_PBP = impactTimeout; set pbParams.ammoFramerate_PBP = ammoFramerate; set pbParams.matList_PBP = matList; set pbParams.gunCamFramerate_PBP = gunCamFramerate; 1; );;