angelwraith Posted April 17, 2011 Share Posted April 17, 2011 (edited) i have a pretty simple script that is needed to attribute the kill to the player after being killed with a script placed explosion.the kill command allows this but i also need it to NOT run on actors that were already dead because the very fact that the kill command can run endlessly on dead actors is what makes it useful to me but also makes it screw up what i need. this is what i have, its not working and im not sure why. what it should do, set a initialized variable if the script acts on a living actor and then after death if that variable is set itll run the kill command on the actor.so, if the explosion hits someone thats alive, and then they die while still effected by the script it should run the kill command on them once to attribute the kill to that actor, and give the proper experience. SCN SUBkillcreditSCRIPT ref meREF int inited begin scripteffectstart set meREF to getself if meREF.getdead == 0 set inited to 1 endif end begin scripteffectupdate if meREF.getdead == 1 && inited == 1 meREF.kill player 0 0 set inited to 0 endif end i had the script below, which works as far as giving the player the kill but runs on already dead actors, so its possible to just shoot other peoples kills gain the kill responsibility and to gain xp, also if theres a dead friendly soldier and the explosion hits them it attributes the death and experience to the player..no beuno.. dont need to be responsible for soldiers that were killed some other way: this DOES NOT DO WHAT I NEED but proves the concept works.. just need better conditionals. if you've got an idea, help is greatly appreciated. SCN SUBkillcreditSCRIPT ref meREF int inited begin gamemode if meREF.getdead == 1 && inited == 0 meREF.kill player 0 0 set inited to 1 endif end Edited April 17, 2011 by angelwraith Link to comment Share on other sites More sharing options...
angelwraith Posted April 17, 2011 Author Share Posted April 17, 2011 ok so i hate that i posted this now, cause as usual i gave up 30 seconds too soon. ive been hammering away at this since i started my mod a couple of months ago, its been driving me crazy as what i had worked but not exactly the way i wanted and right after posting this i realized there was a simple stupid way to achieve what i needed. how i fixed it? scrapped the idea of tracking the enemies and their states. what i figured out:i dont need to run kill on dead actors to get what i need.i just need to apply the damage the explosion was creating through script and instead, on the last shot run the kill command. duh. now works 100% the way i want in game. Link to comment Share on other sites More sharing options...
rickerhk Posted April 17, 2011 Share Posted April 17, 2011 For future reference, GetSelf returns zero for spawned actors, so that may have been some of the problem. Also, on a script effect running on an actor, you don't need to use GetSelf to get the actor's ref, because functions run on the actor implicitly.Soif (GetDead) if (IsKiller Player) return valid data in a Scripteffect that has been applied to an actor. Link to comment Share on other sites More sharing options...
angelwraith Posted April 17, 2011 Author Share Posted April 17, 2011 (edited) wow... you actually had the function i was searching for and for some reason could not find: IsKiller Player effectively cut my script down from like 30 lines to 5 begin gamemode if IsKiller Player != 1 && getdead == 1 kill player 0 0 ; attributes kill and xp to player endif end much better thank you soo very much. changed it again to not run on anything that wouldnt have been an enemy to try to avoid accidentilly attributing a friendly's death to the player. seems to work.SCN SUBkillcreditSCRIPT begin gamemode if ( IsKiller Player != 1 && getdead == 1 ) && ( GetCombatTarget == player || GetFactionRelation player == 1 || (GetFactionRelation player == 0 && GetAV Aggression >= 2) ) kill player 0 0 ; attributes kill and xp to player endif end Edited April 17, 2011 by angelwraith Link to comment Share on other sites More sharing options...
majinshinsa Posted April 17, 2011 Share Posted April 17, 2011 i need this script too for a perk i am writing. this will make it run (course i might be talking too soon) my script runs an effect upon killing so i think this will work for me too Link to comment Share on other sites More sharing options...
Recommended Posts