Artifact Chest 2.0

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
In response to this crap I have decided to come up with yet another artifact system…

This is my idear:

- Artifact chest spawns, sorts through its items based solely on the number of players
- Some items require X# of players, the rest merely have spawn chances multiplied by # of players present
- To clarify: ANY number of players present will increase spawn chances, this new style artifact won’t care about hitpoints, time on, or what not

After the artifact chest sorts that out, it will decide who gets what – but instead of by strength, it will choose by who got the most “damage points”:

Damge Points:
To encourage cooperative game play – “damage points” will be awarded for healing other players (+100) and ice shielding other players (+1000). You will get various obscene amounts of damage points for other aiding activities as they become available, in addition to the obvious: for doing damage to enemies. (And no, beating your summons or fellow players will not count.) You will also lose 1000 damage points for death, regardless of how it came about.

The game master will keep track of your damage points and tie them to a steamed. Every time you get more than 1000 damage points, the game_master will be updated, and your player’s personal counter will reset. This should prevent overflows from gathering huge amounts of damage points on a single map, and will allow you to keep damage points if you get disconnected.

…okay… Now the fun part.

Instead of picking an item randomly, the artifact chest will give the player with the most damage points a pop-up menu, listing all the items it contains.

The player will not have to go to the chest, the pop-up menu will come up wherever he maybe, and the item he chooses from the list will pop-up in his hands, wherever he maybe.

After he chooses his item, the artifact chest will choose the next player with the next most damage points, and so on, and so forth, until its passed out all the items it has to give, or runs out of players to give them to. (one item per player)

This is the first draft of the code:

Code:
//Black chest, the revenge
//- new string and token handling might simplify this mess, so I thought
{
	const ANIM_IDLE idle
	const ANIM_CLOSE close
	const ANIM_OPEN open
	const LIGHT_COLOR (200,200,255)
	const LIGHT_RAD 96
}

{ game_spawn

	//spawn invisible

	hp 1
	invincible  2
	name ''
	width 20
	height 30
	setmodel	misc/treasure.mdl
	setmodelbody 0 1
	setidleanim	ANIM_IDLE

	setsolid none

	setprop ent_me rendermode 5
	setprop ent_me renderamt 0

	setvard BC_DISCONNECTS 0
}

{ game_dynamically_created //<token_items> <token_chances> <token_req_players> <token_disp_names>

	setvard IBC_ITEM_LIST PARAM1
	setvard IBC_ITEM_CHANCES PARAM2
	setvard IBC_REQ_PLAYERS PARAM3
	setvard IBC_ITEM_NAMES PARAM4

	if ( IBC_ITEM_LIST startswith 'PARAM' ) infomsg all "THOTH FUCKED UP (Artifact Chest)" "Dude, artifact this chest has no items!"
	if ( IBC_ITEM_CHANCES startswith 'PARAM' ) infomsg all "THOTH FUCKED UP (Artifact Chest)" "Artifact this chest no spawn chances!"
	if ( IBC_REQ_PLAYERS startswith 'PARAM' ) infomsg all "THOTH FUCKED UP (Artifact Chest)" "Artifact this chest no req players!"
	if ( IBC_ITEM_NAMES startswith 'PARAM' ) infomsg all "THOTH FUCKED UP (Artifact Chest)" "Artifact chest items have no names!"

	if ( PARAM8 isnot 'PARAM8' ) setvard FACE_YAW $vec.yaw(PARAM8) //compatiblity

	setvard ARTIFIACT_DEBUG "ARTIFACT_CHEST ("
	stradd ARTIFIACT_DEBUG game.map.name
	stradd ARTIFIACT_DEBUG "):"

	if ( game.cvar.ms_chatlog ) chatlog $timestamp(>) ARTIFIACT_DEBUG full_inventory: IBC_ITEM_NAMES req_players: IBC_REQ_PLAYERS spawn_chances: IBC_ITEM_CHANCES

	getplayersnb PLAYER_LIST
	setvard N_PLAYERS $get_token_amt(PLAYER_LIST)
	callevent 0.1 filter_items

	if G_DEVELOPER_MODE
	setvard DEV_PLAYER ''
	getplayer DEV_PLAYER 1
	if ( G_DEVELOPER_MODE )
	{
		consolemsg DEV_PLAYER ARTY_DEBUG: ARTIFIACT_DEBUG full_inventory:
		consolemsg DEV_PLAYER ARTY_DEBUG: - items: IBC_ITEM_NAMES
		consolemsg DEV_PLAYER ARTY_DEBUG: - players: IBC_REQ_PLAYERS
		consolemsg DEV_PLAYER ARTY_DEBUG: - chances: IBC_ITEM_CHANCES
	}
}

