/***************************************************************/ /* */ /* PBGUNS.PKG */ /* */ /* plug-in PhotoPaintBall */ /* client - guns management */ /* */ /* version 5 : Loïc Berthelot, dec 2000 */ /* */ /* nouvelle version 4.5 : Loïc Berthelot nov 2000 */ /* */ /* Photo3 Plugin - DMS - march 00 - by Sylvain HUET */ /* */ /* rev September 2001 - by Franck OHAYON & Sebastien DENEUX */ /***************************************************************/ /***************************************************************/ /* */ /* */ /* DATA STRUCTS : */ /* struct GunEl */ /* typeof gunsLib : tab GunEl */ /* var gunsLibSize : I */ /* */ /* */ /* INTERNAL BODY : */ /* guns_freeGun : fun [I] I */ /* guns_loadGun : fun [I] I */ /* guns_load : fun [] I */ /* guns_start2 : fun [] I */ /* */ /* */ /* EXTERNAL BODY */ /* guns_destroy : fun [] I */ /* guns_start : fun [] I */ /* guns_enable : fun [I] I */ /* guns_disable : fun [I] I */ /* */ /* */ /***************************************************************/ /******************************************************************************/ /* */ /* D A T A S T R U C T S */ /* */ /******************************************************************************/ struct GunEl = [ /* name of gun */ name_GEL : S, /******************************************************************/ /* camera gun fields */ /******************************************************************/ /* m3d filename */ filenameGunCam_GEL : S, /* object name */ objInitialNameGunCam_GEL : S, /* object name after modification */ objCurrentNameGunCam_GEL : S, /* shell for the gun */ shellGunCam_GEL : H3d, /* gun object handler */ objGunCam_GEL : H3d, /* shell for ammos */ ammoShellGunCam_GEL : H3d, ammoShellGunCam2_GEL : H3d, /* position of gun on camera */ campos_GEL : [I I I], /* orientation of gun on camera */ camorient_GEL : [I I I], /* scale parameter for the gun */ camscale_GEL : I, /* ammo step between two frames */ ammoDelta_GEL : I, /* position of ammoShell */ ammoPos_GEL : [I I I], /* position of ammoShell2, for the double gun */ ammoPos2_GEL : [I I I], /******************************************************************/ /* others avatars gun fields */ /******************************************************************/ filenameAv_GEL : S, objInitialNameAv_GEL : S, objCurrentNameAv_GEL : S, objAv_GEL : H3d, /* position of gun, on others avatars */ avpos_GEL : [I I I], avorient_GEL : [I I I], /* scale for the gun */ avscale_GEL : I, /* position of ammoShells, on the others avatars */ ammoAvPos_GEL : [I I I], ammoAvPos2_GEL : [I I I], /******************************************************************/ /* general parameters */ /******************************************************************/ /* frames numbers of start and end of reload animation */ reload_GEL : [I I], /* shoot animation */ shoot_GEL : [I I], /* wait animation */ wait_GEL : [I I], /* walk animation */ walk_GEL : [I I], /* timeout for shoot frequency */ timeout_GEL : I, /* 1 if you have this gun, 0 if not */ enable_GEL : I ] mkGunEl;; typeof gunsLib = tab GunEl;; /*rajout d'une arme numero 10 afin de ne pas avoir d'armes lorsqu'on est mort */ var gunsLibSize = 11;; /* MODIF */ /******************************************************************************/ /* */ /* I N T E R N A L B O D Y */ /* */ /******************************************************************************/ /***********************************/ /* guns_freeGun [I] I */ /* */ /* free resources for this gun */ /***********************************/ fun guns_freeGun (i) = if ((M3objName session gunsLib.(i).shellGunCam_GEL) != nil) then ( M3unLink session gunsLib.(i).shellGunCam_GEL; M3delObj session gunsLib.(i).shellGunCam_GEL; ) else nil; if ((M3objName session gunsLib.(i).ammoShellGunCam_GEL) != nil) then M3delObj session gunsLib.(i).ammoShellGunCam_GEL else nil; if ((M3objName session gunsLib.(i).objAv_GEL) != nil) then ( M3unLink session gunsLib.(i).objAv_GEL; M3delObj session gunsLib.(i).objAv_GEL; ) else nil; if ((M3objName session gunsLib.(i).objGunCam_GEL) != nil) then M3delObj session gunsLib.(i).objGunCam_GEL else nil; 1 ;; /***********************************/ /* guns_loadGun [I] I */ /* */ /* load 3d objects for this gun */ /***********************************/ fun guns_loadGun (i) = if ((gunsLib.(i).shellGunCam_GEL == nil) || ((M3objName session gunsLib.(i).shellGunCam_GEL) == nil)) then set gunsLib.(i).shellGunCam_GEL = M3createShell session else nil; if ((gunsLib.(i).objGunCam_GEL == nil) || ((M3objName session gunsLib.(i).objGunCam_GEL) == nil)) then ( M3load session gunsLib.(i).filenameGunCam_GEL gunsLib.(i).shellGunCam_GEL; set gunsLib.(i).objGunCam_GEL = M3getObj session gunsLib.(i).objInitialNameGunCam_GEL; M3link session gunsLib.(i).objGunCam_GEL gunsLib.(i).shellGunCam_GEL; M3recursFillMatObj session gunsLib.(i).objGunCam_GEL; M3renameObj session gunsLib.(i).objGunCam_GEL gunsLib.(i).objCurrentNameGunCam_GEL; ) else nil; if ((gunsLib.(i).objAv_GEL == nil) || ((M3objName session gunsLib.(i).objAv_GEL) == nil)) then ( M3load session gunsLib.(i).filenameAv_GEL nil; set gunsLib.(i).objAv_GEL = M3getObj session gunsLib.(i).objInitialNameAv_GEL; M3recursFillMatObj session gunsLib.(i).objAv_GEL; M3renameObj session gunsLib.(i).objAv_GEL gunsLib.(i).objCurrentNameAv_GEL; ) else nil; if ((gunsLib.(i).ammoShellGunCam_GEL == nil) || ((M3objName session gunsLib.(i).ammoShellGunCam_GEL) == nil)) then set gunsLib.(i).ammoShellGunCam_GEL = M3createShell session else nil; if ((gunsLib.(i).ammoPos2_GEL != nil) && ((gunsLib.(i).ammoShellGunCam2_GEL == nil) || ((M3objName session gunsLib.(i).ammoShellGunCam2_GEL) == nil))) then set gunsLib.(i).ammoShellGunCam2_GEL = M3createShell session else nil; 1 ;; /***********************************/ /* guns_load [] I */ /* */ /* load guns 3d objects */ /***********************************/ fun guns_load () = let 0 -> i in while (i < gunsLibSize) do ( guns_loadGun i; set pbParams.nbLoadedRessources_PBP = pbParams.nbLoadedRessources_PBP + 1; set i = i+1; ) ;; /******************************************/ /* guns_start2 [] I */ /* */ /* load guns library */ /******************************************/ fun guns_start2 () = let 0 -> i in while (i < gunsLibSize) do ( /* get the m3d file */ let strcatn pbItemsPath::(itoa i)::"/"::pbDefault.gunGunCamFln_PBD::nil -> filenameGunCam in let strcatn pbItemsPath::(itoa i)::"/"::pbDefault.gunItemFln_PBD::nil -> filenameItem in let _checkpack filenameGunCam -> fileGunCam in let _checkpack filenameItem -> fileItem in if ((fileGunCam == nil) || (fileItem == nil)) then ( /* defines_fofError "photoGuns.pkg guns_start2() " (strcat strcat filenameGunCam " || " filenameItem);*/ 0; ) else /* get the gun parameter */ let strextr _getpack fileGunCam -> content in let getInfo content pbParamsNames.objName_PBPN -> objNameGunCam in let getInfo content pbParamsNames.name_PBPN -> name in let getInfos content pbParamsNames.camPos_PBPN -> camposStr in let getInfos content pbParamsNames.camOrient_PBPN -> camorientStr in let atoi getInfo content pbParamsNames.camScale_PBPN -> camscale in let getInfos content pbParamsNames.ammoPos_PBPN -> ammoPosStr in let getInfos content pbParamsNames.ammoPos2_PBPN -> ammoPos2Str in let atoi getInfo content pbParamsNames.ammoDelta_PBPN -> ammoDelta in let getInfos content pbParamsNames.reload_PBPN -> reloadStr in let getInfos content pbParamsNames.shoot_PBPN -> shootStr in let getInfos content pbParamsNames.wait_PBPN -> waitStr in let getInfos content pbParamsNames.walk_PBPN -> walkStr in let atoi getInfo content pbParamsNames.gunTimeout_PBPN -> gunTimeout in let strextr _getpack fileItem -> content in let getInfo content pbParamsNames.objName_PBPN -> objNameItem in let getInfos content pbParamsNames.avPos_PBPN -> avposStr in let getInfos content pbParamsNames.avOrient_PBPN -> avorientStr in let atoi getInfo content pbParamsNames.avScale_PBPN -> avscale in let getInfos content pbParamsNames.ammoAvPos_PBPN -> ammoAvPosStr in let getInfos content pbParamsNames.ammoAvPos2_PBPN -> ammoAvPos2Str in ( /* check parameters */ if (objNameGunCam != nil) then nil else defines_loadError pbParamsNames.objName_PBPN filenameGunCam; if (name != nil) then nil else defines_loadError pbParamsNames.name_PBPN filenameGunCam; if (camposStr != nil) then nil else defines_loadError pbParamsNames.camPos_PBPN filenameGunCam; if (camorientStr != nil) then nil else defines_loadError pbParamsNames.camOrient_PBPN filenameGunCam; if (camscale != nil) then nil else defines_loadError pbParamsNames.camScale_PBPN filenameGunCam; if (ammoDelta != nil) then nil else defines_loadError pbParamsNames.ammoDelta_PBPN filenameGunCam; if (ammoPosStr != nil) then nil else defines_loadError pbParamsNames.ammoPos_PBPN filenameGunCam; if (objNameItem != nil) then nil else defines_loadError pbParamsNames.objName_PBPN filenameItem; if (avposStr != nil) then nil else defines_loadError pbParamsNames.avPos_PBPN filenameItem; if (avorientStr != nil) then nil else defines_loadError pbParamsNames.avOrient_PBPN filenameItem; if (avscale != nil) then nil else defines_loadError pbParamsNames.avScale_PBPN filenameItem; if (ammoAvPosStr != nil) then nil else defines_loadError pbParamsNames.ammoAvPos_PBPN filenameItem; if (reloadStr != nil) then nil else defines_loadError pbParamsNames.reload_PBPN filenameGunCam; if (shootStr != nil) then nil else defines_loadError pbParamsNames.shoot_PBPN filenameGunCam; if (waitStr != nil) then nil else defines_loadError pbParamsNames.wait_PBPN filenameGunCam; if (walkStr != nil) then nil else defines_loadError pbParamsNames.walk_PBPN filenameGunCam; if (gunTimeout != nil) then nil else defines_loadError pbParamsNames.gunTimeout_PBPN filenameGunCam; let [(atoi hd camposStr) (atoi hd (tl camposStr)) (atoi (hd (tl (tl camposStr))))] -> campos in let [(atoi hd camorientStr) (atoi hd (tl camorientStr)) (atoi (hd (tl (tl camorientStr))))] -> camorient in let [(atoi hd reloadStr) (atoi hd (tl reloadStr))] -> reload in let [(atoi hd shootStr) (atoi hd (tl shootStr))] -> shoot in let [(atoi hd waitStr) (atoi hd (tl waitStr))] -> wait in let [(atoi hd walkStr) (atoi hd (tl walkStr))] -> walk in let [(atoi hd avposStr) (atoi hd (tl avposStr)) (atoi (hd (tl (tl avposStr))))] -> avpos in let [(atoi hd avorientStr) (atoi hd (tl avorientStr)) (atoi (hd (tl (tl avorientStr))))] -> avorient in let [(atoi hd ammoPosStr) (atoi hd (tl ammoPosStr)) (atoi (hd (tl (tl ammoPosStr))))] -> ammoPos in let [(atoi hd ammoAvPosStr) (atoi hd (tl ammoAvPosStr)) (atoi (hd (tl (tl ammoAvPosStr))))] -> ammoAvPos in let if (ammoPos2Str == nil) then nil else [(atoi hd ammoPos2Str) (atoi hd (tl ammoPos2Str)) (atoi (hd (tl (tl ammoPos2Str))))] -> ammoPos2 in let if (ammoAvPos2Str == nil) then nil else [(atoi hd ammoAvPos2Str) (atoi hd (tl ammoAvPos2Str)) (atoi (hd (tl (tl ammoAvPos2Str))))] -> ammoAvPos2 in ( set gunsLib.(i) = mkGunEl [name filenameGunCam objNameGunCam (strcat objNameGunCam "_PaintBall") nil nil nil nil campos camorient camscale ammoDelta ammoPos ammoPos2 filenameItem objNameItem (strcat objNameItem "_PaintBall") nil avpos avorient avscale ammoAvPos ammoAvPos2 reload shoot wait walk gunTimeout 0 ]; ); 1; ); set i = i+1; set pbParams.nbLoadedRessources_PBP = pbParams.nbLoadedRessources_PBP + 1; ); guns_load; pbFlags_set "guns"; 1 ;; /******************************************************************************/ /* */ /* E X T E R N A L B O D Y */ /* */ /******************************************************************************/ /******************************************/ /* guns_destroy [] I */ /* */ /* destroy the guns lib */ /******************************************/ fun guns_destroy() = let 0 -> i in while (i < gunsLibSize) do ( guns_freeGun i; set i =i+1; ); 1 ;; /******************************************/ /* guns_start [] I */ /* */ /* construct the guns library */ /******************************************/ fun guns_start () = set gunsLib = mktab gunsLibSize nil; guns_start2; 1 ;; /******************************************/ /* guns_enable [I] I */ /* */ /* avatar can use this gun */ /******************************************/ fun guns_enable (index) = set gunsLib.(index).enable_GEL = 1; 1 ;; /******************************************/ /* guns_disable [I] I */ /* */ /* avatar can't use this gun */ /******************************************/ fun guns_disable (index) = set gunsLib.(index).enable_GEL = 0; 1 ;;