Aller au contenu

Photo

problem trying to make one script trigger another


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
el.sombrero

el.sombrero
  • Members
  • 100 messages
 Hey there,

 So, I'm using a trigger on the floor, just after a door, that does this same door be closed and locked.
 I would like that when this door is closed, the player would suffer HP damage. The catch is that the "deal damage" function can't be on the trigger at the floor, I need it to be on the door. I tried to create a simple script that deals damage do the pc and put it "on closed" at the door properties, it compiles ok but it isnt working... the script that I'm trying to use on the door is bellow. Anyone has any ideas?

void main(){
object PC;
effect eEffect;

eEffect = EffectDamage(3, DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_NORMAL);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, PC);

FloatingTextStringOnCreature("Consequence to door closing is ok", PC);
}

#2
kevL

kevL
  • Members
  • 4 078 messages
- a line seems missing:


PC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);

#3
el.sombrero

el.sombrero
  • Members
  • 100 messages
Lets try it... and YES, now it is working!
Can you explain me why this line is necessary. I thought that "object PC" automatically setted the player as object to that effect.
thx!

#4
kevL

kevL
  • Members
  • 4 078 messages
object oPC;

is only a declaration. "I declare there will be object_variable, oPC!" At that point, the compiler says, yeh okay so what?

So you have to tell Mr. compiler, "I hereby define object_variable oPC as GetNearestCreature(...)!"

then the compiler goes, i can work with that. Only then can you go on to say what to do with oPC .....


[ look what you did there with eEffect : same thing. ]

Modifié par kevL, 02 août 2012 - 10:21 .


#5
kevL

kevL
  • Members
  • 4 078 messages
If oPC were a predefined constant you could get away with it. But as it is it's just a variable and needs a user-made definition

#6
el.sombrero

el.sombrero
  • Members
  • 100 messages
Uhm... I thought that if I typed "PC" instead of "oPC" I would be appealing to a constant, instead of a variable.. How do I refer to the player constant? do I have to create it?

#7
kevL

kevL
  • Members
  • 4 078 messages
I've always defined it. There are some string constants defined in 'ginc_param_const' that seem to rely on internal workings of the engine, but they're strings. So unless oPC is conveniently OBJECT_SELF there are a handful of functions that can be used ...

more

+ SetOwnersControlledCompanion( )

- that prolly covers it

Modifié par kevL, 06 août 2012 - 10:08 .