{ filter_items

	if ( FACE_YAW isnot 'FACE_YAW' ) setangle face $vec(0,FACE_YAW,0)

	//remove items that fail spawn chances, or there are not enough players for
	setvard REMOVE_ITEMS ''
	calleventloop $get_token_amt(IBC_ITEM_LIST) filter_items_loop
	if ( $get_token_amt(REMOVE_ITEMS) == $get_token_amt(IBC_ITEM_LIST) )
	{
		if ( game.cvar.ms_chatlog ) chatlog $timestamp(>) ARTIFIACT_DEBUG Removed: all items failed spawn chance rolls.
		deleteent ent_me //got nadda
		local EXIT_SUB 1
	}
	if !EXIT_SUB

	callevent 0.1 remove_items //give a sec for strings to propigate
}

{ filter_items_loop

	local CUR_IDX game.script.iteration
	local CUR_ITEM_REQ_PLAYERS $get_token(IBC_REQ_PLAYERS,CUR_IDX)
	if ( N_PLAYERS < CUR_ITEM_REQ_PLAYERS )
	{
		local REMOVE_ITEM 1
		if G_DEVELOPER_MODE
		consolemsg DEV_PLAYER ARTY_DEBUG: CUR_IDX ( $get_token(IBC_ITEM_LIST,CUR_IDX) ) marked for removal (player req)
	}

	local CUR_ITEM_SPAWNCHANCE $get_token(IBC_ITEM_CHANCES,CUR_IDX)
	multiply CUR_ITEM_SPAWNCHANCE N_PLAYERS
	if ( $rand(1,100) > CUR_ITEM_SPAWNCHANCE )
	{
		local REMOVE_ITEM 1
		if G_DEVELOPER_MODE
		consolemsg DEV_PLAYER ARTY_DEBUG: CUR_IDX ( $get_token(IBC_ITEM_LIST,CUR_IDX) ) marked for removal (spawn chance)
	}

	if REMOVE_ITEM
	token.add REMOVE_ITEMS $get_token(IBC_ITEM_LIST,CUR_IDX)
}

{ remove_items

	if ( G_DEVELOPER_MODE ) consolemsg DEV_PLAYER ARTY_DEBUG: Remove_item_list: REMOVE_ITEMS

	calleventloop $get_token_amt(REMOVE_ITEMS) remove_items_loop
	if ( game.cvar.ms_chatlog ) chatlog $timestamp(>) ARTIFIACT_DEBUG final_inventory: IBC_ITEM_NAMES req_players: IBC_REQ_PLAYERS spawn_chances: IBC_ITEM_CHANCES
	if ( G_DEVELOPER_MODE )
	{
		consolemsg DEV_PLAYER ARTY_DEBUG: ARTIFIACT_DEBUG final_inventory:
		consolemsg DEV_PLAYER ARTY_DEBUG: - items: IBC_ITEM_NAMES
		consolemsg DEV_PLAYER ARTY_DEBUG: - players: IBC_REQ_PLAYERS
		consolemsg DEV_PLAYER ARTY_DEBUG: - chances: IBC_ITEM_CHANCES
	}

	callevent 0.5 choose_player
}

{ remove_items_loop

	local CUR_IDX game.script.iteration
	local ITEM_TO_REMOVE $get_token(REMOVE_ITEMS,CUR_IDX)
	local REMOVE_IDX $get_find_token(IBC_ITEM_LIST,ITEM_TO_REMOVE) 

	if ( G_DEVELOPER_MODE )	consolemsg DEV_PLAYER ARTY_DEBUG: Removing ( $get_token(IBC_ITEM_LIST,REMOVE_IDX) )

	//doing this from here, rather than callevent remove_item, to be safer
	token.del IBC_ITEM_LIST REMOVE_IDX
	token.del IBC_ITEM_CHANCES REMOVE_IDX
	token.del IBC_REQ_PLAYERS REMOVE_IDX
	token.del IBC_ITEM_NAMES REMOVE_IDX
}

{ choose_player

	setvard STRONGEST_IDX 0
	setvard STRONGEST_STAT_LEVEL 0
	calleventloop $get_token_amt(PLAYER_LIST) find_strongest_player
	setvard THE_CHOSEN_ONE $get_token(PLAYER_LIST,STRONGEST_IDX)
	setvard THE_CHOSEN_ONE_IDX STRONGEST_IDX
	token.del PLAYER_LIST STRONGEST_IDX
	callevent inform_player
}

