wrenchman82
Member
Hi All,
This question has been addressed here and there, but I can't seem to get it to work the way I want it. I have an enemy who occasionally spawns a shield, and that shield should absorb all the hits until it dies. I've repurposed some scripts I found in the DnD Rise of Warduke game (masterpiece, that one), and have it mostly working except that the parent still takes damage as usual. Upon summoning, I've tried this:
Which works, and when the shield is destroyed, I use this in the shield script:
In theory, this should make the parent immune to all forms of attacks, and revert it when the shield is destroyed no? Am I missing something?
The spawning script is:
@cmd spawnShield
This question has been addressed here and there, but I can't seem to get it to work the way I want it. I have an enemy who occasionally spawns a shield, and that shield should absorb all the hits until it dies. I've repurposed some scripts I found in the DnD Rise of Warduke game (masterpiece, that one), and have it mostly working except that the parent still takes damage as usual. Upon summoning, I've tried this:
Code:
anim follow2
@script
if(frame==8){
void self = getlocalvar("self");
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL1"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL2"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL3"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL4"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL5"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL6"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL7"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL8"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL9"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL10"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_NORMAL13"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_BURN"), 0, 500);
changeentityproperty(self, "defense", openborconstant("ATK_SHOCK"), 0, 500);
}
@end_script
Which works, and when the shield is destroyed, I use this in the shield script:
Code:
anim death
@script
if(frame==2){
void self = getlocalvar("self");
void Parent = getentityvar(self, 0);
if(Parent){
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL1"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL2"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL3"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL4"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL5"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL6"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL7"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL8"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL9"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL10"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_NORMAL13"), 1, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_BURN"), 0.4, 1);
changeentityproperty(Parent, "defense", openborconstant("ATK_SHOCK"), 0.4, 1);
setentityvar(Parent, 0, NULL());
}
killentity(self); //Suicide!
}
@end_script
In theory, this should make the parent immune to all forms of attacks, and revert it when the shield is destroyed no? Am I missing something?
The spawning script is:
@cmd spawnShield
Code:
void spawnShield(void Name, float dx, float dy, float dz, int Health)
{ // Spawn Shield entity, bind it, store it and set health
void Spawn;
Spawn = spawnBind2(Name, dx, dy, dz, 0, 0, 0);
changeentityproperty(Spawn, "maxhealth", Health);
changeentityproperty(Spawn, "health", Health);
}
void spawnBind2(void Name, float dx, float dy, float dz, int Dir, int Flag, int Num)
{ // Spawn entity, bind it and store each other
void self = getlocalvar("self");
void Spawn;
Spawn = spawn01(Name, dx, dy, dz);
bindentity(Spawn, self, dx, dz, dy, Dir, Flag);
setentityvar(self, Num, Spawn);
setentityvar(Spawn, Num, self);
return Spawn; //Return spawn
}