Aegis Support Board: Hooking Up Globvars - Aegis Support Board

Jump to content

ASB News! ASB 5.0 Beta V2 has now been released!. See here for more Info.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Hooking Up Globvars

#1 User is offline   Kasuha 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 195
  • Joined: 08-February 05

Posted 18 June 2006 - 05:33 AM

In order to prevent our alchemists to transcend with a homunculus alive, I have implemented this simple way of checking the homunculus state:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetGlobalVar]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetGlobalVar]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO



CREATE PROCEDURE [GetGlobalVar]
@Key char(255),
@Data int output
AS

if @Key LIKE 'HOMUNTEST%'
begin
	declare @id int
	set @id = SUBSTRING(@Key, 10, 30)
	select @Data = Modified from HomunInfo where GID = @id
	if @@ROWCOUNT < 1
	begin
		set @Data = 255
	end
	return 1
end
else
begin
	select @Data = data from GlobalVar where keyname = @Key

	if @@ROWCOUNT > 0
	begin
		return 1
	end
	else
	begin
		return 0
	end
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


The code to check the homunculus state looks like this:

		var gvname = v[VAR_CHARACTERID]
		gvname = "HOMUNTEST" + gvname
		var hstate = GetGlobalVar gvname


At the end, hstate may contain the following values:
0 ... unnamed alive
1 ... named alive
2 ... unnamed vaporized
3 ... named vaporized
4 ... unnamed dead
5 ... named dead
255 ... no homunculus at all
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users