Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Alright... Before I go on recreating the charge component in the hacky and probably not very good way which include 3 actions that check for stuff and animation combining, do you have good idea on how to recreate it properly in mind?
...Or am I being overly complicated and missing something as simple as an 'onHitEntity'?
My asset pack [v1.10]
Features a bit of everything! :D
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

MonsterChargeComponent would be pretty obnoxious to recreate. I recommend giving it an attack power of 0 (should stop it from damaging the champions entirely) and using the onEndAction() hook to inflict damage instead - I think all you'd have to do is check if the party is directly in front of the monster when the charge ends.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 »

minmay wrote: edit: oops I just realized you were probably talking about MonsterChargeComponent.
Have you designed a party Charge attack minmay??
Has anyone attempted this?

I have thought about this and how to - on the shelf for now - but a rough idea:
SpoilerShow

Code: Select all

all champs must be ready to attack, have sufficient energy and not immobilized by -paralyzed, slow - conditions 
release secondary attack from a weapon or shield while the party is moving forward (check)
monster up to 3 squares ahead -pits ok , just fall down - no obstacles, check line of fire
disable party inputs, movement, free look etc 
(maybe even get data first then disable champions /remove party while charging)
increase party move speed >> then call party:move (possibly use delayed call to charge 2nd square)
Sounds - heavy footsteps + power attack yell?
Maybe add some screen tilting forward?
Calculate damage - based on aforementioned damage protection (monster type & group as well)
knockback monsters (unless tentacles or juggernaught etc)
OR if the monster is massive / too heavy like a Golem/Warden or party collides with a monster also charging - maybe no knockback >> but injure/damage champions instead 
damage monsters, shake screen
make each champ attack as charge connects, returning false to remove swipes (but you dont get cooldown effects hmm) 
SO/OR.... 
delay the enabling of party inputs movement etc to mimic a cooldown moment??
reduce energy based on distance charged/moved
Thoughts anyone?
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Are we talking about an alternative charge attack for monsters (Like the ogre)?

