OnPlayerDying

Répondre
Partager Rechercher
bon j'ai fais des essaie j'ai une constite de 16 donc un bonus de plus 3 je réussis bien les jets de vigueurs mais au lieu de gagné pv j'en pers



//Nombre de PV perdus par round
int nAgonie = 3;
//Nombre de PV gagnes par round en etant stabilise
int nRecup = 4;
//Delai en secondes entre la perte de PV (6.0 = 1 round)
float fDelai = 2.0;
//DC du Jet de Vigueur permettant de se stabiliser
int nDCFort = 13;
//% de chance d'etre stabilise (entre 1 et 6; 6=100%)
int nStab = 4;

void dying(object oDying, effect eSaigner)
{
int nPv = GetCurrentHitPoints(oDying);
if(nPv <= -15)
{
effect eMort = EffectDeath(FALSE, FALSE);
SpeakString("Vous etes mort.");
PlayVoiceChat(VOICE_CHAT_DEATH, oDying);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eMort, oDying);
return;
}
if (oDying != OBJECT_INVALID && nPv > 0)
{
SpeakString("Vous sortez de l'inconscience.");
PlayVoiceChat(VOICE_CHAT_LAUGH, oDying);
ClearAllActions();
return;
}
if (oDying != OBJECT_INVALID && nPv <= 0 && nPv > -15)
{
effect eAntiDmg = EffectDamageImmunityDecrease(DAMAGE_TYPE_MAGICAL, 100);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAntiDmg, oDying, 0.5);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eSaigner, oDying);
SendMessageToPC(oDying, "Vous sombrez dans l'inconscience.");
PlayVoiceChat(VOICE_CHAT_NEARDEATH, oDying);
int nStvig = FortitudeSave(oDying, nDCFort);
int nChanceStab;
switch(nStvig)
{
case 0:
nChanceStab = d10(1);
break;
case 1:
nChanceStab = d6(1);
break;
default:
nChanceStab = d10(1);
break;
}
if(nChanceStab <= nStab)
{
int nBonusCon = GetAbilityModifier(ABILITY_CONSTITUTION, oDying);
int nStabilise = (nBonusCon + nRecup);
SendMessageToPC(oDying, "Vous etes stabilise.");
effect eStabilise = EffectHeal(nStabilise);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eStabilise, oDying);
}
else
{
DelayCommand(fDelai, dying(oDying, eSaigner));
}
}
}

void main()
{
object oDying = GetLastPlayerDying();
effect eSaigner = EffectDamage(nAgonie);
PlayVoiceChat(VOICE_CHAT_HEALME, oDying);
DelayCommand(fDelai, dying(oDying, eSaigner));
}
Code PHP:

//Nombre de PV perdus par round
int nAgonie 3;
//Nombre de PV gagnes par round en etant stabilise
int nRecup 4;
//Delai en secondes entre la perte de PV (6.0 = 1 round)
float fDelai 2.0;
//DC du Jet de Vigueur permettant de se stabiliser
int nDCFort 13;
//% de chance d'etre stabilise (entre 1 et 6; 6=100%)
int nStab 4;