{ find_strongest_player

	local CUR_IDX game.script.iteration
	local CUR_PLAYER $get_token(PLAYER_LIST,CUR_IDX)
	local PLAYER_STAT $get(CUR_PLAYER,scriptvar,PLR_TOTAL_DMG) //newfunc in player_main/game_master +1000 for heal/iceshield -1000 for death
	if ( PLAYER_STAT > STRONGEST_STAT_LEVEL )
	{
		setvard STRONGEST_STAT_LEVEL PLAYER_STAT
		setvard STRONGEST_IDX CUR_IDX
	}
}

{ inform_player

	if ( !I_MANIFESTED )
	{
		//I have items, manifest
		name Artifact Chest
		playsound 0 10 magic/spawn.wav
		setvard I_MANIFESTED 1
		clientevent persist all monsters/lighted_cl $get(ent_me,index) LIGHT_COLOR LIGHT_RAD
		setvard MY_LIGHT_IDX game.script.last_sent_id
		callexternal GAME_MASTER gm_fade_in $get(ent_me,id) 5
	}
	infomsg THE_CHOSEN_ONE "ARTIFACT CHEST: YOU HAVE BEEN CHOSEN!" "Select and item of your choosing..."
	playanim hold ANIM_OPEN
	menu.open THE_CHOSEN_ONE
}

{ game_menu_getoptions

	calleventloop $get_token_amt(IBC_ITEM_LIST) list_items
}

{ list_items

	local CUR_IDX game.script.iteration
	local CUR_ITEM_NAME $get_token(IBC_ITEM_NAMES,CUR_IDX)

	local reg.mitem.title 	CUR_ITEM_NAME
	local reg.mitem.type 	callback
	local reg.mitem.data CUR_IDX
	local reg.mitem.callback give_item
	menuitem.register
}

{ game_menu_cancel

	//player clicked cancel on the pop-up menu
	local RESP_STRING $get(PARAM1,name)
	strconc RESP_STRING " " has declined to partake in the bounty
	infomsg all "ARTIFACT CHEST" RESP_STRING
	playanim once ANIM_CLOSE
	token.del PLAYER_LIST THE_CHOSEN_ONE_IDX //remove player from list
	callevent 2.0 next_winner
}

{ give_item //<prize_winner> <item_idx>

	if ( G_DEVELOPER_MODE )	consolemsg DEV_PLAYER ARTY_DEBUG: Menu Select PARAM2

	local CUR_ITEM $get_token(IBC_ITEM_LIST,PARAM2)
	local CUR_ITEM_NAME $get_token(IBC_ITEM_NAMES,PARAM2)
	offer PARAM1 CUR_ITEM
	local RESP_STRING $get(PARAM1,name)
	strconc RESP_STRING " " has recieved a CUR_ITEM_NAME from an Artifact Chest. (NO ROLLING!)
	infomsg all "ARTIFACT CHEST" RESP_STRING

	if ( game.cvar.ms_chatlog ) chatlog $timestamp(>) ARTIFIACT_DEBUG $get(PARAM1,name) chose a CUR_ITEM_NAME

	local ITEM_IDX PARAM2
	callevent remove_item ITEM_IDX

	token.del PLAYER_LIST THE_CHOSEN_ONE_IDX //remove player from list
	playanim once ANIM_CLOSE
	callevent 2.0 next_winner
}

{ next_winner

	if ( $get_token_amt(IBC_ITEM_LIST) == 0 )
	{
		callevent fade_away //out of stuff
		local ALL_DONE 1
	}
	if ( $get_token_amt(PLAYER_LIST) == 0 )
	{
		callevent fade_away //out of players
		local ALL_DONE 1
	}

	if !ALL_DONE
	callevent 1.0 choose_player
}

{ remove_item //<item_idx>
	token.del IBC_ITEM_LIST PARAM1
	token.del IBC_ITEM_CHANCES PARAM1
	token.del IBC_REQ_PLAYERS PARAM1
	token.del IBC_ITEM_NAMES PARAM1
}

{ fade_away

	//passed out everything I had, or ran out of players to pass stuff to, fade out
	playsound 0 10 magic/spawn.wav
	clientevent remove all MY_LIGHT_IDX
	callexternal GAME_MASTER gm_fade_out $get(ent_me,id)
	callevent 3.0 fade_away2
}

{ fade_away2

	deleteent ent_me
}