Strictly off the cuff, I'd think use of the party knockback should do the job of the impact effect to the party; with a flash of the injury screen effect, and screen-shake.
Damage (I haven't thought about yet); I had considered a tileDamager, but for minmay's mention of individual damage based on chest armor.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 »

Isaac wrote:Are we talking about an alternative charge attack for monsters (Like the ogre)?

Strictly off the cuff, I'd think use of the party knockback should do the job of the impact effect to the party; with a flash of the injury screen effect, and screen-shake.
Damage (I haven't thought about yet); I had considered a tileDamager, but for minmay's mention of individual damage based on chest armor.
(assuming youre responding to me) Nope - I was referring to a Charge Attack made by / for the Party
(similar to the Ogres yes, but triggered through a weaponor shield secondary action)

---------------------------------------------------

Unrelated Question : is there any way / what is the best way to determine if the player has imported a party?
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

A party charge attack could have the potential to break puzzles due to increased movement speed; a controllable [aimed] charge, even more so.
akroma222 wrote:Unrelated Question : is there any way / what is the best way to determine if the player has imported a party?
Perhaps checking for XP at the start of the game; (XP you didn't give them).
*Checking for equipment too.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

akroma222 wrote:Have you designed a party Charge attack minmay??
No, and I don't plan to.
akroma222 wrote:Unrelated Question : is there any way / what is the best way to determine if the player has imported a party?
As far as I know you cannot determine this from the user scripting interface with 100% accuracy. The closest you could get is to verify that the party looks like it could have been created as a new party - 2 total skill points on every champion (3 if they are a human with Skilled), all baseStats are reachable from the baseline values and initial stat points, no more than 2 traits all of which are valid character creation traits, 0 xp, etc. etc. etc.
If you do this correctly it will 100% stop the player from "cheating" by importing a more powerful party. However they can still import a party with traits that do not exist in your dungeon; there is no way for you to detect that, and it will cause a crash when they cast a spell blah blah blah you probably know about that already.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 »

Isaac wrote:A party charge attack could have the potential to break puzzles due to increased movement speed; a controllable [aimed] charge, even more so.
Good call ;)
Isaac wrote: Perhaps checking for XP at the start of the game; (XP you didn't give them).
*Checking for equipment too.
minmay wrote:As far as I know you cannot determine this from the user scripting interface with 100% accuracy. The closest you could get is to verify that the party looks like it could have been created as a new party - 2 total skill points on every champion (3 if they are a human with Skilled), all baseStats are reachable from the baseline values and initial stat points, no more than 2 traits all of which are valid character creation traits, 0 xp, etc. etc. etc.
Yup, thought I may have to do it this way via a bunch of checks - Thanks both of you :P
minmay wrote:However they can still import a party with traits that do not exist in your dungeon; there is no way for you to detect that, and it will cause a crash when they cast a spell blah blah blah you probably know about that already.

I do indeed - just to confirm - there is naught I can do about this..... except mention explicitly in a readMe file NOT to import any party from another Mod??
I seem to recall someone working on an import party conversion script.... (not that Im interested in implementing it)
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

akroma222 wrote:I do indeed - just to confirm - there is naught I can do about this..... except mention explicitly in a readMe file NOT to import any party from another Mod??
I seem to recall someone working on an import party conversion script.... (not that Im interested in implementing it)
That was the save editor, which includes a button to remove nonstandard traits from the party to prevent this crash. But that's a tool for users to use, you can't integrate it in your mod obviously. There's no practical way to get rid of all the nonstandard traits from within your mod itself, because you don't know what the names of those traits are.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Here is an experimental charge attack for the party; implemented as a magical "Horn of Berserker Charge'.

*It's not necessarily balanced for play, but it does have some usage checks (and experimental limitations). As-is it may well allow the breaking puzzles that can be broken by a faster than expected party —provided they don't need to change direction during the charge.
Feel free to make changes.

Just add & equip the horn to use.

Code: Select all

--items.lua
defineObject{
   name = "horn_of_berserker_charge",
   baseObject = "horn",
   components = {
      {
         class = "Item",
         uiName = "Horn of Berserker Charge",
         gfxIndex = 297,
		 weight = 1.0,
		 primaryAction = "blow",
		 description = "This horn has a pungent earthy smell.",
      },
      
      {
		class = "ItemAction",
		name = "blow",
		uiName = "Blow Horn",
		cooldown = 6,
		onAttack = function(self, champion)
			champion:setCondition("berserk")
		end,
		},
   },
}

defineCondition{
   name = "berserk",
   uiName = "Berserk",
   description = "An incensed charging attack!",
   icon = 1,
   iconAtlas = "assets/textures/gui/conditions.tga",
   beneficial = true,
   harmful = false,
   tickInterval = .1,
   onStart = function(self, champion)
   	 GameMode.setEnableControls(false)
   	 --tests for if party can use the charge attack
   	 local proceed = true
   	 if champion:getEnergy() < 1 then self:setDuration(0) 
   	 	return
     end
     for x = 1, 4 do
   	 	if x ~= champion:getOrdinal() then
   	 		local otherChamp = party.party:getChampion(x)
   	 		if not otherChamp:isAlive() then
   	 		elseif otherChamp:isAlive() and
   	 		   not otherChamp:isReadyToAttack(1) or
   	 	 	   not otherChamp:isReadyToAttack(2) then
   	 	 	   hudPrint("All must be ready to follow the charge!")
		   	   self:setDuration(0)
		   	   return
   	 	 	end
   	 	end 
   	 end
   	 --Charge attack audio/video effects
   	 self:setDuration(5.1)
     party.party:shakeCamera(0.3,0.5)
	 playSound("blow_horn")
     playSound("power_attack_yell_"..champion:getRace().."_"..champion:getSex())
   end,
   onStop = function(self, champion)
   	  GameMode.setEnableControls(true)
   	  end,
   onRecomputeStats = function(self, champion)
   if self:getDuration() == 0 then return end
   champion:setEnergy(champion:getEnergy()*(self:getDuration()*.21) )
    if champion:getEnergy() <= .5 then self:setDuration(0) return end
   end,
   onTick = function(self, champion)	 
   	  local dX,dY = getForward(party.facing)
   	  local mass = 30 + champion:getBaseStat("strength") + champion:getLoad()  --experimental attack damage
     if party.map:isObstacle(party.x+dX,party.y+dY, party.elevation) or party.map:isWall(party.x+dX,party.y+dY, party.elevation) then
      		playSound("party_land")
      			if party.map:isWall(party.x+dX,party.y+dY, party.elevation) then dX = 0 dY=0 mass=mass/2 end
      		for monster in party.map:entitiesAt(party.x+dX,party.y+dY, party.elevation)	do
      			if monster.monster then
      				monster.monster:knockback(party.facing)
      			end	
      		end	
      		damageTile(party.level, party.x+dX, party.y+dY, party.facing, party.elevation, 444, 'physical', mass)
      		party.party:playScreenEffect("damage_screen")
      		self:setDuration(0)
      		return
      end
      party.party:knockback(party.facing)	
   end,
}

** Ideally there should only be one of these available. There is an exploit [quirk of design] if two are present, that allows one tile charge attacks by the other PCs, if they also have horns equipped.
Post Reply