Trouble with Chrdeath.src

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Trouble with Chrdeath.src

Post by gundamwing84 »

hey guys, ive been setting up the old Sanctuary scripts to work and chrdeath is the only one im having trouble with, ive been thinking about how to fix this for 2 days now and trying different things but i just cant get around it :(

the code im having trouble with is:

Code: Select all

function SetUnconscious (statModAmount)
	Set_Critical (1);
	DoMagicStatMod (ghost, STATMOD_ALL, statModAmount, 360);
	if (!SetupUnconsciousPack())
		SendSysMessage (ghost, "There was an error creating an unconscious pack for your items");
		SendSysMessage (ghost, "Your items will remain on your corpse, but they are lootable!");
	endif
	Set_Critical (0);
	
	SysLog ("DEATH: " + ghost.name + " [Knockout] Time:" + ReadGameClock());
	
	Start_Script (":Mithril:UnconsciousTimer", ghost);
endfunction
DoMagicStatMod is comming up with an error stating that " (ghost, STATMOD_ALL, statmodamount, 360); " is not being declared. ive looked through all scripts and there is no .inc for domagicstatmod

Code: Select all

Compiling: D:/shard2/Broken Blade/scripts/misc/chrdeath.src
Variable ghost has not been declared on line 110.
Error compiling statement at D:\shard2\Broken Blade\scripts\misc\chrdeath.src, Line 110
Error in function 'SetUnconscious', File: D:\shard2\Broken Blade\scripts\misc\chrdeath.src, Line 110

Error in function 'SetUnconscious'.
File: D:\shard2\Broken Blade\scripts\misc\chrdeath.src, Line 110
there is no other definition for dostatmod in any of the include files, although i have found an actual script for domagicstatmod.src:

Code: Select all

program do_spell_statmod (parms)
	var cast_on := parms [1];
	var mod_type := parms[2];
	var mod_amount := parms[3];
	var duration := parms[4];

	if (!cast_on or !mod_type or !mod_amount or !duration)
		return;
	endif

	case (mod_type)
		STATMOD_PARALYZE:
			if (cast_on.cmdlevel or cast_on.enable ("invul"))
				return;
			endif
			if (GetObjProperty (cast_on, "prot_paralyze_potion") )
				SendSysMessage (cast_on, "You've been protected from being paralyzed!");
				sleepms (100);
				EraseObjProperty (cast_on, "prot_paralyze_potion");
				return;
			endif
			DoTempMod (cast_on, "p", mod_amount, duration);
		STATMOD_STR:
			if (mod_amount < 0)
				DoTempMod (cast_on, "cstr", mod_amount, duration);
			else
				DoTempMod (cast_on, "str", mod_amount, duration);
			endif
		STATMOD_INT:
			if (mod_amount < 0)
				DoTempMod (cast_on, "cint", mod_amount, duration);
			else
				DoTempMod (cast_on, "int", mod_amount, duration);
			endif
		STATMOD_DEX:
			if (mod_amount < 0)
				DoTempMod (cast_on, "cdex", mod_amount, duration);
			else
				DoTempMod (cast_on, "dex", mod_amount, duration);
			endif
		STATMOD_ALL:
			if (mod_amount < 0)
				DoTempMod (cast_on, "call", mod_amount, duration);
			else
				DoTempMod (cast_on, "all", mod_amount, duration);
			endif
		STATMOD_AR:
			if (mod_amount < 0)
				DoTempMod (cast_on, "car", mod_amount, duration);
			else
				DoTempMod (cast_on, "ar", mod_amount, duration);
			endif
		STATMOD_INCOGNITO:
			DoIncognitoStuff (cast_on, duration);
		default:
			Syslog ("Tried to do an invalid statmod!");
	endcase;
endprogram
^^^(this script is not being used for chrdeath, its just something i found in the sanctuary files under magic effects)



im not that great a scriptor yet so any help at all would be much appreciated
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Re: Trouble with Chrdeath.src

Post by CWO »

What its saying is, in the function SetUnconscious, there is no variable declared that is named "ghost" yet you're using it in that function. Since this is chrdeath.src, this variable will be pretty easy to find. Somewhere in the script there is a program or the entry point of the script. Somewhere along the lines of...

Code: Select all

program chrdeath(corpse, ghost)
the second variable could be ghost, it could be named something else but whatever that second variable is named, this is what you're looking for. If it is ghost, then this will be easy. If SetUnconscious is inside the program, just change the call to

Code: Select all

     SetUnconscious(statModAmount, ghost)
then change the function to read

Code: Select all

function SetUnconscious(statModAmount, ghost)
basically what you are doing is adding the variable to the function call and the definition so that it is passed into that function and used like it should.
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm

Re: Trouble with Chrdeath.src

Post by Yukiko »

I looked at my copy of the Sanctuary scripts. Here is the function as it appears in my copy:

Code: Select all

// Send message, mod stats, and start timer for pler being unconscious
function SetUnconscious( statModAmount )
    Set_Critical( 1 );
    DoMagicStatMod( gGhost, STATMOD_ALL, statModAmount, 360 );
    if( !SetupUnconsciousPack() )
        SendSysMessage( gGhost, "There was an error creating an unconscious pack for your items" );
        SendSysMessage( gGhost, "Your items will remain on your corpse, but they are lootable!" );
    endif
    Set_Critical( 0 );

    SysLog( "DEATH: " + gGhost.name + " [Knockout] Time:" + ReadGameClock() );

    Start_Script( ":mithril:UnconsciousTimer", gGhost );
endfunction
Note the gGhost declaration rather than ghost. Near the beginning of chrdeath.src those variables are declared:

Code: Select all

// Package Includes
include ":npcs:npcbackpacks";

var gGhost;
var gCorpse;
I should note that my copy of the Sanctuary scripts are the final release version (I think POL 0.94 compatible). So if you are looking at a modified version it might be that someone made a mistake and didn't use the proper variable name in the function call.
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Trouble with Chrdeath.src

Post by gundamwing84 »

CWO:
hey there CWO, ive checked through the script again and there is 2 callings for setunconscious but im not completely sure if i can add (,ghost) into it: heres the full script that i have (may be different to origional as ive re-written it myself, although word to word just been updated a tiny bit to work with pol 95 and different spacings).

Code: Select all

use uo;
use os;
use util;

// var Includes
include "include/skills";
include "include/poison";
include "include/possess";
include "include/utility";
include "include/dotempmods";
include "include/myutil";
include "include/magic";

// Package Includes
include ":npcs:npcbackpacks";

program CharacterDeath(corpse, ghost)
	SysLog(TypeOf(ghost));
	
	SendInstaResDialog (ghost);
	EraseAllSkillBonuses (ghost);
	CurePoison (ghost);
	
	SetObjProperty (corpse, "ghost_serial", ghost.serial);
	DismountGhost(ghost, corpse);
	
	if (ghost.cmdlevel)
		if (GetObjProperty (ghost, "possess"))
			UnpossessCorpse (ghost, corpse);
		endif
		return;
	else
		RevokePrivilege (ghost, "hearghosts");
		RevokePrivilege (ghost, "seeghosts");
	endif
	
	InitiateDeathSystem(ghost);
Endprogram

//checks for horse, if so dismounts
function DismountGhost (ghost, corpse)
	foreach item in EnumerateItemsInContainer (corpse)
		if (item.objtype == UOBJ_MOUNT)
			Dismount (ghost, item);
		endif
	endforeach
endfunction

//deathsystem (based on sanctuary)
function InitiateDeathSystem(ghost)
	//get the players death history
	var deathHistory := GetObjProperty (ghost, "deathHistory");
	if (!deathHistory)
		deathHistory :=array;
	endif
	
	//saves current time
	var curTime := ReadGameClock();
	
	//checks if this is their first death, or if their first was before 1 hour ago
	if ((!deathHistory[1]) or ((deathHistory[1]  + 3600) < curTime))
		SetDeathHistory (curTime);
		SetUnconscious (-10);
		return;
		//check if this is their second death
	elseif (deathHistory [1] and !deathHistory[2])
		SetDeathHistory (deathHistory [1], curTime);
		SetUnconscious (-20);
		return;
	endif
	
	
	//send message and take skill loss
	SendSysMessage (ghost, "You have died, and lost some valuable Knowledge...");
	SkillLoss();
	
	//broadcast player death to all online
	foreach player in (EnumerateOnlineCharacters())
		PlaySoundEffectPrivate (player, 0x101, player);
		SendSysMessage (player, ghost.name + "'s death cry is heard throughout the land!", FONT_NORMAL, 48);
	endforeach
	
	//resets death history
	SetDeathHistory(ghost);
	
	SysLog ("DEATH: " + ghost.name + " [True Death] Time: " + ReadGameClock());
	
	//start the death time for player
	Start_Script (":mithril:DeathTimer", ghost);
endfunction

//sets the players death history to the values provided, zero if not
function SetDeathHistory (ghost, firstDeath := 0, secondDeath := 0)
	var deathHistory :=array;
	
	deathHistory[1] := firstDeath;
	deathHistory[2] := secondDeath;
	
	SetObjProperty (ghost, "deathHistory", deathHistory);
endfunction

//send message, mod stats and start timer for pler being unconscious
function SetUnconscious (statModAmount)
	Set_Critical (1);
	DoMagicStatMod (ghost, STATMOD_ALL, statModAmount, 360);
	if (!SetupUnconsciousPack())
		SendSysMessage (ghost, "There was an error creating an unconscious pack for your items");
		SendSysMessage (ghost, "Your items will remain on your corpse, but they are lootable!");
	endif
	Set_Critical (0);
	
	SysLog ("DEATH: " + ghost.name + " [Knockout] Time:" + ReadGameClock());
	
	Start_Script (":Mithril:UnconsciousTimer", ghost);
endfunction

//true death has skill loss!
function SkillLoss()
	Set_Critical (1);
	
	for i := 48
		if (RandomInt (2))
			var attribute := GetAttributeIDBySkillID (i);
			var ghostskill := GetAttributeBaseValue (ghost, attribute);
			ghostskill := CINT (ghostskill * 0.99);
			SetRawSkill (ghost, attribute, BaseToRaw (ghostskill));
		endif
	endfor
	Set_Critical (0)l
endfunction

Function SetupUnconsciousPack()
	corpse.name := "the unconscious body of " + ghost.name;
	
	var unconsciousPack;
	var ghostBank := FindBankBox (ghost.acctname);
	if (ghostBank)
		UnconsciousPack := CreateItemInContainer (ghostBank, 0xe75, 1);
	else
		SysLog ("Can't find " + ghost.name + "'s Bankbox! Making pack in packroom.");
		unconsciousPack := CreateItemAtLocation (6049, 2279, 0, 0xe75, 1);
	endif
	
	if (!unconsciousPack)
		SysLog ("Could not create an unconscious pack for " + ghost.name);
		return 0;
	endif
	
	unconsciousPack.decayat := 0;
	unconsciousPack.name := ghost.name + "'s unconscious pack";
	unconsciousInfo["PackSerial"] := unconsciousPack.serial;
	SetObjProperty (ghost, "unconsciousInfo", unconsciousInfo);
	
	foreach item in ListRootItemsInContainer (corpse)
		MoveItemToContainer (item, unconsciousPack);
	endforeach
	
	return1;
endfunction
now then i put ,ghost into the parts SetUnconscious were:

Code: Select all

	//checks if this is their first death, or if their first was before 1 hour ago
	if ((!deathHistory[1]) or ((deathHistory[1]  + 3600) < curTime))
		SetDeathHistory (curTime);
		SetUnconscious (-10, ghost);
		return;
		//check if this is their second death
	elseif (deathHistory [1] and !deathHistory[2])
		SetDeathHistory (deathHistory [1], curTime);
		SetUnconscious (-20, ghost);
		return;
	endif
and

Code: Select all

function SetUnconscious (statModAmount, ghost)
	Set_Critical (1);
	DoMagicStatMod (ghost, STATMOD_ALL, statModAmount, 360);
	if (!SetupUnconsciousPack())
		SendSysMessage (ghost, "There was an error creating an unconscious pack for your items");
		SendSysMessage (ghost, "Your items will remain on your corpse, but they are lootable!");
	endif
	Set_Critical (0);

but then i get this error while compiling:
Compiling: D:/shard2/Broken Blade/scripts/misc/chrdeath.src
Function SetUnconscious: Parameter ghost was not passed, and there is no default.
Error compiling statement at D:\shard2\Broken Blade\scripts\misc\chrdeath.src, Line 68
Error in IF statement starting at File: D:\shard2\Broken Blade\scripts\misc\chrdeath.src, Line 66
Error compiling statement at D:\shard2\Broken Blade\scripts\misc\chrdeath.src, Line 66
Error in function 'InitiateDeathSystem', File: D:\shard2\Broken Blade\scripts\misc\chrdeath.src, Line 68

Error in function 'InitiateDeathSystem'.
File: D:\shard2\Broken Blade\scripts\misc\chrdeath.src, Line 68
Yukiko:

yeah that was me, as ive been going through each script ive been writing it back in so i can make sense of what everything does, i changed all the variables for gGhost and gCorpse to just ghost and corpse because it didnt make sense to me haha, although i have changed them back to gGhost and gCorpse and im still getting the exact same error :( as you have the scripts you can tell there is no other calling for DoMagicStatMod except for "function setunconscious" in the script and there is no function description of it linked to it :(

any other ideas on what could be wrong? (thanks for the prompt reply guys! :D )
Tomi
POL Developer
Posts: 478
Joined: Tue Feb 21, 2006 5:08 pm

Re: Trouble with Chrdeath.src

Post by Tomi »

You are calling function SetUnconscious with just 1 param when it expects 2 and thats why the following message
Function SetUnconscious: Parameter ghost was not passed, and there is no default.

and about the first problem you had
DoMagicStatMod (ghost, STATMOD_ALL, statModAmount, 360);

remove the space between function name and ( because now it reads them separate

And seems like you are having the same problem with SetUnconscious and alot other functions too, the unconscoius compile problems seems to because of that aswell
SetUnconscious (-20); again no space between function name and (
Polytropon
New User
Posts: 19
Joined: Wed Sep 15, 2010 9:47 pm

Re: Trouble with Chrdeath.src

Post by Polytropon »

There should be a guide about compiler warnings and errors, as a complement to the EScript guide.

Although they seem pretty obvious when you know them, I can´t help remembering when I was 13 and they made me learn Pascal at school. I would´ve killed to know what "Boolean expression expected" meant :P
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Trouble with Chrdeath.src

Post by gundamwing84 »

it compiles! i added in , ghost to everything that involved SetUnconscious and then, removed the spacings for all functions, eg SetUnconscious (statMODall,ghost) is now SetUnconscious(statMODall, ghost) :) thankyou all of you who helped im very grateful, now to fix all the compiler warnings! :((((

youll hear from me again, but hopefully not too soon we all hope :)

thanks again guys, mat
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Trouble with Chrdeath.src

Post by gundamwing84 »

also thankyou very much for that info about the spacings tomi i had no idea about that :)
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Trouble with Chrdeath.src

Post by Turley »

Erm spaces between function and ( serious?
Dont think so :)

Code: Select all

function test 				
	(i)
	
	print   	(i);
endfunction

program blubb       		()
	test 					("it works!");
endprogram
Works perfectly as expected.
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Trouble with Chrdeath.src

Post by gundamwing84 »

:x im confused do i put spacings in or not? haha
User avatar
AsYlum
Grandmaster Poster
Posts: 115
Joined: Sun Feb 05, 2006 5:24 am

Re: Trouble with Chrdeath.src

Post by AsYlum »

gundamwing84 wrote::x im confused do i put spacings in or not? haha
It doesn't matter. Just try to maintain consistent coding style in all your scripts ;)
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Trouble with Chrdeath.src

Post by gundamwing84 »

ahh ill remember that thanks :)
Post Reply