void dying(object oDyingeffect eSaigner)
{
    
int nPv GetCurrentHitPoints(oDying);
    if(
nPv <= -15)
    {
        
effect eMort EffectDeath(FALSEFALSE);
        
SpeakString("Vous etes mort.");
        
PlayVoiceChat(VOICE_CHAT_DEATHoDying);
        
ApplyEffectToObject(DURATION_TYPE_INSTANTeMortoDying);
        return;
    }
    if (
oDying != OBJECT_INVALID && nPv 0)
    {
        
SpeakString("Vous sortez de l'inconscience.");
        
PlayVoiceChat(VOICE_CHAT_LAUGHoDying);
        
ClearAllActions();
        return;
    }
    if (
oDying != OBJECT_INVALID && nPv <= && nPv > -15)
    {
        
effect eAntiDmg EffectDamageImmunityDecrease(DAMAGE_TYPE_MAGICAL100);
        
ApplyEffectToObject(DURATION_TYPE_TEMPORARYeAntiDmgoDying0.5);
        
ApplyEffectToObject(DURATION_TYPE_INSTANTeSaigneroDying);
        
SendMessageToPC(oDying"Vous sombrez dans l'inconscience.");
        
PlayVoiceChat(VOICE_CHAT_NEARDEATHoDying);
        
int nStvig FortitudeSave(oDyingnDCFort);
        
int nChanceStab;
        switch(
nStvig)
        {
            case 
0:
                
nChanceStab d10(1);
                break;
            case 
1:
                
nChanceStab d6(1);
                break;
            default:
                
nChanceStab d10(1);
                break;
        }
        if(
nChanceStab <= nStab)
        {
            
int nBonusCon GetAbilityModifier(ABILITY_CONSTITUTIONoDying);
            
int nStabilise = (nBonusCon nRecup);
            
SendMessageToPC(oDying"Vous etes stabilise.");
            
effect eStabilise EffectHeal(nStabilise);
            
ApplyEffectToObject(DURATION_TYPE_INSTANTeStabiliseoDying);
        }
            else
        {
            
DelayCommand(fDelaidying(oDyingeSaigner));
        }
    }
}

