Genisys wrote...
ffbj wrote...
OH, you are going to tell me how to script. That's a laugh. Well no-one and I mean no-one, at least not to my knowledge ever said you did not have Hutzpah!ÂÂ
I'll laugh with you, he told me I can't script either...
Genesys, Laugh all you like, I've seen your code. Let's review the script I sent back to you corrected... first your original script of 89 lines intended to spawn interference (supercop) on 'improper use of a door' ...
//Script Name: sc_on_unlock
//////////////////////////////////////////
//Created By: Genisys (Guile)
//Created On: 8/19/08
/////////////////////////////////////////
/*
This will spawn in the Super Cop on
the PC for unlocking something they
were not suppose to!
*/
// GM_ODA NOTE: THE ABOVE DESCRIPTION SHOULD INCLUDE EVERYTHING THIS SCRIPT SHOULD DO
////////////////////////////////////////
#include "setxp_inc"
//Main Script
void main()
{
//Declare Major Variables
object oPlayer;
object oTarget;
object oSpawn;
object oMe = OBJECT_SELF;
location lTarget;
int nInt;
lTarget = GetLocation(oTarget); // GM_ODA NOTE: oTarget has not yet been given a value therefore this location will be invalid
//Let's make sure we define just who killed the NPC clearly..
// GM_ODA NOTE: who's talking about killing a NPC? this is on the on_unlocked script of an object!
if(!GetIsPC(GetLastUnlocked()))// GM_ODA NOTE: flawed code block used in numerous scripts in this set WILL NOT WORK AS INTENDED. Did you really test this stuff? As a PC and as a DM and as a npc possessed by a DM?
{
//if It's a DM stop here..
if(GetIsDMPossessed(GetLastUnlocked()))
{ return; }
if(GetIsDM(GetLastUnlocked()))
{ return; } // GM_ODA NOTE: this will NEVER fire, DM's are considered PCs too so would not be included in this if()'s subjects
// GM_ODA NOTE: it is a bad idea to re-invoke GetLastUnlocked() rather than set a variable to use it ONCE.
//IF It truly was an associate who attacked..
if(GetMaster(GetLastUnlocked())!=OBJECT_INVALID)
{
oPlayer = GetMaster(GetLastUnlocked());
}
else
{
oPlayer = GetLastUnlocked();
}
}
else
{
oPlayer = GetLastUnlocked(); // GM_ODA NOTE: this would mean DMs are possible values for the oPlayer ... not what was intended.
}
if(GetIsPC(oPlayer)) // GM_ODA NOTE: why do this same if() twice?
{
//Only Once Ever 30 Seconds!
int DoOnce = GetLocalInt(oPlayer, GetTag(OBJECT_SELF) + "SC");
if (DoOnce==TRUE) {return;}
SetLocalInt(oPlayer, GetTag(OBJECT_SELF) + "SC", TRUE);
DelayCommand(30.0, SetLocalInt(oPlayer, GetTag(OBJECT_SELF) + "SC", TRUE));
//Penalize the player!
ApplyRespawnPenalty(oPlayer);// GM_ODA NOTE: this was never offered in the description for the script. How is this going to work on your DM Avatar eh?
oTarget = oPlayer;
lTarget = GetLocation(oTarget); // GM_ODA NOTE: reduce this and prior line to "lTarget = GetLocation(oPlayer);"
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "supercop", lTarget);
oTarget = oSpawn;
int nInt; // GM_ODA NOTE: NEVER declare variables inside a conditional. This one is declared TWICE!
nInt = GetObjectType(oTarget);
// GM_ODA NOTE: regarding the following section, why would a OBJECT_TYPE_CREATURE you just spawned be anything but a OBJECT_TYPE_CREATURE
if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD), oTarget));
else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD), GetLocation(oTarget)));
AssignCommand(oPlayer, ClearAllActions());
}
//Main Script End
}
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Now the replacement/corrected script of 37 lines that I sent you for your edification.
//Script Name: pw_on_unlock ... supercedes sc_on_unlock - redux by GM_ODA
//sc_on_unlock Created By: Genisys (Guile)
//sc_on_unlock Created On: 8/19/08
/* This will spawn in the Super Cop on the PC for unlocking
something they were not suppose to! */
//Main Script
void main()
{
//Declare Major Variables
object oTarget,oSpawn,oPlayer,oMe = OBJECT_SELF, oTest = GetLastUnlocked();
int DoOnce;
string sControl;
if(!GetIsPC(oTest))
{
if(GetIsDMPossessed(oTest))return;
oPlayer = GetMaster(oTest);
} // resolve for all NPCs
else{oPlayer = oTest;}// resolve for PC
if( (!GetIsObjectValid(oPlayer)) || GetIsDM(oTest) )return; // exit if DM or object not valid
//Only Once Ever(y) 30 Seconds! - begin
sControl = GetTag(OBJECT_SELF) + "SC";
DoOnce = GetLocalInt(oPlayer, sControl);
if (DoOnce==TRUE) {return;}
SetLocalInt(oPlayer, sControl, TRUE);
DelayCommand(30.0, SetLocalInt(oPlayer, sControl, TRUE));
//Only Once Ever(y) 30 Seconds! - end
int nInt;
location lTarget = GetLocation(oPlayer);
CreateObject(OBJECT_TYPE_CREATURE, "supercop", lTarget);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD),lTarget);
AssignCommand(oPlayer, ClearAllActions());
} //Main Script End
*scratches head* Now, don't you wish you'd left that can of worms unopened 'Guile'?
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ffbj - what exactly was it that you say is 'not the way to do it. I only suggested that your use of AssignCommand was incorrect because it targets OBJECT_SELF and I can show you references that say DO NOT DO THIS. If I'm wrong I can accept that but in this case, I think you are confused.
Be well. Game on.
GM_ODA
Modifié par ehye_khandee, 02 septembre 2010 - 01:07 .