Potential abuse:
The few potential abuses I see are all reportable, and would result in removal from FN server auth, they’d include:
- Bots: This wouldn’t actually work, as the player filter is smart enough to detect bots, but since the chat bug is fixed in next release, and thus there is no reason for them, bots will be illegal on FN
- Kicking the most active player at the last second: If this happens, report it. We will remove FN auth. If the strongest player gets kicked after the chest spawns, it will lock.
- Logging on with multiple steam accounts to increase spawn chances: This I can’t do much about. I don’t think it’s worth bringing in HP/AFK requirements to prevent though, as they will just complicated the code. If I see it happening, or get reports of such I’ll risk it, but for now, I’m trying to KISS this, as the artifact chests are notoriously buggy.

Ideas? Suggestions? Opinions? Discuss:

edits: code update
 

Sabre

New Adventurer
MSC Developer
RiP
Joined
Aug 24, 2004
Messages
4,545
Reaction score
1
Age
32
Location
SoCal
This...Would be perfect.
Wow, a month-long break from coding, and you and MiB are coming out with all sorts of awesome shit :D
 
  • Thread starter
  • Admin
  • #3

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Heh, sadly, just because I skipped a month on releases, does not mean I took a break. ><
 

Moira

New Adventurer
Joined
Nov 2, 2007
Messages
25
Reaction score
0
Nice solution to the problems!
Thank you for you hard work.
 
  • Thread starter
  • Admin
  • #5

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Also might be good to point out ahead of time: if you don't want any item the artifact lists to you, hit cancel - and it'll offer the same items to the player with the next highest damage points.
 

Mikkel

New Adventurer
MSC Developer
The Pirates of Dreadwind
Joined
Feb 13, 2007
Messages
1,000
Reaction score
0
Age
28
Location
Denmark
Yaaay.


CAN I HAS 10.000.000 gold?
 

Blasto121

New Adventurer
MSC Developer
The Pirates of Dreadwind
Joined
May 24, 2006
Messages
1,967
Reaction score
0
Age
35
Location
Eugene, OR
YAY I might actually get a chance at an item finally! :D

anyway good job thothie, looking over that code I can see why they can be so buggy, hopefully this can all work out without to much issue.
 
  • Thread starter
  • Admin
  • #9

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
This chest seems to be working fine at the moment... Next trick is getting the Damage Point system to work proper.

Sample arti chest (with crap items), case scripters were curious how to implement:

Code:
		local ITEM_LIST "swords_shortsword;health_apple;item_torch;mana_mpotion"
		local ITEM_CHANCES "50;50;50;100"
		local REQ_PLAYERS  "1;2;1;1"
		local ITEM_NAMES "Shortsword;Apple;Torch;Mana Potion"
[...]
		createnpc chests/black_chest2 SPAWN_POINT ITEM_LIST ITEM_CHANCES REQ_PLAYERS ITEM_NAMES

In that example, the apple requires 2 players to be present, everything else only requires 1, and all have a 50% spawn chance, save the mana potion, which spawns 100% of the time.
 

Shurik3n

New Adventurer
MSC Developer
RiP
Joined
Aug 15, 2006
Messages
1,357
Reaction score
0
Age
31
Sounds really good, just a suggestion though, I think the death penalty should be higher. IMO healing a boss doesn't even out to shielding somebody.
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Shurik3n said:
Sounds really good, just a suggestion though, I think the death penalty should be higher. IMO healing a boss doesn't even out to shielding somebody.
If anyone with less than 500hp dies to a boss, they'll be adding less than 1000 hitpoints to that boss (with the exception of Calrian and Atholo - and Ice Queen stage #3). But there's also the fact that I've no way of distinguishing between types of deaths from the script side dependably, atm, and thus you also lose points when you die to hazards. (Which might be a good thing, makes hazards less of a welcome escape.)
 

CrazyMonkeyDude

New Adventurer
MSC Developer
RiP
Joined
Jun 29, 2007
Messages
2,619
Reaction score
2
Age
32
Hrm. So... This'll make the higher level bosses a little bit more... Interesting. (Using hazard deaths to escape healing the bosses, recharge mana, etc., will become a pain in the ass.) I think there should be a way to escape from bosses(namely Atholo, cause then someone could just sit outside the boss room and get first pick for doing nothing while everyone else loses points by dieing) should this be implemented.

Other than that, I like this idea a lot.
 

Sabre

New Adventurer
MSC Developer
RiP
Joined
Aug 24, 2004
Messages
4,545
Reaction score
1
Age
32
Location
SoCal
Problem is that this might bring back the "IMMA RETRY AND EVADE DETH AND NAO I GET LEWT LOLOL" phase in some people.
Can you perhaps put a retry 'threshold?' i.e.: You reconnect too much, you start losing/lose all your points
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
CrazyMonkeyDude said:
Hrm. So... This'll make the higher level bosses a little bit more... Interesting. (Using hazard deaths to escape healing the bosses, recharge mana, etc., will become a pain in the ass.) I think there should be a way to escape from bosses(namely Atholo, cause then someone could just sit outside the boss room and get first pick for doing nothing while everyone else loses points by dieing) should this be implemented.