void main()
{
    
object oDying GetLastPlayerDying();
    
effect eSaigner EffectDamage(nAgonie);
    
PlayVoiceChat(VOICE_CHAT_HEALMEoDying);
    
DelayCommand(fDelaidying(oDyingeSaigner));

le code est entre [*PHP] et [*/PHP] sans les *
ok pardon je savais pas je recomence alors



Code PHP:


//Nombre de PV perdus par round
int nAgonie 3;
//Nombre de PV gagnes par round en etant stabilise
int nRecup 4;
//Delai en secondes entre la perte de PV (6.0 = 1 round)
float fDelai 2.0;
//DC du Jet de Vigueur permettant de se stabiliser
int nDCFort 13;
//% de chance d'etre stabilise (entre 1 et 6; 6=100%)
int nStab 4;

void dying(object oDyingeffect eSaigner)
{
int nPv GetCurrentHitPoints(oDying);
if(
nPv <= -15)
{
effect eMort EffectDeath(FALSEFALSE);
SpeakString("Vous etes mort.");
PlayVoiceChat(VOICE_CHAT_DEATHoDying);
ApplyEffectToObject(DURATION_TYPE_INSTANTeMortoDying);
return;
}
if (
oDying != OBJECT_INVALID && nPv 0)
{
SpeakString("Vous sortez de l'inconscience.");
PlayVoiceChat(VOICE_CHAT_LAUGHoDying);
ClearAllActions();
return;
}
if (
oDying != OBJECT_INVALID && nPv <= && nPv > -15)
{
effect eAntiDmg EffectDamageImmunityDecrease(DAMAGE_TYPE_MAGICAL100);
ApplyEffectToObject(DURATION_TYPE_TEMPORARYeAntiDmgoDying0.5);
ApplyEffectToObject(DURATION_TYPE_INSTANTeSaigneroDying);
SendMessageToPC(oDying"Vous sombrez dans l'inconscience.");
PlayVoiceChat(VOICE_CHAT_NEARDEATHoDying);
int nStvig FortitudeSave(oDyingnDCFort);
int nChanceStab;
switch(
nStvig)
{
case 
0:
nChanceStab d10(1);
break;
case 
1:
nChanceStab d6(1);
break;
default:
nChanceStab d10(1);
break;
}
if(
nChanceStab <= nStab)
{
int nBonusCon GetAbilityModifier(ABILITY_CONSTITUTIONoDying);
int nStabilise = (nBonusCon nRecup);
SendMessageToPC(oDying"Vous etes stabilise.");
effect eStabilise EffectHeal(nStabilise);
ApplyEffectToObject(DURATION_TYPE_INSTANTeStabiliseoDying);
}
else
{
DelayCommand(fDelaidying(oDyingeSaigner));
}
}
}

void main()
{
object oDying GetLastPlayerDying();
effect eSaigner EffectDamage(nAgonie);
PlayVoiceChat(VOICE_CHAT_HEALMEoDying);
DelayCommand(fDelaidying(oDyingeSaigner));

Voila le scrypt corrigé par notre ami commun a tous RAT.
(pour moi c'est un géni mais il veut pas que je le dise)


Code PHP:



//Nombre de PV perdus par round 
int nAgonie 2
//Nombre de PV gagnes par round en etant stabilise 
int nRecup 4
//Delai en secondes entre la perte de PV (6.0 = 1 round) 
float fDelai 2.0
//DC du Jet de Vigueur permettant de se stabiliser 
int nDCFort 13
//% de chance d'etre stabilise (entre 1 et 6; 6=100%) 
int nStab 4

void dying(object oDyingeffect eSaigner

int nPv GetCurrentHitPoints(oDying); 
if(
nPv <= -10

effect eMort EffectDeath(FALSEFALSE); 
SpeakString("Vous etes mort."); 
PlayVoiceChat(VOICE_CHAT_DEATHoDying); 
ApplyEffectToObject(DURATION_TYPE_INSTANTeMortoDying); 
return; 

if ((
oDying != OBJECT_INVALID) && (nPv 0)) 

DeleteLocalInt(oDying,"BLOKE_PC_MORT");
SpeakString("Vous sortez de l'inconscience."); 
PlayVoiceChat(VOICE_CHAT_LAUGHoDying); 
ClearAllActions(); 
return; 

if ((
oDying != OBJECT_INVALID) && ((nPv >-10) && (nPv <=0))) 

if (!
GetLocalInt(oDying,"BLOKE_PC_MORT"))
{
 
effect eAntiDmg EffectDamageImmunityDecrease(DAMAGE_TYPE_MAGICAL100); 
 
ApplyEffectToObject(DURATION_TYPE_TEMPORARYeAntiDmgoDying0.5); 
 
ApplyEffectToObject(DURATION_TYPE_INSTANTeSaigneroDying); 
 
SendMessageToPC(oDying"Vous sombrez dans l'inconscience."); 
 
PlayVoiceChat(VOICE_CHAT_NEARDEATHoDying); 
}
int nStvig FortitudeSave(oDyingnDCFort); 
int nChanceStab

switch(
nStvig

case 
0
nChanceStab d10(1); 
break; 
case 
1
nChanceStab d6(1); 
break; 
default: 
nChanceStab d10(1); 
break; 

if(
nChanceStab <= nStab

int nBonusCon GetAbilityModifier(ABILITY_CONSTITUTIONoDying); 
int nStabilise = (nBonusCon nRecup); 

if (!
GetLocalInt(oDying,"BLOKE_PC_MORT"))
SendMessageToPC(oDying"Vous etes stabilise.");
 
effect eStabilise EffectHeal(nStabilise); 
ApplyEffectToObject(DURATION_TYPE_INSTANTeStabiliseoDying); 
SetLocalInt(oDying,"BLOKE_PC_MORT",TRUE);
DelayCommand(fDelaidying(oDyingeSaigner));

else 
{
DelayCommand(fDelaidying(oDyingeSaigner)); 
 } 




void main() 

object oDying GetLastPlayerDying(); 
effect eSaigner EffectDamage(nAgonie); 
PlayVoiceChat(VOICE_CHAT_HEALMEoDying); 
DelayCommand(fDelaidying(oDyingeSaigner)); 

Arf mais pourquoi vous avez remonter ce vieux truc, tout le monde va voir qu'avec le temps, j'ai rien fait de tout ce que j'avais annoncé dans ce post
Ce script fonctionne bien chez ceux qui s'en servent ? j'ai fais quelques tests et j'ai l'impression qu'il ne fonctionne pas comme il devrait. Par exemple, mon personnage se stabilise alors qu'il rate son jet de sauvegarde.
haa oui, j'avais oublié ce truc. En fait il loupe le jet de fortitude mais fais quand même un score inf à 4 sur un jet de d10 ce qui le fait stabiliser. ok ok c'est moi ^^.

Par contre, j'ai quand même eu un bug en utilisant ce script, le PJ alors que je lui ai demandé de se reposer juste après avoir repris connaissance, ne pouvait pas se relever, il se déplaçait et reprenait une position de mort, si je lui demandais de se reposer, il se mettait en position puis reprenais une position de mort etc... La position mort était devenue la position normal pour lui :/.
Coucou,

Cela fait un moment que je n'ai plus touché à ce script, mais je pense que ça devrait marcher avec ça:

Code PHP:

//Nombre de PV perdus par round
int nAgonie 1;
//Nombre de PV gagnes par round en etant stabilise
int nRecup 1;
//Delai en secondes entre la perte de PV (6.0 = 1 round)
float fDelai 6.0;
//DC du Jet de Vigueur permettant de se stabiliser
int nDCFort 14;
//% de chance d'etre stabilise (entre 1 et 6; 6=100%)
int nStab 1;

void dying(object oDyingeffect eSaigner)
{
    
int nPv GetCurrentHitPoints(oDying);
    if(
nPv <= -10)
    {
        
effect eMort EffectDeath(FALSEFALSE);
        
SpeakString("Vous etes mort.");
        
PlayVoiceChat(VOICE_CHAT_DEATHoDying);
        
ApplyEffectToObject(DURATION_TYPE_INSTANTeMortoDying);
        return;
    }
    if (
oDying != OBJECT_INVALID && nPv 0)
    {
        
SpeakString("Vous sortez de l'inconscience.");
        
PlayVoiceChat(VOICE_CHAT_LAUGHoDying);
        
SetPlotFlag(oDyingFALSE);
        
ClearAllActions();
        return;
    }
    if (
oDying != OBJECT_INVALID && nPv <= && nPv > -10)
    {
        
effect eAntiDmg EffectDamageImmunityDecrease(DAMAGE_TYPE_MAGICAL100);
        
ApplyEffectToObject(DURATION_TYPE_TEMPORARYeAntiDmgoDying0.5);
        
ApplyEffectToObject(DURATION_TYPE_INSTANTeSaigneroDying);
        
SendMessageToPC(oDying"Vous sombrez dans l'inconscience.");
        
PlayVoiceChat(VOICE_CHAT_NEARDEATHoDying);
        
SetPlotFlag(oDyingTRUE);
        
int nStvig FortitudeSave(oDyingnDCFort);
        
int nChanceStab;
        switch(
nStvig)
        {
            case 
0:
                
nChanceStab d10(1);
                break;
            case 
1:
                
nChanceStab d6(1);
                break;
            default:
                
nChanceStab d10(1);
                break;
        }
        if(
nChanceStab <= nStab)
        {
            
int nBonusCon GetAbilityModifier(ABILITY_CONSTITUTIONoDying);
            
int nStabilise = (nBonusCon nRecup);
            
SendMessageToPC(oDying"Vous etes stabilise.");
            
effect eStabilise EffectHeal(nStabilise);
            
ApplyEffectToObject(DURATION_TYPE_INSTANTeStabiliseoDying);
        }
            else
        {
            
DelayCommand(fDelaidying(oDyingeSaigner));
        }
    }
}

void main()
{
    
object oDying GetLastPlayerDying();
    
effect eSaigner EffectDamage(nAgonie);
    
PlayVoiceChat(VOICE_CHAT_HEALMEoDying);
    
DelayCommand(fDelaidying(oDyingeSaigner));

Bien, j'arrive avec mes gros sabots vu que j'ai l'intention de me construire un petit module perso pour mon LAN avec le tit frère et je lis un peu ce qui se passe ici et je tombe sur ce script.
Alors je tiens à préciser que je n'ai pas encore lu les tutos (oui, c'est mal, j'ai un peu commencé à vrai dire) donc ne me grondez pas .

Bon, je voudrais quelques explications sur l'utilisation du switch/case. Je sais qu'il y en a déjà eu (parce que je les ai lues... c'est malin un tigre ) mais elles ne me semblent pas répondre à mon interrogation.
Je vais mettre mes interrogations en commentaire.

Code PHP:

int nStvig FortitudeSave(oDyingnDCFort);
//si j'ai bien compris, cette ligne effectue un test de vigueur et retourne 0 ou 1.
//Bon pour commencer, il n'y a pas un "type boolean" à la place du int ?
//(C'est pas que l'utilisation du 0 ou du 1 me dérange mais j'ai mes petites habitudes de prog moi).

int nChanceStab;
//Déclaration d'une variable entière ici si je ne me trompe pas.

switch(nStvig)
{
case 
0:
     
nChanceStab d10(1); break;

case 
1:
     
nChanceStab d6(1); break;

default:
     
nChanceStab d10(1); break;
}

//Interêt du switch/case ici ? un simple if n'aurait-il pas suffit ?
//Du genre :

if (nStvig//nStvig boolean si ça existe.
//Sinon, le C (c'est bien du C ou approchant non ?) ne considère-t-il pas le 0 ou 1 comme boolean
//(donc lui appliquant les traitements réservés aux booleans) ?
//Dans le pire des cas, un test (nStvig == 1) fait l'affaire.
{
nChanceStab d6(1);
//Si le test est réussi, la proba est de 1/6
}
else
{
nChanceStab d10(1);
//Dans tous les autres cas, la proba est de 1/10

Bref, c'est plus une question de simplicité de code ici, je ne vois pas de justification au switch/case. Une question d'éthique en somme. Pourquoi sortir le marteau de guerre +2 quand une simple pression du pouce suffit ?
Je m'égare, mais y-a-t-il une justification/subtilité que j'aurais omise ?

Et sinon, accessoirement, vous faites comment les indentations de votre code. Les tab ne passent pas et les espaces non plus apparement (enfin, j'ai ai mis 5 et ça fait rien ).
- En NWScript un Booléen est considéré de la même manière qu'un Integer.

- Le NWScript n'est pas du C, même si il y a des similitudes, tu ne peux pas appliquer tout ce que tu utilises en C ici.

Concernant l'utilisation du switch, oui un IF est plus simple dans le cas présent.
Au départ le script devait effectuer un jet de vigueur, et selon la marge de réussite ou d'erreur, appliquer plus ou moins de chance à la stabilisation. Le switch était donc utile, vu qu'il fallait un cas pour chaque marge de 1 à partir du DC.
Par la suite, la fonction "FortitudeSave" a été utilisée, afin de simplifier le système, et le switch a été purgé des cas inutiles.
Bien entendu il n'était plus nécessaire, mais la structure est restée, un peu comme une route pavée dans une section asphaltée.
Côté performance, c'est pareil, un switch ou un if pour un si petit test, ça change rien. Le switch n'est en fait qu'une astuce permettant d'y voir plus clair lors de tests multiples (mais bon ça je ne l'apprends à personne); mais ici il est vrai que ça fait quelques caractères en trop dans le script..... merci donc de venir te soucier de la pureté de nos scripts, je t'engagerais bien comme script-éboueur si tu t'ennuies
Merci.
Nan mais en fait je me demandais si il y avait un truc que je n'avais pas vu et qui aurait justifié l'utilisation du switch. Ton explication répond parfaitement à mon problème .
Merci pour les réponses .
Répondre

Connectés sur ce fil

 
1 connecté (0 membre et 1 invité) Afficher la liste détaillée des connectés