String to object?
#1
Posté 05 avril 2011 - 10:11
#2
Posté 05 avril 2011 - 10:58
But doing it in reverse wouldn't make much sense since an item only has this string once it is created. Did you want to assign a specific hexidecimal string to an object?
If you are just trying to creat items from strings then you would just use res refs and the functions: CreateItemOnObject, CreateObject.
Perhaps a bit more info about what you want to accomplish would help out?
#3
Posté 05 avril 2011 - 11:43
the script is as clean as it could get while still doing what i want it to while i still understand whats going on in it
Below you can find the script but it wont compile if i uncomment the real lines of code with // in front of them since those lines are getting mismatched type error.
#include "nw_i0_plot"
//start of no xp loss and no gp loss function
void ApplyPenalty(object oPC)
{
//start variables (by default all are 0)
int nXP = GetXP(oPC) - 0;//set the 0 to the amount xp you want to take
int nGP = 0;//set the 0 to the amount gold you want to take
SetLocalInt(GetModule(), "gp_penalty_on", 0);//set to 1 if you are going to take a penalty for gold else leave 0
SetLocalInt(GetModule(), "xp_penalty_on", 0);//set to 1 if you are going to take a penalty for xp else leave 0
//end variables
SetXP(oPC, nXP);
AssignCommand(oPC, TakeGoldFromCreature(nGP, oPC, TRUE));
//the script will do this if gold penalty and xp penalty are turned off
if (GetLocalInt(GetModule(), "gp_penalty_on")== 0 && GetLocalInt(GetModule(), "xp_penalty_on")== 0)
{FloatingTextStringOnCreature("You have respawned without gold loss and without experience loss", oPC, FALSE);}
//the script will do this if gold penalty is turned on and xp penalty is turned off
else if(GetLocalInt(GetModule(), "gp_penalty_on")== 1 && GetLocalInt(GetModule(), "xp_penalty_on")== 0)
{FloatingTextStringOnCreature("You have respawned with gold loss", oPC, FALSE);}
//the script will do this if xp penalty is turned on and gold penalty is turned off
else if(GetLocalInt(GetModule(), "xp_penalty_on")== 1 && GetLocalInt(GetModule(), "gp_penalty_on")== 0)
{FloatingTextStringOnCreature("You have respawned with experience loss", oPC, FALSE);}
//the script will do this if xp penalty is turned on and gold penalty is turned on
else if(GetLocalInt(GetModule(), "xp_penalty_on")== 1 && GetLocalInt(GetModule(), "gp_penalty_on")== 1)
{FloatingTextStringOnCreature("You have respawned with experience and gold loss", oPC, FALSE);}
}
//end of no xp loss and no gp loss function
//start how much hp to restore of respawn function
void Rez(object oPC)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);
RemoveEffects(oPC);
//start of soul stone code that can be removed
do//while the player has the soul stone item
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPC)), oPC);
DestroyObject(GetItemPossessedBy(oPC, "soulstoneitem"));
} while (GetItemPossessedBy(oPC, "soulstoneitem") != OBJECT_INVALID);
//end of soul stone code that can be removed
do//while the player does not have the soul stone item
{ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetCurrentHitPoints(oPC) + 1), oPC);}
while (GetItemPossessedBy(oPC, "soulstoneitem") == OBJECT_INVALID);
}//end how much hp to restore on respawn function
//start function that determines where the player respawns
void Destination(object oPC)
{
int hasrezshrine;//variable that can not be erased or script will break
object oPC;
object oTarget;
switch (GetLocalInt(GetArea(oPC), "hasrezshrine"))
{
//start case 0 (if the area DOES NOT have a rez shrine)
case 0:
//if there is a set bindpoint on the player rez at it
if(GetCampaignString("bindpointdatabase", "sBindPoint", oPC) != "")
//{oTarget = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);}
//end if there is a set bindpoint on the player
//if there IS NOT a set bindpoint on the player
if (GetCampaignString("bindpointdatabase", "sBindPoint", oPC) == "")
{
//if there is a module default respawn point rez at it
if (GetIsObjectValid(GetWaypointByTag("NW_DEATH_TEMPLE")) == TRUE)
{oTarget = GetWaypointByTag("NW_DEATH_TEMPLE");}
//end if there is a module default respawn point
//if there IS NOT a module default respawn point rez where you are
//if (GetIsObjectValid(GetWaypointByTag("NW_DEATH_TEMPLE")) == FALSE)
//{oTarget = GetLocation(oPC);}
//end if there IS NOT a module default respawn point
}//end if there IS NOT a set bindpoint on the player
break;//end case 0 (if the area DOES NOT have a rez shrine)
//start case 1 (if the area DOES have a rez shrine)
case 1:
//if the player found a rez shrine
if (GetLocalInt(oPC, "foundrezshrine") == 1)
{oTarget = GetNearestObjectByTag("rezshrine");}
//end if the player found a rez shrine
//if the player DID NOT find rez shrine
if (GetLocalInt(oPC, "foundrezshrine") == 0)
{
//if there is a set bindpoint on the player rez at it
//if(GetCampaignString("bindpointdatabase", "sBindPoint", oPC) != "")
//{oTarget = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);}
//end if there is a set bindpoint on the player
//if there IS NOT a set bindpoint on the player
if (GetCampaignString("bindpointdatabase", "sBindPoint", oPC) == "")
{
//if there is a module default respawn point rez at it
if (GetIsObjectValid(GetWaypointByTag("NW_DEATH_TEMPLE")) == TRUE)
{oTarget = GetWaypointByTag("NW_DEATH_TEMPLE");}
//end if there is a module default respawn point
//if there IS NOT a module default respawn point rez where you are
//if (GetIsObjectValid(GetWaypointByTag("NW_DEATH_TEMPLE")) == FALSE)
//{oTarget = GetLocation(oPC);}
//end if there IS NOT a module default respawn point
}//end if there IS NOT a set bindpoint on the player
}//end if the player DID NOT find rez shrine
break;//end case 1 (if the area DOES have a rez shrine)
}//end switch
}//end function that determines where the player respawns
void main()
{
object oPC = GetLastRespawnButtonPresser();
object oTarget;//the respawn point the script will pick
location lTarget;
Destination(oPC);//sets the respawn point to use
Rez(oPC);//rez and heals the player
//sets the respawn point chosen by the script as the destination to send the player to
lTarget = GetLocation(oTarget);
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionJumpToLocation(lTarget));
ApplyPenalty(oPC);//by bioware default it should remove gold and xp but i changed that
}
Modifié par Ryuhi2000, 05 avril 2011 - 11:55 .
#4
Posté 06 avril 2011 - 12:01
//{oTarget = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);}
//{oTarget = GetLocation(oPC);}
//{oTarget = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);}
#5
Posté 06 avril 2011 - 12:07
oTarget = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);
To this:
oTarget = GetWaypointByTag(GetCampaignString("bindpointdatabase", "sBindPoint", oPC));
Hope it helps.
#6
Posté 06 avril 2011 - 12:09
Ryuhi2000 wrote...
the three mismatch lines are below and yes i know the one line is there twice it has to be since the code is mirrored everything from the else if the player has not found the rez shrine has to happen if the switch is run under case 0
//{oTarget = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);}
//{oTarget = GetLocation(oPC);}
//{oTarget = GetCampaignString("bindpointdatabase", "sBindPoint", oPC);}
For all 3 of these lines you are telling an object to be either a string or a location. oTarget has to be an object. This is why you are getting the mismatched type.
#7
Posté 06 avril 2011 - 12:21
void Rez(object oPC)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);
RemoveEffects(oPC);
//start of soul stone code that can be removed
if (GetItemPossessedBy(oPC, "soulstoneitem") != OBJECT_INVALID)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPC)), oPC);
DestroyObject(GetItemPossessedBy(oPC, "soulstoneitem"));
}
else
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetCurrentHitPoints(oPC) + 1), oPC);
}
}//end how much hp to restore on respawn function
No need to do any "do while" loops if you aren't looping through anything.
And since the Resurrection effect already heals the player to 1 hp you don't even need that "else" which adds another hit point..unless the desire is for the player to have 2 hps. So you could further condense it like so:
void Rez(object oPC)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);
RemoveEffects(oPC);
//start of soul stone code that can be removed
if (GetItemPossessedBy(oPC, "soulstoneitem") != OBJECT_INVALID)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPC)), oPC);
DestroyObject(GetItemPossessedBy(oPC, "soulstoneitem"));
}
}//end how much hp to restore on respawn function
Modifié par GhostOfGod, 06 avril 2011 - 12:27 .
#8
Posté 06 avril 2011 - 12:34
and i had looping just because the old version of it on nwvault had a cluster EFF of ifs so i tried to avoid if everywhere i could in the script lol but yeah i only need it to run once not loop
#9
Posté 06 avril 2011 - 12:52
#include "nw_i0_plot"
//start of no xp loss and no gp loss function
void ApplyPenalty(object oPC)
{
//start variables (by default all are 0)
int nXP = GetXP(oPC) - 0;//set the 0 to the amount xp you want to take
int nGP = 0;//set the 0 to the amount gold you want to take
SetLocalInt(GetModule(), "gp_penalty_on", 0);//set to 1 if you are going to take a penalty for gold else leave 0
SetLocalInt(GetModule(), "xp_penalty_on", 0);//set to 1 if you are going to take a penalty for xp else leave 0
//end variables
SetXP(oPC, nXP);
AssignCommand(oPC, TakeGoldFromCreature(nGP, oPC, TRUE));
//the script will do this if gold penalty and xp penalty are turned off
if (GetLocalInt(GetModule(), "gp_penalty_on")== 0 && GetLocalInt(GetModule(), "xp_penalty_on")== 0)
{FloatingTextStringOnCreature("You have respawned without gold loss and without experience loss", oPC, FALSE);}
//the script will do this if gold penalty is turned on and xp penalty is turned off
else if(GetLocalInt(GetModule(), "gp_penalty_on")== 1 && GetLocalInt(GetModule(), "xp_penalty_on")== 0)
{FloatingTextStringOnCreature("You have respawned with gold loss", oPC, FALSE);}
//the script will do this if xp penalty is turned on and gold penalty is turned off
else if(GetLocalInt(GetModule(), "xp_penalty_on")== 1 && GetLocalInt(GetModule(), "gp_penalty_on")== 0)
{FloatingTextStringOnCreature("You have respawned with experience loss", oPC, FALSE);}
//the script will do this if xp penalty is turned on and gold penalty is turned on
else if(GetLocalInt(GetModule(), "xp_penalty_on")== 1 && GetLocalInt(GetModule(), "gp_penalty_on")== 1)
{FloatingTextStringOnCreature("You have respawned with experience and gold loss", oPC, FALSE);}
}
//end of no xp loss and no gp loss function
//start how much hp to restore of respawn function
void Rez(object oPC)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);
RemoveEffects(oPC);
//start of soul stone code that can be removed
if (GetItemPossessedBy(oPC, "soulstoneitem") != OBJECT_INVALID)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPC)), oPC);
DestroyObject(GetItemPossessedBy(oPC, "soulstoneitem"));
}
}//end how much hp to restore on respawn function
//start function that determines where the player respawns
void Destination(object oPC)
{
object oArea = GetArea(oPC);
int iShrineCheck = GetLocalInt(oArea, "hasrezshrine");
object oTarget;
//if there is a set bindpoint on the player teleport to it
if (GetCampaignString("bindpointdatabase", "sBindPoint", oPC) != "")
{
oTarget = GetWaypointByTag(GetCampaignString("bindpointdatabase", "sBindPoint", oPC));
AssignCommand(oPC, ActionJumpToObject(oTarget));
}
//else if there is a shrine in the area teleport to it
else if (iShrineCheck == 1)
{
oTarget = GetNearestObjectByTag("rezshrine", oPC, 1);
AssignCommand(oPC, ActionJumpToObject(oTarget));
}
//else if there is a valid death temple WP then teleport to it
else if (GetIsObjectValid(GetWaypointByTag("NW_DEATH_TEMPLE")) == TRUE)
{
oTarget = GetWaypointByTag("NW_DEATH_TEMPLE");
AssignCommand(oPC, ActionJumpToObject(oTarget));
}
}//end function that determines where the player respawns
void main()
{
object oPC = GetLastRespawnButtonPresser();
Rez(oPC);//rez and heals the player
ApplyPenalty(oPC);//by bioware default it should remove gold and xp but i changed that
Destination(oPC);//player respawns at appropriate waypoint
}
I haven't tested this or anything but just figured I'd point out how you can streamline it a bit.
Modifié par GhostOfGod, 06 avril 2011 - 12:53 .
#10
Posté 06 avril 2011 - 01:34
Modifié par Ryuhi2000, 06 avril 2011 - 01:36 .
#11
Posté 06 avril 2011 - 02:31
#12
Posté 06 avril 2011 - 04:20
#13
Posté 04 mai 2011 - 05:35





Retour en haut