Other than that, I like this idea a lot.

Workaround for that maybe to reset everyone's damage points when a boss spawns. It might not make the previous points useless - as I may find uses for damage points in regular chests as well.

Problem is that this might bring back the "IMMA RETRY AND EVADE DETH AND NAO I GET LEWT LOLOL" phase in some people.
Can you perhaps put a retry 'threshold?' i.e.: You reconnect too much, you start losing/lose all your points
Blarg... True... The whole retain points on reconnect is difficult to implement too. Disconnects, in which the server doesn't go down, are rare enough that I suppose that I could just drop that aspect ('specially if I have trouble getting it to work right).
 

Picadilly

New Adventurer
The True Followers of the Lost
Joined
Jan 10, 2007
Messages
176
Reaction score
0
Location
Taipei
I'm amazed that Thothie finds the time to do all this...
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
I got some time off from babysitting old folk, as the one with the shingles is getting well enough to spend more time on his own. However, I have to start hosting a LARP in about two weeks, thus I'm trying to cram in as much stuff as I can...

MiB has been a HUGE help these past few days as well, a lot of the newer stuff would be impossible without him (even these chests take advantage of a few new script functions he introduced). I'm afraid I get the sense he's burning out though. (I ride my coders way too hard.)
 

CrazyMonkeyDude

New Adventurer
MSC Developer
RiP
Joined
Jun 29, 2007
Messages
2,619
Reaction score
2
Age
32
Thothie said:
Problem is that this might bring back the "IMMA RETRY AND EVADE DETH AND NAO I GET LEWT LOLOL" phase in some people.
Can you perhaps put a retry 'threshold?' i.e.: You reconnect too much, you start losing/lose all your points
Blarg... True... The whole retain points on reconnect is difficult to implement too. Disconnects, in which the server doesn't go down, are rare enough that I suppose that I could just drop that aspect ('specially if I have trouble getting it to work right).

Not for me. I tend to get dropped a lot. :\
 

The Man In Black

Administrator
Staff member
Administrator
Moderator
RiP
Joined
Jul 9, 2006
Messages
6,904
Reaction score
68
I think the ice shield bonus is too high. Unless you do the reset-when-boss-spawns, you could get a guy ice shielding throughout the level when it does nothing, just to get points.

I can probably get it so you can tell what killed the player via the scripts.

We may be able to call a special event when the player uses 'retry' or 'reconnect'

I'm getting a bit burned out, but I've a feeling it has to do with the code itself, not with you. Could also be RL things ;-)
 

FER

New Adventurer
MSC Developer
RiP
Joined
Sep 16, 2006
Messages
2,758
Reaction score
0
Age
34
Location
on Belser's army
Can't it be done the same way as the xp penalty? (lose xp by monsters, nothazard)
 

Thothie

Administrator
Staff member
Administrator
Moderator
MSC Archivist
Joined
Apr 8, 2005
Messages
16,342
Reaction score
326
Location
lost
Yeah, but it'd be kinda nice to have something to make it worth your while to avoid hazards,
other than the fact you have to walk back to the battle.

In totally unrelated forum stretching news, here's Helena at midnight under the new lighting system:
(clicky to enlarge)
helena_midnight_thumb.jpg
helena_midnight2_thumb.jpg
helena_midnight3_thumb.jpg
Lights, actually... Stay bright! ;)

Tis a particularly nice effect with the fireplace lighting coming out the door (prob coulda got a better screenie).

This also has a nice 24 step lightning gradient that alters every hour. It's pretty smooth
except for the 16->17 hour transition (day to dusk) - although, it's no more jarring than before.

Sadly, this requires a client-side patch, so you won't see this on the ultra-beta or anything.
 

Blasto121

New Adventurer
MSC Developer
The Pirates of Dreadwind
Joined
May 24, 2006
Messages
1,967
Reaction score
0
Age
35
Location
Eugene, OR
thats pretty sweet no more need to make it daylight again on a server, the time can finally just flow.
 

villager

New Adventurer
RiP
Joined
Nov 21, 2006
Messages
1,272
Reaction score
0
Age
32
Freaking awesome, I can't wait to actually use my firewood :D
 

Wrath

New Adventurer
Joined
Jun 8, 2007
Messages
351
Reaction score
0
Age
30
Wow thats amazing! :D I like the way this system sounds. :eek:
 
Top