/***************************************************************/ /* */ /* PBCLIENT.PKG */ /* */ /* plug-in PaintBall */ /* client */ /* */ /* version 5 : Loïc Berthelot, CryoNetworks, mars 2001 */ /* */ /* version 4.5 : Loïc Berthelot nov 2000 */ /* avec l'aide de Olivier Lamotte */ /* */ /* Photo3 Plugin - DMS - march 00 - by Sylvain HUET */ /* rev September 2001 - by Franck OHAYON & Sebastien DENEUX */ /* */ /***************************************************************/ /****************************************************************/ /* */ /* */ /* DATA STRUCT : */ /* typeof avfile : S */ /* typeof class : S */ /* typeof pbs : [Pb r1] */ /* */ /* */ /* UTILS : */ /* pb_removeSpoTexture : fun [Timer Pb] */ /* pbbyob : fun [Pb Ob] I */ /* pb_destroy : fun [Ob] I */ /* pb_destroy2 : fun [Ob Pb] I */ /* */ /* */ /* LOADING AND RELOADING GUNS : */ /* pb_processReloadTimer : fun [Timer u0] I */ /* pb_reload : fun [Pb] I */ /* pb_showGun : fun [Pb] I */ /* pb_loaded : fun [UserI S S Pb] I */ /* pb_updateInfos : fun [UserI S S Pb] I */ /* pb_load : fun [Pb I] I */ /* */ /* */ /* COMMUNICATION WITH ITEMSDISTRIBUTION PLUGIN : */ /* item_updateLife : fun [I S Tag] I */ /* item_spinachDamage : fun [S Tag Pb] I */ /* item_gun : fun [S Tag Pb] I */ /* item_ammos : fun [S Tag] I */ /* item_indicate : fun [S S S [User r1] Tag Pb] I */ /* */ /* */ /* AVATARS MANAGEMENT - PART 1 : */ /* pb_click : fun [Ob H3d HMat3d I Pb] I */ /* pb_setbmp : fun [Pb I I] Pb */ /* pb_render : fun [Ob [ObjSurface [I I]] Pb] I */ /* pb_applyface : fun [S Pb] I */ /* pb_updateFace : fun [S Pb] I */ /* pb_shoot : fun [UserI S S [Ob Pb]] I */ /* pb_shooted : fun [UserI S S Pb] I */ /* pb_printDialogueMsg : fun [UserI S S] I */ /* pb_printPlayersMsg : fun [UserI S S] I */ /* pb_erase : fun [UserI S S Pb] I */ /* pb_testWalk : fun [Ob [[I I I] [I I I]] cllbck] I */ /* pb_disableSpinachDamage : fun [Timer Pb] I */ /* pb_enableSpinachDamage : fun [UserI S S Pb] I */ /* pb_disableOwnerSpinachDamage : fun [Timer Pb] I */ /* pb_enableOwnerSpinachDamage : fun [UserI S S Pb] I */ /* pb_startOb : fun [Ob Pb I] I */ /* pb_processShootTimer : fun [Timer u0] I */ /* pb_isPBmat : fun [[S r1] S] I */ /* */ /* */ /* KEYS CONTROL FUNCTIONS */ /* pb_keyShoot : fun [Pb] I */ /* pb_keyReload : fun [Pb] I */ /* pb_keyInterf : fun [Pb] I */ /* pb_keyControl : fun [Ob Pb] I */ /* pb_keyGun : fun [Pb I] I */ /* pb_keySpeaking : fun [I Pb] I */ /* pb_key : fun [Ob [I I] Pb] I */ /* */ /* */ /* AVATARS MANAGEMENT - PART 2 */ /* pb_getphoto : fun [S [User r1] Pb] I */ /* pb_anim : fun [Ob [H3d I]] I */ /* pb_welcomeOb : fun [Ob Pb I] I */ /* pb_endDownload : fun [S [I Ob Pb]] I */ /* pb_downloadRes : fun [[S r1] [I Ob Pb]] I */ /* pb_newOb : fun [Ob] I */ /* pb_start : fun [S S S [User r1] Tag] I */ /* IniPlug : fun [S] I */ /* */ /* */ /****************************************************************/ /********************************************************************************/ /********************************************************************************/ /** **/ /** D A T A S T R U C T **/ /** **/ /********************************************************************************/ /********************************************************************************/ /* paintball avatar m3d filename */ typeof avfile = S;; /* paintball players list */ typeof pbs=[Pb r1];; typeof ListStateOb = [[S I] r1];; /* MODIF */ var updatePhoto = 0;; /*passe a 1 quand la photo est change, remis a 0 lors de la recreation de l'ob, evite de se teleporter a un cht de photo*/ typeof PB_ShootTimer = Timer;; typeof PB_HackTimerInit = Timer;; /********************************************************************************/ /********************************************************************************/ /** **/ /** BODY - UTILS **/ /** **/ /********************************************************************************/ /********************************************************************************/ proto pb_updateFace = fun [Timer Pb] I;; /*******************************************/ /* pb_removeSpotTexture [Timer Pb] */ /* */ /* remove a spot from avatar's texture and */ /* and update its texture */ /*******************************************/ fun pb_removeSpotTexture (t, p) = _deltimer t; set p.timersList_PB = remove_from_list p.timersList_PB t; impacts_removeSpot p; pb_updateFace nil p ;; /*******************************************/ /* pbbyob [Pb Ob] I */ /* */ /* used for search in list */ /*******************************************/ fun pbbyob (p, o) = p.ob_PB == o ;; /* MODIF */ /******************************************************************************* Function to research the name of Ob in the Avatar State List a -> [S I] : an element of the ListStateOb name -> S : then name of Ob <- I : *******************************************************************************/ fun searchbyObname (a,name) = let a -> [Obname _] in !strcmp Obname name ;; /*proto pb_keyShootStop = fun [Pb] I;;*/ /*******************************************/ /* pb_destroy [Ob] I */ /* */ /* clean avatar's objects */ /*******************************************/ fun pb_destroy (o, p) = MOVE_CloseOb; /* MODIF MOVE */ /*_DLGMessageBox _channel nil "CLIENT DESTROY local" ObName o 0;*/ /* mise a jour des score */ if pbData.alive_PBDATA == 0 then let pbData.score_PBDATA -> scoreValue in if scoreValue == 0 then nil else _DMSeventTag this (strcat class ".finalScore") itoa scoreValue nil nil else nil; set ListStateOb = removef_from_list ListStateOb @searchbyObname ObName o; /*seb*/ let M3getFather session ObGetMain o -> target in if ((M3objName session target) != nil) then M3delObj session target else nil; if updatePhoto then /*evite d'afficher la page welcome quand il y a un cht de photo, met les data a nil quand on quitte le paintball afin de reafficher la page welcome au prochain lct*/ nil else set pbData=nil; /*modif SD*/ 0 ;; fun pb_destroy2 (o, p) = set ListStateOb = removef_from_list ListStateOb @searchbyObname ObName o; /*seb*/ set obOthers=remove_from_list obOthers o; set pbs=remove_from_list pbs p; _DSbitmap p.pbmp_PB; if ((M3objName session ObGetMain o) != nil) then M3delObj session ObGetMain o else nil; 0 ;; /********************************************************************************/ /********************************************************************************/ /** **/ /** BODY - LOADING AND RELOADING GUNS **/ /** **/ /********************************************************************************/ /********************************************************************************/ /******************************************************************************* set the end of reload animation t -> Timer : timer z -> u0 : *******************************************************************************/ fun pb_processReloadTimer (t, z) = _deltimer t; set gcm.isReloading = 0; 1 ;; /******************************************************************************* make the avatar reload p -> Pb : Pb struct <- I *******************************************************************************/ fun pb_reload (p) = /* reload on camera */ gunCam_reload; sounds_reload p.itemIndex_PB; /* update ammos values */ ammos_reload p.itemIndex_PB; interf_updateAmmos; /* empty the set of ammos spot on the camera */ apply_on_list p.timersList_PB @pb_removeSpotTexture p; impacts_emptySpots p; /* timer to end reload animation */ let _starttimer _channel gcm.reloadTimeout -> t in _rfltimer t @pb_processReloadTimer nil; 1 ;; /******************************************************************************* an avatar has taken a gun. update m3d objects. p -> Pb : Pb struct <- I *******************************************************************************/ fun pb_showGun (p) = /*_DLGMessageBox _channel nil "GUN" "" 0;*/ /* delete Gun tha avatar used before changing */ if ((p.gunObj_PB != nil) && ((M3objName session p.gunObj_PB) != nil)) then ( /* delete old gun from scene */ M3unLink session p.gunObj_PB; M3delObj session p.gunObj_PB; ) else nil; /* copy gun object */ set p.gunObj_PB = M3copyObj session gunsLib.(p.itemIndex_PB).objAv_GEL; M3link session p.gunObj_PB p.gunShell_PB; /* pos of gun and ammos shell, near avatar */ M3setObjScale session p.gunObj_PB gunsLib.(p.itemIndex_PB).avscale_GEL; M3setObjVec session p.gunShell_PB gunsLib.(p.itemIndex_PB).avpos_GEL; M3setObjAng session p.gunShell_PB gunsLib.(p.itemIndex_PB).avorient_GEL; M3setObjVec session p.ammoShell_PB gunsLib.(p.itemIndex_PB).ammoAvPos_GEL; /* second ammos shell, if exists */ if (gunsLib.(p.itemIndex_PB).ammoAvPos2_GEL == nil) then nil else M3setObjVec session p.ammo2Shell_PB gunsLib.(p.itemIndex_PB).ammoAvPos2_GEL; 1 ;; /*******************************************/ /* pb_loaded [UserI S S Pb] I */ /* */ /* an avatar has taken a gun, make your */ /* avatar tell what gun you have, and show */ /* the new gun on the other avatar */ /*******************************************/ fun pb_loaded (ui, action, param, p) = if pbData.alive_PBDATA then ( UsendMessage ObUi owner "infos" (itoa pbData.itemIndex_PBDATA); ) else nil; set p.itemIndex_PB = atoi param; pb_showGun p; 1 ;; /*******************************************/ /* pb_updateInfos [UserI S S Pb] I */ /* */ /* an avatar reminds others of the gun he */ /* has */ /*******************************************/ fun pb_updateInfos (ui, action, param, p) = /*_DLGMessageBox _channel nil "INFO" param 0;*/ set p.itemIndex_PB = atoi param; pb_showGun p; 1 ;; /******************************************************************************* You load a Gun p -> Pb : Pb struct index -> I : The index of the gun <- I *******************************************************************************/ fun pb_load (p, index) = /* if you don't have it, you can't use it! */ if (!gunsLib.(index).enable_GEL) then nil else ( /* store the new gun's id */ set p.itemIndex_PB = index; set pbData.itemIndex_PBDATA = index; /* screen update */ interf_updateAmmos; /* reload animation */ gunCam_load index; /* pos of ammos shell */ M3setObjVec session p.ammoShell_PB gunsLib.(index).ammoAvPos_GEL; /* MODIF */ if (gunsLib.(index).ammoAvPos2_GEL == nil) then /* MODIF */ nil else M3setObjVec session p.ammo2Shell_PB gunsLib.(index).ammoAvPos2_GEL; /* MODIF */ /* tell the others what you have loaded */ UsendMessage ObUi owner "load" (itoa index); pb_reload p; 1; ) ;; /********************************************************************************/ /********************************************************************************/ /** **/ /** BODY - MANAGE INTERACTION BETWEEN ITEMS AND YOUR AVATAR, **/ /** THROUGH COMMUNICATION WITH ITEMSDISTRIBUTION PLUGIN **/ /** **/ /********************************************************************************/ /********************************************************************************/ /******************************************************************************* you have taken a life item value -> I : param -> S : tag -> TAG : <- I *******************************************************************************/ fun item_updateLife (value, param, tag) = if (pbData.life_PBDATA == 100) then nil else ( /* tell itemsDistribution plugin to remove item from the scene */ _DMSreplyTag tag param nil 0; sounds_life; /* update life values */ data_updateLife value; interf_updateLife; interf_printMsg PBIF_OBJECTS_MSG_TYPE (strcat strcat "life : + " (itoa value) " points"); 1; ) ;; /******************************************************************************* you have taken the spinachDamage item param -> S : tag -> TAG : p -> : <- I *******************************************************************************/ fun item_spinachDamage (param, tag, p) = /* tell itemsDistribution plugin to remove item from the scene */ _DMSreplyTag tag param nil 0; sounds_spinachDamage; /* update life values */ data_updateLife 100; interf_updateLife; /* send message to all players in order to turn spinachDamage ON */ UsendMessage (ObUi p.ob_PB) "spinachDamage" (strcatn DMSlogin::" take the SPINACH DAMAGE !!"::nil); 1 ;; /******************************************************************************* you have taken a gun item param -> S : tag -> TAG : p -> : <- I *******************************************************************************/ fun item_gun (param, tag, p) = /* get the gun ID in library */ let atoi substr param ((strlen param)-1) 1 -> index in /* if you already have it */ if (gunsLib.(index).enable_GEL) then ( /* then take it anyway, */ /* and update ammos values if needed */ if (ammosLib.(index).nb_AEL == ammosLib.(index).nbMax_AEL) then nil else ( _DMSreplyTag tag param nil 0; sounds_reload index; ammos_update index ammosLib.(index).nbMax_AEL; interf_updateAmmos; interf_printMsg PBIF_OBJECTS_MSG_TYPE (strcat "ammos : " ammosLib.(index).name_AEL); 0; ) ) /* else take the gun itself */ else ( /* itemsDistribution plugin removes */ /* item from the scene */ _DMSreplyTag tag param nil 0; /* enable the gun item for your avatar */ guns_enable index; sounds_reload index; /* update 2d interface */ interf_updateGuns; ammos_update index ammosLib.(index).nbMax_AEL; interf_updateAmmos; /* load this gun if you don't have a better one */ if ((pbData.itemIndex_PBDATA < index) || (index == 0)) then pb_load p index else nil; interf_printMsg PBIF_OBJECTS_MSG_TYPE (strcat "gun : " gunsLib.(index).name_GEL); 1; ) ;; /******************************************************************************* you have taken an ammos item param -> S : tag -> TAG : <- I *******************************************************************************/ fun item_ammos (param, tag) = /* get the ammo ID in library */ let atoi substr param ((strlen param)-1) 1 -> index in if (ammosLib.(index).nb_AEL == ammosLib.(index).nbMax_AEL) then nil else ( /* remove it from scene */ /* (ItemsDistribution plugin) */ _DMSreplyTag tag param nil 0; sounds_reload index; /* update ammos values */ ammos_update index ammosLib.(index).clipCapacity_AEL; interf_updateAmmos; interf_printMsg PBIF_OBJECTS_MSG_TYPE (strcat "ammos : " ammosLib.(index).name_AEL); 1; ) ;; /********************************************/ /* item_indicate [S S S [User r1] Tag Pb] I */ /* */ /* action received from */ /* itemsDistribution plugin */ /* */ /* tells what item you walked on, and let */ /* you decide if you take it or not */ /********************************************/ fun item_indicate (from, action, param, ulist, tag, p) = if (!pbData.alive_PBDATA) then /* MODIF */ nil else ( /* little life item */ if (!strcmp param pbItems.life1_PBITM) then item_updateLife 10 param tag /* big life item */ else if (!strcmp param pbItems.life2_PBITM) then item_updateLife 50 param tag /* spinachDamage item */ else if (!strcmp param pbItems.spinachDamage_PBITM) then item_spinachDamage param tag p /* gun item */ else if ((strfindi "gun" param 0) != nil) then item_gun param tag p /* ammos item */ else if ((strfindi "ammo" param 0) != nil) then item_ammos param tag else nil; 1; ) ;; /********************************************************************************/ /********************************************************************************/ /** **/ /** BODY - AVATARS MANAGEMENT - PART 1 **/ /** **/ /********************************************************************************/ /********************************************************************************/ /********************************************/ /* pb_click [Ob H3d HMat3d I Pb] I */ /* */ /* callback */ /* you clicked on an avatar, in order to */ /* target him */ /********************************************/ fun pb_click (o, hdlr, mat, btn, p) = /* get your and his positions */ let M3calcPosRef session (ObGetMain owner) shell -> [mypos _] in let M3calcPosRef session (ObGetMain o) shell -> [otherpos _] in /* get the angle to target him */ let M3angularTarget mypos otherpos -> [ealpha ebeta egamma] in let M3getObjAng session (ObGetMain owner) -> [oa _ og] in let M3getObjAng session myavatar -> [_ mb mg] in ( /* target the avatar */ M3setObjAng session (ObGetMain owner) [oa ebeta og]; M3setObjAng session myavatar [ealpha mb mg]; ); 1 ;; /********************************************/ /* pb_render [Ob [ObjSurface [I I]] Pb] I */ /* */ /* postrender callback */ /* apply ammos spot on screen */ /********************************************/ fun pb_render (o, z, p)= MOVE_MouseMove o z; let z->[d [x y]] in let _GETsurfaceSize d -> [dW dH] in ( /* apply gun sight bitmap on screen */ let sightsLib.(p.itemIndex_PB) -> sight in _Bitmap2Surface d ((dW/2) - sight.halfWidth_SEL) ((dH/2) - sight.halfHeight_SEL) sight.b_SEL 0 0 sight.width_SEL sight.height_SEL sight.transparencyColor_SEL; let 0 -> i in /* apply all spots on screen */ let p.ai_PB.allocatedSize_AI -> maxIndex in while (i < maxIndex) do ( let p.ai_PB.spots_AI.(i) -> spot in let spot.spot_Sel -> spotEl in /* MODIF 2208 */ if ((spot.y_Sel-spot.decal)>=spotEl.h_SLel/2) && ((spot.x_Sel-spot.decal)>=spotEl.w_SLel/2) then _Bitmap2Surface d spot.x_Sel spot.y_Sel impactsLib.(spot.index_Sel).bmp_IL spotEl.x_SLel 0 spotEl.w_SLel spotEl.h_SLel impactsLib.(spot.index_Sel).tc_IL else if !((spot.y_Sel-spot.decal)>=spotEl.h_SLel/2) && ((spot.x_Sel-spot.decal)>=spotEl.w_SLel/2) then _Bitmap2Surface d spot.x_Sel spot.y_Sel+((spotEl.h_SLel/2)-(spot.y_Sel-spot.decal)) impactsLib.(spot.index_Sel).bmp_IL spotEl.x_SLel ((spotEl.h_SLel/2)-(spot.y_Sel-spot.decal)) spotEl.w_SLel (spotEl.h_SLel-((spotEl.h_SLel/2)-(spot.y_Sel-spot.decal))) impactsLib.(spot.index_Sel).tc_IL else if ((spot.y_Sel-spot.decal)>=spotEl.h_SLel/2) && !((spot.x_Sel-spot.decal)>=spotEl.w_SLel/2) then _Bitmap2Surface d spot.x_Sel+((spotEl.w_SLel/2)-(spot.x_Sel-spot.decal)) spot.y_Sel impactsLib.(spot.index_Sel).bmp_IL spotEl.x_SLel+((spotEl.w_SLel/2)-(spot.x_Sel-spot.decal)) 0 (spotEl.w_SLel-((spotEl.w_SLel/2)-(spot.x_Sel-spot.decal))) spotEl.h_SLel impactsLib.(spot.index_Sel).tc_IL else ( let _CRbitmap _channel spotEl.w_SLel spotEl.h_SLel -> tmp in ( _CPbitmap16 tmp 0 0 impactsLib.(spot.index_Sel).bmp_IL spotEl.x_SLel ((spotEl.h_SLel/2)-(spot.y_Sel-spot.decal)) spotEl.w_SLel (spotEl.h_SLel-((spotEl.h_SLel/2)-(spot.y_Sel-spot.decal))) impactsLib.(spot.index_Sel).tc_IL; _Bitmap2Surface d spot.x_Sel+((spotEl.w_SLel/2)-(spot.x_Sel-spot.decal)) spot.y_Sel+((spotEl.h_SLel/2)-(spot.y_Sel-spot.decal)) tmp ((spotEl.w_SLel/2)-(spot.x_Sel-spot.decal)) 0 (spotEl.w_SLel-((spotEl.w_SLel/2)-(spot.x_Sel-spot.decal))) (spotEl.h_SLel-((spotEl.h_SLel/2)-(spot.y_Sel-spot.decal))) 1 ); ); set i = i+1; ); /* 2d interface on screen */ interf_render d dW dH; ); /*);*/ /* exec shooted ammos animation, */ /* if not nil */ exec shoot_CbPostRender with [shoot_fifo]; 0 ;; /********************************************/ /* pb_applyface [S Pb] I */ /* */ /* apply a bitmap photo on the avatar */ /********************************************/ fun pb_applyface (s, p, transparency)= /*_DLGMessageBox _channel nil "APPLY FACE" "" 0;*/ _DSbitmap p.pbmp_PB; _DSbitmap p.ipbmp_PB; M3freeTexture session p.tx_PB; let _LDbitmap _channel _checkpack s -> imagebmp in let if imagebmp==nil then _LDjpeg _channel _checkpack s else imagebmp -> image in let M3getFirstSon session ObGetMain p.ob_PB-> h in let M3copyObjMaterial session h hd M3listOfMaterials session h -> mat in let _GETbitmapSize image -> [w h] in let M3copyMaterialTexture session mat -> t in ( set p.ipbmp_PB = _SCPbitmap (_CRbitmap _channel 64 64) 0 0 64-1 64-1 image 0 0 w-1 h-1 nil; /* stretche l'image avatar en 64*64 */ set p.pbmp_PB= _SCPbitmap (_CRbitmap _channel 64 64) 0 0 64-1 64-1 image 0 0 w-1 h-1 nil; /* sinon cause problèmes pour bitmap <64*64*/ set p.file_PB=s; set p.tx_PB=t; if transparency then /*sd*/ let _GETpixel16 image 0 0 -> colRGB in let ((colRGB&16252928)>>16)+(colRGB&63488)+((colRGB&248)<<16) -> colBGR in ( M3setType session mat MAT_TRANSP|M3getType session mat; M3setTransparencyColor session t colBGR ) else nil; M3blitTexture16 session t image; 0; ) ;; /*modified 10-99 by Sebastien DENEUX : transparency color of the photo = left top pixel*/ fun applyface(s,o,f)= let _LDbitmap _channel _checkpack s -> imagebmp in let if imagebmp==nil then _LDjpeg _channel _checkpack s else imagebmp -> image in let M3getFirstSon session ObGetMain o-> h in let M3copyObjMaterial session h hd M3listOfMaterials session h-> mat in let M3copyMaterialTexture session mat -> t in (if f then let _GETpixel16 image 0 0 -> colRGB in let ((colRGB&16252928)>>16)+(colRGB&63488)+((colRGB&248)<<16) -> colBGR in (M3setType session mat MAT_TRANSP|M3getType session mat; M3setTransparencyColor session t colBGR) else nil; M3blitTexture16 session t image; _DSbitmap image);; /********************************************/ /* pb_updateFace [S Pb] I */ /* */ /* apply ammos spot on the avatar's texture */ /********************************************/ fun pb_updateFace (t,p) = /* _DLGMessageBox _channel nil "SHOOT ON TEXTURE" "UpdateFace" 0;*/ let _GETbitmapSize p.pbmp_PB -> [w h] in ( _DSbitmap p.pbmp_PB; set p.pbmp_PB = _CPbitmap16 (_CRbitmap _channel 64 64) 0 0 p.ipbmp_PB 0 0 w h nil; /*test seb*/ /*_CPbitmap16 (_CRbitmap _channel w h) 0 0 p.ipbmp_PB 0 0 w h nil;*/ ); let 0 -> i in let p.ai_PB.allocatedSize_AI -> maxIndex in while (i < maxIndex) do ( let p.ai_PB.spots_AI.(i) -> item in _CPbitmap16 p.pbmp_PB item.x_Sel item.y_Sel impactsLib.(item.index_Sel).bmp_IL item.spot_Sel.x_SLel 0 item.spot_Sel.w_SLel item.spot_Sel.h_SLel impactsLib.(item.index_Sel).tc_IL; set i = i+1; 1; ); M3blitTexture16 session p.tx_PB p.pbmp_PB; 1 ;; proto pb_welcomeOb = fun [Ob Pb I] I;; /********************************************/ /* pb_shoot [UserI S S [Ob Pb]] I */ /* */ /* you took a shoot, update your life */ /* values, add an ammo spot on screen */ /********************************************/ fun pb_shoot (ui, action, param, tuple) = if (pbData.alive_PBDATA) then /* MODIF POUR PAS PERDRE DE POINTS MEME LORSQU'ON EST MORT */ ( let tuple -> [o p] in /* get shoot parameters */ let hd strextr param -> [indexStr [spinachDamageStr [us [vs [zs [cs _]]]]]] in let atoi cs -> c in let atoi indexStr -> index in let atoi spinachDamageStr -> spinachDamage in let getView3dSize w3d ->[w h] in ( let atoi zs -> zsInt in let atoi us -> usInt in let atoi vs -> vsInt in /* to define the different taille of the impact */ /* MODIF */ let if (zsInt> 1500) then 4 else if (zsInt> 1200) then 3 else if (zsInt> 600) then 2 else if (zsInt> 350) then 1 else if (zsInt> 70) then 0 else 0 -> steps in let if ((4 - steps)*50)>0 then (steps - 4)*50 else -25 -> decal in /* get shoot coordinates */ /* MODIF */ let w - ( - decal + ftoi( ((itof usInt) /. (itof 256)) *. itof w)) -> xDest in let h - ( - decal + (ftoi( ((itof vsInt) /. (itof 256)) *. itof h))) -> yDest in let mkSpotsEl [index impactsLib.(index).screenlib_IL.(steps) xDest yDest decal] -> spot in ( /* store the spot in your spot tab */ impacts_insertSpot p spot; /*_DLGMessageBox _channel nil "IMPACT ECRAN" strcatn "X:"::(itoa xDest)::"Y:"::(itoa yDest)::nil 0*/ ); /* timer to remove spot from screen */ let _starttimer _channel 1800 -> t in ( set p.timersList_PB = t::p.timersList_PB; _rfltimer t @pb_removeSpotTexture p; /* applique texture impact sur fenetre 3D */ ); /* update life value */ data_updateLife (-(ammosLib.(index).power_AEL * spinachDamage)); interf_updateLife; /* mise a jour des score */ if pbData.alive_PBDATA == 0 then let itoa pbData.score_PBDATA -> scoreValue in _DMSeventTag this (strcat class ".finalScore") scoreValue nil nil else nil; /* play the hurt sound */ sounds_hurt index; ); /* message for applying spot on your */ /* avatar's texture, on others clients */ UsendMessage ui "shooted" param; 0 ) else ( let tuple -> [o p] in pb_welcomeOb o p 0 /*welcome page and no teleport*/ ) ;; /********************************************/ /* pb_shooted [UserI S S Pb] I */ /* */ /* an avatar has taken a shoot. apply a */ /* spot on his texture */ /********************************************/ fun pb_shooted (ui, action, param, p) = /* permet de mettre les impacts précédents avant d'en mettre un nouveau (pour photo avatar >64*64) */ /* MODIF 2208 */ let _GETbitmapSize p.pbmp_PB -> [w h] in ( _DSbitmap p.pbmp_PB; set p.pbmp_PB = _CPbitmap16 (_CRbitmap _channel 64 64) 0 0 p.ipbmp_PB 0 0 w h nil; ); let 0 -> i in let p.ai_PB.allocatedSize_AI -> maxIndex in while (i < maxIndex) do ( let p.ai_PB.spots_AI.(i) -> item in _CPbitmap16 p.pbmp_PB item.x_Sel item.y_Sel impactsLib.(item.index_Sel).bmp_IL item.spot_Sel.x_SLel 0 item.spot_Sel.w_SLel item.spot_Sel.h_SLel impactsLib.(item.index_Sel).tc_IL; set i = i+1; 1; ); /* get shoot parameters */ let hd strextr param -> [indexStr [spinachDamageStr [us [vs [zs [cs _]]]]]] in let atoi cs -> c in let atoi indexStr -> index in let _GETbitmapSize p.pbmp_PB ->[w h] in ( let atoi zs -> zsInt in let atoi us -> usInt in let atoi vs -> vsInt in /* to define the different lenght of the impact */ /* MODIF */ let if (zsInt> 1500) then 4 else if (zsInt> 1200) then 3 else if (zsInt> 600) then 2 else if (zsInt> 350) then 1 else if (zsInt> 70) then 0 else 0 -> steps in let -(30 - (steps + 1) * 5) -> decal in /* get shoot coordinates */ /* MODIF */ let _GETbitmapSize p.pbmp_PB -> [w h] in let decal + ftoi( ((itof usInt) /. (itof 256)) *. itof w/*64*/) -> xDest in let h/*64*/ - ( - decal + (ftoi( ((itof vsInt) /. (itof 256)) *. itof h/*64*/))) -> yDest in let mkSpotsEl [index impactsLib.(index).avatarlib_IL.(steps) xDest yDest decal] -> spot in /* store the spot in avatar's spot tab */ let impacts_insertSpot p spot -> spotIndex in ( /* apply spot on texture */ set p.pbmp_PB = _CPbitmap16 p.pbmp_PB spot.x_Sel spot.y_Sel impactsLib.(index).bmp_IL spot.spot_Sel.x_SLel 0 spot.spot_Sel.w_SLel spot.spot_Sel.h_SLel impactsLib.(index).tc_IL; /* timer to remove spot from texture */ let _starttimer _channel 1800 -> t in ( set p.timersList_PB = t::p.timersList_PB; _rfltimer t @pb_removeSpotTexture p; ); /*_DLGMessageBox _channel nil "SHOOT ON TEXTURE" "shooted" 0;*/ M3blitTexture16 session p.tx_PB p.pbmp_PB; ); 1; ) ;; /********************************************/ /* pb_printDialogueMsg [UserI S S] I */ /* */ /* a player send a chat message */ /********************************************/ fun pb_printDialogueMsg (ui, action, param) = interf_printMsg PBIF_DIALOGUE_MSG_TYPE param; 1 ;; /********************************************/ /* pb_printPlayersMsg [UserI S S] I */ /* */ /* a message concerning a player has been */ /* sent. */ /********************************************/ fun pb_printPlayersMsg (ui, action, param) = interf_printMsg PBIF_PLAYERS_MSG_TYPE param; 1 ;; /********************************************/ /* pb_erase [UserI S S Pb] I */ /* */ /* re-initialize avatar's photo */ /********************************************/ /* fun pb_erase(ui, action, param, p) = if (p.file_PB != nil) then ( nil ) else ( set p.file_PB = (strcat pbItemsPath "logopaintball.jpg"); 1 ); pb_applyface p.file_PB p p.transparency; 0 ;; */ /***********************************************/ /* pb_testWalk [Ob [[I I I] [I I I]] cllbck] I */ /* */ /* obcontrol first callback */ /* check if avatar is moving, and update */ /* animation of gun in consequence */ /***********************************************/ fun pb_testWalk (o, v, f) = let v -> [[x1 y1 z1] [x2 y2 z2]] in if ((x1 == 0) && (y1 == 0) && (z1 == 0)) then /* avatar is not moving */ ( if (gcm.isWaiting || gcm.isShooting || gcm.isReloading) then nil else ( set gcm.isWaiting = 1; set gcm.isWalking = 0; gunCam_wait; ) ) else /* avatar is walking */ ( if (gcm.isWalking || gcm.isShooting || gcm.isReloading) then nil else ( set gcm.isWaiting = 0; set gcm.isWalking = 1; gunCam_walk; ) ); /* exef initial callback */ exec f with [o v]; 1 ;; /***********************************************/ /* pb_disableSpinachDamage [Timer Pb] I */ /* */ /* disable spinachDamage bonus of the avatar */ /***********************************************/ fun pb_disableSpinachDamage (t, p) = _deltimer t; set p.spinachDamage_PB = 1; 1 ;; /***********************************************/ /* pb_enableSpinachDamage [UserI S S Pb] I */ /* */ /* enable spinachDamage bonus of the avatar */ /***********************************************/ fun pb_enableSpinachDamage (ui, action, param, p) = interf_printMsg PBIF_PLAYERS_MSG_TYPE param; set p.spinachDamage_PB = 2; let _starttimer _channel PBDATA_SPINACHDAMAGE_TIMEOUT -> t in _rfltimer t @pb_disableSpinachDamage p; 1 ;; /***********************************************/ /* pb_disableOwnerSpinachDamage [Timer Pb] I */ /* */ /* make a message appear when your */ /* spinachDamage bonus is over */ /***********************************************/ fun pb_disableOwnerSpinachDamage (t, p) = _deltimer t; interf_printMsg PBIF_PLAYERS_MSG_TYPE "... spinach damage over ..."; 1 ;; /************************************************/ /* pb_enableOwnerSpinachDamage [UserI S S Pb] I */ /* */ /* you took the spinachDamage bonus, set your */ /* avatar parameter. */ /************************************************/ fun pb_enableOwnerSpinachDamage (ui, action, param, p) = let _starttimer _channel PBDATA_SPINACHDAMAGE_TIMEOUT -> t in _rfltimer t @pb_disableOwnerSpinachDamage p; pb_enableSpinachDamage ui action param p; 1 ;; /* MODIF */ /******************************************************************************* Each time an avatar is born or dead we update the Avatar State List ui -> UI : cli -> CLIENT : action -> nil : param -> [[S I] r1] : ListStateOb <- *******************************************************************************/ fun AvState (ui, action, param) = let lineextr param -> [name [state _]] in let (search_in_list ListStateOb @searchbyObname name ) -> f in ( if f!=nil then ( mutate f <- [ _ (atoi state)]; 1 ) else ( set ListStateOb = [name (atoi state)]::ListStateOb; 1 ); ); 1 ;; /* MODIF */ /******************************************************************************* Transform the List from Server in Avatar State List list -> [[S I] r1] : ListStateOb <- [S r1] : new sort of list *******************************************************************************/ fun ListAvState (list) = if list == nil then nil else let list -> [name [state next]] in [name (atoi state)]::(ListAvState next) ;; /* MODIF */ /******************************************************************************* Function to Obtain the Avatar State List ui -> UI : cli -> CLIENT : action -> nil : param -> nil : <- *******************************************************************************/ fun ListAv (ui, action, param) = set ListStateOb = ListAvState lineextr param; 1 ;; /************************************************/ /* pb_startOb [Ob Pb I] I */ /* */ /* your avatar is starting to play */ /************************************************/ fun pb_startOb (o, p, tel) = /*_DLGMessageBox _channel nil "startob" DMSlogin 0;*/ /* set postrender callback */ set pbControl.enable_PBCTRL = 0; ObCbPostRender o mkfun3 @pb_render p; UcbMessage ObUi o ["shoot" mkfun4 @pb_shoot [o p]]::["AvState" @AvState]::["ListAvState" @ListAv]:: ["printDialogueMsg" @pb_printDialogueMsg]:: ["printPlayersMsg" @pb_printPlayersMsg]:: ["spinachDamage" mkfun4 @pb_enableOwnerSpinachDamage p]::nil; /* start gun animation on camera */ gcm_start; gunCam_start o; /* Must do that when we change photo of avatar to see our gun */ guns_loadGun p.itemIndex_PB; /* MODIF */ guns_enable p.itemIndex_PB; /* MODIF */ /* show gun on camera */ gunCam_load p.itemIndex_PB; /* Must do that when we change photo of avatar for the other to see our gun */ UsendMessage ObUi owner "load" (itoa p.itemIndex_PB); /* MODIF */ /* ask server to receive the Avatar state list */ UsendMessage ObUi o "reception" nil; /* MODIF */ /* give the new state (alive) to the server */ /*_DLGMessageBox _channel nil "CLI AVSTATE 2" "" 0;*/ /*SD*/ UsendMessage ObUi o "AvState" linebuild (ObName o)::(itoa 1)::(itoa (updatePhoto || !tel))::nil; /*does not teleport user if updatePhoto*/ set updatePhoto = 0; /* update 2D interface */ interf_updateAmmos; interf_updateScore; interf_updateLife; interf_updateGuns; interf_updateMsg; interf_initTalk; if (!pbData.alive_PBDATA) then ( /* update ammos values */ ammos_reload p.itemIndex_PB; /* tell the others what you loaded */ UsendMessage ObUi owner "load" (itoa p.itemIndex_PB); /* player is begining to play */ data_alive; 1; ) else 0 ;; /************************************************/ /* pb_processShootTimer [Timer u0] I */ /* */ /* end of shooting animation */ /************************************************/ fun pb_processShootTimer (t,z) = _deltimer t; set gcm.isShooting = 0; 1 ;; /**************************************/ /* pb_isPBmat [[S r1] S] I */ /* */ /* return 1 if m is a paintBall */ /* material name, 0 if not... */ /* <=> 1 if the texture has to be */ /* painted. */ /**************************************/ fun pb_isPBmat (list, m) = if (list == nil) then 0 else let hd list -> fst in if (!strcmp M3materialName session m fst) then 1 else pb_isPBmat (tl list) m ;; /********************************************************************************/ /********************************************************************************/ /** **/ /** BODY - KEYS CONTROL FUNCTIONS **/ /** **/ /********************************************************************************/ /********************************************************************************/ /**************************************/ /* pb_keyShoot [Pb] I */ /* */ /* you hit the shoot key. */ /**************************************/ fun pb_keyShoot (onetimer, p) = if ((gcm.isReloading) || (gcm.isShooting) || (ammosLib.(p.itemIndex_PB).clipNb_AEL == 0)) then nil else ( /* set animations flags */ set gcm.isWaiting = 0; set gcm.isWalking = 0; set gcm.isShooting = 1; set gcm.shootTimer = _starttimer _channel gcm.shootTimeout; _rfltimer gcm.shootTimer @pb_processShootTimer nil; /* make the gun shoot on camera */ gunCam_shoot; sounds_shoot p.itemIndex_PB; /* get target informations */ let MX3renderInfo session cam 0 0 -> [h m u v z] in let search_in_list obOthers @obbyson h -> o2 in let if o2==nil || !(pb_isPBmat pbParams.matList_PBP m) then 0 else 1 /* the target is gonna be hit */ -> codeTouch in ( /* check if the avatar we want to shoot is alive or not ! */ let (search_in_list ListStateOb @searchbyObname ObName o2 ) -> [Obname Laststate] in /* MODIF */ ( if codeTouch == 1 then /* MODIF */ ( if Laststate == 1 then ( /* update score of shooter */ /* MODIF */ set pbData.score_PBDATA = pbData.score_PBDATA + (ammosLib.(p.itemIndex_PB).power_AEL * p.spinachDamage_PB); interf_updateScore; let itoa pbData.score_PBDATA -> scoreValue in _DMSeventTag this (strcat class ".updateScore") scoreValue nil nil; ) else nil ) else nil; /* if your gun is a simple one */ if (gunsLib.(p.itemIndex_PB).ammoAvPos2_GEL == nil) then ( /* update ammos values in your clip */ set ammosLib.(p.itemIndex_PB).clipNb_AEL = ammosLib.(p.itemIndex_PB).clipNb_AEL - 1; /* update 2d interface */ interf_updateAmmos; /* shoot once */ shoot_shoot p o2 h u v z codeTouch Laststate gunsLib.(p.itemIndex_PB).ammoShellGunCam_GEL p.ammoShell_PB; ) /* your gun is a double one */ else ( /* update ammos values in your clip */ set ammosLib.(p.itemIndex_PB).clipNb_AEL = ammosLib.(p.itemIndex_PB).clipNb_AEL - 2; /* update 2d interface */ interf_updateAmmos; /* shoot twice */ shoot_shoot p o2 h u v z codeTouch Laststate gunsLib.(p.itemIndex_PB).ammoShellGunCam_GEL p.ammoShell_PB; shoot_shoot p o2 h u v z codeTouch Laststate gunsLib.(p.itemIndex_PB).ammoShellGunCam2_GEL p.ammo2Shell_PB; ); ); ); ) ;; fun pb_keyShootStart (p) = pb_keyShoot nil p; set PB_ShootTimer = _rfltimer _starttimer _channel 500 @pb_keyShoot p; 0 ;; fun pb_keyShootStop (p) = if PB_ShootTimer == nil then nil else ( _deltimer PB_ShootTimer; set PB_ShootTimer = nil ); 0 ;; /**************************************/ /* pb_keyReload [Pb] I */ /* */ /* you hit the reload key. */ /**************************************/ fun pb_keyReload (p) = if ((gcm.isReloading) || (ammosLib.(p.itemIndex_PB).nb_AEL == 0)) then nil else ( /* set animation flag */ set gcm.isReloading = 1; set gcm.isWaiting = 0; set gcm.isWalking = 0; /* reload */ pb_reload p; 1; ) ;; /**************************************/ /* pb_keyInterf [Pb] I */ /* */ /* you hit the 2d interface key. */ /* switch 2d interface fields */ /**************************************/ fun pb_keyInterf (p) = interf_change; 1 ;; /**************************************/ /* pb_keyControl [Ob Pb] I */ /* */ /* make the controls screen appear or */ /* disappear */ /**************************************/ fun pb_keyControl (o, p) = if (pbControl.enable_PBCTRL) then ( set pbControl.enable_PBCTRL = 0; ObCbPostRender o mkfun3 @pb_render p; 1; ) else ( set pbControl.enable_PBCTRL = 1; ObCbPostRender o @control_render; 1; ) ;; /**************************************/ /* pb_keyGun [Pb I] I */ /* */ /* you load a gun */ /**************************************/ fun pb_keyGun (p, code) = let if (code == pbKeys.g1_PBK) then 1 else if (code == pbKeys.g2_PBK) then 2 else if (code == pbKeys.g3_PBK) then 3 else if (code == pbKeys.g4_PBK) then 4 else if (code == pbKeys.g5_PBK) then 5 else if (code == pbKeys.g6_PBK) then 6 else if (code == pbKeys.g7_PBK) then 7 else if (code == pbKeys.g8_PBK) then 8 else if (code == pbKeys.g9_PBK) then 9 else if (code == pbKeys.g0_PBK) then 0 else nil -> index in if ((index == nil) || (index == pbData.itemIndex_PBDATA)) then nil else ( pb_load p index; 1; ) ;; fun pb_Stophacklife() = if PB_HackTimerInit == nil then nil else ( _deltimer PB_HackTimerInit; set PB_HackTimerInit = nil; ); 0 ;; fun pb_hacklife (hackTimer, param ) = let param -> [i] in if i > 10 then ( pb_Stophacklife; 0 ) else ( data_updateLife 100; interf_updateLife; mutate param <- [i+1]; 0 ); /* let param -> [i] in _DLGMessageBox _channel nil "i" itoa i 0; */ 0 ;; /**************************************/ /* pb_keySpeaking [I Pb] I */ /* */ /* character to add to the sequence */ /* chat. */ /**************************************/ fun pb_keySpeaking (a, b, p) = if (a == pbKeys.enter_PBK) then ( /* send the message to others */ set pbData.speaking_PBDATA = 0; MOVE_TreatKeyDown 1; if !strcmp pbInterf.talkLine_PBIF "give me all ammo! ok" then ( let 0 -> j in while j<10 do ( guns_enable j; ammos_update j ammosLib.(j).nbMax_AEL; set j = j+1 ); interf_updateGuns; 1 ) else if !strcmp pbInterf.talkLine_PBIF "give me my life! ok" then ( data_updateLife 100; interf_updateLife ) else if !strcmp pbInterf.talkLine_PBIF "give me invicibility! ok" then ( set PB_HackTimerInit = _rfltimer _starttimer _channel 2000 @pb_hacklife [0]; 0 ) else ( UsendMessage (ObUi p.ob_PB) "printDialogueMsg" (strcatn DMSlogin::" : "::pbInterf.talkLine_PBIF::nil); 1 ); set pbInterf.talkLine_PBIF = nil; 1; ) else ( /* just print the character on screen */ interf_printTalk b; 0; ) ;; /**************************************/ /* pb_key [Ob [I I] Pb] I */ /* */ /* you hit a key down. */ /**************************************/ fun pb_key (o, z, p) = let z->[a b] in if (pbData.speaking_PBDATA) then pb_keySpeaking a b p else if (a == pbKeys.config_PBK) then /* CONFIG */ MOVE_ShowConfiguration o /* MODIF 26-10 */ else if (a == pbKeys.quit_PBK) then _DMSeventTag this (strcat class ".quit") nil nil nil else if (pbData.alive_PBDATA) then pb_keyGun p a else 0 ;; /********************************************************************************/ /********************************************************************************/ /** **/ /** BODY - AVATARS MANAGEMENT - PART 2 **/ /** **/ /********************************************************************************/ /********************************************************************************/ /**************************************/ /* pb_getphoto [S [User r1] Pb] I */ /* */ /* tag from "getphoto" event */ /**************************************/ fun pb_getphoto (param, ulist, p) = let strextr param -> l in /*sd*/ let getInfo l "sign" -> sign in let getInfo l "trans" -> trans in ( if sign==nil then ( set p.file_PB = (strcat pbItemsPath "logo.bmp"); /* MODIF 1709 */ pb_applyface p.file_PB p 0 ) else ( set p.transparency = atoi trans; pb_applyface sign p atoi trans ) ) ;; /**************************************/ /* pb_anim [Ob [H3d I]] I */ /* */ /* callback to animate avatars */ /**************************************/ fun pb_anim (o, q)= let q->[h x] in let (100+x)&4095 -> x in let if x&2048 then 3072-x else x-1024 -> z in ( let M3getObjAng session h -> [a _ c] in M3setObjAng session h [a z c]; let M3getObjVec session h -> [a _ c] in M3setObjVec session h [a (z>>6) c]; mutate q<-[_ x]; 0; ) ;; /**************************************/ /* pb_welcomeOb [Ob Pb I] I */ /* */ /* you enter the paintball scene */ /**************************************/ fun pb_welcomeOb (o, p , tel) = pb_keyShootStop p; /* arret du tir automatique */ pb_Stophacklife; /* arret invinsible */ set pbInterf.talkLine_PBIF = nil; /* arret de tout message */ MOVE_TreatKeyDown 1; set pbData.speaking_PBDATA = 0; /*set pbData.chphoto_PBDATA = 0 ; */ /* MODIF */ /* send message to server that i'm dead and i want new position */ UsendMessage ObUi o "AvState" linebuild (ObName o)::(itoa 0)::(itoa !tel)::nil; /* MODIF */ /* player didn't begin to play yet */ data_dead; loading_destroy; /*destruction de toutes les armes */ /* MODIF */ guns_destroy; /* reset data values */ set pbData.score_PBDATA = 0; set pbData.life_PBDATA = 100; set p.itemIndex_PB = 1; set pbData.itemIndex_PBDATA = 1; guns_load; /* reset guns and ammos */ let 0 -> i in while (i < pbNbItems) do ( guns_disable i; set ammosLib.(i).nb_AEL = ammosLib.(i).nbMax_AEL; set ammosLib.(i).clipNb_AEL = 0; set i=i+1; ); guns_enable 1; /* print the controls screen */ set pbControl.enable_PBCTRL = 1; /* allow to load invisible gun when u're dead */ UsendMessage ObUi owner "load" itoa 10; /* MODIF */ /* les balles que j'ai tiré même si je suis mort doivent arriver */ /* MODIF */ while (shoot_fifo != nil) do exec shoot_CbPostRender with [shoot_fifo]; ObCbPostRender o @control_render; 1 ;; fun PB_cbManageKey (param, downevent, p, o) = if !(pbData.alive_PBDATA) then if (!strcmpi param pbKeys.start_PBK) && downevent then pb_startOb o p 1 else nil else if (!strcmpi param pbKeys.shoot_PBK) && !pbControl.enable_PBCTRL then if downevent then pb_keyShootStart p else pb_keyShootStop p else if (!strcmpi param pbKeys.reload_PBK) && downevent then pb_keyReload p else if (!strcmpi param pbKeys.control_PBK) && downevent then ( pb_keyShootStop p; pb_keyControl o p ) else if ((!strcmpi param pbKeys.talk_PBK) && !pbControl.enable_PBCTRL) && !downevent then ( pb_keyShootStop p; set pbData.speaking_PBDATA = 1; MOVE_TreatKeyDown 0; interf_updateTalk; 1; ) else if (!pbControl.enable_PBCTRL) && (!strcmpi param pbKeys.interf_PBK) && downevent then pb_keyInterf p else nil; 1 ;; /***************************************/ /* pb_endDownload [S [I Ob Pb]] I */ /* */ /* a resource file has been downloaded */ /***************************************/ fun pb_endDownload (fln, tuple) = let tuple -> [priority o p] in let loading_render o [(ObBuffer w3d) nil] -> _ in /* if all files have been downloaded */ if (pbParams.nbLoadedRessources_PBP == (pbParams.nbRessources_PBP-1)) then ( set pbParams.nbLoadedRessources_PBP = pbParams.nbLoadedRessources_PBP+1; /* start all the librarys */ impacts_start; ammos_start; guns_start; sights_start; sounds_start; interf_start; control_start; /* and tell the others you're in */ UsendMessage ObUi owner "printPlayersMsg" (strcat (ObName owner) " entered the game"); /* set the default paintball photo */ /*_DMSeventTag this (strcat class ".setPhoto") "dms/3d/plugins/paintballav/items/logopaintball.jpg" nil nil;*/ /* LAST MODIF SD*/ /* the paintball plugin is complettly started */ _DMSeventTag this (strcat class ".activated") nil nil nil; /* start the game */ pb_welcomeOb o p 1; /*welcome page and teleport user*/ 1; ) else ( /*_fooS strcat strcat "PAINTBALL : " fln " downloaded";*/ set pbParams.nbLoadedRessources_PBP = pbParams.nbLoadedRessources_PBP+1; 0; ) ;; /***************************************/ /* pb_downloadRes [[S r1] [I Ob Pb]] I */ /* */ /* download resources */ /***************************************/ fun pb_downloadRes (filesList, tuple) = let tuple -> [counter o p] in if (filesList == nil) then 1 else let filesList -> [fstFile nxtFiles] in ( _RSCdownloadP this fstFile fstFile (mknode @pb_endDownload [counter o p]) nil counter; pb_downloadRes nxtFiles [(counter+1) o p]; ) ;; fun cbUpdateclass(from, action, param, ulist, tag, p) = /*SD*/ set updatePhoto = 1; /*_DLGMessageBox _channel nil "cbUpdateclass" "" 0;*/ UsendMessage ObUi p.ob_PB "updateClass" nil; 0 ;; /***************************************/ /* pb_newOb [Ob] I */ /* */ /* instances entry */ /***************************************/ fun pb_newOb (o) = /* if it's you */ if o==owner then ( MOVE_NewOb o; let M3createShell session -> sh in let M3createShell session -> sh0 in /* create ammos spot tab */ let mkAvImpacts [(mktab 10 nil) 10 0] -> avatarImpacts in let if (pbData == nil) then data_start else nil -> tmp in let mkPb [o pbData.itemIndex_PBDATA avatarImpacts nil nil nil nil nil nil nil 0x808080+(rand&0x7f7f)+((rand&0x7f)<<16) nil 1 nil 0] -> p in ( /* action from ItemsDistribution plugin */ _DMSdefineActions this [strcat class ".update" mkfun6 @cbUpdateclass p]:: [strcat class ".indicateItem" mkfun6 @item_indicate p]:: nil; set MOVE_cbManageKey = mkfun3 mkfun4 @PB_cbManageKey o p; M3setObjVec session sh0 [0 160 0]; let M3createSphere session 100 -> h in ( M3setObjVec session h [0 110 0]; M3link session h sh ); /* create ammos shell */ set p.ammoShell_PB = M3createShell session; M3link session p.ammoShell_PB sh0; set p.ammo2Shell_PB = M3createShell session; M3link session p.ammo2Shell_PB sh0; M3setObjVec session p.ammoShell_PB gunsLib.(p.itemIndex_PB).ammoAvPos_GEL; if (gunsLib.(p.itemIndex_PB).ammoAvPos2_GEL == nil) then nil else M3setObjVec session p.ammo2Shell_PB gunsLib.(p.itemIndex_PB).ammoAvPos2_GEL; M3link session sh0 sh; M3link session sh shellav; ObSetMain o sh0; ObCbDestroy o mkfun2 @pb_destroy p; /* MODIF 11-10 */ ObSetCam o; ObCbControlKeyDown o mkfun3 @pb_key p; ObCbControl o mkfun3 @pb_testWalk (ObControl o); /* deplacement de l'objet */ set myavatar = M3getFather session ObGetMain o; /* save the entry position of avatar */ set pbData.entryPos_PBDATA = M3getObjVec session myavatar; if (pbFlags.firstTime_PBF) then ( set pbFlags.firstTime_PBF = 0; /* set the postrender callbcack */ /* to the resources loading bar */ ObCbPostRender o @loading_render; /* download resources */ pb_downloadRes defines_getResFiles [1 o p]; 1 ) else /*des que l'on a tout download une fois on passe directement*/ ( /* the paintball plugin is completly started */ _DMSeventTag this (strcat class ".activated") nil nil nil; if pbData.alive_PBDATA==1 then /*dans le jeu*/ if updatePhoto==1 then pb_startOb o p 0 else nil else /*sur la page d'accueil*/ if updatePhoto==1 then ( /* si je change photo etant mort*/ pb_welcomeOb o p 0 /* noteleport*/ ) else ( /* si je click sur bouton paintballAv étant vivant*/ pb_welcomeOb o p 1; /*teleport*/ ); 0 ); 1 ); ) /* if it's somedoy else */ else ( /* copy avatar object */ /*_DLGMessageBox _channel nil "newOB others" ObName o 0;*/ let M3createShell session -> sh in let M3copyObj session avatar -> hnew in /* create ammos spot tab */ let mkAvImpacts [(mktab 10 nil) 10 0] -> avatarImpacts in let mkPb [o 1 avatarImpacts nil nil nil nil nil nil nil nil nil 1 nil 0] -> p in ( /* create ammos shell */ set p.gunShell_PB = M3createShell session; M3link session p.gunShell_PB hnew; set p.ammoShell_PB = M3createShell session; M3link session p.ammoShell_PB hnew; set p.ammo2Shell_PB = M3createShell session; M3link session p.ammo2Shell_PB hnew; M3link session hnew sh; ObSetMain o sh; ObCbAnim o mkfun2 @pb_anim [hnew 0]; ObCbDestroy o mknode @pb_destroy2 p; ObCbClick o mkfun5 @pb_click p; UcbMessage ObUi o ["shooted" mkfun4 @pb_shooted p]::/*["erase" mkfun4 @pb_erase p]::*/ ["load" mkfun4 @pb_loaded p]::["ammo" @shoot_shooted]:: ["infos" mkfun4 @pb_updateInfos p]::["printDialogueMsg" @pb_printDialogueMsg]:: ["printPlayersMsg" @pb_printPlayersMsg]::["spinachDamage" mkfun4 @pb_enableSpinachDamage p]:: ["AvState" @AvState]::["ListAvState" @ListAv]::nil; /* MODIF */ _DMSeventTag this (strcat class ".getPhoto") nil (UgetUser ObUi o)::nil [mkfun3 @pb_getphoto p 3600 0]; /*seb*/ /* tell the others what you loaded */ if !pbData.alive_PBDATA then ( UsendMessage ObUi owner "load" itoa 10; ) else ( /*_DLGMessageBox _channel nil "CLI AVSTATE 1" "" 0;*/ UsendMessage ObUi o "AvState" (linebuild (ObName o)::(itoa 1)::(itoa 1)::nil); /* MODIF 2208 */ UsendMessage ObUi owner "load" itoa pbData.itemIndex_PBDATA; /* MODIF 2208 */ ); /*fin seb*/ set pbs=p::pbs; set obOthers=o::obOthers; ); 0; ) ;; /* INITIALIZATION */ fun IniPlug(file) = /* librarys initialization */ defines_start; loading_start; /* start plugin initialization */ srand time; set class=getInfo strextr _getpack _checkpack file "name"; set avfile = strcat pbItemsPath "av.m3d"; M3load session avfile nil; set avatar=M3getObj session "avatar"; M3recursFillMatObj session avatar; PlugRegister class @pb_newOb nil; 0 ;;