Forum

> > Stranded II > Scripts > Scripting Questions
Forums overviewStranded II overview Scripts overviewLog in to reply

English Scripting Questions

2,429 replies
Page
To the start Previous 1 2109 110 111121 122 Next To the start

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
Vectar666 has written
I have idea for spear, if throw it on rightclick with s2 cmd projectile command, and change behaviour to blade, so you can do melee attack with less dmg.


I think this has already been done in massive mod, but i'm not 100% sure

old Re: Scripting Questions

Psytechnic
User Off Offline

Quote
Yep, I know it has been done before and I think it was in MM.

I have a question about scripting (which is rare for me), but what I want to acheive is easy to explain... I'm thinking of modelling an amulet, which in itself is easy, but not everyone will be sure what it's for, but I want it to act as a behavioural ward.

Basically, if you are in possession of the amulet then any agressive unit (raptors/lions etc) flee instead of attacking.

The hard part is I want this behaviour to be scripted purely in the item script space, making it an addition rather than a modification of the game system.

Anyone got any ideas?

old Re: Scripting Questions

Xaeveax
User Off Offline

Quote
Yet again I have found another issue. When I try to add a unit to the game, it doesn't show up. I even copy/pasted the data EXACTLY the same as a previous unit (except the id of course) yet it doesn't show up. I made the limit up to the maximum of 500, but on 126 it stops.

old Re: Scripting Questions

Lion_Hearted
User Off Offline

Quote
Erm...


It ain't going to show up on the random map, or even on any of the adventure modes unless you add it to the random map file...



Check the editor... scroll down to the bottom of the list when you reach the units, and there, (if your ID is the biggest number) is your units...

old Re: Scripting Questions

Vectarrio
User Off Offline

Quote
Jesterhead37 has written
But even in the editor it doesn't show up.

Then delete the "editor=0" line!

@Psytechnic
Make loop.
s2 cmd loop ("units"){
local $lid=loop_id()
s2 cmd ai_mode $lid, "flee", "unit", 1;
}

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
@Vectar:
I think there are some poblems in your script.
for example the s2 cmd loop command has to be repeated by usign a s2 cmd timer but this could cause laggs if there are many units on the map.
also there cant be a local variable because the amulet is in the players inventory.
last problem is, that the line with the ai_mode you wrote would make the player flee instead of the aggressive unit.

I would suggest using a scipt like this:
1
2
3
4
5
6
7
8
9
on:load {
	timer 0, 500, 0, "amulet";
}

on:amulet {
	if(playerspotted==1) {
		ai_behavioursignal "distract", "raptor", 50, "unit", 1;
	}
}
this should prevent aggressive units that live on land from coming closer to the player than the distance on the radius which here is set at 50.
to also chase away aggressive water or air units you have to repeat the ai_behavioursignal command and replace "raptor" with "predatorfish" or "killerbird".

More >

old Re: Scripting Questions

Psytechnic
User Off Offline

Quote
That comes with the problem that I can't keep the script example contained to a simple items_.inf file... If I can't get this sorted, I don't see much point in making the amulet... I just kinda wanted to use pearls for something useful.

old Re: Scripting Questions

BiGSiD
User Off Offline

Quote
amulet: good, the only thing that had occurred to me:
put 2 of the pearls as eyes on an excrement and use a leaf for a hat for Mr.Hankey and using as ammunition for the blowgun

old Re: Scripting Questions

Xaeveax
User Off Offline

Quote
or write 'behavior=idle' in the behavior spot. Both work fine.
Hmm... I dont know if this is a 'scripting question', but how do I add a texture to an object that is in a .3ds format without having 3DStudio?
edited 1×, last 20.10.10 03:02:02 pm

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
the script for this would be like this:
1
2
3
on:load {
	texture "[PATH]/[NAME].[FORMAT]";
}
write this into the unit's scriptbox in the editor and replace the terms path, name and format.

this should replace the unit's original skin with the chosen texture.

old Re: Scripting Questions

UnIdEnTiFiEd
User Off Offline

Quote
How can I make it if I eat something i have a chance of geting the poison state, and 1-3 days later i'm cured of it?

EDIT= also how can i make it that when i die, it loads a map and i'm on full health again?
edited 2×, last 21.10.10 08:24:14 am

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
UnIdEnTiFiEd has written
How can I make it if I eat something i have a chance of geting the poison state, and 1-3 days later i'm cured of it?

you have to write this into de definition script of the item in its items_*.inf file:
1
2
3
4
5
6
on:eat {
	if(random(0,2)==0) {
		addstate "unit", 1, 2;
		$poison=3;
	}
}
also you have to write this into the game.inf file between the lines "script=start" and "script=end":
1
2
3
4
5
6
7
8
on:changeday {
	if(gotstate("unit", 1, 2)==1) {
		$poison--;
		if($poison==0) {
			freestate "unit", 1, 2;
		}
	}
}


UnIdEnTiFiEd has written
EDIT= also how can i make it that when i die, it loads a map and i'm on full health again?

write this into the units.inf file into the script of the player (Unit #1):
1
2
3
4
on:kill {
	revive 1;
	loadmap "[MAPNAME].[FORMAT]", 1, 1, 1, 1, 1, 1;
}

old Re: Scripting Questions

Xaeveax
User Off Offline

Quote
For lets say a sword, is there a way to make it that when I swing, it hits everything around me? Like, how do I bring up the range of the sword? Is there a limit to how much range it can have?

old Re: Scripting Questions

Hurri04
Super User Off Offline

Quote
the player himself has a specific attackrange which is set at 45 in the original game.

I think a script like this in the definition script of the sword should work fine:
1
2
3
on:attack1 {
	areal_event "wildblow", getx("unit", 1), gety("unit", 1), getz("unit", 1), 45, 0;
}
then write this into the game.inf file:
1
2
3
4
5
6
7
8
9
10
11
12
13
on:wildblow {
	loop("units") {
		if(inrange("unit", loop_id(), 45)==1) {
			damage "unit", loop_id(), [DAMAGE DONE BY SWORD];
		}
	}

	loop("objects") {
		if(inrange("object", loop_id(), 45)==1) {
			damage "object", loop_id(), [DAMAGE DONE BY SWORD];
		}
	}
}
More >


if you wish to also damage items by this sword-strike just repeat the block of 4 script lines, beginning with the loop command and replace the class with "items" in the loop command line and "item" in the other two lines.
To the start Previous 1 2109 110 111121 122 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview